Commit 6d7c489f authored by root's avatar root

update of entityreference and views

parent 01ac2e46
......@@ -6,4 +6,7 @@ sites/*/files
sites/*/private
#ignore stats
stats
\ No newline at end of file
stats
#ignore .sql file (too large for git)
framaforms.sql
\ No newline at end of file
......@@ -8,6 +8,10 @@ Description
Framaforms est un logiciel de création de formulaires en ligne.
Lire https://framablog.org/2016/10/05/framaforms-noffrez-plus-les-reponses-que-vous-collectez-a-google/ et https://framablog.org/2016/10/05/en-savoir-un-peu-plus-sur-le-projet-framaforms/ pour plus d'informations.
Changelog
============
Un changelog sommaire est disponible sur https://framagit.org/framasoft/framaforms/wikis/logbook
Utilisation
=============
......
......@@ -29,9 +29,9 @@ files[] = tests/entityreference.admin.test
files[] = tests/entityreference.feeds.test
files[] = tests/entityreference.entity_translation.test
; Information added by Drupal.org packaging script on 2017-05-23
version = "7.x-1.4"
; Information added by Drupal.org packaging script on 2017-08-16
version = "7.x-1.5"
core = "7.x"
project = "entityreference"
datestamp = "1495557187"
datestamp = "1502895850"
<?php
define('ENTITYREFERENCE_DENIED', '- Restricted access -');
/**
* @file
* Entityreference primary module file.
......@@ -1106,10 +1108,14 @@ function entityreference_autocomplete_callback_get_matches($type, $field, $insta
if (isset($tag_last)) {
// Get an array of matching entities.
$entity_labels = $handler->getReferencableEntities($tag_last, $instance['widget']['settings']['match_operator'], 10);
$denied_label = t(ENTITYREFERENCE_DENIED);
// Loop through the products and convert them into autocomplete output.
foreach ($entity_labels as $values) {
foreach ($values as $entity_id => $label) {
// Never autocomplete entities that aren't accessible.
if ($label == $denied_label) {
continue;
}
$key = "$label ($entity_id)";
// Strip starting/trailing white spaces, line breaks and tags.
$key = preg_replace('/\s\s+/', ' ', str_replace("\n", '', trim(decode_entities(strip_tags($key)))));
......
......@@ -4,9 +4,9 @@ core = 7.x
package = Fields
dependencies[] = entityreference
; Information added by Drupal.org packaging script on 2017-05-23
version = "7.x-1.4"
; Information added by Drupal.org packaging script on 2017-08-16
version = "7.x-1.5"
core = "7.x"
project = "entityreference"
datestamp = "1495557187"
datestamp = "1502895850"
......@@ -309,7 +309,7 @@ class EntityReference_SelectionHandler_Generic implements EntityReference_Select
*/
public function getLabel($entity) {
$target_type = $this->field['settings']['target_type'];
return entity_access('view', $target_type, $entity) ? entity_label($target_type, $entity) : t('- Restricted access -');
return entity_access('view', $target_type, $entity) ? entity_label($target_type, $entity) : t(ENTITYREFERENCE_DENIED);
}
/**
......
......@@ -271,7 +271,7 @@ class EntityReferenceHandlersTestCase extends DrupalWebTestCase {
),
'result' => array(
'user' => array(
$users['admin']->uid => '- Restricted access -',
$users['admin']->uid => ENTITYREFERENCE_DENIED,
$users['non_admin']->uid => $user_labels['non_admin'],
),
),
......
......@@ -8,9 +8,9 @@ dependencies[] = feeds
dependencies[] = feeds_ui
dependencies[] = entityreference
; Information added by Drupal.org packaging script on 2017-05-23
version = "7.x-1.4"
; Information added by Drupal.org packaging script on 2017-08-16
version = "7.x-1.5"
core = "7.x"
project = "entityreference"
datestamp = "1495557187"
datestamp = "1502895850"
......@@ -40,7 +40,7 @@ function views_ajax() {
// Load the view.
$view = views_get_view($name);
if ($view && $view->access($display_id)) {
if ($view && $view->access($display_id) && $view->set_display($display_id) && $view->display_handler->use_ajax()) {
// Fix 'q' for paging.
if (!empty($path)) {
$_GET['q'] = $path;
......
<?php
/**
* @file
* Definition of ViewsAjaxTest.
*/
/**
* Tests views ajax display.
*/
class ViewsAjaxTest extends ViewsSqlTest {
public static function getInfo() {
return array(
'name' => 'Ajax',
'description' => 'Test views with and without ajax enabled.',
'group' => 'Views Handlers',
);
}
public function setUp() {
parent::setUp('views', 'views_test');
// Create a second node.
$this->drupalCreateNode(array('type' => 'article', 'status' => NODE_PUBLISHED));
}
/**
* Perform a simple AJAX POST HTTP request.
*
* @param string $path
* Drupal path where the request should be POSTed.
* @param string $accept
* The value for the "Accept" header. Usually either 'application/json' or
* 'application/vnd.drupal-ajax'.
* @param array $post
* The POST data. When making a 'application/vnd.drupal-ajax' request, the
* Ajax page state data should be included. Use getAjaxPageStatePostData()
* for that.
*
* @return
* The content returned from the call to curl_exec().
*/
public function simpleAjaxPost($path, $accept, $post = array()) {
$options['absolute'] = TRUE;
foreach ($post as $key => $value) {
// Encode according to application/x-www-form-urlencoded
// Both names and values needs to be urlencoded, according to
// http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.1
$post[$key] = urlencode($key) . '=' . urlencode($value);
}
$postfields = implode('&', $post);
$headers = array(
'Accept: ' . $accept,
'Content-Type: application/x-www-form-urlencoded',
);
return $this->curlExec(array(
CURLOPT_URL => url($path, $options),
CURLOPT_POST => TRUE,
CURLOPT_POSTFIELDS => $postfields,
CURLOPT_HTTPHEADER => $headers,
));
}
/**
* Tests an ajax and non-ajax view.
*/
public function testAjaxView() {
$this->drupalCreateNode();
$this->drupalGet('test_ajax_view');
$drupal_settings = $this->drupalGetSettings();
$this->assertTrue(isset($drupal_settings['views']['ajax_path']), 'The Ajax callback path is set in drupalSettings.');
$this->assertEqual(count($drupal_settings['views']['ajaxViews']), 1);
$view_entry = current(array_keys($drupal_settings['views']['ajaxViews']));
$this->assertEqual($drupal_settings['views']['ajaxViews'][$view_entry]['view_name'], 'test_ajax_view', 'The view\'s ajaxViews array entry has the correct \'view_name\' key.');
$this->assertEqual($drupal_settings['views']['ajaxViews'][$view_entry]['view_display_id'], 'page_1', 'The view\'s ajaxViews array entry has the correct \'view_display_id\' key.');
$post = [
'view_name' => 'test_ajax_view',
'view_display_id' => 'page_1',
];
$response = $this->simpleAjaxPost('views/ajax', 'application/json', $post);
$data = drupal_json_decode($response);
$this->assertTrue(isset($data[0]['settings']['views']['ajaxViews']));
// Ensure that the view insert command is part of the result.
$this->assertEqual($data[1]['command'], 'insert');
$this->assertTrue(strpos($data[1]['selector'], '.view-dom-id-') === 0);
$this->drupalSetContent($data[1]['data']);
$result = $this->xpath('//div[contains(@class, "views-row")]');
$this->assertEqual(count($result), 2, 'Ensure that two items are rendered in the HTML.');
$post = [
'view_name' => 'test_noajax_view',
'view_display_id' => 'default',
];
$response = $this->simpleAjaxPost('views/ajax', 'application/json', $post);
$data = drupal_json_decode($response);
// In Drupal 7 we get an ajax response with no commands instead of a 403 if
// the view cannot be accessed.
foreach ($data as $item) {
$this->assertIdentical('settings', $item['command']);
$this->assertTrue(empty($item['data']));
}
}
}
......@@ -5,9 +5,9 @@ core = 7.x
dependencies[] = views
hidden = TRUE
; Information added by Drupal.org packaging script on 2017-04-02
version = "7.x-3.16"
; Information added by Drupal.org packaging script on 2017-08-16
version = "7.x-3.17"
core = "7.x"
project = "views"
datestamp = "1491158591"
datestamp = "1502903349"
<?php
/**
......@@ -274,5 +275,57 @@ function views_test_views_default_views() {
$views[$view->name] = $view;
$view = new view();
$view->name = 'test_ajax_view';
$view->description = '';
$view->tag = '';
$view->base_table = 'node';
$view->human_name = '';
$view->core = 0;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['use_ajax'] = TRUE;
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'none';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'node';
/* Display: Page */
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->display->display_options['path'] = 'test_ajax_view';
$views[$view->name] = $view;
$view = new view();
$view->name = 'test_noajax_view';
$view->description = '';
$view->tag = '';
$view->base_table = 'node';
$view->human_name = '';
$view->core = 0;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['use_ajax'] = FALSE;
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'none';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'none';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'node';
$views[$view->name] = $view;
return $views;
}
......@@ -301,6 +301,7 @@ files[] = tests/styles/views_plugin_style_unformatted.test
files[] = tests/views_access.test
files[] = tests/views_analyze.test
files[] = tests/views_basic.test
files[] = tests/views_ajax.test
files[] = tests/views_argument_default.test
files[] = tests/views_argument_validator.test
files[] = tests/views_exposed_form.test
......@@ -327,9 +328,9 @@ files[] = tests/views_cache.test
files[] = tests/views_view.test
files[] = tests/views_ui.test
; Information added by Drupal.org packaging script on 2017-04-02
version = "7.x-3.16"
; Information added by Drupal.org packaging script on 2017-08-16
version = "7.x-3.17"
core = "7.x"
project = "views"
datestamp = "1491158591"
datestamp = "1502903349"
......@@ -7,9 +7,9 @@ dependencies[] = views
files[] = views_ui.module
files[] = plugins/views_wizard/views_ui_base_views_wizard.class.php
; Information added by Drupal.org packaging script on 2017-04-02
version = "7.x-3.16"
; Information added by Drupal.org packaging script on 2017-08-16
version = "7.x-3.17"
core = "7.x"
project = "views"
datestamp = "1491158591"
datestamp = "1502903349"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment