diff --git a/core/modules/book/book.module b/core/modules/book/book.module index 7c43e28..d24b9ee 100644 --- a/core/modules/book/book.module +++ b/core/modules/book/book.module @@ -249,19 +249,6 @@ function book_admin_paths() { } /** - * Implements hook_entity_info_alter(). - */ -function book_entity_info_alter(&$info) { - // Add the 'Print' view mode for nodes. - $info['node']['view modes'] += array( - 'print' => array( - 'label' => t('Print'), - 'custom settings' => FALSE, - ), - ); -} - -/** * Implements hook_block_info(). */ function book_block_info() { diff --git a/core/modules/book/config/view_mode.node.print.yml b/core/modules/book/config/view_mode.node.print.yml new file mode 100644 index 0000000..1ed8183 --- /dev/null +++ b/core/modules/book/config/view_mode.node.print.yml @@ -0,0 +1,5 @@ +machine_name: node.print +name: Print +custom: '0' +type: node +locked: '1' diff --git a/core/modules/entity_ui/css/entity_ui.admin.css b/core/modules/entity_ui/css/entity_ui.admin.css new file mode 100644 index 0000000..8d68fd6 --- /dev/null +++ b/core/modules/entity_ui/css/entity_ui.admin.css @@ -0,0 +1,8 @@ +/** + * @file + * Stylesheet for the administration pages of the Entity UI module. + */ + +.operations { + width: 100px; +} diff --git a/core/modules/entity_ui/entity_ui.admin.inc b/core/modules/entity_ui/entity_ui.admin.inc index 8f23cd8..af636cd 100644 --- a/core/modules/entity_ui/entity_ui.admin.inc +++ b/core/modules/entity_ui/entity_ui.admin.inc @@ -10,12 +10,16 @@ */ function entity_ui_view_mode_list() { $build = array(); + $weight = 0; $controller = entity_list_controller('view_mode'); foreach (entity_get_info() as $type => $info) { - if ($type != 'view_mode') { + if ($type != 'view_mode' && !empty($info['fieldable'])) { $build[$type] = $controller->set($type)->render(); + // Content is usually the most important entity type in the system. + $build[$type]['#weight'] = ($type == 'node') ? -10 : $weight++; } } + $build['#attached']['css'][] = drupal_get_path('module', 'entity_ui') . '/css/entity_ui.admin.css'; return $build; } diff --git a/core/modules/entity_ui/lib/Drupal/entity_ui/ViewModeFormController.php b/core/modules/entity_ui/lib/Drupal/entity_ui/ViewModeFormController.php index a7f499c..5fd192c 100644 --- a/core/modules/entity_ui/lib/Drupal/entity_ui/ViewModeFormController.php +++ b/core/modules/entity_ui/lib/Drupal/entity_ui/ViewModeFormController.php @@ -23,7 +23,7 @@ public function form(array $form, array &$form_state, EntityInterface $view_mode $form['type'] = array( '#type' => 'item', '#title' => t('Entity type'), - '#markup' => $entity_info['label'], + '#markup' => check_plain($entity_info['label']), ); $form['name'] = array( '#type' => 'textfield', diff --git a/core/modules/entity_ui/lib/Drupal/entity_ui/ViewModeListController.php b/core/modules/entity_ui/lib/Drupal/entity_ui/ViewModeListController.php index 7c7010b..f227980 100644 --- a/core/modules/entity_ui/lib/Drupal/entity_ui/ViewModeListController.php +++ b/core/modules/entity_ui/lib/Drupal/entity_ui/ViewModeListController.php @@ -37,7 +37,7 @@ public function load() { * Overrides Drupal\Core\Entity\EntityListController::buildHeader(); */ public function buildHeader() { - $header['name'] = t('Name'); + $header['name'] = check_plain($this->type['label']); $header['operations'] = t('Operations'); return $header; } @@ -46,8 +46,9 @@ public function buildHeader() { * Overrides Drupal\Core\Entity\EntityListController::buildRow(); */ public function buildRow(EntityInterface $view_mode) { - $row['name'] = $view_mode->label(); + $row['name'] = check_plain($view_mode->label()); $row['operations']['data'] = $this->buildOperations($view_mode); + $row['operations']['class'] = array('operations'); return $row; } @@ -78,7 +79,6 @@ public function render() { ), 'colspan' => count($build['#header']), ); - $build['#caption'] = $this->type['label']; return $build; } diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/FilledStandardUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/FilledStandardUpgradePathTest.php index da4034b..654bea7 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/FilledStandardUpgradePathTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/FilledStandardUpgradePathTest.php @@ -86,5 +86,13 @@ public function testFilledStandardUpgrade() { $blog_type = node_type_load('blog'); $this->assertEqual($blog_type->module, 'node', "Content type 'blog' has been reassigned from the blog module to the node module."); $this->assertEqual($blog_type->base, 'node_content', "The base string used to construct callbacks corresponding to content type 'Blog' has been reassigned to 'node_content'."); + + // Verify all core view modes have been converted to config. + $entity_info = entity_get_info(); + foreach ($entity_info as $type => $info) { + if (!empty($info['fieldable'])) { + $this->assertTrue(!empty($info['view modes']), format_string('View modes for @entity_type have been converted', array('@entity_type' => $info['label']))); + } + } } } diff --git a/core/modules/system/system.install b/core/modules/system/system.install index d0deae1..560cbd1 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -2188,6 +2188,51 @@ function system_update_8030() { } /** + * Moves entity view modes to config. + * + * @ingroup config_upgrade + */ +function system_update_8031() { + // We can't call entity_info() in an update hook, so we hardcode them. + // We only care about the core view modes as hook_entity_info_alter() will + // still work since that was the only way to add custom view modes in D7. + $view_modes = array( + 'node' => array( + 'full' => 'Full content', + 'teaser', 'Teaser', + 'rss' => 'RSS', + 'search_index' => 'Search index', + 'search_result' => 'Search result', + 'print' => 'Print', + ), + 'file' => array( + 'full' => 'File default', + ), + 'comment' => array( + 'full' => 'Full comment', + ), + 'user' => array( + 'full' => 'User account', + ), + 'taxonomy_term' => array( + 'full' => 'Taxonomy term page', + ), + ); + + foreach ($view_modes as $entity_type => $view_modes) { + foreach ($view_modes as $key => $name) { + config('view_mode.' . $entity_type . '.' . $key) + ->set('machine_name', $entity_type . '.' . $key) + ->set('name', $key) + ->set('type', $entity_type) + ->set('locked', TRUE) + ->set('custom', FALSE) + ->save(); + } + } +} + +/** * @} End of "defgroup updates-7.x-to-8.x". * The next series of updates should start at 9000. */ diff --git a/core/modules/taxonomy/config/view_mode.taxonomy_vocabulary.full.yml b/core/modules/taxonomy/config/view_mode.taxonomy_vocabulary.full.yml deleted file mode 100644 index f689959..0000000 --- a/core/modules/taxonomy/config/view_mode.taxonomy_vocabulary.full.yml +++ /dev/null @@ -1,5 +0,0 @@ -machine_name: taxonomy_vocabulary.full -name: Taxonomy vocabulary default -custom: '0' -type: taxonomy_vocabulary -locked: '1'