drupal core updated to 7.28
This commit is contained in:
@@ -7,8 +7,8 @@ files[] = aggregator.test
|
||||
configure = admin/config/services/aggregator/settings
|
||||
stylesheets[all][] = aggregator.css
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
project = "drupal"
|
||||
datestamp = "1375928238"
|
||||
datestamp = "1399522731"
|
||||
|
||||
|
@@ -260,6 +260,7 @@ function aggregator_schema() {
|
||||
'primary key' => array('iid'),
|
||||
'indexes' => array(
|
||||
'fid' => array('fid'),
|
||||
'timestamp' => array('timestamp'),
|
||||
),
|
||||
'foreign keys' => array(
|
||||
'aggregator_feed' => array(
|
||||
@@ -325,6 +326,15 @@ function aggregator_update_7003() {
|
||||
db_add_index('aggregator_feed', 'url', array(array('url', 255)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add index on timestamp.
|
||||
*/
|
||||
function aggregator_update_7004() {
|
||||
if (!db_index_exists('aggregator_item', 'timestamp')) {
|
||||
db_add_index('aggregator_item', 'timestamp', array('timestamp'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @} End of "addtogroup updates-7.x-extra"
|
||||
*/
|
||||
|
@@ -288,6 +288,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.
|
||||
*
|
||||
@@ -931,7 +935,7 @@ class AggregatorRenderingTestCase extends AggregatorTestCase {
|
||||
// up.
|
||||
$feed->block = 0;
|
||||
aggregator_save_feed((array) $feed);
|
||||
// It is nescessary to flush the cache after saving the number of items.
|
||||
// It is necessary to flush the cache after saving the number of items.
|
||||
drupal_flush_all_caches();
|
||||
// Check that the block is no longer displayed.
|
||||
$this->drupalGet('node');
|
||||
@@ -1016,4 +1020,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, format_string('Feed %name exists.', array('%name' => $feed->title)));
|
||||
$this->assertRaw("Quote" Amp&");
|
||||
}
|
||||
}
|
||||
|
@@ -5,8 +5,8 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
project = "drupal"
|
||||
datestamp = "1375928238"
|
||||
datestamp = "1399522731"
|
||||
|
||||
|
14
modules/aggregator/tests/aggregator_test_title_entities.xml
Normal file
14
modules/aggregator/tests/aggregator_test_title_entities.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<?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" Amp&</title>
|
||||
<link>http://example.com/example-turns-one</link>
|
||||
<description>Some text.</description>
|
||||
</item>
|
||||
</channel>
|
||||
</rss>
|
@@ -87,13 +87,13 @@
|
||||
* and any value provided can be modified by a user on the block
|
||||
* configuration screen.
|
||||
* - pages: (optional) See 'visibility' above. A string that contains one or
|
||||
* more page paths separated by '\n', '\r', or '\r\n' when 'visibility' is
|
||||
* set to BLOCK_VISIBILITY_NOTLISTED or BLOCK_VISIBILITY_LISTED, or custom
|
||||
* PHP code when 'visibility' is set to BLOCK_VISIBILITY_PHP. Paths may use
|
||||
* '*' as a wildcard (matching any number of characters); '<front>'
|
||||
* designates the site's front page. For BLOCK_VISIBILITY_PHP, the PHP
|
||||
* code's return value should be TRUE if the block is to be made visible or
|
||||
* FALSE if the block should not be visible.
|
||||
* more page paths separated by "\n", "\r", or "\r\n" when 'visibility' is
|
||||
* set to BLOCK_VISIBILITY_NOTLISTED or BLOCK_VISIBILITY_LISTED (example:
|
||||
* "<front>\nnode/1"), or custom PHP code when 'visibility' is set to
|
||||
* BLOCK_VISIBILITY_PHP. Paths may use '*' as a wildcard (matching any
|
||||
* number of characters); '<front>' designates the site's front page. For
|
||||
* BLOCK_VISIBILITY_PHP, the PHP code's return value should be TRUE if the
|
||||
* block is to be made visible or FALSE if the block should not be visible.
|
||||
*
|
||||
* For a detailed usage example, see block_example.module.
|
||||
*
|
||||
@@ -200,11 +200,13 @@ function hook_block_save($delta = '', $edit = array()) {
|
||||
* within the module, defined in hook_block_info().
|
||||
*
|
||||
* @return
|
||||
* An array containing the following elements:
|
||||
* Either an empty array so the block will not be shown or an array containing
|
||||
* the following elements:
|
||||
* - subject: The default localized title of the block. If the block does not
|
||||
* have a default title, this should be set to NULL.
|
||||
* - content: The content of the block's body. This may be a renderable array
|
||||
* (preferable) or a string containing rendered HTML content.
|
||||
* (preferable) or a string containing rendered HTML content. If the content
|
||||
* is empty the block will not be shown.
|
||||
*
|
||||
* For a detailed usage example, see block_example.module.
|
||||
*
|
||||
@@ -253,8 +255,9 @@ function hook_block_view($delta = '') {
|
||||
* specific block.
|
||||
*
|
||||
* @param $data
|
||||
* An array of data, as returned from the hook_block_view() implementation of
|
||||
* the module that defined the block:
|
||||
* The data as returned from the hook_block_view() implementation of the
|
||||
* module that defined the block. This could be an empty array or NULL value
|
||||
* (if the block is empty) or an array containing:
|
||||
* - subject: The default localized title of the block.
|
||||
* - content: Either a string or a renderable array representing the content
|
||||
* of the block. You should check that the content is an array before trying
|
||||
@@ -287,8 +290,9 @@ function hook_block_view_alter(&$data, $block) {
|
||||
* specific block, rather than implementing hook_block_view_alter().
|
||||
*
|
||||
* @param $data
|
||||
* An array of data, as returned from the hook_block_view() implementation of
|
||||
* the module that defined the block:
|
||||
* The data as returned from the hook_block_view() implementation of the
|
||||
* module that defined the block. This could be an empty array or NULL value
|
||||
* (if the block is empty) or an array containing:
|
||||
* - subject: The localized title of the block.
|
||||
* - content: Either a string or a renderable array representing the content
|
||||
* of the block. You should check that the content is an array before trying
|
||||
|
@@ -6,8 +6,8 @@ core = 7.x
|
||||
files[] = block.test
|
||||
configure = admin/structure/block
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
project = "drupal"
|
||||
datestamp = "1375928238"
|
||||
datestamp = "1399522731"
|
||||
|
||||
|
@@ -401,23 +401,27 @@ function _block_rehash($theme = NULL) {
|
||||
}
|
||||
// Save the blocks defined in code for alter context.
|
||||
$code_blocks = $current_blocks;
|
||||
$database_blocks = db_select('block', 'b')
|
||||
$database_blocks = db_select('block', 'b', array('fetch' => PDO::FETCH_ASSOC))
|
||||
->fields('b')
|
||||
->condition($or)
|
||||
->condition('theme', $theme)
|
||||
->execute();
|
||||
$original_database_blocks = array();
|
||||
foreach ($database_blocks as $block) {
|
||||
// Preserve info which is not in the database.
|
||||
$block->info = $current_blocks[$block->module][$block->delta]['info'];
|
||||
$module = $block['module'];
|
||||
$delta = $block['delta'];
|
||||
$original_database_blocks[$module][$delta] = $block;
|
||||
// The cache mode can only by set from hook_block_info(), so that has
|
||||
// precedence over the database's value.
|
||||
if (isset($current_blocks[$block->module][$block->delta]['cache'])) {
|
||||
$block->cache = $current_blocks[$block->module][$block->delta]['cache'];
|
||||
if (isset($current_blocks[$module][$delta]['cache'])) {
|
||||
$block['cache'] = $current_blocks[$module][$delta]['cache'];
|
||||
}
|
||||
// Preserve info which is not in the database.
|
||||
$block['info'] = $current_blocks[$module][$delta]['info'];
|
||||
// Blocks stored in the database override the blocks defined in code.
|
||||
$current_blocks[$block->module][$block->delta] = get_object_vars($block);
|
||||
$current_blocks[$module][$delta] = $block;
|
||||
// Preserve this block.
|
||||
$bids[$block->bid] = $block->bid;
|
||||
$bids[$block['bid']] = $block['bid'];
|
||||
}
|
||||
drupal_alter('block_info', $current_blocks, $theme, $code_blocks);
|
||||
foreach ($current_blocks as $module => $module_blocks) {
|
||||
@@ -456,7 +460,15 @@ function _block_rehash($theme = NULL) {
|
||||
else {
|
||||
$primary_keys = array();
|
||||
}
|
||||
drupal_write_record('block', $block, $primary_keys);
|
||||
// If the block is new or differs from the original database block, save
|
||||
// it. To determine whether there was a change it is enough to examine
|
||||
// the values for the keys in the original database record as that
|
||||
// contained every database field.
|
||||
if (!$primary_keys || array_diff_assoc($original_database_blocks[$module][$delta], $block)) {
|
||||
drupal_write_record('block', $block, $primary_keys);
|
||||
// Make it possible to test this.
|
||||
$block['saved'] = TRUE;
|
||||
}
|
||||
// Add to the list of blocks we return.
|
||||
$blocks[] = $block;
|
||||
}
|
||||
@@ -880,9 +892,11 @@ function _block_render_blocks($region_blocks) {
|
||||
else {
|
||||
$array = module_invoke($block->module, 'block_view', $block->delta);
|
||||
|
||||
// Valid PHP function names cannot contain hyphens.
|
||||
$delta = str_replace('-', '_', $block->delta);
|
||||
// Allow modules to modify the block before it is viewed, via either
|
||||
// hook_block_view_alter() or hook_block_view_MODULE_DELTA_alter().
|
||||
drupal_alter(array('block_view', "block_view_{$block->module}_{$block->delta}"), $array, $block);
|
||||
drupal_alter(array('block_view', "block_view_{$block->module}_{$delta}"), $array, $block);
|
||||
|
||||
if (isset($cid)) {
|
||||
cache_set($cid, $array, 'cache_block', CACHE_TEMPORARY);
|
||||
|
@@ -193,7 +193,7 @@ class BlockTestCase extends DrupalWebTestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test block visibility when using "pages" restriction but leaving
|
||||
* Test block visibility when using "pages" restriction but leaving
|
||||
* "pages" textarea empty
|
||||
*/
|
||||
function testBlockVisibilityListedEmpty() {
|
||||
@@ -752,6 +752,48 @@ class BlockTemplateSuggestionsUnitTest extends DrupalUnitTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests for hook_block_view_MODULE_DELTA_alter().
|
||||
*/
|
||||
class BlockViewModuleDeltaAlterWebTest extends DrupalWebTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Block view module delta alter',
|
||||
'description' => 'Test the hook_block_view_MODULE_DELTA_alter() hook.',
|
||||
'group' => 'Block',
|
||||
);
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
parent::setUp(array('block_test'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that the alter hook is called, even if the delta contains a hyphen.
|
||||
*/
|
||||
public function testBlockViewModuleDeltaAlter() {
|
||||
$block = new stdClass;
|
||||
$block->module = 'block_test';
|
||||
$block->delta = 'test_underscore';
|
||||
$block->title = '';
|
||||
$render_array = _block_render_blocks(array('region' => $block));
|
||||
$render = array_pop($render_array);
|
||||
$test_underscore = $render->content['#markup'];
|
||||
$this->assertEqual($test_underscore, 'hook_block_view_MODULE_DELTA_alter', 'Found expected altered block content for delta with underscore');
|
||||
|
||||
$block = new stdClass;
|
||||
$block->module = 'block_test';
|
||||
$block->delta = 'test-hyphen';
|
||||
$block->title = '';
|
||||
$render_array = _block_render_blocks(array('region' => $block));
|
||||
$render = array_pop($render_array);
|
||||
$test_hyphen = $render->content['#markup'];
|
||||
$this->assertEqual($test_hyphen, 'hook_block_view_MODULE_DELTA_alter', 'Hyphens (-) in block delta were replaced by underscore (_)');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that hidden regions do not inherit blocks when a theme is enabled.
|
||||
*/
|
||||
@@ -857,3 +899,81 @@ class BlockInvalidRegionTestCase extends DrupalWebTestCase {
|
||||
$this->assertNoRaw($warning_message, 'Disabled block in the invalid region will not trigger the warning.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that block rehashing works correctly.
|
||||
*/
|
||||
class BlockHashTestCase extends DrupalWebTestCase {
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Block rehash',
|
||||
'description' => 'Checks _block_rehash() functionality.',
|
||||
'group' => 'Block',
|
||||
);
|
||||
}
|
||||
|
||||
function setUp() {
|
||||
parent::setUp(array('block'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that block rehashing does not write to the database too often.
|
||||
*/
|
||||
function testBlockRehash() {
|
||||
// No hook_block_info_alter(), no save.
|
||||
$this->doRehash();
|
||||
module_enable(array('block_test'), FALSE);
|
||||
// Save the new blocks, check that the new blocks exist by checking weight.
|
||||
_block_rehash();
|
||||
$this->assertWeight(0);
|
||||
// Now hook_block_info_alter() exists but no blocks are saved on a second
|
||||
// rehash.
|
||||
$this->doRehash();
|
||||
$this->assertWeight(0);
|
||||
// Now hook_block_info_alter() exists and is changing one block which
|
||||
// should be saved.
|
||||
$GLOBALS['conf']['block_test_info_alter'] = 1;
|
||||
$this->doRehash(TRUE);
|
||||
$this->assertWeight(10000);
|
||||
// Now hook_block_info_alter() exists but already changed the block's
|
||||
// weight before, so it should not be saved again.
|
||||
$this->doRehash();
|
||||
$this->assertWeight(10000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a block rehash and checks several related assertions.
|
||||
*
|
||||
* @param $alter_active
|
||||
* Set to TRUE if the block_test module's hook_block_info_alter()
|
||||
* implementation is expected to make a change that results in an existing
|
||||
* block needing to be resaved to the database. Defaults to FALSE.
|
||||
*/
|
||||
function doRehash($alter_active = FALSE) {
|
||||
$saves = 0;
|
||||
foreach (_block_rehash() as $block) {
|
||||
$module = $block['module'];
|
||||
$delta = $block['delta'];
|
||||
if ($alter_active && $module == 'block_test' && $delta == 'test_html_id') {
|
||||
$this->assertFalse(empty($block['saved']), "$module $delta saved");
|
||||
$saves++;
|
||||
}
|
||||
else {
|
||||
$this->assertTrue(empty($block['saved']), "$module $delta not saved");
|
||||
}
|
||||
}
|
||||
$this->assertEqual($alter_active, $saves);
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that the block_test module's block has a given weight.
|
||||
*
|
||||
* @param $weight
|
||||
* The expected weight.
|
||||
*/
|
||||
function assertWeight($weight) {
|
||||
$db_weight = db_query('SELECT weight FROM {block} WHERE module = :module AND delta = :delta', array(':module' => 'block_test', ':delta' => 'test_html_id'))->fetchField();
|
||||
// By casting to string the assert fails on FALSE.
|
||||
$this->assertIdentical((string) $db_weight, (string) $weight);
|
||||
}
|
||||
}
|
||||
|
@@ -5,8 +5,8 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
project = "drupal"
|
||||
datestamp = "1375928238"
|
||||
datestamp = "1399522731"
|
||||
|
||||
|
@@ -22,6 +22,14 @@ function block_test_block_info() {
|
||||
'cache' => variable_get('block_test_caching', DRUPAL_CACHE_PER_ROLE),
|
||||
);
|
||||
|
||||
$blocks['test_underscore'] = array(
|
||||
'info' => t('Test underscore'),
|
||||
);
|
||||
|
||||
$blocks['test-hyphen'] = array(
|
||||
'info' => t('Test hyphen'),
|
||||
);
|
||||
|
||||
$blocks['test_html_id'] = array(
|
||||
'info' => t('Test block html id'),
|
||||
);
|
||||
@@ -34,3 +42,26 @@ function block_test_block_info() {
|
||||
function block_test_block_view($delta = 0) {
|
||||
return array('content' => variable_get('block_test_content', ''));
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_block_view_MODULE_DELTA_alter().
|
||||
*/
|
||||
function block_test_block_view_block_test_test_underscore_alter(&$data, $block) {
|
||||
$data['content'] = 'hook_block_view_MODULE_DELTA_alter';
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_block_view_MODULE_DELTA_alter().
|
||||
*/
|
||||
function block_test_block_view_block_test_test_hyphen_alter(&$data, $block) {
|
||||
$data['content'] = 'hook_block_view_MODULE_DELTA_alter';
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_block_info_alter().
|
||||
*/
|
||||
function block_test_block_info_alter(&$blocks) {
|
||||
if (variable_get('block_test_info_alter')) {
|
||||
$blocks['block_test']['test_html_id']['weight'] = 10000;
|
||||
}
|
||||
}
|
||||
|
@@ -13,8 +13,8 @@ regions[footer] = Footer
|
||||
regions[highlighted] = Highlighted
|
||||
regions[help] = Help
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
project = "drupal"
|
||||
datestamp = "1375928238"
|
||||
datestamp = "1399522731"
|
||||
|
||||
|
@@ -5,8 +5,8 @@ version = VERSION
|
||||
core = 7.x
|
||||
files[] = blog.test
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
project = "drupal"
|
||||
datestamp = "1375928238"
|
||||
datestamp = "1399522731"
|
||||
|
||||
|
@@ -42,8 +42,8 @@ class BlogTestCase extends DrupalWebTestCase {
|
||||
|
||||
$this->drupalGet('blog/' . $this->big_user->uid);
|
||||
$this->assertResponse(200);
|
||||
$this->assertTitle(t("@name's blog", array('@name' => format_username($this->big_user))) . ' | Drupal', t('Blog title was displayed'));
|
||||
$this->assertText(t('You are not allowed to post a new blog entry.'), t('No new entries can be posted without the right permission'));
|
||||
$this->assertTitle(t("@name's blog", array('@name' => format_username($this->big_user))) . ' | Drupal', 'Blog title was displayed');
|
||||
$this->assertText(t('You are not allowed to post a new blog entry.'), 'No new entries can be posted without the right permission');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,8 +54,8 @@ class BlogTestCase extends DrupalWebTestCase {
|
||||
|
||||
$this->drupalGet('blog/' . $this->own_user->uid);
|
||||
$this->assertResponse(200);
|
||||
$this->assertTitle(t("@name's blog", array('@name' => format_username($this->own_user))) . ' | Drupal', t('Blog title was displayed'));
|
||||
$this->assertText(t('@author has not created any blog entries.', array('@author' => format_username($this->own_user))), t('Users blog displayed with no entries'));
|
||||
$this->assertTitle(t("@name's blog", array('@name' => format_username($this->own_user))) . ' | Drupal', 'Blog title was displayed');
|
||||
$this->assertText(t('@author has not created any blog entries.', array('@author' => format_username($this->own_user))), 'Users blog displayed with no entries');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,7 +73,7 @@ class BlogTestCase extends DrupalWebTestCase {
|
||||
$edit = array();
|
||||
$edit['blog_block_count'] = 5;
|
||||
$this->drupalPost('admin/structure/block/manage/blog/recent/configure', $edit, t('Save block'));
|
||||
$this->assertEqual(variable_get('blog_block_count', 10), 5, t('Number of recent blog posts changed.'));
|
||||
$this->assertEqual(variable_get('blog_block_count', 10), 5, 'Number of recent blog posts changed.');
|
||||
|
||||
// Do basic tests for each user.
|
||||
$this->doBasicTests($this->any_user, TRUE);
|
||||
@@ -132,31 +132,31 @@ class BlogTestCase extends DrupalWebTestCase {
|
||||
$this->drupalGet('admin/help/blog');
|
||||
$this->assertResponse($response2);
|
||||
if ($response2 == 200) {
|
||||
$this->assertTitle(t('Blog | Drupal'), t('Blog help node was displayed'));
|
||||
$this->assertText(t('Blog'), t('Blog help node was displayed'));
|
||||
$this->assertTitle(t('Blog | Drupal'), 'Blog help node was displayed');
|
||||
$this->assertText(t('Blog'), 'Blog help node was displayed');
|
||||
}
|
||||
|
||||
// Verify the blog block was displayed.
|
||||
$this->drupalGet('');
|
||||
$this->assertResponse(200);
|
||||
$this->assertText(t('Recent blog posts'), t('Blog block was displayed'));
|
||||
$this->assertText(t('Recent blog posts'), 'Blog block was displayed');
|
||||
|
||||
// View blog node.
|
||||
$this->drupalGet('node/' . $node->nid);
|
||||
$this->assertResponse(200);
|
||||
$this->assertTitle($node->title . ' | Drupal', t('Blog node was displayed'));
|
||||
$this->assertTitle($node->title . ' | Drupal', 'Blog node was displayed');
|
||||
$breadcrumb = array(
|
||||
l(t('Home'), NULL),
|
||||
l(t('Blogs'), 'blog'),
|
||||
l(t("!name's blog", array('!name' => format_username($node_user))), 'blog/' . $node_user->uid),
|
||||
);
|
||||
$this->assertRaw(theme('breadcrumb', array('breadcrumb' => $breadcrumb)), t('Breadcrumbs were displayed'));
|
||||
$this->assertRaw(theme('breadcrumb', array('breadcrumb' => $breadcrumb)), 'Breadcrumbs were displayed');
|
||||
|
||||
// View blog edit node.
|
||||
$this->drupalGet('node/' . $node->nid . '/edit');
|
||||
$this->assertResponse($response);
|
||||
if ($response == 200) {
|
||||
$this->assertTitle('Edit Blog entry ' . $node->title . ' | Drupal', t('Blog edit node was displayed'));
|
||||
$this->assertTitle('Edit Blog entry ' . $node->title . ' | Drupal', 'Blog edit node was displayed');
|
||||
}
|
||||
|
||||
if ($response == 200) {
|
||||
@@ -166,12 +166,12 @@ class BlogTestCase extends DrupalWebTestCase {
|
||||
$edit["title"] = 'node/' . $node->nid;
|
||||
$edit["body[$langcode][0][value]"] = $this->randomName(256);
|
||||
$this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
|
||||
$this->assertRaw(t('Blog entry %title has been updated.', array('%title' => $edit["title"])), t('Blog node was edited'));
|
||||
$this->assertRaw(t('Blog entry %title has been updated.', array('%title' => $edit["title"])), 'Blog node was edited');
|
||||
|
||||
// Delete blog node.
|
||||
$this->drupalPost('node/' . $node->nid . '/delete', array(), t('Delete'));
|
||||
$this->assertResponse($response);
|
||||
$this->assertRaw(t('Blog entry %title has been deleted.', array('%title' => $edit["title"])), t('Blog node was deleted'));
|
||||
$this->assertRaw(t('Blog entry %title has been deleted.', array('%title' => $edit["title"])), 'Blog node was deleted');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,29 +185,29 @@ class BlogTestCase extends DrupalWebTestCase {
|
||||
// Confirm blog entries link exists on the user page.
|
||||
$this->drupalGet('user/' . $user->uid);
|
||||
$this->assertResponse(200);
|
||||
$this->assertText(t('View recent blog entries'), t('View recent blog entries link was displayed'));
|
||||
$this->assertText(t('View recent blog entries'), 'View recent blog entries link was displayed');
|
||||
|
||||
// Confirm the recent blog entries link goes to the user's blog page.
|
||||
$this->clickLink('View recent blog entries');
|
||||
$this->assertTitle(t("@name's blog | Drupal", array('@name' => format_username($user))), t('View recent blog entries link target was correct'));
|
||||
$this->assertTitle(t("@name's blog | Drupal", array('@name' => format_username($user))), 'View recent blog entries link target was correct');
|
||||
|
||||
// Confirm a blog page was displayed.
|
||||
$this->drupalGet('blog');
|
||||
$this->assertResponse(200);
|
||||
$this->assertTitle('Blogs | Drupal', t('Blog page was displayed'));
|
||||
$this->assertText(t('Home'), t('Breadcrumbs were displayed'));
|
||||
$this->assertTitle('Blogs | Drupal', 'Blog page was displayed');
|
||||
$this->assertText(t('Home'), 'Breadcrumbs were displayed');
|
||||
$this->assertLink(t('Create new blog entry'));
|
||||
|
||||
// Confirm a blog page was displayed per user.
|
||||
$this->drupalGet('blog/' . $user->uid);
|
||||
$this->assertTitle(t("@name's blog | Drupal", array('@name' => format_username($user))), t('User blog node was displayed'));
|
||||
$this->assertTitle(t("@name's blog | Drupal", array('@name' => format_username($user))), 'User blog node was displayed');
|
||||
|
||||
// Confirm a blog feed was displayed.
|
||||
$this->drupalGet('blog/feed');
|
||||
$this->assertTitle(t('Drupal blogs'), t('Blog feed was displayed'));
|
||||
$this->assertTitle(t('Drupal blogs'), 'Blog feed was displayed');
|
||||
|
||||
// Confirm a blog feed was displayed per user.
|
||||
$this->drupalGet('blog/' . $user->uid . '/feed');
|
||||
$this->assertTitle(t("@name's blog", array('@name' => format_username($user))), t('User blog feed was displayed'));
|
||||
$this->assertTitle(t("@name's blog", array('@name' => format_username($user))), 'User blog feed was displayed');
|
||||
}
|
||||
}
|
||||
|
@@ -7,8 +7,8 @@ files[] = book.test
|
||||
configure = admin/content/book/settings
|
||||
stylesheets[all][] = book.css
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
project = "drupal"
|
||||
datestamp = "1375928238"
|
||||
datestamp = "1399522731"
|
||||
|
||||
|
@@ -5,8 +5,8 @@ version = VERSION
|
||||
core = 7.x
|
||||
files[] = color.test
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
project = "drupal"
|
||||
datestamp = "1375928238"
|
||||
datestamp = "1399522731"
|
||||
|
||||
|
@@ -240,6 +240,7 @@ function color_scheme_form($complete_form, &$form_state, $theme) {
|
||||
$form['palette'][$name] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => check_plain($names[$name]),
|
||||
'#value_callback' => 'color_palette_color_value',
|
||||
'#default_value' => $value,
|
||||
'#size' => 8,
|
||||
);
|
||||
@@ -294,6 +295,52 @@ function theme_color_scheme_form($variables) {
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the value for a palette color field.
|
||||
*
|
||||
* @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.
|
||||
* @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.
|
||||
*/
|
||||
function color_palette_color_value($element, $input = FALSE, $form_state = array()) {
|
||||
// If we suspect a possible cross-site request forgery attack, only accept
|
||||
// hexadecimal CSS color strings from user input, to avoid problems when this
|
||||
// value is used in the JavaScript preview.
|
||||
if ($input !== FALSE) {
|
||||
// Start with the provided value for this textfield, and validate that if
|
||||
// necessary, falling back on the default value.
|
||||
$value = form_type_textfield_value($element, $input, $form_state);
|
||||
if (!$value || !isset($form_state['complete form']['#token']) || color_valid_hexadecimal_string($value) || drupal_valid_token($form_state['values']['form_token'], $form_state['complete form']['#token'])) {
|
||||
return $value;
|
||||
}
|
||||
else {
|
||||
return $element['#default_value'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if a hexadecimal CSS color string is valid.
|
||||
*
|
||||
* @param $color
|
||||
* The string to check.
|
||||
*
|
||||
* @return
|
||||
* TRUE if the string is a valid hexadecimal CSS color string, or FALSE if it
|
||||
* isn't.
|
||||
*/
|
||||
function color_valid_hexadecimal_string($color) {
|
||||
return preg_match('/^#([a-f0-9]{3}){1,2}$/iD', $color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Form validation handler for color_scheme_form().
|
||||
*
|
||||
@@ -302,7 +349,7 @@ function theme_color_scheme_form($variables) {
|
||||
function color_scheme_form_validate($form, &$form_state) {
|
||||
// Only accept hexadecimal CSS color strings to avoid XSS upon use.
|
||||
foreach ($form_state['values']['palette'] as $key => $color) {
|
||||
if (!preg_match('/^#([a-f0-9]{3}){1,2}$/iD', $color)) {
|
||||
if (!color_valid_hexadecimal_string($color)) {
|
||||
form_set_error('palette][' . $key, t('%name must be a valid hexadecimal CSS color value.', array('%name' => $form['color']['palette'][$key]['#title'])));
|
||||
}
|
||||
}
|
||||
|
@@ -9,8 +9,8 @@ files[] = comment.test
|
||||
configure = admin/content/comment
|
||||
stylesheets[all][] = comment.css
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
project = "drupal"
|
||||
datestamp = "1375928238"
|
||||
datestamp = "1399522731"
|
||||
|
||||
|
@@ -490,7 +490,7 @@ function comment_permalink($cid) {
|
||||
// Return the node view, this will show the correct comment in context.
|
||||
return menu_execute_active_handler('node/' . $node->nid, FALSE);
|
||||
}
|
||||
drupal_not_found();
|
||||
return MENU_NOT_FOUND;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2304,7 +2304,7 @@ function template_preprocess_comment(&$variables) {
|
||||
$variables['signature'] = $comment->signature;
|
||||
|
||||
$uri = entity_uri('comment', $comment);
|
||||
$uri['options'] += array('attributes' => array('class' => 'permalink', 'rel' => 'bookmark'));
|
||||
$uri['options'] += array('attributes' => array('class' => array('permalink'), 'rel' => 'bookmark'));
|
||||
|
||||
$variables['title'] = l($comment->subject, $uri['path'], $uri['options']);
|
||||
$variables['permalink'] = l(t('Permalink'), $uri['path'], $uri['options']);
|
||||
|
@@ -155,7 +155,7 @@ class CommentHelperCase extends DrupalWebTestCase {
|
||||
$mode_text = 'required';
|
||||
break;
|
||||
}
|
||||
$this->setCommentSettings('comment_preview', $mode, 'Comment preview ' . $mode_text . '.');
|
||||
$this->setCommentSettings('comment_preview', $mode, format_string('Comment preview @mode_text.', array('@mode_text' => $mode_text)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -175,7 +175,7 @@ class CommentHelperCase extends DrupalWebTestCase {
|
||||
* Anonymous level.
|
||||
*/
|
||||
function setCommentAnonymous($level) {
|
||||
$this->setCommentSettings('comment_anonymous', $level, 'Anonymous commenting set to level ' . $level . '.');
|
||||
$this->setCommentSettings('comment_anonymous', $level, format_string('Anonymous commenting set to level @level.', array('@level' => $level)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -185,7 +185,7 @@ class CommentHelperCase extends DrupalWebTestCase {
|
||||
* Comments per page value.
|
||||
*/
|
||||
function setCommentsPerPage($number) {
|
||||
$this->setCommentSettings('comment_default_per_page', $number, 'Number of comments per page set to ' . $number . '.');
|
||||
$this->setCommentSettings('comment_default_per_page', $number, format_string('Number of comments per page set to @number.', array('@number' => $number)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -201,7 +201,7 @@ class CommentHelperCase extends DrupalWebTestCase {
|
||||
function setCommentSettings($name, $value, $message) {
|
||||
variable_set($name . '_article', $value);
|
||||
// Display status message.
|
||||
$this->assertTrue(TRUE, $message);
|
||||
$this->pass($message);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -273,7 +273,7 @@ class CommentInterfaceTest extends CommentHelperCase {
|
||||
$this->setCommentPreview(DRUPAL_DISABLED);
|
||||
$this->setCommentForm(TRUE);
|
||||
$this->setCommentSubject(FALSE);
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Comment paging changed.'));
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, 'Comment paging changed.');
|
||||
$this->drupalLogout();
|
||||
|
||||
// Post comment #1 without subject or preview.
|
||||
@@ -583,7 +583,7 @@ class CommentInterfaceTest extends CommentHelperCase {
|
||||
$this->setCommentPreview(DRUPAL_DISABLED);
|
||||
$this->setCommentForm(TRUE);
|
||||
$this->setCommentSubject(FALSE);
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Comment paging changed.'));
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, 'Comment paging changed.');
|
||||
$this->drupalLogout();
|
||||
|
||||
// Creates a second user to post comments.
|
||||
@@ -954,7 +954,7 @@ class CommentPreviewTest extends CommentHelperCase {
|
||||
$this->setCommentPreview(DRUPAL_OPTIONAL);
|
||||
$this->setCommentForm(TRUE);
|
||||
$this->setCommentSubject(TRUE);
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Comment paging changed.'));
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, 'Comment paging changed.');
|
||||
$this->drupalLogout();
|
||||
|
||||
// Login as web user and add a signature and a user picture.
|
||||
@@ -1000,7 +1000,7 @@ class CommentPreviewTest extends CommentHelperCase {
|
||||
$this->setCommentPreview(DRUPAL_OPTIONAL);
|
||||
$this->setCommentForm(TRUE);
|
||||
$this->setCommentSubject(TRUE);
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Comment paging changed.'));
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, 'Comment paging changed.');
|
||||
|
||||
$edit = array();
|
||||
$edit['subject'] = $this->randomName(8);
|
||||
@@ -1238,7 +1238,7 @@ class CommentPagerTest extends CommentHelperCase {
|
||||
$comments[] = $this->postComment($node, $this->randomName(), $this->randomName(), TRUE);
|
||||
$comments[] = $this->postComment($node, $this->randomName(), $this->randomName(), TRUE);
|
||||
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_FLAT, t('Comment paging changed.'));
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_FLAT, 'Comment paging changed.');
|
||||
|
||||
// Set comments to one per page so that we are able to test paging without
|
||||
// needing to insert large numbers of comments.
|
||||
@@ -1279,7 +1279,7 @@ class CommentPagerTest extends CommentHelperCase {
|
||||
// If we switch to threaded mode, the replies on the oldest comment
|
||||
// should be bumped to the first page and comment 6 should be bumped
|
||||
// to the second page.
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Switched to threaded mode.'));
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, 'Switched to threaded mode.');
|
||||
$this->drupalGet('node/' . $node->nid, array('query' => array('page' => 0)));
|
||||
$this->assertTrue($this->commentExists($reply, TRUE), 'In threaded mode, reply appears on page 1.');
|
||||
$this->assertFalse($this->commentExists($comments[1]), 'In threaded mode, comment 2 has been bumped off of page 1.');
|
||||
@@ -1339,7 +1339,7 @@ class CommentPagerTest extends CommentHelperCase {
|
||||
// - 2
|
||||
// - 5
|
||||
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_FLAT, t('Comment paging changed.'));
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_FLAT, 'Comment paging changed.');
|
||||
|
||||
$expected_order = array(
|
||||
0,
|
||||
@@ -1353,7 +1353,7 @@ class CommentPagerTest extends CommentHelperCase {
|
||||
$this->drupalGet('node/' . $node->nid);
|
||||
$this->assertCommentOrder($comments, $expected_order);
|
||||
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Switched to threaded mode.'));
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, 'Switched to threaded mode.');
|
||||
|
||||
$expected_order = array(
|
||||
0,
|
||||
@@ -1435,7 +1435,7 @@ class CommentPagerTest extends CommentHelperCase {
|
||||
// - 2
|
||||
// - 5
|
||||
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_FLAT, t('Comment paging changed.'));
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_FLAT, 'Comment paging changed.');
|
||||
|
||||
$expected_pages = array(
|
||||
1 => 5, // Page of comment 5
|
||||
@@ -1453,7 +1453,7 @@ class CommentPagerTest extends CommentHelperCase {
|
||||
$this->assertIdentical($expected_page, $returned_page, format_string('Flat mode, @new replies: expected page @expected, returned page @returned.', array('@new' => $new_replies, '@expected' => $expected_page, '@returned' => $returned_page)));
|
||||
}
|
||||
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Switched to threaded mode.'));
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, 'Switched to threaded mode.');
|
||||
|
||||
$expected_pages = array(
|
||||
1 => 5, // Page of comment 5
|
||||
@@ -1509,7 +1509,7 @@ class CommentNodeAccessTest extends CommentHelperCase {
|
||||
$this->setCommentPreview(DRUPAL_DISABLED);
|
||||
$this->setCommentForm(TRUE);
|
||||
$this->setCommentSubject(TRUE);
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Comment paging changed.'));
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, 'Comment paging changed.');
|
||||
$this->drupalLogout();
|
||||
|
||||
// Post comment.
|
||||
@@ -2126,7 +2126,7 @@ class CommentThreadingTestCase extends CommentHelperCase {
|
||||
$this->setCommentPreview(DRUPAL_DISABLED);
|
||||
$this->setCommentForm(TRUE);
|
||||
$this->setCommentSubject(TRUE);
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Comment paging changed.'));
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, 'Comment paging changed.');
|
||||
$this->drupalLogout();
|
||||
|
||||
// Create a node.
|
||||
|
@@ -6,8 +6,8 @@ core = 7.x
|
||||
files[] = contact.test
|
||||
configure = admin/structure/contact
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
project = "drupal"
|
||||
datestamp = "1375928238"
|
||||
datestamp = "1399522731"
|
||||
|
||||
|
@@ -5,8 +5,8 @@ version = VERSION
|
||||
core = 7.x
|
||||
files[] = contextual.test
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
project = "drupal"
|
||||
datestamp = "1375928238"
|
||||
datestamp = "1399522731"
|
||||
|
||||
|
@@ -32,7 +32,7 @@ function hook_dashboard_regions() {
|
||||
* An array containing all dashboard regions, in the format provided by
|
||||
* hook_dashboard_regions().
|
||||
*/
|
||||
function hook_dashboard_regions_alter($regions) {
|
||||
function hook_dashboard_regions_alter(&$regions) {
|
||||
// Remove the sidebar region defined by the core dashboard module.
|
||||
unset($regions['dashboard_sidebar']);
|
||||
}
|
||||
|
@@ -7,8 +7,8 @@ files[] = dashboard.test
|
||||
dependencies[] = block
|
||||
configure = admin/dashboard/customize
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
project = "drupal"
|
||||
datestamp = "1375928238"
|
||||
datestamp = "1399522731"
|
||||
|
||||
|
@@ -49,15 +49,15 @@ class DashboardBlocksTestCase extends DrupalWebTestCase {
|
||||
|
||||
// Ensure admin access.
|
||||
$this->drupalGet('admin/dashboard');
|
||||
$this->assertResponse(200, t('Admin has access to the dashboard.'));
|
||||
$this->assertRaw($custom_block['title'], t('Admin has access to a dashboard block.'));
|
||||
$this->assertResponse(200, 'Admin has access to the dashboard.');
|
||||
$this->assertRaw($custom_block['title'], 'Admin has access to a dashboard block.');
|
||||
|
||||
// Ensure non-admin access is denied.
|
||||
$normal_user = $this->drupalCreateUser();
|
||||
$this->drupalLogin($normal_user);
|
||||
$this->drupalGet('admin/dashboard');
|
||||
$this->assertResponse(403, t('Non-admin has no access to the dashboard.'));
|
||||
$this->assertNoText($custom_block['title'], t('Non-admin has no access to a dashboard block.'));
|
||||
$this->assertResponse(403, 'Non-admin has no access to the dashboard.');
|
||||
$this->assertNoText($custom_block['title'], 'Non-admin has no access to a dashboard block.');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -70,7 +70,7 @@ class DashboardBlocksTestCase extends DrupalWebTestCase {
|
||||
$this->drupalGet('admin/dashboard/configure');
|
||||
foreach ($dashboard_regions as $region => $description) {
|
||||
$elements = $this->xpath('//option[@value=:region]', array(':region' => $region));
|
||||
$this->assertTrue(!empty($elements), t('%region is an available choice on the dashboard block configuration page.', array('%region' => $region)));
|
||||
$this->assertTrue(!empty($elements), format_string('%region is an available choice on the dashboard block configuration page.', array('%region' => $region)));
|
||||
}
|
||||
|
||||
// Ensure blocks cannot be placed in dashboard regions on the standard
|
||||
@@ -78,7 +78,7 @@ class DashboardBlocksTestCase extends DrupalWebTestCase {
|
||||
$this->drupalGet('admin/structure/block');
|
||||
foreach ($dashboard_regions as $region => $description) {
|
||||
$elements = $this->xpath('//option[@value=:region]', array(':region' => $region));
|
||||
$this->assertTrue(empty($elements), t('%region is not an available choice on the block configuration page.', array('%region' => $region)));
|
||||
$this->assertTrue(empty($elements), format_string('%region is not an available choice on the block configuration page.', array('%region' => $region)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,24 +94,24 @@ class DashboardBlocksTestCase extends DrupalWebTestCase {
|
||||
$custom_block['regions[stark]'] = 'dashboard_main';
|
||||
$this->drupalPost('admin/structure/block/add', $custom_block, t('Save block'));
|
||||
$this->drupalGet('admin/dashboard');
|
||||
$this->assertRaw($custom_block['title'], t('Block appears on the dashboard.'));
|
||||
$this->assertRaw($custom_block['title'], 'Block appears on the dashboard.');
|
||||
|
||||
$edit = array();
|
||||
$edit['modules[Core][dashboard][enable]'] = FALSE;
|
||||
$this->drupalPost('admin/modules', $edit, t('Save configuration'));
|
||||
$this->assertText(t('The configuration options have been saved.'), t('Modules status has been updated.'));
|
||||
$this->assertNoRaw('assigned to the invalid region', t('Dashboard blocks gracefully disabled.'));
|
||||
$this->assertText(t('The configuration options have been saved.'), 'Modules status has been updated.');
|
||||
$this->assertNoRaw('assigned to the invalid region', 'Dashboard blocks gracefully disabled.');
|
||||
module_list(TRUE);
|
||||
$this->assertFalse(module_exists('dashboard'), t('Dashboard disabled.'));
|
||||
$this->assertFalse(module_exists('dashboard'), 'Dashboard disabled.');
|
||||
|
||||
$edit['modules[Core][dashboard][enable]'] = 'dashboard';
|
||||
$this->drupalPost('admin/modules', $edit, t('Save configuration'));
|
||||
$this->assertText(t('The configuration options have been saved.'), t('Modules status has been updated.'));
|
||||
$this->assertText(t('The configuration options have been saved.'), 'Modules status has been updated.');
|
||||
module_list(TRUE);
|
||||
$this->assertTrue(module_exists('dashboard'), t('Dashboard enabled.'));
|
||||
$this->assertTrue(module_exists('dashboard'), 'Dashboard enabled.');
|
||||
|
||||
$this->drupalGet('admin/dashboard');
|
||||
$this->assertRaw($custom_block['title'], t('Block still appears on the dashboard.'));
|
||||
$this->assertRaw($custom_block['title'], 'Block still appears on the dashboard.');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,21 +121,21 @@ class DashboardBlocksTestCase extends DrupalWebTestCase {
|
||||
// Test "Recent comments", which should be available (defined as
|
||||
// "administrative") but not enabled.
|
||||
$this->drupalGet('admin/dashboard');
|
||||
$this->assertNoText(t('Recent comments'), t('"Recent comments" not on dashboard.'));
|
||||
$this->assertNoText(t('Recent comments'), '"Recent comments" not on dashboard.');
|
||||
$this->drupalGet('admin/dashboard/drawer');
|
||||
$this->assertText(t('Recent comments'), t('Drawer of disabled blocks includes a block defined as "administrative".'));
|
||||
$this->assertNoText(t('Syndicate'), t('Drawer of disabled blocks excludes a block not defined as "administrative".'));
|
||||
$this->assertText(t('Recent comments'), 'Drawer of disabled blocks includes a block defined as "administrative".');
|
||||
$this->assertNoText(t('Syndicate'), 'Drawer of disabled blocks excludes a block not defined as "administrative".');
|
||||
$this->drupalGet('admin/dashboard/configure');
|
||||
$elements = $this->xpath('//select[@id=:id]//option[@selected="selected"]', array(':id' => 'edit-blocks-comment-recent-region'));
|
||||
$this->assertTrue($elements[0]['value'] == 'dashboard_inactive', t('A block defined as "administrative" defaults to dashboard_inactive.'));
|
||||
$this->assertTrue($elements[0]['value'] == 'dashboard_inactive', 'A block defined as "administrative" defaults to dashboard_inactive.');
|
||||
|
||||
// Now enable the block on the dashboard.
|
||||
$values = array();
|
||||
$values['blocks[comment_recent][region]'] = 'dashboard_main';
|
||||
$this->drupalPost('admin/dashboard/configure', $values, t('Save blocks'));
|
||||
$this->drupalGet('admin/dashboard');
|
||||
$this->assertText(t('Recent comments'), t('"Recent comments" was placed on dashboard.'));
|
||||
$this->assertText(t('Recent comments'), '"Recent comments" was placed on dashboard.');
|
||||
$this->drupalGet('admin/dashboard/drawer');
|
||||
$this->assertNoText(t('Recent comments'), t('Drawer of disabled blocks excludes enabled blocks.'));
|
||||
$this->assertNoText(t('Recent comments'), 'Drawer of disabled blocks excludes enabled blocks.');
|
||||
}
|
||||
}
|
||||
|
@@ -5,8 +5,8 @@ version = VERSION
|
||||
core = 7.x
|
||||
files[] = dblog.test
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
project = "drupal"
|
||||
datestamp = "1375928238"
|
||||
datestamp = "1399522731"
|
||||
|
||||
|
@@ -11,7 +11,7 @@
|
||||
class DBLogTestCase extends DrupalWebTestCase {
|
||||
|
||||
/**
|
||||
* A user with some relevent administrative permissions.
|
||||
* A user with some relevant administrative permissions.
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
|
@@ -1,4 +1,8 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Hooks provided by the Field module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup hooks
|
||||
@@ -37,6 +41,8 @@
|
||||
* - delete: (optional) String containing markup (normally a link) used as the
|
||||
* element's 'delete' operation in the administration interface. Only for
|
||||
* 'form' context.
|
||||
*
|
||||
* @ingroup field_types
|
||||
*/
|
||||
function hook_field_extra_fields() {
|
||||
$extra['node']['poll'] = array(
|
||||
@@ -76,6 +82,8 @@ function hook_field_extra_fields() {
|
||||
* The associative array of 'pseudo-field' components.
|
||||
*
|
||||
* @see hook_field_extra_fields()
|
||||
*
|
||||
* @ingroup field_types
|
||||
*/
|
||||
function hook_field_extra_fields_alter(&$info) {
|
||||
// Force node title to always be at the top of the list by default.
|
||||
@@ -113,6 +121,9 @@ function hook_field_extra_fields_alter(&$info) {
|
||||
/**
|
||||
* Define Field API field types.
|
||||
*
|
||||
* Along with this hook, you also need to implement other hooks. See
|
||||
* @link field_types Field Types API @endlink for more information.
|
||||
*
|
||||
* @return
|
||||
* An array whose keys are field type names and whose values are arrays
|
||||
* describing the field type, with the following key/value pairs:
|
||||
@@ -199,8 +210,11 @@ function hook_field_info_alter(&$info) {
|
||||
/**
|
||||
* Define the Field API schema for a field structure.
|
||||
*
|
||||
* This hook MUST be defined in .install for it to be detected during
|
||||
* installation and upgrade.
|
||||
* This is invoked when a field is created, in order to obtain the database
|
||||
* schema from the module that defines the field's type.
|
||||
*
|
||||
* This hook must be defined in the module's .install file for it to be detected
|
||||
* during installation and upgrade.
|
||||
*
|
||||
* @param $field
|
||||
* A field structure.
|
||||
@@ -650,6 +664,8 @@ function hook_field_delete_revision($entity_type, $entity, $field, $instance, $l
|
||||
* The source entity from which field values are being copied.
|
||||
* @param $source_langcode
|
||||
* The source language from which field values are being copied.
|
||||
*
|
||||
* @ingroup field_language
|
||||
*/
|
||||
function hook_field_prepare_translation($entity_type, $entity, $field, $instance, $langcode, &$items, $source_entity, $source_langcode) {
|
||||
// If the translating user is not permitted to use the assigned text format,
|
||||
@@ -1244,7 +1260,7 @@ function hook_field_formatter_view($entity_type, $entity, $field, $instance, $la
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup field_attach
|
||||
* @addtogroup field_attach
|
||||
* @{
|
||||
*/
|
||||
|
||||
@@ -1306,6 +1322,13 @@ function hook_field_attach_load($entity_type, $entities, $age, $options) {
|
||||
* This hook is invoked after the field module has performed the operation.
|
||||
*
|
||||
* See field_attach_validate() for details and arguments.
|
||||
*
|
||||
* @param $entity_type
|
||||
* The type of $entity; e.g., 'node' or 'user'.
|
||||
* @param $entity
|
||||
* The entity with fields to validate.
|
||||
* @param array $errors
|
||||
* An associative array of errors keyed by field_name, language, delta.
|
||||
*/
|
||||
function hook_field_attach_validate($entity_type, $entity, &$errors) {
|
||||
// @todo Needs function body.
|
||||
@@ -1510,6 +1533,8 @@ function hook_field_attach_prepare_translation_alter(&$entity, $context) {
|
||||
* - entity_type: The type of the entity to be displayed.
|
||||
* - entity: The entity with fields to render.
|
||||
* - langcode: The language code $entity has to be displayed in.
|
||||
*
|
||||
* @ingroup field_language
|
||||
*/
|
||||
function hook_field_language_alter(&$display_language, $context) {
|
||||
// Do not apply core language fallback rules if they are disabled or if Locale
|
||||
@@ -1531,6 +1556,8 @@ function hook_field_language_alter(&$display_language, $context) {
|
||||
* An associative array containing:
|
||||
* - entity_type: The type of the entity the field is attached to.
|
||||
* - field: A field data structure.
|
||||
*
|
||||
* @ingroup field_language
|
||||
*/
|
||||
function hook_field_available_languages_alter(&$languages, $context) {
|
||||
// Add an unavailable language.
|
||||
@@ -1581,7 +1608,7 @@ function hook_field_attach_rename_bundle($entity_type, $bundle_old, $bundle_new)
|
||||
* @param $entity_type
|
||||
* The type of entity; for example, 'node' or 'user'.
|
||||
* @param $bundle
|
||||
* The bundle that was just deleted.
|
||||
* The name of the bundle that was just deleted.
|
||||
* @param $instances
|
||||
* An array of all instances that existed for the bundle before it was
|
||||
* deleted.
|
||||
@@ -1596,7 +1623,7 @@ function hook_field_attach_delete_bundle($entity_type, $bundle, $instances) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @} End of "defgroup field_attach".
|
||||
* @} End of "addtogroup field_attach".
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -2256,6 +2283,10 @@ function hook_field_storage_pre_update($entity_type, $entity, &$skip_fields) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @} End of "addtogroup field_storage
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns the maximum weight for the entity components handled by the module.
|
||||
*
|
||||
@@ -2269,9 +2300,12 @@ function hook_field_storage_pre_update($entity_type, $entity, &$skip_fields) {
|
||||
* @param $context
|
||||
* The context for which the maximum weight is requested. Either 'form', or
|
||||
* the name of a view mode.
|
||||
*
|
||||
* @return
|
||||
* The maximum weight of the entity's components, or NULL if no components
|
||||
* were found.
|
||||
*
|
||||
* @ingroup field_info
|
||||
*/
|
||||
function hook_field_info_max_weight($entity_type, $bundle, $context) {
|
||||
$weights = array();
|
||||
@@ -2283,6 +2317,11 @@ function hook_field_info_max_weight($entity_type, $bundle, $context) {
|
||||
return $weights ? max($weights) : NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @addtogroup field_types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Alters the display settings of a field before it gets displayed.
|
||||
*
|
||||
@@ -2349,6 +2388,10 @@ function hook_field_display_ENTITY_TYPE_alter(&$display, $context) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @} End of "addtogroup field_types
|
||||
*/
|
||||
|
||||
/**
|
||||
* Alters the display settings of pseudo-fields before an entity is displayed.
|
||||
*
|
||||
@@ -2364,6 +2407,8 @@ function hook_field_display_ENTITY_TYPE_alter(&$display, $context) {
|
||||
* - entity_type: The entity type; e.g., 'node' or 'user'.
|
||||
* - bundle: The bundle name.
|
||||
* - view_mode: The view mode, e.g. 'full', 'teaser'...
|
||||
*
|
||||
* @ingroup field_types
|
||||
*/
|
||||
function hook_field_extra_fields_display_alter(&$displays, $context) {
|
||||
if ($context['entity_type'] == 'taxonomy_term' && $context['view_mode'] == 'full') {
|
||||
@@ -2393,6 +2438,8 @@ function hook_field_extra_fields_display_alter(&$displays, $context) {
|
||||
* - instance: The instance of the field.
|
||||
*
|
||||
* @see hook_field_widget_properties_alter()
|
||||
*
|
||||
* @ingroup field_widget
|
||||
*/
|
||||
function hook_field_widget_properties_ENTITY_TYPE_alter(&$widget, $context) {
|
||||
// Change a widget's type according to the time of day.
|
||||
@@ -2403,10 +2450,6 @@ function hook_field_widget_properties_ENTITY_TYPE_alter(&$widget, $context) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @} End of "addtogroup field_storage".
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup field_crud
|
||||
* @{
|
||||
@@ -2602,6 +2645,8 @@ function hook_field_purge_instance($instance) {
|
||||
*
|
||||
* @param $field
|
||||
* The field being purged.
|
||||
*
|
||||
* @ingroup field_storage
|
||||
*/
|
||||
function hook_field_storage_purge_field($field) {
|
||||
$table_name = _field_sql_storage_tablename($field);
|
||||
@@ -2619,6 +2664,8 @@ function hook_field_storage_purge_field($field) {
|
||||
*
|
||||
* @param $instance
|
||||
* The instance being purged.
|
||||
*
|
||||
* @ingroup field_storage
|
||||
*/
|
||||
function hook_field_storage_purge_field_instance($instance) {
|
||||
db_delete('my_module_field_instance_info')
|
||||
@@ -2640,6 +2687,8 @@ function hook_field_storage_purge_field_instance($instance) {
|
||||
* The (possibly deleted) field whose data is being purged.
|
||||
* @param $instance
|
||||
* The deleted field instance whose data is being purged.
|
||||
*
|
||||
* @ingroup field_storage
|
||||
*/
|
||||
function hook_field_storage_purge($entity_type, $entity, $field, $instance) {
|
||||
list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
|
||||
@@ -2679,6 +2728,8 @@ function hook_field_storage_purge($entity_type, $entity, $field, $instance) {
|
||||
*
|
||||
* @return
|
||||
* TRUE if the operation is allowed, and FALSE if the operation is denied.
|
||||
*
|
||||
* @ingroup field_types
|
||||
*/
|
||||
function hook_field_access($op, $field, $entity_type, $entity, $account) {
|
||||
if ($field['field_name'] == 'field_of_interest' && $op == 'edit') {
|
||||
|
@@ -976,6 +976,12 @@ function field_attach_insert($entity_type, $entity) {
|
||||
/**
|
||||
* Save field data for an existing entity.
|
||||
*
|
||||
* When calling this function outside an entity save operation be sure to
|
||||
* clear caches for the entity:
|
||||
* @code
|
||||
* entity_get_controller($entity_type)->resetCache(array($entity_id))
|
||||
* @endcode
|
||||
*
|
||||
* @param $entity_type
|
||||
* The type of $entity; e.g. 'node' or 'user'.
|
||||
* @param $entity
|
||||
|
@@ -11,8 +11,8 @@ dependencies[] = field_sql_storage
|
||||
required = TRUE
|
||||
stylesheets[all][] = theme/field.css
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
project = "drupal"
|
||||
datestamp = "1375928238"
|
||||
datestamp = "1399522731"
|
||||
|
||||
|
@@ -819,9 +819,9 @@ function field_view_value($entity_type, $entity, $field_name, $item, $display =
|
||||
*
|
||||
* This function can be used by third-party modules that need to output an
|
||||
* isolated field.
|
||||
* - Do not use inside node (or other entities) templates, use
|
||||
* - Do not use inside node (or any other entity) templates; use
|
||||
* render($content[FIELD_NAME]) instead.
|
||||
* - Do not use to display all fields in an entity, use
|
||||
* - Do not use to display all fields in an entity; use
|
||||
* field_attach_prepare_view() and field_attach_view() instead.
|
||||
* - The field_view_value() function can be used to output a single formatted
|
||||
* field value, without label or wrapping field markup.
|
||||
|
@@ -7,8 +7,8 @@ dependencies[] = field
|
||||
files[] = field_sql_storage.test
|
||||
required = TRUE
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
project = "drupal"
|
||||
datestamp = "1375928238"
|
||||
datestamp = "1399522731"
|
||||
|
||||
|
@@ -7,8 +7,8 @@ dependencies[] = field
|
||||
dependencies[] = options
|
||||
files[] = tests/list.test
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
project = "drupal"
|
||||
datestamp = "1375928238"
|
||||
datestamp = "1399522731"
|
||||
|
||||
|
@@ -5,8 +5,8 @@ package = Testing
|
||||
version = VERSION
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
project = "drupal"
|
||||
datestamp = "1375928238"
|
||||
datestamp = "1399522731"
|
||||
|
||||
|
@@ -6,8 +6,8 @@ core = 7.x
|
||||
dependencies[] = field
|
||||
files[] = number.test
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
project = "drupal"
|
||||
datestamp = "1375928238"
|
||||
datestamp = "1399522731"
|
||||
|
||||
|
@@ -6,8 +6,8 @@ core = 7.x
|
||||
dependencies[] = field
|
||||
files[] = options.test
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
project = "drupal"
|
||||
datestamp = "1375928238"
|
||||
datestamp = "1399522731"
|
||||
|
||||
|
@@ -359,7 +359,7 @@ class OptionsWidgetsTestCase extends FieldTestCase {
|
||||
|
||||
// Test the 'None' option.
|
||||
|
||||
// Check that the 'none' option has no efect if actual options are selected
|
||||
// Check that the 'none' option has no effect if actual options are selected
|
||||
// as well.
|
||||
$edit = array("card_2[$langcode][]" => array('_none' => '_none', 0 => 0));
|
||||
$this->drupalPost('test-entity/manage/' . $entity->ftid . '/edit', $edit, t('Save'));
|
||||
|
@@ -7,8 +7,8 @@ dependencies[] = field
|
||||
files[] = text.test
|
||||
required = TRUE
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
project = "drupal"
|
||||
datestamp = "1375928238"
|
||||
datestamp = "1399522731"
|
||||
|
||||
|
@@ -6,8 +6,8 @@ files[] = field_test.entity.inc
|
||||
version = VERSION
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
project = "drupal"
|
||||
datestamp = "1375928238"
|
||||
datestamp = "1399522731"
|
||||
|
||||
|
@@ -60,7 +60,7 @@ function field_test_schema() {
|
||||
'description' => 'The base table for test entities with a bundle key.',
|
||||
'fields' => array(
|
||||
'ftid' => array(
|
||||
'description' => 'The primary indentifier for a test_entity_bundle_key.',
|
||||
'description' => 'The primary identifier for a test_entity_bundle_key.',
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
@@ -79,7 +79,7 @@ function field_test_schema() {
|
||||
'description' => 'The base table for test entities with a bundle.',
|
||||
'fields' => array(
|
||||
'ftid' => array(
|
||||
'description' => 'The primary indentifier for a test_entity_bundle.',
|
||||
'description' => 'The primary identifier for a test_entity_bundle.',
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
|
@@ -936,7 +936,7 @@ function field_ui_display_overview_form($form, &$form_state, $entity_type, $bund
|
||||
$field_label_options = array(
|
||||
'above' => t('Above'),
|
||||
'inline' => t('Inline'),
|
||||
'hidden' => t('<Hidden>'),
|
||||
'hidden' => '<' . t('Hidden') . '>',
|
||||
);
|
||||
$extra_visibility_options = array(
|
||||
'visible' => t('Visible'),
|
||||
@@ -992,7 +992,7 @@ function field_ui_display_overview_form($form, &$form_state, $entity_type, $bund
|
||||
);
|
||||
|
||||
$formatter_options = field_ui_formatter_options($field['type']);
|
||||
$formatter_options['hidden'] = t('<Hidden>');
|
||||
$formatter_options['hidden'] = '<' . t('Hidden') . '>';
|
||||
$table[$name]['format'] = array(
|
||||
'type' => array(
|
||||
'#type' => 'select',
|
||||
|
@@ -6,8 +6,8 @@ core = 7.x
|
||||
dependencies[] = field
|
||||
files[] = field_ui.test
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
project = "drupal"
|
||||
datestamp = "1375928238"
|
||||
datestamp = "1399522731"
|
||||
|
||||
|
@@ -318,7 +318,7 @@ function field_ui_field_attach_create_bundle($entity_type, $bundle) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the adminstration path for a bundle.
|
||||
* Determines the administration path for a bundle.
|
||||
*/
|
||||
function _field_ui_bundle_admin_path($entity_type, $bundle_name) {
|
||||
$bundles = field_info_bundles($entity_type);
|
||||
|
@@ -186,7 +186,7 @@ function file_field_load($entity_type, $entities, $field, $instances, $langcode,
|
||||
$items[$id][$delta] = NULL;
|
||||
}
|
||||
else {
|
||||
$items[$id][$delta] = array_merge($item, (array) $files[$item['fid']]);
|
||||
$items[$id][$delta] = array_merge((array) $files[$item['fid']], $item);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -215,8 +215,16 @@ function file_field_presave($entity_type, $entity, $field, $instance, $langcode,
|
||||
// Make sure that each file which will be saved with this object has a
|
||||
// permanent status, so that it will not be removed when temporary files are
|
||||
// cleaned up.
|
||||
foreach ($items as $item) {
|
||||
foreach ($items as $delta => $item) {
|
||||
if (empty($item['fid'])) {
|
||||
unset($items[$delta]);
|
||||
continue;
|
||||
}
|
||||
$file = file_load($item['fid']);
|
||||
if (empty($file)) {
|
||||
unset($items[$delta]);
|
||||
continue;
|
||||
}
|
||||
if (!$file->status) {
|
||||
$file->status = FILE_STATUS_PERMANENT;
|
||||
file_save($file);
|
||||
@@ -760,7 +768,7 @@ function file_field_widget_submit($form, &$form_state) {
|
||||
$langcode = $element['#language'];
|
||||
$parents = $element['#field_parents'];
|
||||
|
||||
$submitted_values = drupal_array_get_nested_value($form_state['values'], array_slice($button['#array_parents'], 0, -2));
|
||||
$submitted_values = drupal_array_get_nested_value($form_state['values'], array_slice($button['#parents'], 0, -2));
|
||||
foreach ($submitted_values as $delta => $submitted_value) {
|
||||
if (!$submitted_value['fid']) {
|
||||
unset($submitted_values[$delta]);
|
||||
@@ -771,7 +779,7 @@ function file_field_widget_submit($form, &$form_state) {
|
||||
$submitted_values = array_values($submitted_values);
|
||||
|
||||
// Update form_state values.
|
||||
drupal_array_set_nested_value($form_state['values'], array_slice($button['#array_parents'], 0, -2), $submitted_values);
|
||||
drupal_array_set_nested_value($form_state['values'], array_slice($button['#parents'], 0, -2), $submitted_values);
|
||||
|
||||
// Update items.
|
||||
$field_state = field_form_get_state($parents, $field_name, $langcode, $form_state);
|
||||
|
@@ -6,8 +6,8 @@ core = 7.x
|
||||
dependencies[] = field
|
||||
files[] = tests/file.test
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
project = "drupal"
|
||||
datestamp = "1375928238"
|
||||
datestamp = "1399522731"
|
||||
|
||||
|
@@ -83,7 +83,7 @@ Drupal.file = Drupal.file || {
|
||||
'%filename': this.value.replace('C:\\fakepath\\', ''),
|
||||
'%extensions': extensionPattern.replace(/\|/g, ', ')
|
||||
});
|
||||
$(this).closest('div.form-managed-file').prepend('<div class="messages error file-upload-js-error">' + error + '</div>');
|
||||
$(this).closest('div.form-managed-file').prepend('<div class="messages error file-upload-js-error" aria-live="polite">' + error + '</div>');
|
||||
this.value = '';
|
||||
return false;
|
||||
}
|
||||
|
@@ -246,7 +246,7 @@ function file_ajax_upload() {
|
||||
return array('#type' => 'ajax', '#commands' => $commands);
|
||||
}
|
||||
|
||||
list($form, $form_state) = ajax_get_form();
|
||||
list($form, $form_state, $form_id, $form_build_id, $commands) = ajax_get_form();
|
||||
|
||||
if (!$form) {
|
||||
// Invalid form_build_id.
|
||||
@@ -284,7 +284,6 @@ function file_ajax_upload() {
|
||||
$js = drupal_add_js();
|
||||
$settings = call_user_func_array('array_merge_recursive', $js['settings']['data']);
|
||||
|
||||
$commands = array();
|
||||
$commands[] = ajax_command_replace(NULL, $output, $settings);
|
||||
return array('#type' => 'ajax', '#commands' => $commands);
|
||||
}
|
||||
|
@@ -5,8 +5,8 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
project = "drupal"
|
||||
datestamp = "1375928238"
|
||||
datestamp = "1399522731"
|
||||
|
||||
|
@@ -7,8 +7,8 @@ files[] = filter.test
|
||||
required = TRUE
|
||||
configure = admin/config/content/formats
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
project = "drupal"
|
||||
datestamp = "1375928238"
|
||||
datestamp = "1399522731"
|
||||
|
||||
|
@@ -739,8 +739,8 @@ function filter_list_format($format_id) {
|
||||
* @param $text
|
||||
* The text to be filtered.
|
||||
* @param $format_id
|
||||
* (optional) The format ID of the text to be filtered. If no format is
|
||||
* assigned, the fallback format will be used. Defaults to NULL.
|
||||
* (optional) The machine name of the filter format to be used to filter the
|
||||
* text. Defaults to the fallback format. See filter_fallback_format().
|
||||
* @param $langcode
|
||||
* (optional) The language code of the text to be filtered, e.g. 'en' for
|
||||
* English. This allows filters to be language aware so language specific
|
||||
|
@@ -9,8 +9,8 @@ files[] = forum.test
|
||||
configure = admin/structure/forum
|
||||
stylesheets[all][] = forum.css
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
project = "drupal"
|
||||
datestamp = "1375928238"
|
||||
datestamp = "1399522731"
|
||||
|
||||
|
@@ -5,8 +5,8 @@ version = VERSION
|
||||
core = 7.x
|
||||
files[] = help.test
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
project = "drupal"
|
||||
datestamp = "1375928238"
|
||||
datestamp = "1399522731"
|
||||
|
||||
|
@@ -592,15 +592,15 @@ function image_crop_form($data) {
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Anchor'),
|
||||
'#options' => array(
|
||||
'left-top' => t('Top') . ' ' . t('Left'),
|
||||
'center-top' => t('Top') . ' ' . t('Center'),
|
||||
'right-top' => t('Top') . ' ' . t('Right'),
|
||||
'left-center' => t('Center') . ' ' . t('Left'),
|
||||
'left-top' => t('Top left'),
|
||||
'center-top' => t('Top center'),
|
||||
'right-top' => t('Top right'),
|
||||
'left-center' => t('Center left'),
|
||||
'center-center' => t('Center'),
|
||||
'right-center' => t('Center') . ' ' . t('Right'),
|
||||
'left-bottom' => t('Bottom') . ' ' . t('Left'),
|
||||
'center-bottom' => t('Bottom') . ' ' . t('Center'),
|
||||
'right-bottom' => t('Bottom') . ' ' . t('Right'),
|
||||
'right-center' => t('Center right'),
|
||||
'left-bottom' => t('Bottom left'),
|
||||
'center-bottom' => t('Bottom center'),
|
||||
'right-bottom' => t('Bottom right'),
|
||||
),
|
||||
'#theme' => 'image_anchor',
|
||||
'#default_value' => $data['anchor'],
|
||||
|
@@ -351,7 +351,7 @@ function image_field_widget_form(&$form, &$form_state, $field, $instance, $langc
|
||||
if ($field['cardinality'] == 1) {
|
||||
// If there's only one field, return it as delta 0.
|
||||
if (empty($elements[0]['#default_value']['fid'])) {
|
||||
$elements[0]['#description'] = theme('file_upload_help', array('description' => $instance['description'], 'upload_validators' => $elements[0]['#upload_validators']));
|
||||
$elements[0]['#description'] = theme('file_upload_help', array('description' => field_filter_xss($instance['description']), 'upload_validators' => $elements[0]['#upload_validators']));
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@@ -7,8 +7,8 @@ dependencies[] = file
|
||||
files[] = image.test
|
||||
configure = admin/config/media/image-styles
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
project = "drupal"
|
||||
datestamp = "1375928238"
|
||||
datestamp = "1399522731"
|
||||
|
||||
|
@@ -835,7 +835,7 @@ function image_style_deliver($style, $scheme) {
|
||||
else {
|
||||
$headers = module_invoke_all('file_download', $image_uri);
|
||||
if (in_array(-1, $headers) || empty($headers)) {
|
||||
return drupal_access_denied();
|
||||
return MENU_ACCESS_DENIED;
|
||||
}
|
||||
if (count($headers)) {
|
||||
foreach ($headers as $name => $value) {
|
||||
@@ -972,7 +972,9 @@ function image_style_flush($style) {
|
||||
// Delete the style directory in each registered wrapper.
|
||||
$wrappers = file_get_stream_wrappers(STREAM_WRAPPERS_WRITE_VISIBLE);
|
||||
foreach ($wrappers as $wrapper => $wrapper_data) {
|
||||
file_unmanaged_delete_recursive($wrapper . '://styles/' . $style['name']);
|
||||
if (file_exists($directory = $wrapper . '://styles/' . $style['name'])) {
|
||||
file_unmanaged_delete_recursive($directory);
|
||||
}
|
||||
}
|
||||
|
||||
// Let other modules update as necessary on flush.
|
||||
@@ -1010,10 +1012,14 @@ function image_style_flush($style) {
|
||||
*/
|
||||
function image_style_url($style_name, $path) {
|
||||
$uri = image_style_path($style_name, $path);
|
||||
|
||||
// The passed-in $path variable can be either a relative path or a full URI.
|
||||
$original_uri = file_uri_scheme($path) ? file_stream_wrapper_uri_normalize($path) : file_build_uri($path);
|
||||
|
||||
// The token query is added even if the 'image_allow_insecure_derivatives'
|
||||
// variable is TRUE, so that the emitted links remain valid if it is changed
|
||||
// back to the default FALSE.
|
||||
$token_query = array(IMAGE_DERIVATIVE_TOKEN => image_style_path_token($style_name, file_stream_wrapper_uri_normalize($path)));
|
||||
$token_query = array(IMAGE_DERIVATIVE_TOKEN => image_style_path_token($style_name, $original_uri));
|
||||
|
||||
// If not using clean URLs, the image derivative callback is only available
|
||||
// with the query string. If the file does not exist, use url() to ensure
|
||||
|
@@ -216,10 +216,20 @@ class ImageStylesPathAndUrlTestCase extends DrupalWebTestCase {
|
||||
}
|
||||
// Add some extra chars to the token.
|
||||
$this->drupalGet(str_replace(IMAGE_DERIVATIVE_TOKEN . '=', IMAGE_DERIVATIVE_TOKEN . '=Zo', $generate_url));
|
||||
$this->assertResponse(403, 'Image was inaccessible at the URL wih an invalid token.');
|
||||
$this->assertResponse(403, 'Image was inaccessible at the URL with an invalid token.');
|
||||
// Change the parameter name so the token is missing.
|
||||
$this->drupalGet(str_replace(IMAGE_DERIVATIVE_TOKEN . '=', 'wrongparam=', $generate_url));
|
||||
$this->assertResponse(403, 'Image was inaccessible at the URL wih a missing token.');
|
||||
$this->assertResponse(403, 'Image was inaccessible at the URL with a missing token.');
|
||||
|
||||
// Check that the generated URL is the same when we pass in a relative path
|
||||
// rather than a URI. We need to temporarily switch the default scheme to
|
||||
// match the desired scheme before testing this, then switch it back to the
|
||||
// "temporary" scheme used throughout this test afterwards.
|
||||
variable_set('file_default_scheme', $scheme);
|
||||
$relative_path = file_uri_target($original_uri);
|
||||
$generate_url_from_relative_path = image_style_url($this->style_name, $relative_path);
|
||||
$this->assertEqual($generate_url, $generate_url_from_relative_path, 'Generated URL is the same regardless of whether it came from a relative path or a file URI.');
|
||||
variable_set('file_default_scheme', 'temporary');
|
||||
|
||||
// Fetch the URL that generates the file.
|
||||
$this->drupalGet($generate_url);
|
||||
@@ -268,7 +278,7 @@ class ImageStylesPathAndUrlTestCase extends DrupalWebTestCase {
|
||||
elseif ($clean_url) {
|
||||
// Add some extra chars to the token.
|
||||
$this->drupalGet(str_replace(IMAGE_DERIVATIVE_TOKEN . '=', IMAGE_DERIVATIVE_TOKEN . '=Zo', $generate_url));
|
||||
$this->assertResponse(200, 'Existing image was accessible at the URL wih an invalid token.');
|
||||
$this->assertResponse(200, 'Existing image was accessible at the URL with an invalid token.');
|
||||
}
|
||||
|
||||
// Allow insecure image derivatives to be created for the remainder of this
|
||||
|
@@ -6,8 +6,8 @@ core = 7.x
|
||||
files[] = image_module_test.module
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
project = "drupal"
|
||||
datestamp = "1375928238"
|
||||
datestamp = "1399522731"
|
||||
|
||||
|
@@ -1242,9 +1242,7 @@ function locale_translate_delete_page($lid) {
|
||||
if ($source = db_query('SELECT lid, source FROM {locales_source} WHERE lid = :lid', array(':lid' => $lid))->fetchObject()) {
|
||||
return drupal_get_form('locale_translate_delete_form', $source);
|
||||
}
|
||||
else {
|
||||
return drupal_not_found();
|
||||
}
|
||||
return MENU_NOT_FOUND;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -6,8 +6,8 @@ core = 7.x
|
||||
files[] = locale.test
|
||||
configure = admin/config/regional/language
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
project = "drupal"
|
||||
datestamp = "1375928238"
|
||||
datestamp = "1399522731"
|
||||
|
||||
|
@@ -1685,7 +1685,7 @@ class LocaleBrowserDetectionTest extends DrupalUnitTestCase {
|
||||
);
|
||||
|
||||
$test_cases = array(
|
||||
// Equal qvalue for each language, choose the site prefered one.
|
||||
// Equal qvalue for each language, choose the site preferred one.
|
||||
'en,en-US,fr-CA,fr,es-MX' => 'en',
|
||||
'en-US,en,fr-CA,fr,es-MX' => 'en',
|
||||
'fr,en' => 'en',
|
||||
|
@@ -5,8 +5,8 @@ package = Testing
|
||||
version = VERSION
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
project = "drupal"
|
||||
datestamp = "1375928238"
|
||||
datestamp = "1399522731"
|
||||
|
||||
|
@@ -512,8 +512,7 @@ function menu_delete_menu_page($menu) {
|
||||
// System-defined menus may not be deleted.
|
||||
$system_menus = menu_list_system_menus();
|
||||
if (isset($system_menus[$menu['menu_name']])) {
|
||||
drupal_access_denied();
|
||||
return;
|
||||
return MENU_ACCESS_DENIED;
|
||||
}
|
||||
return drupal_get_form('menu_delete_menu_confirm', $menu);
|
||||
}
|
||||
@@ -622,8 +621,7 @@ function menu_item_delete_page($item) {
|
||||
// Links defined via hook_menu may not be deleted. Updated items are an
|
||||
// exception, as they can be broken.
|
||||
if ($item['module'] == 'system' && !$item['updated']) {
|
||||
drupal_access_denied();
|
||||
return;
|
||||
return MENU_ACCESS_DENIED;
|
||||
}
|
||||
return drupal_get_form('menu_item_delete_form', $item);
|
||||
}
|
||||
|
@@ -6,8 +6,8 @@ core = 7.x
|
||||
files[] = menu.test
|
||||
configure = admin/structure/menu
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
project = "drupal"
|
||||
datestamp = "1375928238"
|
||||
datestamp = "1399522731"
|
||||
|
||||
|
@@ -255,11 +255,11 @@ function _node_characters($length) {
|
||||
*/
|
||||
function node_type_form_validate($form, &$form_state) {
|
||||
$type = new stdClass();
|
||||
$type->type = trim($form_state['values']['type']);
|
||||
$type->type = $form_state['values']['type'];
|
||||
$type->name = trim($form_state['values']['name']);
|
||||
|
||||
// Work out what the type was before the user submitted this form
|
||||
$old_type = trim($form_state['values']['old_type']);
|
||||
$old_type = $form_state['values']['old_type'];
|
||||
|
||||
$types = node_type_get_names();
|
||||
|
||||
@@ -288,7 +288,7 @@ function node_type_form_submit($form, &$form_state) {
|
||||
|
||||
$type = node_type_set_defaults();
|
||||
|
||||
$type->type = trim($form_state['values']['type']);
|
||||
$type->type = $form_state['values']['type'];
|
||||
$type->name = trim($form_state['values']['name']);
|
||||
$type->orig_type = trim($form_state['values']['orig_type']);
|
||||
$type->old_type = isset($form_state['values']['old_type']) ? $form_state['values']['old_type'] : $type->type;
|
||||
|
@@ -471,6 +471,7 @@ function node_admin_nodes() {
|
||||
$header['operations'] = array('data' => t('Operations'));
|
||||
|
||||
$query = db_select('node', 'n')->extend('PagerDefault')->extend('TableSort');
|
||||
$query->addTag('node_admin_filter');
|
||||
node_build_filter_query($query);
|
||||
|
||||
if (!user_access('bypass node access')) {
|
||||
@@ -695,6 +696,7 @@ function node_multiple_delete_confirm($form, &$form_state, $nodes) {
|
||||
function node_multiple_delete_confirm_submit($form, &$form_state) {
|
||||
if ($form_state['values']['confirm']) {
|
||||
node_delete_multiple(array_keys($form_state['values']['nodes']));
|
||||
cache_clear_all();
|
||||
$count = count($form_state['values']['nodes']);
|
||||
watchdog('content', 'Deleted @count posts.', array('@count' => $count));
|
||||
drupal_set_message(format_plural($count, 'Deleted 1 post.', 'Deleted @count posts.'));
|
||||
|
@@ -1033,9 +1033,17 @@ function hook_node_type_delete($info) {
|
||||
* This hook is invoked only on the module that defines the node's content type
|
||||
* (use hook_node_delete() to respond to all node deletions).
|
||||
*
|
||||
* This hook is invoked from node_delete_multiple() after the node has been
|
||||
* removed from the node table in the database, before hook_node_delete() is
|
||||
* invoked, and before field_attach_delete() is called.
|
||||
* This hook is invoked from node_delete_multiple() before hook_node_delete()
|
||||
* is invoked and before field_attach_delete() is called.
|
||||
*
|
||||
* Note that when this hook is invoked, the changes have not yet been written
|
||||
* to the database, because a database transaction is still in progress. The
|
||||
* transaction is not finalized until the delete operation is entirely
|
||||
* completed and node_delete_multiple() goes out of scope. You should not rely
|
||||
* on data in the database at this time as it is not updated yet. You should
|
||||
* also note that any write/update database queries executed from this hook are
|
||||
* also not committed immediately. Check node_delete_multiple() and
|
||||
* db_transaction() for more info.
|
||||
*
|
||||
* @param $node
|
||||
* The node that is being deleted.
|
||||
@@ -1063,21 +1071,19 @@ function hook_delete($node) {
|
||||
* @ingroup node_api_hooks
|
||||
*/
|
||||
function hook_prepare($node) {
|
||||
if ($file = file_check_upload($field_name)) {
|
||||
$file = file_save_upload($field_name, _image_filename($file->filename, NULL, TRUE));
|
||||
if ($file) {
|
||||
if (!image_get_info($file->uri)) {
|
||||
form_set_error($field_name, t('Uploaded file is not a valid image'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$file = file_save_upload($field_name, _image_filename($file->filename, NULL, TRUE));
|
||||
if ($file) {
|
||||
if (!image_get_info($file->uri)) {
|
||||
form_set_error($field_name, t('Uploaded file is not a valid image'));
|
||||
return;
|
||||
}
|
||||
$node->images['_original'] = $file->uri;
|
||||
_image_build_derivatives($node, TRUE);
|
||||
$node->new_file = TRUE;
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
$node->images['_original'] = $file->uri;
|
||||
_image_build_derivatives($node, TRUE);
|
||||
$node->new_file = TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -9,8 +9,8 @@ required = TRUE
|
||||
configure = admin/structure/types
|
||||
stylesheets[all][] = node.css
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
project = "drupal"
|
||||
datestamp = "1375928238"
|
||||
datestamp = "1399522731"
|
||||
|
||||
|
@@ -114,6 +114,7 @@ function node_schema() {
|
||||
'uid' => array('uid'),
|
||||
'tnid' => array('tnid'),
|
||||
'translate' => array('translate'),
|
||||
'language' => array('language'),
|
||||
),
|
||||
'unique keys' => array(
|
||||
'vid' => array('vid'),
|
||||
@@ -925,6 +926,13 @@ function node_update_7013() {
|
||||
db_add_unique_key('node', 'vid', array('vid'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an index on {node}.language.
|
||||
*/
|
||||
function node_update_7014() {
|
||||
db_add_index('node', 'language', array('language'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @} End of "addtogroup updates-7.x-extra".
|
||||
*/
|
||||
|
@@ -1179,10 +1179,8 @@ function node_save($node) {
|
||||
module_invoke_all('node_' . $op, $node);
|
||||
module_invoke_all('entity_' . $op, $node, 'node');
|
||||
|
||||
// Update the node access table for this node. There's no need to delete
|
||||
// existing records if the node is new.
|
||||
$delete = $op == 'update';
|
||||
node_access_acquire_grants($node, $delete);
|
||||
// Update the node access table for this node.
|
||||
node_access_acquire_grants($node);
|
||||
|
||||
// Clear internal properties.
|
||||
unset($node->is_new);
|
||||
@@ -1685,7 +1683,7 @@ function node_search_admin() {
|
||||
);
|
||||
$form['content_ranking']['#theme'] = 'node_search_admin';
|
||||
$form['content_ranking']['info'] = array(
|
||||
'#value' => '<em>' . t('The following numbers control which properties the content search should favor when ordering the results. Higher numbers mean more influence, zero means the property is ignored. Changing these numbers does not require the search index to be rebuilt. Changes take effect immediately.') . '</em>'
|
||||
'#markup' => '<p><em>' . t('Influence is a numeric multiplier used in ordering search results. A higher number means the corresponding factor has more influence on search results; zero means the factor is ignored. Changing these numbers does not require the search index to be rebuilt. Changes take effect immediately.') . '</em></p>'
|
||||
);
|
||||
|
||||
// Note: reversed to reflect that higher number = higher ranking.
|
||||
@@ -1872,7 +1870,7 @@ function theme_node_search_admin($variables) {
|
||||
|
||||
$output = drupal_render($form['info']);
|
||||
|
||||
$header = array(t('Factor'), t('Weight'));
|
||||
$header = array(t('Factor'), t('Influence'));
|
||||
foreach (element_children($form['factors']) as $key) {
|
||||
$row = array();
|
||||
$row[] = $form['factors'][$key]['#title'];
|
||||
@@ -2224,8 +2222,8 @@ function node_last_changed($nid) {
|
||||
/**
|
||||
* Returns a list of all the existing revision numbers.
|
||||
*
|
||||
* @param Drupal\node\Node $node
|
||||
* The node entity.
|
||||
* @param $node
|
||||
* The node object.
|
||||
*
|
||||
* @return
|
||||
* An associative array keyed by node revision number.
|
||||
@@ -3292,6 +3290,17 @@ function node_query_entity_field_access_alter(QueryAlterableInterface $query) {
|
||||
/**
|
||||
* Helper for node access functions.
|
||||
*
|
||||
* Queries tagged with 'node_access' that are not against the {node} table
|
||||
* should add the base table as metadata. For example:
|
||||
* @code
|
||||
* $query
|
||||
* ->addTag('node_access')
|
||||
* ->addMetaData('base_table', 'taxonomy_index');
|
||||
* @endcode
|
||||
* If the query is not against the {node} table, an attempt is made to guess
|
||||
* the table, but is not recommended to rely on this as it is deprecated and not
|
||||
* allowed in Drupal 8. It is always safer to provide the table.
|
||||
*
|
||||
* @param $query
|
||||
* The query to add conditions to.
|
||||
* @param $type
|
||||
|
@@ -542,6 +542,7 @@ function node_delete_confirm_submit($form, &$form_state) {
|
||||
if ($form_state['values']['confirm']) {
|
||||
$node = node_load($form_state['values']['nid']);
|
||||
node_delete($form_state['values']['nid']);
|
||||
cache_clear_all();
|
||||
watchdog('content', '@type: deleted %title.', array('@type' => $node->type, '%title' => $node->title));
|
||||
drupal_set_message(t('@type %title has been deleted.', array('@type' => node_type_get_name($node), '%title' => $node->title)));
|
||||
}
|
||||
|
@@ -571,6 +571,8 @@ class NodeCreationTestCase extends DrupalWebTestCase {
|
||||
);
|
||||
|
||||
try {
|
||||
// An exception is generated by node_test_exception_node_insert() if the
|
||||
// title is 'testing_transaction_exception'.
|
||||
node_save((object) $edit);
|
||||
$this->fail(t('Expected exception has not been thrown.'));
|
||||
}
|
||||
@@ -1363,6 +1365,22 @@ class NodeSaveTestCase extends DrupalWebTestCase {
|
||||
$node = node_load($node->nid);
|
||||
$this->assertEqual($node->title, 'updated_presave', 'Static cache has been cleared.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests saving a node on node insert.
|
||||
*
|
||||
* This test ensures that a node has been fully saved when hook_node_insert()
|
||||
* is invoked, so that the node can be saved again in a hook implementation
|
||||
* without errors.
|
||||
*
|
||||
* @see node_test_node_insert()
|
||||
*/
|
||||
function testNodeSaveOnInsert() {
|
||||
// node_test_node_insert() triggers a save on insert if the title equals
|
||||
// 'new'.
|
||||
$node = $this->drupalCreateNode(array('title' => 'new'));
|
||||
$this->assertEqual($node->title, 'Node ' . $node->nid, 'Node saved on node insert.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2426,6 +2444,35 @@ class NodeTokenReplaceTestCase extends DrupalWebTestCase {
|
||||
$output = token_replace($input, array('node' => $node), array('language' => $language, 'sanitize' => FALSE));
|
||||
$this->assertEqual($output, $expected, format_string('Unsanitized node token %token replaced.', array('%token' => $input)));
|
||||
}
|
||||
|
||||
// Repeat for a node without a summary.
|
||||
$settings['body'] = array(LANGUAGE_NONE => array(array('value' => $this->randomName(32), 'summary' => '')));
|
||||
$node = $this->drupalCreateNode($settings);
|
||||
|
||||
// Load node (without summary) so that the body and summary fields are
|
||||
// structured properly.
|
||||
$node = node_load($node->nid);
|
||||
$instance = field_info_instance('node', 'body', $node->type);
|
||||
|
||||
// Generate and test sanitized token - use full body as expected value.
|
||||
$tests = array();
|
||||
$tests['[node:summary]'] = _text_sanitize($instance, $langcode, $node->body[$langcode][0], 'value');
|
||||
|
||||
// Test to make sure that we generated something for each token.
|
||||
$this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated for node without a summary.');
|
||||
|
||||
foreach ($tests as $input => $expected) {
|
||||
$output = token_replace($input, array('node' => $node), array('language' => $language));
|
||||
$this->assertEqual($output, $expected, format_string('Sanitized node token %token replaced for node without a summary.', array('%token' => $input)));
|
||||
}
|
||||
|
||||
// Generate and test unsanitized tokens.
|
||||
$tests['[node:summary]'] = $node->body[$langcode][0]['value'];
|
||||
|
||||
foreach ($tests as $input => $expected) {
|
||||
$output = token_replace($input, array('node' => $node), array('language' => $language, 'sanitize' => FALSE));
|
||||
$this->assertEqual($output, $expected, format_string('Unsanitized node token %token replaced for node without a summary.', array('%token' => $input)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2755,3 +2802,78 @@ class NodeEntityViewModeAlterTest extends NodeWebTestCase {
|
||||
$this->assertEqual($build['#view_mode'], 'teaser', 'The view mode has correctly been set to teaser.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the cache invalidation of node operations.
|
||||
*/
|
||||
class NodePageCacheTest extends NodeWebTestCase {
|
||||
|
||||
/**
|
||||
* An admin user with administrative permissions for nodes.
|
||||
*/
|
||||
protected $admin_user;
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Node page cache test',
|
||||
'description' => 'Test cache invalidation of node operations.',
|
||||
'group' => 'Node',
|
||||
);
|
||||
}
|
||||
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
variable_set('cache', 1);
|
||||
variable_set('page_cache_maximum_age', 300);
|
||||
|
||||
$this->admin_user = $this->drupalCreateUser(array(
|
||||
'bypass node access',
|
||||
'access content overview',
|
||||
'administer nodes',
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests deleting nodes clears page cache.
|
||||
*/
|
||||
public function testNodeDelete() {
|
||||
$node_path = 'node/' . $this->drupalCreateNode()->nid;
|
||||
|
||||
// Populate page cache.
|
||||
$this->drupalGet($node_path);
|
||||
|
||||
// Login and delete the node.
|
||||
$this->drupalLogin($this->admin_user);
|
||||
$this->drupalPost($node_path . '/delete', array(), t('Delete'));
|
||||
|
||||
// Logout and check the node is not available.
|
||||
$this->drupalLogout();
|
||||
$this->drupalGet($node_path);
|
||||
$this->assertResponse(404);
|
||||
|
||||
// Create two new nodes.
|
||||
$nodes[0] = $this->drupalCreateNode();
|
||||
$nodes[1] = $this->drupalCreateNode();
|
||||
$node_path = 'node/' . $nodes[0]->nid;
|
||||
|
||||
// Populate page cache.
|
||||
$this->drupalGet($node_path);
|
||||
|
||||
// Login and delete the nodes.
|
||||
$this->drupalLogin($this->admin_user);
|
||||
$this->drupalGet('admin/content');
|
||||
$edit = array(
|
||||
'operation' => 'delete',
|
||||
'nodes[' . $nodes[0]->nid . ']' => TRUE,
|
||||
'nodes[' . $nodes[1]->nid . ']' => TRUE,
|
||||
);
|
||||
$this->drupalPost(NULL, $edit, t('Update'));
|
||||
$this->drupalPost(NULL, array(), t('Delete'));
|
||||
|
||||
// Logout and check the node is not available.
|
||||
$this->drupalLogout();
|
||||
$this->drupalGet($node_path);
|
||||
$this->assertResponse(404);
|
||||
}
|
||||
}
|
||||
|
@@ -136,10 +136,29 @@ function node_tokens($type, $tokens, array $data = array(), array $options = arr
|
||||
case 'body':
|
||||
case 'summary':
|
||||
if ($items = field_get_items('node', $node, 'body', $language_code)) {
|
||||
$column = ($name == 'body') ? 'value' : 'summary';
|
||||
$instance = field_info_instance('node', 'body', $node->type);
|
||||
$field_langcode = field_language('node', $node, 'body', $language_code);
|
||||
$replacements[$original] = $sanitize ? _text_sanitize($instance, $field_langcode, $items[0], $column) : $items[0][$column];
|
||||
// If the summary was requested and is not empty, use it.
|
||||
if ($name == 'summary' && !empty($items[0]['summary'])) {
|
||||
$output = $sanitize ? _text_sanitize($instance, $field_langcode, $items[0], 'summary') : $items[0]['summary'];
|
||||
}
|
||||
// Attempt to provide a suitable version of the 'body' field.
|
||||
else {
|
||||
$output = $sanitize ? _text_sanitize($instance, $field_langcode, $items[0], 'value') : $items[0]['value'];
|
||||
// A summary was requested.
|
||||
if ($name == 'summary') {
|
||||
if (isset($instance['display']['teaser']['settings']['trim_length'])) {
|
||||
$trim_length = $instance['display']['teaser']['settings']['trim_length'];
|
||||
}
|
||||
else {
|
||||
// Use default value.
|
||||
$trim_length = NULL;
|
||||
}
|
||||
// Generate an optionally trimmed summary of the body field.
|
||||
$output = text_summary($output, $instance['settings']['text_processing'] ? $items[0]['format'] : NULL, $trim_length);
|
||||
}
|
||||
}
|
||||
$replacements[$original] = $output;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@@ -5,8 +5,8 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
project = "drupal"
|
||||
datestamp = "1375928238"
|
||||
datestamp = "1399522731"
|
||||
|
||||
|
@@ -5,8 +5,8 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
project = "drupal"
|
||||
datestamp = "1375928238"
|
||||
datestamp = "1399522731"
|
||||
|
||||
|
@@ -161,3 +161,21 @@ function node_test_entity_view_mode_alter(&$view_mode, $context) {
|
||||
$view_mode = $change_view_mode;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_node_insert().
|
||||
*
|
||||
* This tests saving a node on node insert.
|
||||
*
|
||||
* @see NodeSaveTest::testNodeSaveOnInsert()
|
||||
*/
|
||||
function node_test_node_insert($node) {
|
||||
// Set the node title to the node ID and save.
|
||||
if ($node->title == 'new') {
|
||||
$node->title = 'Node '. $node->nid;
|
||||
// Remove the is_new flag, so that the node is updated and not inserted
|
||||
// again.
|
||||
unset($node->is_new);
|
||||
node_save($node);
|
||||
}
|
||||
}
|
||||
|
@@ -5,8 +5,8 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
project = "drupal"
|
||||
datestamp = "1375928238"
|
||||
datestamp = "1399522731"
|
||||
|
||||
|
@@ -380,6 +380,9 @@ function _openid_parse_message($message) {
|
||||
|
||||
/**
|
||||
* Return a nonce value - formatted per OpenID spec.
|
||||
*
|
||||
* NOTE: This nonce is not cryptographically secure and only suitable for use
|
||||
* by the test framework.
|
||||
*/
|
||||
function _openid_nonce() {
|
||||
// YYYY-MM-DDThh:mm:ssZ, plus some optional extra unique characters.
|
||||
@@ -549,7 +552,7 @@ function _openid_dh_rand($stop) {
|
||||
}
|
||||
|
||||
do {
|
||||
$bytes = "\x00" . _openid_get_bytes($nbytes);
|
||||
$bytes = "\x00" . drupal_random_bytes($nbytes);
|
||||
$n = _openid_dh_binary_to_long($bytes);
|
||||
// Keep looping if this value is in the low duplicated range.
|
||||
} while (_openid_math_cmp($n, $duplicate) < 0);
|
||||
@@ -558,23 +561,7 @@ function _openid_dh_rand($stop) {
|
||||
}
|
||||
|
||||
function _openid_get_bytes($num_bytes) {
|
||||
$f = &drupal_static(__FUNCTION__);
|
||||
$bytes = '';
|
||||
if (!isset($f)) {
|
||||
$f = @fopen(OPENID_RAND_SOURCE, "r");
|
||||
}
|
||||
if (!$f) {
|
||||
// pseudorandom used
|
||||
$bytes = '';
|
||||
for ($i = 0; $i < $num_bytes; $i += 4) {
|
||||
$bytes .= pack('L', mt_rand());
|
||||
}
|
||||
$bytes = substr($bytes, 0, $num_bytes);
|
||||
}
|
||||
else {
|
||||
$bytes = fread($f, $num_bytes);
|
||||
}
|
||||
return $bytes;
|
||||
return drupal_random_bytes($num_bytes);
|
||||
}
|
||||
|
||||
function _openid_response($str = NULL) {
|
||||
|
@@ -5,8 +5,8 @@ package = Core
|
||||
core = 7.x
|
||||
files[] = openid.test
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
project = "drupal"
|
||||
datestamp = "1375928238"
|
||||
datestamp = "1399522731"
|
||||
|
||||
|
@@ -15,13 +15,14 @@ function openid_schema() {
|
||||
'idp_endpoint_uri' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'description' => 'URI of the OpenID Provider endpoint.',
|
||||
'not null' => TRUE,
|
||||
'description' => 'Primary Key: URI of the OpenID Provider endpoint.',
|
||||
),
|
||||
'assoc_handle' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
'description' => 'Primary Key: Used to refer to this association in subsequent messages.',
|
||||
'description' => 'Used to refer to this association in subsequent messages.',
|
||||
),
|
||||
'assoc_type' => array(
|
||||
'type' => 'varchar',
|
||||
@@ -51,7 +52,10 @@ function openid_schema() {
|
||||
'description' => 'The lifetime, in seconds, of this association.',
|
||||
),
|
||||
),
|
||||
'primary key' => array('assoc_handle'),
|
||||
'primary key' => array('idp_endpoint_uri'),
|
||||
'unique keys' => array(
|
||||
'assoc_handle' => array('assoc_handle'),
|
||||
),
|
||||
);
|
||||
|
||||
$schema['openid_nonce'] = array(
|
||||
@@ -158,3 +162,69 @@ function openid_update_6000() {
|
||||
/**
|
||||
* @} End of "addtogroup updates-6.x-to-7.x".
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup updates-7.x-extra
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Bind associations to their providers.
|
||||
*/
|
||||
function openid_update_7000() {
|
||||
db_drop_table('openid_association');
|
||||
|
||||
$schema = array(
|
||||
'description' => 'Stores temporary shared key association information for OpenID authentication.',
|
||||
'fields' => array(
|
||||
'idp_endpoint_uri' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
'description' => 'Primary Key: URI of the OpenID Provider endpoint.',
|
||||
),
|
||||
'assoc_handle' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
'description' => 'Used to refer to this association in subsequent messages.',
|
||||
),
|
||||
'assoc_type' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => 32,
|
||||
'description' => 'The signature algorithm used: one of HMAC-SHA1 or HMAC-SHA256.',
|
||||
),
|
||||
'session_type' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => 32,
|
||||
'description' => 'Valid association session types: "no-encryption", "DH-SHA1", and "DH-SHA256".',
|
||||
),
|
||||
'mac_key' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'description' => 'The MAC key (shared secret) for this association.',
|
||||
),
|
||||
'created' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
'description' => 'UNIX timestamp for when the association was created.',
|
||||
),
|
||||
'expires_in' => array(
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
'description' => 'The lifetime, in seconds, of this association.',
|
||||
),
|
||||
),
|
||||
'primary key' => array('idp_endpoint_uri'),
|
||||
'unique keys' => array(
|
||||
'assoc_handle' => array('assoc_handle'),
|
||||
),
|
||||
);
|
||||
db_create_table('openid_association', $schema);
|
||||
}
|
||||
|
||||
/**
|
||||
* @} End of "addtogroup updates-7.x-extra".
|
||||
*/
|
||||
|
@@ -839,7 +839,7 @@ function openid_verify_assertion($service, $response) {
|
||||
// direct verification: ignore the openid.assoc_handle, even if present.
|
||||
// See http://openid.net/specs/openid-authentication-2_0.html#rfc.section.11.4.1
|
||||
if (!empty($response['openid.assoc_handle']) && empty($response['openid.invalidate_handle'])) {
|
||||
$association = db_query("SELECT * FROM {openid_association} WHERE assoc_handle = :assoc_handle", array(':assoc_handle' => $response['openid.assoc_handle']))->fetchObject();
|
||||
$association = db_query("SELECT * FROM {openid_association} WHERE idp_endpoint_uri = :endpoint AND assoc_handle = :assoc_handle", array(':endpoint' => $service['uri'], ':assoc_handle' => $response['openid.assoc_handle']))->fetchObject();
|
||||
}
|
||||
|
||||
if ($association && isset($association->session_type)) {
|
||||
@@ -871,6 +871,7 @@ function openid_verify_assertion($service, $response) {
|
||||
// database to avoid reusing it again on a subsequent authentication request.
|
||||
// See http://openid.net/specs/openid-authentication-2_0.html#rfc.section.11.4.2.2
|
||||
db_delete('openid_association')
|
||||
->condition('idp_endpoint_uri', $service['uri'])
|
||||
->condition('assoc_handle', $response['invalidate_handle'])
|
||||
->execute();
|
||||
}
|
||||
|
@@ -694,13 +694,6 @@ class OpenIDTestCase extends DrupalWebTestCase {
|
||||
$this->assertEqual(_openid_dh_xorsecret('123456790123456790123456790', "abc123ABC\x00\xFF"), "\xa4'\x06\xbe\xf1.\x00y\xff\xc2\xc1", '_openid_dh_xorsecret() returned expected result.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test _openid_get_bytes().
|
||||
*/
|
||||
function testOpenidGetBytes() {
|
||||
$this->assertEqual(strlen(_openid_get_bytes(20)), 20, '_openid_get_bytes() returned expected result.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test _openid_signature().
|
||||
*/
|
||||
|
@@ -6,8 +6,8 @@ core = 7.x
|
||||
dependencies[] = openid
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
project = "drupal"
|
||||
datestamp = "1375928238"
|
||||
datestamp = "1399522731"
|
||||
|
||||
|
@@ -13,5 +13,5 @@ function openid_test_install() {
|
||||
// Generate a MAC key (Message Authentication Code) used for signing messages.
|
||||
// The variable is base64-encoded, because variables cannot contain non-UTF-8
|
||||
// data.
|
||||
variable_set('openid_test_mac_key', base64_encode(_openid_get_bytes(20)));
|
||||
variable_set('openid_test_mac_key', drupal_random_key(20));
|
||||
}
|
||||
|
@@ -4,8 +4,8 @@ package = Core
|
||||
version = VERSION
|
||||
core = 7.x
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
project = "drupal"
|
||||
datestamp = "1375928238"
|
||||
datestamp = "1399522731"
|
||||
|
||||
|
@@ -146,6 +146,10 @@ function overlay_init() {
|
||||
// If this page shouldn't be rendered inside the overlay, redirect to the
|
||||
// parent.
|
||||
elseif (!path_is_admin($current_path)) {
|
||||
// Prevent open redirects by ensuring the current path is not an absolute URL.
|
||||
if (url_is_external($current_path)) {
|
||||
$current_path = '<front>';
|
||||
}
|
||||
overlay_close_dialog($current_path, array('query' => drupal_get_query_parameters(NULL, array('q', 'render'))));
|
||||
}
|
||||
|
||||
|
@@ -6,8 +6,8 @@ core = 7.x
|
||||
files[] = path.test
|
||||
configure = admin/config/search/path
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
project = "drupal"
|
||||
datestamp = "1375928238"
|
||||
datestamp = "1399522731"
|
||||
|
||||
|
@@ -5,8 +5,8 @@ version = VERSION
|
||||
core = 7.x
|
||||
files[] = php.test
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
project = "drupal"
|
||||
datestamp = "1375928238"
|
||||
datestamp = "1399522731"
|
||||
|
||||
|
@@ -17,7 +17,7 @@ function php_help($path, $arg) {
|
||||
$output .= '<h3>' . t('Uses') . '</h3>';
|
||||
$output .= '<dl>';
|
||||
$output .= '<dt>' . t('Enabling execution of PHP in text fields') . '</dt>';
|
||||
$output .= '<dd>' . t('The PHP filter module allows users with the proper permissions to include custom PHP code that will get executed when pages of your site are processed. While this is a powerful and flexible feature if used by a trusted user with PHP experience, it is a significant and dangerous security risk in the hands of a malicious or inexperienced user. Even a trusted user may accidentally compromise the site by entering malformed or incorrect PHP code. Only the most trusted users should be granted permission to use the PHP filter, and all PHP code added through the PHP filter should be carefully examined before use. <a href="@php-snippets">Example PHP snippets</a> can be found on Drupal.org.', array('@php-snippets' => url('http://http://drupal.org/documentation/customization/php-snippets'))) . '</dd>';
|
||||
$output .= '<dd>' . t('The PHP filter module allows users with the proper permissions to include custom PHP code that will get executed when pages of your site are processed. While this is a powerful and flexible feature if used by a trusted user with PHP experience, it is a significant and dangerous security risk in the hands of a malicious or inexperienced user. Even a trusted user may accidentally compromise the site by entering malformed or incorrect PHP code. Only the most trusted users should be granted permission to use the PHP filter, and all PHP code added through the PHP filter should be carefully examined before use. <a href="@php-snippets">Example PHP snippets</a> can be found on Drupal.org.', array('@php-snippets' => url('http://drupal.org/documentation/customization/php-snippets'))) . '</dd>';
|
||||
$output .= '</dl>';
|
||||
return $output;
|
||||
}
|
||||
|
@@ -6,8 +6,8 @@ core = 7.x
|
||||
files[] = poll.test
|
||||
stylesheets[all][] = poll.css
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
project = "drupal"
|
||||
datestamp = "1375928238"
|
||||
datestamp = "1399522731"
|
||||
|
||||
|
@@ -11,8 +11,8 @@ configure = admin/config/people/profile
|
||||
; See user_system_info_alter().
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
project = "drupal"
|
||||
datestamp = "1375928238"
|
||||
datestamp = "1399522731"
|
||||
|
||||
|
@@ -571,6 +571,7 @@ function template_preprocess_profile_listing(&$variables) {
|
||||
// Supply filtered version of $fields that have values.
|
||||
foreach ($variables['fields'] as $field) {
|
||||
if ($field->value) {
|
||||
$variables['profile'][$field->name] = new stdClass();
|
||||
$variables['profile'][$field->name]->title = $field->title;
|
||||
$variables['profile'][$field->name]->value = $field->value;
|
||||
$variables['profile'][$field->name]->type = $field->type;
|
||||
|
@@ -17,17 +17,15 @@ function profile_browse() {
|
||||
if ($name && $field->fid) {
|
||||
// Only allow browsing of fields that have a page title set.
|
||||
if (empty($field->page)) {
|
||||
drupal_not_found();
|
||||
return;
|
||||
return MENU_NOT_FOUND;
|
||||
}
|
||||
// Do not allow browsing of private and hidden fields by non-admins.
|
||||
if (!user_access('administer users') && ($field->visibility == PROFILE_PRIVATE || $field->visibility == PROFILE_HIDDEN)) {
|
||||
drupal_access_denied();
|
||||
return;
|
||||
return MENU_ACCESS_DENIED;
|
||||
}
|
||||
|
||||
// Compile a list of fields to show.
|
||||
$fields = db_query('SELECT name, title, type, weight, page FROM {profile_field} WHERE fid <> :fid AND visibility = :visibility ORDER BY weight', array(
|
||||
$fields = db_query('SELECT name, title, type, weight, page, visibility FROM {profile_field} WHERE fid <> :fid AND visibility = :visibility ORDER BY weight', array(
|
||||
':fid' => $field->fid,
|
||||
':visibility' => PROFILE_PUBLIC_LISTINGS,
|
||||
))->fetchAll();
|
||||
@@ -54,8 +52,7 @@ function profile_browse() {
|
||||
$query->condition('v.value', '%' . db_like($value) . '%', 'LIKE');
|
||||
break;
|
||||
default:
|
||||
drupal_not_found();
|
||||
return;
|
||||
return MENU_NOT_FOUND;
|
||||
}
|
||||
|
||||
$uids = $query
|
||||
@@ -85,7 +82,7 @@ function profile_browse() {
|
||||
return $output;
|
||||
}
|
||||
elseif ($name && !$field->fid) {
|
||||
drupal_not_found();
|
||||
return MENU_NOT_FOUND;
|
||||
}
|
||||
else {
|
||||
// Compile a list of fields to show.
|
||||
|
@@ -42,25 +42,25 @@ class ProfileTestCase extends DrupalWebTestCase {
|
||||
|
||||
$this->drupalPost('admin/config/people/profile/add/' . $type, $edit, t('Save field'));
|
||||
$fid = db_query("SELECT fid FROM {profile_field} WHERE title = :title", array(':title' => $title))->fetchField();
|
||||
$this->assertTrue($fid, t('New Profile field has been entered in the database'));
|
||||
$this->assertTrue($fid, 'New Profile field has been entered in the database');
|
||||
|
||||
// Check that the new field is appearing on the user edit form.
|
||||
$this->drupalGet('user/' . $this->admin_user->uid . '/edit/' . $category);
|
||||
|
||||
// Checking field.
|
||||
if ($type == 'date') {
|
||||
$this->assertField($form_name . '[month]', t('Found month selection field'));
|
||||
$this->assertField($form_name . '[day]', t('Found day selection field'));
|
||||
$this->assertField($form_name . '[year]', t('Found day selection field'));
|
||||
$this->assertField($form_name . '[month]', 'Found month selection field');
|
||||
$this->assertField($form_name . '[day]', 'Found day selection field');
|
||||
$this->assertField($form_name . '[year]', 'Found day selection field');
|
||||
}
|
||||
else {
|
||||
$this->assertField($form_name , t('Found form named @name', array('@name' => $form_name)));
|
||||
$this->assertField($form_name , format_string('Found form named @name', array('@name' => $form_name)));
|
||||
}
|
||||
|
||||
// Checking name.
|
||||
$this->assertText($title, t('Checking title for field %title', array('%title' => $title)));
|
||||
$this->assertText($title, format_string('Checking title for field %title', array('%title' => $title)));
|
||||
// Checking explanation.
|
||||
$this->assertText($edit['explanation'], t('Checking explanation for field %title', array('%title' => $title)));
|
||||
$this->assertText($edit['explanation'], format_string('Checking explanation for field %title', array('%title' => $title)));
|
||||
|
||||
return array(
|
||||
'fid' => $fid,
|
||||
@@ -96,18 +96,18 @@ class ProfileTestCase extends DrupalWebTestCase {
|
||||
|
||||
// Checking field.
|
||||
if ($type == 'date') {
|
||||
$this->assertField($form_name . '[month]', t('Found month selection field'));
|
||||
$this->assertField($form_name . '[day]', t('Found day selection field'));
|
||||
$this->assertField($form_name . '[year]', t('Found day selection field'));
|
||||
$this->assertField($form_name . '[month]', 'Found month selection field');
|
||||
$this->assertField($form_name . '[day]', 'Found day selection field');
|
||||
$this->assertField($form_name . '[year]', 'Found day selection field');
|
||||
}
|
||||
else {
|
||||
$this->assertField($form_name , t('Found form named @name', array('@name' => $form_name)));
|
||||
$this->assertField($form_name , format_string('Found form named @name', array('@name' => $form_name)));
|
||||
}
|
||||
|
||||
// Checking name.
|
||||
$this->assertText($title, t('Checking title for field %title', array('%title' => $title)));
|
||||
$this->assertText($title, format_string('Checking title for field %title', array('%title' => $title)));
|
||||
// Checking explanation.
|
||||
$this->assertText($edit['explanation'], t('Checking explanation for field %title', array('%title' => $title)));
|
||||
$this->assertText($edit['explanation'], format_string('Checking explanation for field %title', array('%title' => $title)));
|
||||
|
||||
return array(
|
||||
'fid' => $fid,
|
||||
@@ -141,11 +141,11 @@ class ProfileTestCase extends DrupalWebTestCase {
|
||||
|
||||
// Check profile page.
|
||||
$content = $this->drupalGet('user/' . $this->normal_user->uid);
|
||||
$this->assertText($field['title'], t('Found profile field with title %title', array('%title' => $field['title'])));
|
||||
$this->assertText($field['title'], format_string('Found profile field with title %title', array('%title' => $field['title'])));
|
||||
|
||||
if ($field['type'] != 'checkbox') {
|
||||
// $value must be cast to a string in order to be found by assertText.
|
||||
$this->assertText("$value", t('Found profile field with value %value', array('%value' => $value)));
|
||||
$this->assertText("$value", format_string('Found profile field with value %value', array('%value' => $value)));
|
||||
}
|
||||
|
||||
return $value;
|
||||
@@ -160,7 +160,7 @@ class ProfileTestCase extends DrupalWebTestCase {
|
||||
function deleteProfileField($field) {
|
||||
$this->drupalPost('admin/config/people/profile/delete/' . $field['fid'], array(), t('Delete'));
|
||||
$this->drupalGet('admin/config/people/profile');
|
||||
$this->assertNoText($field['title'], t('Checking deleted field %title', array('%title' => $field['title'])));
|
||||
$this->assertNoText($field['title'], format_string('Checking deleted field %title', array('%title' => $field['title'])));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,9 +270,9 @@ class ProfileTestDate extends ProfileTestCase {
|
||||
|
||||
// Check profile page.
|
||||
$this->drupalGet('user/' . $this->normal_user->uid);
|
||||
$this->assertText($field['title'], t('Found profile field with title %title', array('%title' => $field['title'])));
|
||||
$this->assertText($field['title'], format_string('Found profile field with title %title', array('%title' => $field['title'])));
|
||||
|
||||
$this->assertText('01/09/1983', t('Found date profile field.'));
|
||||
$this->assertText('01/09/1983', 'Found date profile field.');
|
||||
|
||||
$edit = array(
|
||||
'name' => $field['form_name'],
|
||||
@@ -305,10 +305,10 @@ class ProfileTestWeights extends ProfileTestCase {
|
||||
$this->setProfileField($field2, $this->randomName(8));
|
||||
|
||||
$profile_edit = $this->drupalGet('user/' . $this->normal_user->uid . '/edit/' . $category);
|
||||
$this->assertTrue(strpos($profile_edit, $field1['title']) > strpos($profile_edit, $field2['title']), t('Profile field weights are respected on the user edit form.'));
|
||||
$this->assertTrue(strpos($profile_edit, $field1['title']) > strpos($profile_edit, $field2['title']), 'Profile field weights are respected on the user edit form.');
|
||||
|
||||
$profile_page = $this->drupalGet('user/' . $this->normal_user->uid);
|
||||
$this->assertTrue(strpos($profile_page, $field1['title']) > strpos($profile_page, $field2['title']), t('Profile field weights are respected on the user profile page.'));
|
||||
$this->assertTrue(strpos($profile_page, $field1['title']) > strpos($profile_page, $field2['title']), 'Profile field weights are respected on the user profile page.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -344,15 +344,15 @@ class ProfileTestAutocomplete extends ProfileTestCase {
|
||||
|
||||
// Check that autocompletion html is found on the user's profile edit page.
|
||||
$this->drupalGet('user/' . $this->admin_user->uid . '/edit/' . $category);
|
||||
$this->assertRaw($autocomplete_html, t('Autocomplete found.'));
|
||||
$this->assertRaw('misc/autocomplete.js', t('Autocomplete JavaScript found.'));
|
||||
$this->assertRaw('class="form-text form-autocomplete"', t('Autocomplete form element class found.'));
|
||||
$this->assertRaw($autocomplete_html, 'Autocomplete found.');
|
||||
$this->assertRaw('misc/autocomplete.js', 'Autocomplete JavaScript found.');
|
||||
$this->assertRaw('class="form-text form-autocomplete"', 'Autocomplete form element class found.');
|
||||
|
||||
// Check the autocompletion path using the first letter of our user's profile
|
||||
// field value to make sure access is allowed and a valid result if found.
|
||||
$this->drupalGet('profile/autocomplete/' . $field['fid'] . '/' . $field['value'][0]);
|
||||
$this->assertResponse(200, t('Autocomplete path allowed to user with permission.'));
|
||||
$this->assertRaw($field['value'], t('Autocomplete value found.'));
|
||||
$this->assertResponse(200, 'Autocomplete path allowed to user with permission.');
|
||||
$this->assertRaw($field['value'], 'Autocomplete value found.');
|
||||
|
||||
// Logout and login with a user without the 'access user profiles' permission.
|
||||
$this->drupalLogout();
|
||||
@@ -360,11 +360,11 @@ class ProfileTestAutocomplete extends ProfileTestCase {
|
||||
|
||||
// Check that autocompletion html is not found on the user's profile edit page.
|
||||
$this->drupalGet('user/' . $this->normal_user->uid . '/edit/' . $category);
|
||||
$this->assertNoRaw($autocomplete_html, t('Autocomplete not found.'));
|
||||
$this->assertNoRaw($autocomplete_html, 'Autocomplete not found.');
|
||||
|
||||
// User should be denied access to the profile autocomplete path.
|
||||
$this->drupalGet('profile/autocomplete/' . $field['fid'] . '/' . $field['value'][0]);
|
||||
$this->assertResponse(403, t('Autocomplete path denied to user without permission.'));
|
||||
$this->assertResponse(403, 'Autocomplete path denied to user without permission.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -403,48 +403,48 @@ class ProfileBlockTestCase extends ProfileTestCase {
|
||||
$edit = array();
|
||||
$edit['blocks[profile_author-information][region]'] = 'footer';
|
||||
$this->drupalPost('admin/structure/block', $edit, t('Save blocks'));
|
||||
$this->assertText(t('The block settings have been updated.'), t('Block successfully move to footer region.'));
|
||||
$this->assertText(t('The block settings have been updated.'), 'Block successfully move to footer region.');
|
||||
|
||||
// Enable field 1.
|
||||
$this->drupalPost('admin/structure/block/manage/profile/author-information/configure', array(
|
||||
'profile_block_author_fields[' . $this->field1['form_name'] . ']' => TRUE,
|
||||
), t('Save block'));
|
||||
$this->assertText(t('The block configuration has been saved.'), t('Block configuration set.'));
|
||||
$this->assertText(t('The block configuration has been saved.'), 'Block configuration set.');
|
||||
|
||||
// Visit the node and confirm that the field is displayed.
|
||||
$this->drupalGet('node/' . $this->node->nid);
|
||||
$this->assertRaw($this->value1, t('Field 1 is displayed'));
|
||||
$this->assertNoRaw($this->value2, t('Field 2 is not displayed'));
|
||||
$this->assertRaw($this->value1, 'Field 1 is displayed');
|
||||
$this->assertNoRaw($this->value2, 'Field 2 is not displayed');
|
||||
|
||||
// Enable only field 2.
|
||||
$this->drupalPost('admin/structure/block/manage/profile/author-information/configure', array(
|
||||
'profile_block_author_fields[' . $this->field1['form_name'] . ']' => FALSE,
|
||||
'profile_block_author_fields[' . $this->field2['form_name'] . ']' => TRUE,
|
||||
), t('Save block'));
|
||||
$this->assertText(t('The block configuration has been saved.'), t('Block configuration set.'));
|
||||
$this->assertText(t('The block configuration has been saved.'), 'Block configuration set.');
|
||||
|
||||
// Visit the node and confirm that the field is displayed.
|
||||
$this->drupalGet('node/' . $this->node->nid);
|
||||
$this->assertNoRaw($this->value1, t('Field 1 is not displayed'));
|
||||
$this->assertRaw($this->value2, t('Field 2 is displayed'));
|
||||
$this->assertNoRaw($this->value1, 'Field 1 is not displayed');
|
||||
$this->assertRaw($this->value2, 'Field 2 is displayed');
|
||||
|
||||
// Enable both fields.
|
||||
$this->drupalPost('admin/structure/block/manage/profile/author-information/configure', array(
|
||||
'profile_block_author_fields[' . $this->field1['form_name'] . ']' => TRUE,
|
||||
'profile_block_author_fields[' . $this->field2['form_name'] . ']' => TRUE,
|
||||
), t('Save block'));
|
||||
$this->assertText(t('The block configuration has been saved.'), t('Block configuration set.'));
|
||||
$this->assertText(t('The block configuration has been saved.'), 'Block configuration set.');
|
||||
|
||||
// Visit the node and confirm that the field is displayed.
|
||||
$this->drupalGet('node/' . $this->node->nid);
|
||||
$this->assertRaw($this->value1, t('Field 1 is displayed'));
|
||||
$this->assertRaw($this->value2, t('Field 2 is displayed'));
|
||||
$this->assertRaw($this->value1, 'Field 1 is displayed');
|
||||
$this->assertRaw($this->value2, 'Field 2 is displayed');
|
||||
|
||||
// Enable the link to the user profile.
|
||||
$this->drupalPost('admin/structure/block/manage/profile/author-information/configure', array(
|
||||
'profile_block_author_fields[user_profile]' => TRUE,
|
||||
), t('Save block'));
|
||||
$this->assertText(t('The block configuration has been saved.'), t('Block configuration set.'));
|
||||
$this->assertText(t('The block configuration has been saved.'), 'Block configuration set.');
|
||||
|
||||
// Visit the node and confirm that the user profile link is displayed.
|
||||
$this->drupalGet('node/' . $this->node->nid);
|
||||
|
@@ -5,8 +5,8 @@ version = VERSION
|
||||
core = 7.x
|
||||
files[] = rdf.test
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
project = "drupal"
|
||||
datestamp = "1375928238"
|
||||
datestamp = "1399522731"
|
||||
|
||||
|
@@ -484,7 +484,7 @@ function rdf_preprocess_node(&$variables) {
|
||||
$element = array(
|
||||
'#tag' => 'meta',
|
||||
'#attributes' => array(
|
||||
'content' => $variables['title'],
|
||||
'content' => $variables['node']->title,
|
||||
'about' => $variables['node_url'],
|
||||
),
|
||||
);
|
||||
|
@@ -313,13 +313,18 @@ class RdfMappingDefinitionTestCase extends TaxonomyWebTestCase {
|
||||
*/
|
||||
function testAttributesInMarkup2() {
|
||||
$type = $this->drupalCreateContentType(array('type' => 'test_bundle_hook_install'));
|
||||
$node = $this->drupalCreateNode(array('type' => 'test_bundle_hook_install'));
|
||||
// Create node with single quotation mark title to ensure it does not get
|
||||
// escaped more than once.
|
||||
$node = $this->drupalCreateNode(array(
|
||||
'type' => 'test_bundle_hook_install',
|
||||
'title' => $this->randomName(8) . "'",
|
||||
));
|
||||
$isoDate = date('c', $node->changed);
|
||||
$url = url('node/' . $node->nid);
|
||||
$this->drupalGet('node/' . $node->nid);
|
||||
|
||||
// Ensure the mapping defined in rdf_module.test is used.
|
||||
$test_bundle_title = $this->xpath("//meta[@property='dc:title' and @content='$node->title']");
|
||||
$test_bundle_title = $this->xpath('//meta[@property="dc:title" and @content="' . $node->title . '"]');
|
||||
$test_bundle_meta = $this->xpath("//div[(@about='$url') and contains(@typeof, 'foo:mapping_install1') and contains(@typeof, 'bar:mapping_install2')]//span[contains(@property, 'dc:date') and contains(@property, 'dc:created') and @datatype='xsd:dateTime' and @content='$isoDate']");
|
||||
$this->assertTrue(!empty($test_bundle_title), 'Property dc:title is present in meta tag.');
|
||||
$this->assertTrue(!empty($test_bundle_meta), 'RDF type is present on post. Properties dc:date and dc:created are present on post date.');
|
||||
@@ -436,7 +441,7 @@ class RdfCommentAttributesTestCase extends CommentHelperCase {
|
||||
$this->setCommentPreview(DRUPAL_OPTIONAL);
|
||||
$this->setCommentForm(TRUE);
|
||||
$this->setCommentSubject(TRUE);
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Comment paging changed.'));
|
||||
$this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, 'Comment paging changed.');
|
||||
|
||||
// Creates the nodes on which the test comments will be posted.
|
||||
$this->drupalLogin($this->web_user);
|
||||
|
@@ -5,8 +5,8 @@ version = VERSION
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-08-08
|
||||
version = "7.23"
|
||||
; Information added by Drupal.org packaging script on 2014-05-08
|
||||
version = "7.28"
|
||||
project = "drupal"
|
||||
datestamp = "1375928238"
|
||||
datestamp = "1399522731"
|
||||
|
||||
|
@@ -25,7 +25,7 @@
|
||||
* the template.
|
||||
*
|
||||
* Default keys within $info_split:
|
||||
* - $info_split['type']: Node type (or item type string supplied by module).
|
||||
* - $info_split['module']: The module that implemented the search query.
|
||||
* - $info_split['user']: Author of the node linked to users profile. Depends
|
||||
* on permission.
|
||||
* - $info_split['date']: Last update of the node. Short formatted.
|
||||
|
@@ -105,6 +105,8 @@ class SearchQuery extends SelectQueryExtender {
|
||||
* Stores score expressions.
|
||||
*
|
||||
* @var array
|
||||
*
|
||||
* @see addScore()
|
||||
*/
|
||||
protected $scores = array();
|
||||
|
||||
@@ -116,7 +118,7 @@ class SearchQuery extends SelectQueryExtender {
|
||||
protected $scoresArguments = array();
|
||||
|
||||
/**
|
||||
* Total value of all the multipliers.
|
||||
* Stores multipliers for score expressions.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
@@ -391,21 +393,39 @@ class SearchQuery extends SelectQueryExtender {
|
||||
/**
|
||||
* Adds a custom score expression to the search query.
|
||||
*
|
||||
* Each score expression can optionally use a multiplier, and multiple
|
||||
* expressions are combined.
|
||||
* Score expressions are used to order search results. If no calls to
|
||||
* addScore() have taken place, a default keyword relevance score will be
|
||||
* used. However, if at least one call to addScore() has taken place, the
|
||||
* keyword relevance score is not automatically added.
|
||||
*
|
||||
* Also note that if you call orderBy() directly on the query, search scores
|
||||
* will not automatically be used to order search results. Your orderBy()
|
||||
* expression can reference 'calculated_score', which will be the total
|
||||
* calculated score value.
|
||||
*
|
||||
* @param $score
|
||||
* The score expression.
|
||||
* The score expression, which should evaluate to a number between 0 and 1.
|
||||
* The string 'i.relevance' in a score expression will be replaced by a
|
||||
* measure of keyword relevance between 0 and 1.
|
||||
* @param $arguments
|
||||
* Custom query arguments for that expression.
|
||||
* Query arguments needed to provide values to the score expression.
|
||||
* @param $multiply
|
||||
* If set, the score is multiplied with that value. Search query ensures
|
||||
* that the search scores are still normalized.
|
||||
* If set, the score is multiplied with this value. However, all scores
|
||||
* with multipliers are then divided by the total of all multipliers, so
|
||||
* that overall, the normalization is maintained.
|
||||
*
|
||||
* @return object
|
||||
* The updated query object.
|
||||
*/
|
||||
public function addScore($score, $arguments = array(), $multiply = FALSE) {
|
||||
if ($multiply) {
|
||||
$i = count($this->multiply);
|
||||
// Modify the score expression so it is multiplied by the multiplier,
|
||||
// with a divisor to renormalize.
|
||||
$score = "CAST(:multiply_$i AS DECIMAL) * COALESCE(( " . $score . "), 0) / CAST(:total_$i AS DECIMAL)";
|
||||
// Add an argument for the multiplier. The :total_$i argument is taken
|
||||
// care of in the execute() method, which is when the total divisor is
|
||||
// calculated.
|
||||
$arguments[':multiply_' . $i] = $multiply;
|
||||
$this->multiply[] = $multiply;
|
||||
}
|
||||
@@ -446,8 +466,9 @@ class SearchQuery extends SelectQueryExtender {
|
||||
}
|
||||
|
||||
if (count($this->multiply)) {
|
||||
// Add the total multiplicator as many times as requested to maintain
|
||||
// normalization as far as possible.
|
||||
// Re-normalize scores with multipliers by dividing by the total of all
|
||||
// multipliers. The expressions were altered in addScore(), so here just
|
||||
// add the arguments for the total.
|
||||
$i = 0;
|
||||
$sum = array_sum($this->multiply);
|
||||
foreach ($this->multiply as $total) {
|
||||
@@ -456,13 +477,20 @@ class SearchQuery extends SelectQueryExtender {
|
||||
}
|
||||
}
|
||||
|
||||
// Replace i.relevance pseudo-field with the actual, normalized value.
|
||||
$this->scores = str_replace('i.relevance', '(' . (1.0 / $this->normalize) . ' * i.score * t.count)', $this->scores);
|
||||
// Convert scores to an expression.
|
||||
// Replace the pseudo-expression 'i.relevance' with a measure of keyword
|
||||
// relevance in all score expressions, using string replacement. Careful
|
||||
// though! If you just print out a float, some locales use ',' as the
|
||||
// decimal separator in PHP, while SQL always uses '.'. So, make sure to
|
||||
// set the number format correctly.
|
||||
$relevance = number_format((1.0 / $this->normalize), 10, '.', '');
|
||||
$this->scores = str_replace('i.relevance', '(' . $relevance . ' * i.score * t.count)', $this->scores);
|
||||
|
||||
// Add all scores together to form a query field.
|
||||
$this->addExpression('SUM(' . implode(' + ', $this->scores) . ')', 'calculated_score', $this->scoresArguments);
|
||||
|
||||
// If an order has not yet been set for this query, add a default order
|
||||
// that sorts by the calculated sum of scores.
|
||||
if (count($this->getOrderBy()) == 0) {
|
||||
// Add default order after adding the expression.
|
||||
$this->orderBy('calculated_score', 'DESC');
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user