applied security contrib modules updates
didn't repatched view module, keep it in mind, may be necessary
This commit is contained in:
@@ -1,9 +1,33 @@
|
||||
|
||||
Title 7.x-1.x, xxxx-xx-xx
|
||||
-------------------------
|
||||
#2757739 by Pol, jyraya, alexverb, plach, ademarco, dxvargas: Added text format
|
||||
support to the title text field.
|
||||
|
||||
|
||||
Title 7.x-1.0-alpha9, 2017-01-13
|
||||
--------------------------------
|
||||
#2757739 by dewalt, Pol: Token value is not sanitized, when replaced from title
|
||||
field.
|
||||
#2813673 by plach, czigor, Stevel: Tests broken since new permission in drupal
|
||||
core.
|
||||
|
||||
|
||||
Title 7.x-1.0-alpha8, 2016-03-28
|
||||
--------------------------------
|
||||
#2465141 by DuaelFr, Matthijs, jfrederick: Used entity_uri() options if given.
|
||||
#2602568 by sdstyles: Fixed title_entity_label() should be documented as
|
||||
callback implementation.
|
||||
#2605040 by ShaxA, joelpittet, sylus: Removed recursive call to
|
||||
entity_get_info().
|
||||
#2040055 by flux423, cs_shadow, visabhishek, plach, OlyN: Fixed Notice:
|
||||
Undefined index: safe_value in title_field_formatter_view().
|
||||
#2426105 by Peacog, jcisio: Fixed Views "Link this field to the original entity"
|
||||
doesn't work when using relationship.
|
||||
#2286147 by plach: Language fallback does not work when an entity translation is
|
||||
unpublished.
|
||||
#2286145 by plach: Prevent empty translations from being synced into the legacy field.
|
||||
#2286145 by plach: Prevent empty translations from being synced into the legacy
|
||||
field.
|
||||
#1772116 by duellj, GaëlG | f4o: Fixed Menu link title is not getting node title
|
||||
by default.
|
||||
#1779268 by ndobromirov | brycesenz: Undefined index: field_name in
|
||||
|
@@ -9,6 +9,7 @@
|
||||
* Tests for legacy field replacement.
|
||||
*/
|
||||
class TitleFieldReplacementTestCase extends DrupalWebTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Field replacement',
|
||||
@@ -17,14 +18,17 @@ class TitleFieldReplacementTestCase extends DrupalWebTestCase {
|
||||
);
|
||||
}
|
||||
|
||||
function setUp() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp('entity', 'field_test', 'title', 'title_test');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test field replacement API and workflow.
|
||||
*/
|
||||
function testFieldReplacementWorkflow() {
|
||||
public function testFieldReplacementWorkflow() {
|
||||
$info = entity_get_info('test_entity');
|
||||
$label_key = $info['entity keys']['label'];
|
||||
$field_name = $label_key . '_field';
|
||||
@@ -78,7 +82,7 @@ class TitleFieldReplacementTestCase extends DrupalWebTestCase {
|
||||
// and view.
|
||||
$entity = title_test_entity_test_load($entity);
|
||||
title_test_phase_check('after_load', $entity);
|
||||
$build = entity_view('test_entity', array($entity->ftid => $entity));
|
||||
entity_view('test_entity', array($entity->ftid => $entity));
|
||||
|
||||
foreach (title_test_phase_store() as $phase => $value) {
|
||||
$this->assertTrue($value, t('Field synchronization is correctly performed on %phase.', array('%phase' => $phase)));
|
||||
@@ -95,8 +99,16 @@ class TitleFieldReplacementTestCase extends DrupalWebTestCase {
|
||||
/**
|
||||
* Test field replacement UI.
|
||||
*/
|
||||
function testFieldReplacementUI() {
|
||||
$admin_user = $this->drupalCreateUser(array('access administration pages', 'view the administration theme', 'administer content types', 'administer taxonomy', 'administer comments'));
|
||||
public function testFieldReplacementUI() {
|
||||
$permissions = array(
|
||||
'access administration pages',
|
||||
'view the administration theme',
|
||||
'administer content types',
|
||||
'administer taxonomy',
|
||||
'administer comments',
|
||||
'administer fields',
|
||||
);
|
||||
$admin_user = $this->drupalCreateUser($permissions);
|
||||
$this->drupalLogin($admin_user);
|
||||
|
||||
foreach (entity_get_info() as $entity_type => $entity_info) {
|
||||
@@ -147,12 +159,14 @@ class TitleFieldReplacementTestCase extends DrupalWebTestCase {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests for legacy field replacement.
|
||||
*/
|
||||
class TitleAdminSettingsTestCase extends DrupalWebTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Admin settings',
|
||||
@@ -161,7 +175,10 @@ class TitleAdminSettingsTestCase extends DrupalWebTestCase {
|
||||
);
|
||||
}
|
||||
|
||||
function setUp() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp('field_test', 'title', 'title_test');
|
||||
$admin_user = $this->drupalCreateUser(array('administer site configuration', 'administer taxonomy'));
|
||||
$this->drupalLogin($admin_user);
|
||||
@@ -170,15 +187,18 @@ class TitleAdminSettingsTestCase extends DrupalWebTestCase {
|
||||
/**
|
||||
* Check for automated title_field attachment.
|
||||
*/
|
||||
function testAutomatedFieldAttachement() {
|
||||
$this->assertAutomatedFieldAttachement(TRUE);
|
||||
$this->assertAutomatedFieldAttachement(FALSE);
|
||||
public function testAutomatedFieldAttachment() {
|
||||
$this->doTestAutomatedFieldAttachment(TRUE);
|
||||
$this->doTestAutomatedFieldAttachment(FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that the fields are replaced or skipped depdening on the given value.
|
||||
* Check that the fields are replaced or skipped depending on the given value.
|
||||
*
|
||||
* @param bool $enabled
|
||||
* Whether replacement is enabled or not.
|
||||
*/
|
||||
function assertAutomatedFieldAttachement($enabled) {
|
||||
public function doTestAutomatedFieldAttachment($enabled) {
|
||||
$edit = array(
|
||||
'title_taxonomy_term[auto_attach][name]' => $enabled,
|
||||
'title_taxonomy_term[auto_attach][description]' => $enabled,
|
||||
@@ -198,6 +218,7 @@ class TitleAdminSettingsTestCase extends DrupalWebTestCase {
|
||||
$this->assertTrue(title_field_replacement_enabled($entity_type, $bundle, 'name') == $enabled, 'Name field correctly processed.');
|
||||
$this->assertTrue(title_field_replacement_enabled($entity_type, $bundle, 'description') == $enabled, 'Description field correctly processed.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -213,11 +234,22 @@ class TitleTranslationTestCase extends DrupalWebTestCase {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp('locale', 'entity_translation', 'title', 'field_test', 'title_test');
|
||||
|
||||
// Create a power user.
|
||||
$admin_user = $this->drupalCreateUser(array('administer modules', 'view the administration theme', 'administer languages', 'administer taxonomy', 'administer entity translation', 'translate any entity'));
|
||||
$permissions = array(
|
||||
'administer modules',
|
||||
'view the administration theme',
|
||||
'administer languages',
|
||||
'administer taxonomy',
|
||||
'administer entity translation',
|
||||
'translate any entity',
|
||||
);
|
||||
$admin_user = $this->drupalCreateUser($permissions);
|
||||
$this->drupalLogin($admin_user);
|
||||
|
||||
// Enable a translation language.
|
||||
@@ -242,6 +274,7 @@ class TitleTranslationTestCase extends DrupalWebTestCase {
|
||||
$edit = array(
|
||||
'name' => $this->randomString(),
|
||||
'machine_name' => $name,
|
||||
'entity_translation_taxonomy' => 1,
|
||||
);
|
||||
$this->drupalPost('admin/structure/taxonomy/add', $edit, t('Save'));
|
||||
$this->vocabulary = taxonomy_vocabulary_machine_name_load($name);
|
||||
@@ -406,6 +439,14 @@ class TitleTranslationTestCase extends DrupalWebTestCase {
|
||||
|
||||
/**
|
||||
* Loads a term using the given language as active language.
|
||||
*
|
||||
* @param int $tid
|
||||
* The term identifier.
|
||||
* @param string|null $langcode
|
||||
* (optional) The active language to be set. Defaults to none.
|
||||
*
|
||||
* @return object|bool
|
||||
* A term object.
|
||||
*/
|
||||
protected function termLoad($tid, $langcode = NULL) {
|
||||
drupal_static_reset();
|
||||
|
@@ -7,9 +7,9 @@ dependencies[] = title
|
||||
dependencies[] = entity
|
||||
dependencies[] = entity_translation
|
||||
|
||||
; Information added by Drupal.org packaging script on 2015-03-23
|
||||
version = "7.x-1.0-alpha7+14-dev"
|
||||
; Information added by Drupal.org packaging script on 2017-01-13
|
||||
version = "7.x-1.0-alpha9+1-dev"
|
||||
core = "7.x"
|
||||
project = "title"
|
||||
datestamp = "1427069882"
|
||||
datestamp = "1484304486"
|
||||
|
||||
|
@@ -41,6 +41,9 @@ function title_entity_info() {
|
||||
'label' => t('Title'),
|
||||
'description' => '',
|
||||
) + $instance,
|
||||
'additional keys' => array(
|
||||
'format' => 'format',
|
||||
),
|
||||
),
|
||||
),
|
||||
'efq bundle conditions' => TRUE,
|
||||
@@ -122,12 +125,31 @@ function title_field_term_description_submit($entity_type, $entity, $legacy_fiel
|
||||
*/
|
||||
function title_field_text_sync_get($entity_type, $entity, $legacy_field, $info, $langcode) {
|
||||
$value = NULL;
|
||||
$format = 'plain_text';
|
||||
|
||||
$info += array(
|
||||
'additional keys' => array(
|
||||
'format' => 'format',
|
||||
),
|
||||
);
|
||||
|
||||
$format_key = $info['additional keys']['format'];
|
||||
$field_name = $info['field']['field_name'];
|
||||
// Return values only if there is any available to process for the current
|
||||
// language.
|
||||
if (!empty($entity->{$field_name}[$langcode]) && is_array($entity->{$field_name}[$langcode])) {
|
||||
$items = $entity->{$field_name}[$langcode];
|
||||
$value = !empty($items[0]['value']) ? $items[0]['value'] : NULL;
|
||||
$item = $entity->{$field_name}[$langcode][0] + array(
|
||||
'value' => NULL,
|
||||
'format' => NULL,
|
||||
);
|
||||
$value = $item['value'];
|
||||
$format = $item['format'];
|
||||
}
|
||||
return array($legacy_field => $value);
|
||||
|
||||
return array(
|
||||
$legacy_field => $value,
|
||||
$format_key => $format,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,15 +165,26 @@ function title_field_text_sync_set($entity_type, $entity, $legacy_field, $info,
|
||||
function title_field_text_with_summary_sync_get($entity_type, $entity, $legacy_field, $info, $langcode) {
|
||||
$value = NULL;
|
||||
$format = NULL;
|
||||
|
||||
$info += array(
|
||||
'additional keys' => array(
|
||||
'format' => 'format',
|
||||
),
|
||||
);
|
||||
|
||||
$format_key = $info['additional keys']['format'];
|
||||
$field_name = $info['field']['field_name'];
|
||||
// Return values only if there is any available to process for the current
|
||||
// language.
|
||||
if (!empty($entity->{$field_name}[$langcode]) && is_array($entity->{$field_name}[$langcode])) {
|
||||
$items = $entity->{$field_name}[$langcode];
|
||||
$value = !empty($items[0]['value']) ? $items[0]['value'] : NULL;
|
||||
$format = $entity->{$field_name}[$langcode][0]['format'];
|
||||
$item = $entity->{$field_name}[$langcode][0] + array(
|
||||
'value' => NULL,
|
||||
'format' => NULL,
|
||||
);
|
||||
$value = $item['value'];
|
||||
$format = $item['format'];
|
||||
}
|
||||
|
||||
return array(
|
||||
$legacy_field => $value,
|
||||
$format_key => $format,
|
||||
|
@@ -97,13 +97,23 @@ function title_field_formatter_settings_summary($field, $instance, $view_mode) {
|
||||
*/
|
||||
function title_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
|
||||
$settings = $display['settings'];
|
||||
$output = isset($items[0]) ? $items[0]['safe_value'] : '';
|
||||
$output = '';
|
||||
if (isset($items[0]['safe_value'])) {
|
||||
$output = $items[0]['safe_value'];
|
||||
}
|
||||
elseif (isset($items[0]['value'])) {
|
||||
$output = _text_sanitize($instance, $langcode, $items[0], 'value');
|
||||
}
|
||||
$element = array();
|
||||
|
||||
if (!empty($output)) {
|
||||
if ($settings['title_link'] == 'content') {
|
||||
$uri = entity_uri($entity_type, $entity);
|
||||
$output = l($output, $uri['path'], array('html' => TRUE));
|
||||
$options = array('html' => TRUE);
|
||||
if (!empty($uri['options'])) {
|
||||
$options = array_merge($options, $uri['options']);
|
||||
}
|
||||
$output = l($output, $uri['path'], $options);
|
||||
}
|
||||
|
||||
$wrap_tag = empty($settings['title_style']) ? '_none' : $settings['title_style'];
|
||||
|
@@ -9,9 +9,9 @@ files[] = title.module
|
||||
files[] = views/views_handler_title_field.inc
|
||||
files[] = tests/title.test
|
||||
|
||||
; Information added by Drupal.org packaging script on 2015-03-23
|
||||
version = "7.x-1.0-alpha7+14-dev"
|
||||
; Information added by Drupal.org packaging script on 2017-01-13
|
||||
version = "7.x-1.0-alpha9+1-dev"
|
||||
core = "7.x"
|
||||
project = "title"
|
||||
datestamp = "1427069882"
|
||||
datestamp = "1484304486"
|
||||
|
||||
|
@@ -105,17 +105,7 @@ function title_field_replacement_info($entity_type, $legacy_field = NULL) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an entity label value.
|
||||
*
|
||||
* @param $entity
|
||||
* The entity whose label has to be displayed.
|
||||
* @param $type
|
||||
* The name of the entity type.
|
||||
* @param $langcode
|
||||
* (Optional) The language the entity label has to be displayed in.
|
||||
*
|
||||
* @return
|
||||
* The entity label as a string value.
|
||||
* Implements callback_entity_info_label().
|
||||
*/
|
||||
function title_entity_label($entity, $type, $langcode = NULL) {
|
||||
$entity_info = entity_get_info($type);
|
||||
@@ -754,6 +744,7 @@ function title_tokens_alter(array &$replacements, array $context) {
|
||||
$entity = $context['data'][$context['type']];
|
||||
list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
|
||||
$options = $context['options'];
|
||||
$sanitize = !empty($options['sanitize']);
|
||||
|
||||
// Since Title tokens are mostly used in storage contexts we default to
|
||||
// the current working language, that is the entity language. Modules
|
||||
@@ -766,13 +757,10 @@ function title_tokens_alter(array &$replacements, array $context) {
|
||||
if (title_field_replacement_enabled($entity_type, $bundle, $legacy_field)) {
|
||||
if (isset($context['tokens'][$legacy_field])) {
|
||||
$langcode = field_language($entity_type, $entity, $info['field']['field_name'], $langcode);
|
||||
$values = $info['callbacks']['sync_get']($entity_type, $entity, $legacy_field, $info, $langcode);
|
||||
$item = $values[$legacy_field];
|
||||
$item = $info['callbacks']['sync_get']($entity_type, $entity, $legacy_field, $info, $langcode);
|
||||
if (!empty($item)) {
|
||||
if (is_array($item)) {
|
||||
$item = reset($item);
|
||||
}
|
||||
$replacements[$context['tokens'][$legacy_field]] = $item;
|
||||
list($value, $format) = array_values($item);
|
||||
$replacements[$context['tokens'][$legacy_field]] = check_markup($value, $format, $langcode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -6,9 +6,8 @@
|
||||
*/
|
||||
function title_field_views_data_alter(&$data) {
|
||||
foreach (entity_get_info() as $entity_type => $entity_info) {
|
||||
$replacements = title_field_replacement_info($entity_type);
|
||||
if ($replacements) {
|
||||
foreach ($replacements as $replacement) {
|
||||
if (!empty($entity_info['field replacement'])) {
|
||||
foreach ($entity_info['field replacement'] as $replacement) {
|
||||
if (isset($replacement['field']['field_name'])) {
|
||||
$field = field_info_field($replacement['field']['field_name']);
|
||||
$table = _field_sql_storage_tablename($field);
|
||||
|
@@ -36,13 +36,13 @@ class views_handler_title_field extends views_handler_field_field {
|
||||
if (!empty($this->options['link_to_entity'])) {
|
||||
$values = $this->original_values;
|
||||
$entity_type = $this->definition['entity_tables'][$this->base_table];
|
||||
$entity_info = entity_get_info($entity_type);
|
||||
$key = $entity_info['entity keys']['id'];
|
||||
$key = $this->field_alias;
|
||||
if (!empty($values->_field_data[$key]['entity'])) {
|
||||
$entity = $values->_field_data[$key]['entity'];
|
||||
$uri = entity_uri($entity_type, $entity);
|
||||
$this->options['alter']['make_link'] = TRUE;
|
||||
$this->options['alter']['path'] = $uri['path'];
|
||||
$this->options['alter']['options'] = !empty($uri['options']) ? $uri['options'] : array();
|
||||
}
|
||||
}
|
||||
return parent::render_item($count, $item);
|
||||
|
Reference in New Issue
Block a user