Skip to content
id: theme.breakpoint_test_theme.breakpoint_test_theme
uuid: 94b96e6e-a032-4b29-8100-efd5bf854fd1
name: breakpoint_test_theme
label: 'Breakpoint test theme'
breakpoint_ids:
- theme.breakpoint_test_theme.mobile
- theme.breakpoint_test_theme.narrow
- theme.breakpoint_test_theme.wide
- theme.breakpoint_test_theme.tv
source: breakpoint_test_theme
sourceType: theme
status: true
langcode: en
id: theme.breakpoint_test_theme.test
uuid: fcc25180-7e18-4149-8962-98d706faa59a
name: test
label: 'Test Theme'
breakpoint_ids:
- theme.breakpoint_test_theme.mobile
- theme.breakpoint_test_theme.narrow
- theme.breakpoint_test_theme.wide
source: breakpoint_test_theme
sourceType: theme
status: true
langcode: en
mobile: '(min-width: 0px)'
narrow: '(min-width: 560px)'
wide: '(min-width: 851px)'
tv: 'only screen and (min-width: 3456px)'
......@@ -320,9 +320,9 @@ public function getLangcodes() {
if (empty($langcodes)) {
$langcodes = array();
// Collect languages included with CKEditor based on file listing.
$ckeditor_languages = new \GlobIterator(DRUPAL_ROOT . '/core/assets/vendor/ckeditor/lang/*.js');
foreach ($ckeditor_languages as $language_file) {
$langcode = $language_file->getBasename('.js');
$ckeditor_languages = glob(DRUPAL_ROOT . '/core/assets/vendor/ckeditor/lang/*.js');
foreach ($ckeditor_languages as $language_filename) {
$langcode = basename($language_filename, '.js');
$langcodes[$langcode] = $langcode;
}
cache('ckeditor.languages')->set('langcodes', $langcodes);
......
......@@ -1731,3 +1731,20 @@ function comment_library_info() {
);
return $libraries;
}
/**
* #post_render_cache callback; replaces the placeholder with the comment form.
*
* @param array $context
* An array with the following keys:
* - entity_type: an entity type
* - entity_id: an entity ID
* - field_name: a comment field name
*
* @return array $element
* The updated $element.
*/
function comment_replace_form_placeholder(array $context) {
$entity = entity_load($context['entity_type'], $context['entity_id']);
return comment_add($entity, $context['field_name']);
}
......@@ -2,9 +2,7 @@
/**
* @file
* Provide views data and handlers for comment.module.
*
* @ingroup views_module_handlers
* Provide views data for comment.module.
*/
/**
......
......@@ -36,7 +36,6 @@
* fieldable = TRUE,
* translatable = TRUE,
* render_cache = FALSE,
* route_base_path = "admin/structure/comments/manage/{bundle}",
* entity_keys = {
* "id" = "cid",
* "bundle" = "field_id",
......@@ -48,7 +47,8 @@
* },
* links = {
* "canonical" = "comment.permalink",
* "edit-form" = "comment.edit_page"
* "edit-form" = "comment.edit_page",
* "admin-form" = "comment.bundle"
* }
* )
*/
......
......@@ -138,7 +138,24 @@ public function viewElements(FieldItemListInterface $items) {
if ($status == COMMENT_OPEN && $comment_settings['form_location'] == COMMENT_FORM_BELOW) {
// Only show the add comment form if the user has permission.
if ($this->currentUser->hasPermission('post comments')) {
$output['comment_form'] = comment_add($entity, $field_name);
// All users in the "anonymous" role can use the same form: it is fine
// for this form to be stored in the render cache.
if ($this->currentUser->isAnonymous()) {
$output['comment_form'] = comment_add($entity, $field_name);
}
// All other users need a user-specific form, which would break the
// render cache: hence use a #post_render_cache callback.
else {
$output['comment_form'] = array(
'#type' => 'render_cache_placeholder',
'#callback' => 'comment_replace_form_placeholder',
'#context' => array(
'entity_type' => $entity->entityType(),
'entity_id' => $entity->id(),
'field_name' => $field_name
),
);
}
}
}
......
......@@ -229,11 +229,11 @@ function testCommentFunctionality() {
));
$this->drupalLogin($limited_user);
// Test that default field exists.
$this->drupalGet('admin/structure/entity-test/manage/entity_test/fields');
$this->drupalGet('entity_test/structure/entity_test/fields');
$this->assertText(t('Comment settings'));
$this->assertLinkByHref('admin/structure/entity-test/manage/entity_test/fields/entity_test.entity_test.comment');
$this->assertLinkByHref('entity_test/structure/entity_test/fields/entity_test.entity_test.comment');
// Test widget hidden option is not visible when there's no comments.
$this->drupalGet('admin/structure/entity-test/manage/entity_test/entity-test/fields/entity_test.entity_test.comment');
$this->drupalGet('entity_test/structure/entity_test/entity-test/fields/entity_test.entity_test.comment');
$this->assertNoField('edit-default-value-input-comment-und-0-status-0');
$this->drupalLogin($this->admin_user);
......@@ -343,20 +343,20 @@ function testCommentFunctionality() {
'administer entity_test content',
));
$this->drupalLogin($limited_user);
$this->drupalGet('admin/structure/entity-test/manage/entity_test/fields/entity_test.entity_test.comment');
$this->drupalGet('entity_test/structure/entity_test/fields/entity_test.entity_test.comment');
$this->assertNoFieldChecked('edit-default-value-input-comment-0-status-0');
$this->assertNoFieldChecked('edit-default-value-input-comment-0-status-1');
$this->assertFieldChecked('edit-default-value-input-comment-0-status-2');
// Test comment option change in field settings.
$edit = array('default_value_input[comment][0][status]' => COMMENT_CLOSED);
$this->drupalPostForm(NULL, $edit, t('Save settings'));
$this->drupalGet('admin/structure/entity-test/manage/entity_test/fields/entity_test.entity_test.comment');
$this->drupalGet('entity_test/structure/entity_test/fields/entity_test.entity_test.comment');
$this->assertNoFieldChecked('edit-default-value-input-comment-0-status-0');
$this->assertFieldChecked('edit-default-value-input-comment-0-status-1');
$this->assertNoFieldChecked('edit-default-value-input-comment-0-status-2');
// Add a new comment field.
$this->drupalGet('admin/structure/entity-test/manage/entity_test/fields');
$this->drupalGet('entity_test/structure/entity_test/fields');
$edit = array(
'fields[_add_new_field][label]' => 'Foobar',
'fields[_add_new_field][field_name]' => 'foobar',
......
......@@ -23,13 +23,10 @@ class ConfigFieldInstanceMapper extends ConfigEntityMapper {
*/
public function getBaseRouteParameters() {
$parameters = parent::getBaseRouteParameters();
// @todo All core content entity path placeholders can be fully filled in
// with an additional {bundle} value in their paths, but a more
// predictable solution would be ideal. See
// https://drupal.org/node/2134871
$base_entity_info = $this->entityManager->getDefinition($this->pluginDefinition['base_entity_type']);
// @todo Field instances have no method to return the bundle the instance is
// attached to. See https://drupal.org/node/2134861
$parameters['bundle'] = $this->entity->bundle;
$parameters[$base_entity_info['bundle_entity_type']] = $this->entity->bundle;
return $parameters;
}
......
contact.category_edit:
title: 'Edit'
route_name: contact.category_edit
tab_root_id: contact.category_edit
......@@ -67,10 +67,6 @@ function contact_menu() {
'title' => 'Edit contact category',
'route_name' => 'contact.category_edit',
);
$items['admin/structure/contact/manage/%contact_category/edit'] = array(
'title' => 'Edit',
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items['contact'] = array(
'title' => 'Contact',
......
......@@ -3,8 +3,6 @@
/**
* @file
* Provide views data for contact.module.
*
* @ingroup views_module_handlers
*/
/**
......
......@@ -26,10 +26,13 @@
* entity_keys = {
* "bundle" = "category"
* },
* route_base_path = "admin/structure/contact/manage/{bundle}",
* bundle_entity_type = "contact_category",
* fieldable = TRUE,
* bundle_keys = {
* "bundle" = "id"
* },
* links = {
* "admin-form" = "contact.category_edit"
* }
* )
*/
......
......@@ -156,7 +156,7 @@ function content_translation_menu() {
if (content_translation_enabled($entity_type)) {
$path = _content_translation_link_to_router_path($entity_type, $info['links']['canonical']);
$entity_position = count(explode('/', $path)) - 1;
$keys = array_flip(array('load_arguments'));
$keys = array_flip(array('theme_callback', 'theme_arguments', 'load_arguments'));
$menu_info = array_intersect_key($info['translation']['content_translation'], $keys) + array('file' => 'content_translation.pages.inc');
$item = array();
......
......@@ -6,6 +6,21 @@
* Adds contextual links to perform actions related to elements on a page.
*/
/**
* Implements hook_menu().
*/
function contextual_menu() {
// @todo Remove this menu item in http://drupal.org/node/1954892 when theme
// callbacks are replaced with something else.
$items['contextual/render'] = array(
'route_name' => 'contextual.render',
'theme callback' => 'ajax_base_page_theme',
'type' => MENU_CALLBACK,
);
return $items;
}
/**
* Implements hook_toolbar().
*/
......
......@@ -2,7 +2,5 @@ contextual.render:
path: '/contextual/render'
defaults:
_controller: '\Drupal\contextual\ContextualController::render'
options:
_theme: ajax_base_page
requirements:
_permission: 'access contextual links'
......@@ -2,9 +2,7 @@
/**
* @file
* Provide views data and handlers for contextual.module.
*
* @ingroup views_module_handlers
* Provide views data for contextual.module.
*/
/**
......
......@@ -91,9 +91,7 @@
}
.contextual-region .contextual .contextual-links a {
background-color: #fff;
/* This is an unfortunately necessary use of !important to prevent white
* links on a white background or some similar illegible combination. */
color: #333 !important;
color: #333;
display: block;
font-family: sans-serif;
font-size: small;
......