Skip to content
<?php
/**
* @file
* Contains \Drupal\block\Theme\AdminDemoNegotiator.
*/
namespace Drupal\block\Theme;
use Drupal\Core\Theme\ThemeNegotiatorInterface;
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
use Symfony\Component\HttpFoundation\Request;
/**
* Negotiates the theme for the block admin demo page via the URL.
*/
class AdminDemoNegotiator implements ThemeNegotiatorInterface {
/**
* {@inheritdoc}
*/
public function determineActiveTheme(Request $request) {
// We return exactly what was passed in, to guarantee that the page will
// always be displayed using the theme whose blocks are being configured.
if ($request->attributes->get(RouteObjectInterface::ROUTE_NAME) == 'block.admin_demo') {
return $request->attributes->get('theme');
}
}
}
......@@ -696,28 +696,43 @@ function template_preprocess_book_navigation(&$variables) {
if ($book_link['mlid']) {
$variables['tree'] = book_children($book_link);
$build = array();
if ($prev = book_prev($book_link)) {
$prev_href = url($prev['href']);
drupal_add_html_head_link(array('rel' => 'prev', 'href' => $prev_href));
$build['#attached']['drupal_add_html_head_link'][][] = array(
'rel' => 'prev',
'href' => $prev_href,
);
$variables['prev_url'] = $prev_href;
$variables['prev_title'] = check_plain($prev['title']);
}
if ($book_link['plid'] && $parent = book_link_load($book_link['plid'])) {
$parent_href = url($parent['link_path']);
drupal_add_html_head_link(array('rel' => 'up', 'href' => $parent_href));
$build['#attached']['drupal_add_html_head_link'][][] = array(
'rel' => 'up',
'href' => $parent_href,
);
$variables['parent_url'] = $parent_href;
$variables['parent_title'] = check_plain($parent['title']);
}
if ($next = book_next($book_link)) {
$next_href = url($next['href']);
drupal_add_html_head_link(array('rel' => 'next', 'href' => $next_href));
$build['#attached']['drupal_add_html_head_link'][][] = array(
'rel' => 'next',
'href' => $next_href,
);
$variables['next_url'] = $next_href;
$variables['next_title'] = check_plain($next['title']);
}
}
if (!empty($build)) {
drupal_render($build);
}
$variables['has_links'] = FALSE;
// Link variables to filter for values and set state of the flag variable.
$links = array('prev_url', 'prev_title', 'parent_url', 'parent_title', 'next_url', 'next_title');
......
......@@ -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.
*/
/**
......
......@@ -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
),
);
}
}
}
......
......@@ -3,8 +3,6 @@
/**
* @file
* Provide views data for contact.module.
*
* @ingroup views_module_handlers
*/
/**
......
......@@ -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;
......
......@@ -3,8 +3,6 @@
/**
* @file
* Provide views data for dblog.module.
*
* @ingroup views_module_handlers
*/
/**
......
......@@ -17,6 +17,26 @@
use Drupal\entity\Entity\EntityDisplay;
use Drupal\user\TempStoreFactory;
/**
* Implements hook_menu().
*/
function edit_menu() {
// @todo Remove these menu items in http://drupal.org/node/1954892 when theme
// callbacks are replaced with something else.
$items['edit/metadata'] = array(
'route_name' => 'edit.metadata',
'theme callback' => 'ajax_base_page_theme',
'type' => MENU_CALLBACK,
);
$items['edit/form/%/%/%/%/%'] = array(
'route_name' => 'edit.field_form',
'theme callback' => 'ajax_base_page_theme',
'type' => MENU_CALLBACK,
);
return $items;
}
/**
* Implements hook_permission().
*/
......
......@@ -2,10 +2,9 @@ edit.metadata:
path: '/edit/metadata'
defaults:
_controller: '\Drupal\edit\EditController::metadata'
options:
_theme: ajax_base_page
requirements:
_permission: 'access in-place editing'
edit.attachments:
path: '/edit/attachments'
defaults:
......@@ -17,9 +16,6 @@ edit.field_form:
path: '/edit/form/{entity_type}/{entity}/{field_name}/{langcode}/{view_mode_id}'
defaults:
_controller: '\Drupal\edit\EditController::fieldForm'
options:
_access_mode: 'ALL'
_theme: ajax_base_page
requirements:
_permission: 'access in-place editing'
_access_edit_entity_field: 'TRUE'
......
......@@ -139,6 +139,21 @@ function editor_library_info() {
return $libraries;
}
/**
* Implements hook_menu().
*/
function editor_menu() {
// @todo Remove this menu item in http://drupal.org/node/1954892 when theme
// callbacks are replaced with something else.
$items['editor/%/%/%/%/%'] = array(
'route_name' => 'editor.field_untransformed_text',
'theme callback' => 'ajax_base_page_theme',
'type' => MENU_CALLBACK,
);
return $items;
}
/**
* Implements hook_form_FORM_ID_alter().
*/
......
......@@ -2,8 +2,6 @@ editor.field_untransformed_text:
path: '/editor/{entity_type}/{entity}/{field_name}/{langcode}/{view_mode_id}'
defaults:
_controller: '\Drupal\editor\EditorController::getUntransformedText'
options:
_theme: ajax_base_page
requirements:
_permission: 'access in-place editing'
_access_edit_entity_field: 'TRUE'
......
......@@ -2,9 +2,7 @@
/**
* @file
* Provide Views data and handlers for field.module.
*
* @ingroup views_module_handlers
* Provide Views data for field.module.
*/
use Drupal\Component\Utility\NestedArray;
......
......@@ -37,6 +37,21 @@ function file_help($path, $arg) {
}
}
/**
* Implements hook_menu().
*/
function file_menu() {
$items = array();
$items['file/ajax'] = array(
'route_name' => 'file.ajax_upload',
'theme callback' => 'ajax_base_page_theme',
'type' => MENU_CALLBACK,
);
return $items;
}
/**
* Implements hook_element_info().
*
......
......@@ -2,8 +2,6 @@ file.ajax_upload:
path: '/file/ajax'
defaults:
_controller: '\Drupal\file\Controller\FileWidgetAjaxController::upload'
options:
_theme: ajax_base_page
requirements:
_permission: 'access content'
......