diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 7dc75f5..ce64e46 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -1697,8 +1697,8 @@ function watchdog($type, $message, array $variables = NULL, $severity = WATCHDOG /** * Sets a message to display to the user. * - * Messages are stored in a session variable and displayed in page.tpl.php via - * the $messages theme variable. + * Messages are stored in a session variable and displayed in the page template + * via the $messages theme variable. * * Example usage: * @code diff --git a/core/includes/common.inc b/core/includes/common.inc index 5e8e2d1..643b151 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -4994,14 +4994,14 @@ function drupal_pre_render_link($element) { * * In this example, the links are grouped by functionality, which can be * helpful to themers who want to display certain kinds of links independently. - * For example, adding this code to node.tpl.php will result in the comment + * For example, adding this code to node.html.twig will result in the comment * links being rendered as a single list: * @code * print render($content['links']['comment']); * @endcode * * (where $node->content has been transformed into $content before handing - * control to the node.tpl.php template). + * control to the node.html.twig template). * * The pre_render function defined here allows the above flexibility, but also * allows the following code to be used to render all remaining links into a @@ -5065,7 +5065,7 @@ function drupal_pre_render_dropbutton($element) { * A string or array representing the content of a page. The array consists of * the following keys: * - #type: Value is always 'page'. This pushes the theming through - * page.tpl.php (required). + * the page template (required). * - #show_messages: Suppress drupal_get_message() items. Used by Batch * API (optional). * @@ -5915,7 +5915,7 @@ function element_set_attributes(array &$element, array $map) { * - name: The real name of the theme for display purposes. * - description: Brief description. * - screenshot: Path to screenshot relative to the theme's .info.yml file. - * - engine: Theme engine; typically phptemplate. + * - engine: Theme engine; typically twig. * - base theme: Name of a base theme, if applicable. * - regions: Listed regions. * - features: Features available. diff --git a/core/includes/entity.api.php b/core/includes/entity.api.php index 148f11d..1912fe1 100644 --- a/core/includes/entity.api.php +++ b/core/includes/entity.api.php @@ -344,7 +344,7 @@ function hook_entity_view(\Drupal\Core\Entity\EntityInterface $entity, \Drupal\e * If a module wishes to act on the rendered HTML of the entity rather than the * structured content array, it may use this hook to add a #post_render * callback. Alternatively, it could also implement hook_preprocess_HOOK() for - * the particular entity type template, if there is one (e.g., node.tpl.php). + * the particular entity type template, if there is one (e.g., node.html.twig). * See drupal_render() and theme() for details. * * @param $build diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 721453a..c4a3d9a 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -267,11 +267,9 @@ function _drupal_theme_initialize($theme, $base_theme = array(), $registry_callb include_once DRUPAL_ROOT . '/' . $theme->owner; } } - // Load twig as secondary always available engine. - // @todo Make twig the default engine and remove this. This is required - // because (by design) the theme system doesn't allow modules to register more - // than one type of extension. We need a temporary backwards compatibility - // layer to allow us to perform core-wide .tpl.php to .html.twig conversion. + + // Always include Twig so that PHPTemplate themes do not have to convert all + // core and contrib templates in order to use the PHPTemplate engine. include_once DRUPAL_ROOT . '/core/themes/engines/twig/twig.engine'; if (isset($registry_callback)) { @@ -512,28 +510,6 @@ function _theme_process_registry(&$cache, $name, $type, $theme, $path) { if (!isset($info['path'])) { $result[$hook]['template'] = $path . '/templates/' . $info['template']; } - if ($type == 'module' || $type == 'theme_engine') { - // Add two render engines for modules and theme engines. - // @todo Remove and make twig the default engine. - $render_engines = array( - '.html.twig' => 'twig', - '.tpl.php' => 'phptemplate' - ); - - // Find the best engine for this template. - foreach ($render_engines as $extension => $engine) { - // Render the output using the template file. - $template_file = $result[$hook]['template'] . $extension; - if (isset($info['path'])) { - $template_file = $info['path'] . '/' . $template_file; - } - if (file_exists($template_file)) { - $result[$hook]['template_file'] = $template_file; - $result[$hook]['engine'] = $engine; - break; - } - } - } } // Allow variable processors for all theming hooks, whether the hook is @@ -665,12 +641,6 @@ function _theme_build_registry($theme, $base_theme, $theme_engine) { _theme_process_registry($cache, $theme_engine, 'theme_engine', $theme->name, dirname($theme->filename)); } - if ($theme_engine == 'phptemplate') { - // Check for Twig templates if this is a PHPTemplate theme. - // @todo Remove this once all core themes are converted to Twig. - _theme_process_registry($cache, 'twig', 'theme_engine', $theme->name, dirname($theme->filename)); - } - // Finally, hooks provided by the theme itself. _theme_process_registry($cache, $theme->name, 'theme', $theme->name, dirname($theme->filename)); @@ -846,7 +816,7 @@ function drupal_find_base_themes($themes, $key, $used_keys = array()) { * theme_HOOK() (e.g., theme_taxonomy_term()) or via a template file named * according to the value of the 'template' key registered with the theme hook * (see hook_theme() for details). Default templates are implemented with the - * PHPTemplate rendering engine and are named the same as the theme hook, with + * Twig rendering engine and are named the same as the theme hook, with * underscores changed to hyphens, so for the 'taxonomy_term' theme hook, the * default template is 'taxonomy-term.tpl.php'. * @@ -858,9 +828,9 @@ function drupal_find_base_themes($themes, $key, $used_keys = array()) { * default implementation of the 'menu_tree' theme hook by implementing a * bartik_menu_tree() function), or by adding a template file within its folder * structure that follows the template naming structure used by the theme's - * rendering engine (for example, since the Bartik theme uses the PHPTemplate - * rendering engine, it overrides the default implementation of the 'page' theme - * hook by containing a 'page.tpl.php' file within its folder structure). + * rendering engine (for example, since the Bartik theme uses the Twig rendering + * engine, it overrides the default implementation of the 'page' theme hook by + * containing a 'page.html.twig' file within its folder structure). * * If the implementation is a template file, several functions are called * before the template file is invoked, to modify the $variables array. These @@ -1122,9 +1092,8 @@ function theme($hook, $variables = array()) { } } else { - // Default render function and extension. - $render_function = 'theme_render_template'; - $extension = '.tpl.php'; + $render_function = 'twig_render_template'; + $extension = '.html.twig'; // The theme engine may use a different extension and a different renderer. global $theme_engine; @@ -1138,13 +1107,6 @@ function theme($hook, $variables = array()) { $extension = $extension_function(); } } - // @todo Change this 'if' back to 'elseif' once Twig conversion is - // complete. Normally only modules have this key set. - if (isset($info['engine'])) { - if (function_exists($info['engine'] . '_render_template')) { - $render_function = $info['engine'] . '_render_template'; - } - } } // In some cases, a template implementation may not have had @@ -1182,12 +1144,6 @@ function theme($hook, $variables = array()) { if (isset($info['path'])) { $template_file = $info['path'] . '/' . $template_file; } - - // Modules can override this. - if (isset($info['template_file'])) { - $template_file = $info['template_file']; - } - $output = $render_function($template_file, $variables); } @@ -2725,10 +2681,15 @@ function _template_preprocess_default_variables() { } /** - * Preprocess variables for html.tpl.php + * Prepares variables for HTML document templates. + * + * Default template: html.html.twig. + * + * @param array $variables + * An associative array containing: + * - page: A render element representing the page. * * @see system_elements() - * @see html.tpl.php */ function template_preprocess_html(&$variables) { $language_interface = language(LANGUAGE_TYPE_INTERFACE); @@ -2847,10 +2808,12 @@ function template_preprocess_html(&$variables) { } /** - * Preprocess variables for page.tpl.php + * Prepares variables for the page template. + * + * Default template: page.html.twig. * - * Most themes utilize their own copy of page.tpl.php. The default is located - * inside "modules/system/page.tpl.php". Look in there for the full list of + * Most themes utilize their own copy of page.html.twig. The default is located + * inside "modules/system/page.html.twig". Look in there for the full list of * variables. * * Uses the arg() function to generate a series of page template suggestions @@ -2861,7 +2824,6 @@ function template_preprocess_html(&$variables) { * * @see drupal_render_page() * @see template_process_page() - * @see page.tpl.php */ function template_preprocess_page(&$variables) { $language_interface = language(LANGUAGE_TYPE_INTERFACE); @@ -2898,6 +2860,36 @@ function template_preprocess_page(&$variables) { $variables['site_slogan'] = (theme_get_setting('features.slogan') ? filter_xss_admin($site_config->get('slogan')) : ''); $variables['tabs'] = menu_local_tabs(); + // Pass the main menu and secondary menu to the template as render arrays. + if (!empty($variables['main_menu'])) { + $variables['main_menu'] = array( + '#theme' =>'links__system_main_menu', + '#links' => $variables['main_menu'], + '#attributes' => array( + 'id' => 'main-menu', + 'class' => array('links', 'inline', 'clearfix'), + ), + '#heading' => array( + 'text' => t('Main menu'), + 'class' => array('element-invisible'), + ) + ); + } + if (!empty($variables['secondary_menu'])) { + $variables['secondary_menu'] = array( + '#theme' =>'links__system_secondary_menu', + '#links' => $variables['secondary_menu'], + '#attributes' => array( + 'id' => 'secondary-menu', + 'class' => array('links', 'inline', 'clearfix'), + ), + '#heading' => array( + 'text' => t('Secondary menu'), + 'class' => array('element-invisible'), + ) + ); + } + if ($node = menu_get_object()) { $variables['node'] = $node; } @@ -2909,13 +2901,12 @@ function template_preprocess_page(&$variables) { } /** - * Process variables for page.tpl.php + * Processes variables for page.html.twig. * * Perform final addition of variables before passing them into the template. * To customize these variables, simply set them in an earlier step. * * @see template_preprocess_page() - * @see page.tpl.php */ function template_process_page(&$variables) { if (!isset($variables['breadcrumb'])) { @@ -2923,7 +2914,10 @@ function template_process_page(&$variables) { // re-use the cache of an already rendered menu containing the active link // for the current page. // @see menu_tree_page_data() - $variables['breadcrumb'] = theme('breadcrumb', array('breadcrumb' => drupal_get_breadcrumb())); + $variables['breadcrumb'] = array( + '#theme' => 'breadcrumb', + '#breadcrumb' => drupal_get_breadcrumb(), + ); } if (!isset($variables['title'])) { $variables['title'] = drupal_get_title(); @@ -2932,27 +2926,26 @@ function template_process_page(&$variables) { // Generate messages last in order to capture as many as possible for the // current page. if (!isset($variables['messages'])) { - $variables['messages'] = $variables['show_messages'] ? theme('status_messages') : ''; + $variables['messages'] = $variables['show_messages'] ? array('#theme' => 'status_messages') : ''; } } /** - * Process variables for html.tpl.php + * Processes variables for html.html.twig. * * Perform final addition and modification of variables before passing into * the template. To customize these variables, call drupal_render() on elements * in $variables['page'] during THEME_preprocess_page(). * * @see template_preprocess_html() - * @see html.tpl.php */ function template_process_html(&$variables) { drupal_add_library('system', 'html5shiv', TRUE); // Render page_top and page_bottom into top level variables. - $variables['page_top'] = drupal_render($variables['page']['page_top']); - $variables['page_bottom'] = drupal_render($variables['page']['page_bottom']); + $variables['page_top'] = isset($variables['page']['page_top']) ? drupal_render($variables['page']['page_top']) : ''; + $variables['page_bottom'] = isset($variables['page']['page_bottom']) ? drupal_render($variables['page']['page_bottom']) : ''; // Place the rendered HTML for the page body into a top level variable. - $variables['page'] = $variables['page']['#children']; + $variables['page'] = $variables['page']['#children']; $variables['page_bottom'] .= drupal_get_js('footer'); $variables['head'] = drupal_get_html_head(); @@ -3032,18 +3025,19 @@ function theme_get_suggestions($args, $base, $delimiter = '__') { } /** - * Process variables for maintenance-page.tpl.php. + * Prepare variables for maintenance page templates. + * + * Default template: maintenance-page.html.twig. * * The variables array generated here is a mirror of * template_preprocess_page(). This preprocessor will run its course when * theme_maintenance_page() is invoked. An alternate template file of - * maintenance-page--offline.tpl.php can be used when the database is offline to - * hide errors and completely replace the content. - * - * The $variables array contains the following arguments: - * - $content + * maintenance-page--offline.html.twig can be used when the database is offline + * to hide errors and completely replace the content. * - * @see maintenance-page.tpl.php + * @param array $variables + * An associative array containing: + * - content - An array of page content. */ function template_preprocess_maintenance_page(&$variables) { global $theme; @@ -3141,7 +3135,7 @@ function template_preprocess_maintenance_page(&$variables) { * The variables array generated here is a mirror of template_process_html(). * This processor will run its course when theme_maintenance_page() is invoked. * - * @see maintenance-page.tpl.php + * @see maintenance-page.html.twig * @see template_process_html() */ function template_process_maintenance_page(&$variables) { diff --git a/core/modules/aggregator/aggregator.module b/core/modules/aggregator/aggregator.module index bd65f4f..221b921 100644 --- a/core/modules/aggregator/aggregator.module +++ b/core/modules/aggregator/aggregator.module @@ -539,7 +539,7 @@ function aggregator_filter_xss($value) { } /** - * Implements hook_preprocess_HOOK() for block.tpl.php. + * Implements hook_preprocess_HOOK() for block.html.twig. */ function aggregator_preprocess_block(&$variables) { if ($variables['configuration']['module'] == 'aggregator') { diff --git a/core/modules/aggregator/aggregator.pages.inc b/core/modules/aggregator/aggregator.pages.inc index 10ba125..32509ce 100644 --- a/core/modules/aggregator/aggregator.pages.inc +++ b/core/modules/aggregator/aggregator.pages.inc @@ -281,9 +281,14 @@ function theme_aggregator_summary_item($variables) { } /** - * Processes variables for aggregator-item.tpl.php. + * Prepares variables for aggregator item templates. * - * @see aggregator-item.tpl.php + * Default template: aggregator-item.html.twig. + * + * @param array $variables + * An associative array containing: + * - aggregator_item: An individual feed item for display on the aggregator + * page. */ function template_preprocess_aggregator_item(&$variables) { $item = $variables['aggregator_item']; @@ -309,6 +314,8 @@ function template_preprocess_aggregator_item(&$variables) { foreach ($item->categories as $category) { $variables['categories'][$category->cid] = l($category->title, 'aggregator/categories/' . $category->cid); } + + $variables['attributes']['class'][] = 'feed-item'; } /** @@ -515,9 +522,15 @@ function theme_aggregator_page_opml($variables) { } /** - * Processes variables for aggregator-summary-items.tpl.php. + * Prepares variables for aggregator summary templates. * - * @see aggregator-summary-items.tpl.php + * Default template: aggregator-summary-items.html.twig. + * + * @param array $variables + * An associative array containing: + * - source: A Drupal\aggregator\Plugin\Core\Entity\Feed instance representing + * the feed source. + * - summary_items: An array of feed items. */ function template_preprocess_aggregator_summary_items(&$variables) { $variables['title'] = check_plain($variables['source'] instanceof EntityInterface ? $variables['source']->label() : $variables['source']->title); @@ -533,9 +546,14 @@ function template_preprocess_aggregator_summary_items(&$variables) { } /** - * Processes variables for aggregator-summary-item.tpl.php. + * Processes variables for aggregator summary item templates. * - * @see aggregator-summary-item.tpl.php + * Default template: aggregator-summary-item.html.twig. + * + * @param array $variables + * An associative array containing: + * - aggregator_item: The feed item. + * - view_mode: How the item is being displayed. */ function template_preprocess_aggregator_summary_item(&$variables) { $item = $variables['aggregator_item']; @@ -556,9 +574,14 @@ function template_preprocess_aggregator_summary_item(&$variables) { } /** - * Processes variables for aggregator-feed-source.tpl.php. + * Prepares variables for aggregator feed source templates. + * + * Default template: aggregator-feed-source.html.twig. * - * @see aggregator-feed-source.tpl.php + * @param array $variables + * An associative array containing: + * - aggregator_feed: A Drupal\aggregator\Plugin\Core\Entity\Feed instance + * representing the feed source. */ function template_preprocess_aggregator_feed_source(&$variables) { $feed = $variables['aggregator_feed']; @@ -584,4 +607,6 @@ function template_preprocess_aggregator_feed_source(&$variables) { if (user_access('administer news feeds')) { $variables['last_checked'] = l($variables['last_checked'], 'admin/config/services/aggregator'); } + + $variables['attributes']['class'][] = 'feed-source'; } diff --git a/core/modules/aggregator/templates/aggregator-feed-source.html.twig b/core/modules/aggregator/templates/aggregator-feed-source.html.twig new file mode 100644 index 0000000..0bb2ddb --- /dev/null +++ b/core/modules/aggregator/templates/aggregator-feed-source.html.twig @@ -0,0 +1,35 @@ +{# +/** + * @file + * Default theme implementation to present the source of the feed. + * + * The contents are rendered above feed listings when browsing source feeds. + * For example, "example.com/aggregator/sources/1". + * + * Available variables: + * - source_icon: Feed icon linked to the source. Rendered through + * feed-icon.html.twig. + * - source_image: Image set by the feed source. + * - source_description: Description set by the feed source. + * - source_url: URL to the feed source. + * - last_checked: How long ago the feed was checked locally. + * + * @see template_preprocess() + * @see template_preprocess_aggregator_feed_source() + * + * @ingroup themeable + */ +#} + + {{ source_icon }} + {{ source_image }} +
+ {{ source_description }} +
+
+ {{ 'URL'|t }}: {{ source_url }} +
+
+ {{ 'Updated'|t }}: {{ last_checked }} +
+ diff --git a/core/modules/aggregator/templates/aggregator-feed-source.tpl.php b/core/modules/aggregator/templates/aggregator-feed-source.tpl.php deleted file mode 100644 index f9cfa55..0000000 --- a/core/modules/aggregator/templates/aggregator-feed-source.tpl.php +++ /dev/null @@ -1,36 +0,0 @@ - -
- - -
- -
-
- -
-
- -
-
diff --git a/core/modules/aggregator/templates/aggregator-item.html.twig b/core/modules/aggregator/templates/aggregator-item.html.twig new file mode 100644 index 0000000..6a0185b --- /dev/null +++ b/core/modules/aggregator/templates/aggregator-item.html.twig @@ -0,0 +1,44 @@ +{# +/** + * @file + * Default theme implementation to present a feed item in an aggregator page. + * + * Available variables: + * - feed_url: URL to the originating feed item. + * - feed_title: Title of the feed item. + * - source_url: Link to the local source section. + * - source_title: Title of the remote source. + * - source_date: Date the feed was posted on the remote source. + * - content: Feed item content. + * - categories: Linked categories assigned to the feed. + * + * @see template_preprocess() + * @see template_preprocess_aggregator_item() + * + * @ingroup themeable + */ +#} + +

+ {{ feed_title }} +

+ +
+ {% if source_url %} + {{ source_title }} - + {% endif %} + {{ source_date }} +
+ + {% if content %} +
+ {{ content }} +
+ {% endif %} + + {% if categories %} +
+ {{ 'Categories'|t }}: {{ categories|join(', ') }} +
+ {% endif %} + diff --git a/core/modules/aggregator/templates/aggregator-item.tpl.php b/core/modules/aggregator/templates/aggregator-item.tpl.php deleted file mode 100644 index 74b2284..0000000 --- a/core/modules/aggregator/templates/aggregator-item.tpl.php +++ /dev/null @@ -1,47 +0,0 @@ - -
-

- -

- -
- - - - - -
- - -
- -
- - - -
- : -
- - -
diff --git a/core/modules/aggregator/templates/aggregator-summary-items.html.twig b/core/modules/aggregator/templates/aggregator-summary-items.html.twig new file mode 100644 index 0000000..5376fda --- /dev/null +++ b/core/modules/aggregator/templates/aggregator-summary-items.html.twig @@ -0,0 +1,24 @@ +{# +/** + * @file + * Default theme implementation to present feeds as list items. + * + * Each iteration generates a single feed source or category. + * + * Available variables: + * - title: Title of the feed or category. + * - summary_list: Unordered list of linked feed items generated through + * theme_item_list(). + * - source_url: URL to the local source or category. + * + * @see template_preprocess() + * @see template_preprocess_aggregator_summary_items() + * + * @ingroup themeable + */ +#} +

{{ title }}

+{{ summary_list }} + diff --git a/core/modules/aggregator/templates/aggregator-summary-items.tpl.php b/core/modules/aggregator/templates/aggregator-summary-items.tpl.php deleted file mode 100644 index 8f19fe1..0000000 --- a/core/modules/aggregator/templates/aggregator-summary-items.tpl.php +++ /dev/null @@ -1,24 +0,0 @@ - -

- - diff --git a/core/modules/aggregator/templates/aggregator-wrapper.tpl.php b/core/modules/aggregator/templates/aggregator-wrapper.tpl.php deleted file mode 100644 index 0e97ba4..0000000 --- a/core/modules/aggregator/templates/aggregator-wrapper.tpl.php +++ /dev/null @@ -1,20 +0,0 @@ - -
- - -
diff --git a/core/modules/block/block.admin.inc b/core/modules/block/block.admin.inc index f94ce25..e6da2f6 100644 --- a/core/modules/block/block.admin.inc +++ b/core/modules/block/block.admin.inc @@ -6,6 +6,7 @@ */ use Drupal\block\Plugin\Core\Entity\Block; +use Drupal\Core\Template\Attribute; /** * Page callback: Attaches CSS for the block region demo. @@ -84,13 +85,13 @@ function block_admin_edit(Block $entity) { } /** - * Processes variables for block-admin-display-form.tpl.php. + * Prepares variables for block admin display form templates. * - * The $variables array contains the following arguments: - * - $form + * Default template: block-admin-display-form.html.twig. * - * @see block-admin-display.tpl.php - * @see theme_block_admin_display() + * @param array $variables + * An associative array containing: + * - form: A render element representing the form. */ function template_preprocess_block_admin_display_form(&$variables) { $variables['block_regions'] = $variables['form']['block_regions']['#value']; @@ -120,12 +121,19 @@ function template_preprocess_block_admin_display_form(&$variables) { $variables['block_listing'][$region][$i] = new stdClass(); $variables['block_listing'][$region][$i]->row_class = !empty($block['#attributes']['class']) ? implode(' ', $block['#attributes']['class']) : ''; $variables['block_listing'][$region][$i]->block_modified = !empty($block['#attributes']['class']) && in_array('block-modified', $block['#attributes']['class']); - $variables['block_listing'][$region][$i]->block_title = drupal_render($block['info']); - $variables['block_listing'][$region][$i]->region_select = drupal_render($block['region']) . drupal_render($block['theme']); - $variables['block_listing'][$region][$i]->weight_select = drupal_render($block['weight']); - $variables['block_listing'][$region][$i]->operations = drupal_render($block['operations']); + $variables['block_listing'][$region][$i]->block_title = $block['info']; + $variables['block_listing'][$region][$i]->region_select = array( + 'region' => array( + 'data' => $block['region'], + '#weight' => 1, + ), + 'theme' => array( + 'data' => $block['theme'], + '#weight' => 2, + ), + ); + $variables['block_listing'][$region][$i]->weight_select = $block['weight']; + $variables['block_listing'][$region][$i]->operations = $block['operations']; $variables['block_listing'][$region][$i]->printed = FALSE; } - - $variables['form_submit'] = drupal_render_children($variables['form']); } diff --git a/core/modules/block/block.api.php b/core/modules/block/block.api.php index c2bf7ff..93a113a 100644 --- a/core/modules/block/block.api.php +++ b/core/modules/block/block.api.php @@ -20,7 +20,7 @@ * If the module wishes to act on the rendered HTML of the block rather than * the structured content array, it may use this hook to add a #post_render * callback. Alternatively, it could also implement hook_preprocess_HOOK() for - * block.tpl.php. See drupal_render() and theme() documentation respectively + * block.html.twig. See drupal_render() and theme() documentation respectively * for details. * * In addition to hook_block_view_alter(), which is called for all blocks, there diff --git a/core/modules/block/block.module b/core/modules/block/block.module index d94ec3b..8b24c9d 100644 --- a/core/modules/block/block.module +++ b/core/modules/block/block.module @@ -515,21 +515,23 @@ function block_rebuild() { } /** - * Processes variables for block.tpl.php. + * Prepares variables for block templates. + * + * Default template: block.html.twig. * * Prepares the values passed to the theme_block function to be passed * into a pluggable template engine. Uses block properties to generate a * series of template file suggestions. If none are found, the default - * block.tpl.php is used. - * - * Most themes utilize their own copy of block.tpl.php. The default is located - * inside "modules/block/block.tpl.php". Look in there for the full list of - * variables. + * block.html.twig is used. * - * The $variables array contains the following arguments: - * - $block + * Most themes use their own copy of block.html.twig. The default is located + * inside "core/modules/block/templates/block.html.twig". Look in there for the + * full list of available variables. * - * @see block.tpl.php + * @param array $variables + * An associative array containing: + * - elements: An associative array containing the properties of the element. + * Properties used: #block, #configuration, #children, #plugin_id. */ function template_preprocess_block(&$variables) { $block_counter = &drupal_static(__FUNCTION__, array()); @@ -566,7 +568,7 @@ function template_preprocess_block(&$variables) { if ($id = $variables['elements']['#block']->id()) { $config_id = explode('.', $id); $machine_name = array_pop($config_id); - $variables['block_html_id'] = drupal_html_id('block-' . $machine_name); + $variables['attributes']['id'] = drupal_html_id('block-' . $machine_name); $variables['theme_hook_suggestions'][] = 'block__' . $machine_name; } } diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php index dfc3b61..c3fbca3 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php @@ -135,11 +135,13 @@ protected function renderTests() { $entity = entity_load('block', 'stark.test_block'); $output = entity_view($entity, 'block'); $expected = array(); - $expected[] = '
'; - $expected[] = ''; + $expected[] = '
'; + $expected[] = ' '; $expected[] = ' '; + $expected[] = ''; $expected[] = '
'; - $expected[] = '
'; + $expected[] = ' '; + $expected[] = '
'; $expected[] = '
'; $expected[] = ''; $expected_output = implode("\n", $expected); @@ -159,12 +161,14 @@ protected function renderTests() { $entity->save(); $output = entity_view($entity, 'block'); $expected = array(); - $expected[] = '
'; - $expected[] = ''; - $expected[] = '

Powered by Bananas

'; + $expected[] = '
'; $expected[] = ' '; + $expected[] = '

Powered by Bananas

'; + $expected[] = ' '; + $expected[] = ''; $expected[] = '
'; - $expected[] = '
'; + $expected[] = ' '; + $expected[] = '
'; $expected[] = '
'; $expected[] = ''; $expected_output = implode("\n", $expected); diff --git a/core/modules/block/templates/block-admin-display-form.html.twig b/core/modules/block/templates/block-admin-display-form.html.twig new file mode 100644 index 0000000..e3ba40e --- /dev/null +++ b/core/modules/block/templates/block-admin-display-form.html.twig @@ -0,0 +1,56 @@ +{# +/** + * @file + * Default theme implementation to configure blocks. + * + * Available variables: + * - block_regions: A collection of regions. Keyed by name with the title as value. + * - block_listing: A collection of blocks keyed by region and then delta. + * - form: The form elements. + * + * Each block_listing[region] contains a collection of blocks for that region. + * - data: Each data in block_listing[region] contains. + * - region_title: Region title for the listed block. + * - block_title: Block title. + * - region_select: Drop-down menu for assigning a region. + * - weight_select: Drop-down menu for setting weights. + * - operations: Block operations. + * + * @see template_preprocess() + * @see template_preprocess_block_admin_display_form() + * + * @ingroup themeable + */ +#} + + + + + + + + + + + {% set row = 0 %} + {% for region, title in block_regions %} + + + + + + + {% for delta, data in block_listing[region] %} + + + + + + + {% set row = row + 1 %} + {% endfor %} + {% endfor %} + +
{{ 'Block'|t }}{{ 'Region'|t }}{{ 'Weight'|t }}{{ 'Operations'|t }}
{{ title }}
{{ 'No blocks in this region'|t }}
{{ data.block_title }}{{ data.region_select }}{{ data.weight_select }}{{ data.operations }}
+ +{{ form }} diff --git a/core/modules/block/templates/block-admin-display-form.tpl.php b/core/modules/block/templates/block-admin-display-form.tpl.php deleted file mode 100644 index 4fa3e70..0000000 --- a/core/modules/block/templates/block-admin-display-form.tpl.php +++ /dev/null @@ -1,58 +0,0 @@ -region_title: Region title for the listed block. - * - $data->block_title: Block title. - * - $data->region_select: Drop-down menu for assigning a region. - * - $data->weight_select: Drop-down menu for setting weights. - * - $data->operations: Block operations. - * - * @see template_preprocess_block_admin_display_form() - * @see theme_block_admin_display() - * - * @ingroup themeable - */ -?> - - - - - - - - - - - - $title): ?> - - - - - - - $data): ?> - - - - - - - - - - -
block_title; ?>region_select; ?>weight_select; ?>operations; ?>
- - diff --git a/core/modules/block/templates/block.html.twig b/core/modules/block/templates/block.html.twig new file mode 100644 index 0000000..757f8f5 --- /dev/null +++ b/core/modules/block/templates/block.html.twig @@ -0,0 +1,55 @@ +{# +/** + * @file + * Default theme implementation to display a block. + * + * Available variables: + * - plugin_id: The ID of the block implementation. + * - label: The configured label of the block if visible. + * - configuration: A list of the block's configuration values. + * - label: The configured label for the block. + * - label_display: The display settings for the label. + * - module: The module that provided this block plugin. + * - cache: The cache settings. + * - Block plugin specific settings will also be stored here. + * - block - The full block entity. + * - label_hidden: The hidden block title value if the block was + * configured to hide the title ('label' is empty in this case). + * - module: The module that generated the block. + * - delta: An ID for the block, unique within each module. + * - region: The block region embedding the current block. + * - content: The content of this block. + * - attributes: HTML attributes for the containing element. + * - id: A valid HTML ID and guaranteed unique. + * - class: Classes that can be used to style contextually through + * CSS. These can be manipulated through preprocess functions. The default + * values can be one or more of the following: + * - block: The current template type, i.e., "theming hook". + * - block-[module]: The module generating the block. For example, the user + * module is responsible for handling the default user navigation block. + * In that case the class would be 'block-user'. + * - title_attributes: HTML attributes for the title element. + * - content_attributes: HTML attributes for the content element. + * - title_prefix: Additional output populated by modules, intended to be + * displayed in front of the main title tag that appears in the template. + * - title_suffix: Additional output populated by modules, intended to be + * displayed after the main title tag that appears in the template. + * + * @see template_preprocess() + * @see template_preprocess_block() + * + * @ingroup themeable + */ + @todo Remove the div around content as per http://drupal.org/node/1972122. +#} + + {{ title_prefix }} + {% if label %} + {{ label }} + {% endif %} + {{ title_suffix }} + + + {{ content }} + + diff --git a/core/modules/block/templates/block.tpl.php b/core/modules/block/templates/block.tpl.php deleted file mode 100644 index 106dd6b..0000000 --- a/core/modules/block/templates/block.tpl.php +++ /dev/null @@ -1,59 +0,0 @@ - - -
> - -
> - - - - - > - - - - > - -
-
diff --git a/core/modules/block/tests/themes/block_test_theme/page.tpl.php b/core/modules/block/tests/themes/block_test_theme/page.tpl.php deleted file mode 100644 index ba72882..0000000 --- a/core/modules/block/tests/themes/block_test_theme/page.tpl.php +++ /dev/null @@ -1,78 +0,0 @@ - - -
- - - - - - - - - - - - - -
- -
-
- - -

- -
- - - - -
-
- - - -
diff --git a/core/modules/book/book.module b/core/modules/book/book.module index 3ac47f4..59f1e45 100644 --- a/core/modules/book/book.module +++ b/core/modules/book/book.module @@ -948,7 +948,7 @@ function _book_link_defaults($nid) { } /** - * Implements hook_preprocess_HOOK() for block.tpl.php. + * Implements hook_preprocess_HOOK() for block.html.twig. */ function book_preprocess_block(&$variables) { if ($variables['configuration']['module'] == 'book') { @@ -957,7 +957,9 @@ function book_preprocess_block(&$variables) { } /** - * Processes variables for book-all-books-block.tpl.php. + * Prepares variables for book listing block templates. + * + * Default template: book-all-books-block.html.twig. * * All non-renderable elements are removed so that the template has full access * to the structured data but can also simply iterate over all elements and @@ -965,9 +967,8 @@ function book_preprocess_block(&$variables) { * * @param array $variables * An associative array containing the following key: - * - book_menus - * - * @see book-all-books-block.tpl.php + * - book_menus: An associative array containing renderable menu links for all + * book menus. */ function template_preprocess_book_all_books_block(&$variables) { // Remove all non-renderable elements. @@ -979,13 +980,14 @@ function template_preprocess_book_all_books_block(&$variables) { } /** - * Processes variables for book-navigation.tpl.php. + * Prepares variables for book navigation templates. + * + * Default template: book-navigation.html.twig. * * @param array $variables * An associative array containing the following key: - * - book_link - * - * @see book-navigation.tpl.php + * - book_link: An associative array of book link properties. + * Properties used: bid, link_title, depth, plid, mlid. */ function template_preprocess_book_navigation(&$variables) { drupal_add_css(drupal_get_path('module', 'book') . '/book.theme.css'); @@ -1101,15 +1103,15 @@ function book_toc($bid, $depth_limit, $exclude = array()) { } /** - * Preprocesses variables for book-export-html.tpl.php. + * Prepares variables for book export templates. * - * @param array $variables - * An associative array containing the following keys: - * - title - * - contents - * - depth + * Default template: book-export-html.html.twig. * - * @see book-export-html.tpl.php + * @param array $variables + * An associative array containing: + * - title: The title of the book. + * - contents: Output of each book page. + * - depth: The max depth of the book. */ function template_preprocess_book_export_html(&$variables) { global $base_url; @@ -1191,14 +1193,15 @@ function book_node_export(EntityInterface $node, $children = '') { } /** - * Processes variables for book-node-export-html.tpl.php. + * Prepares variables for single node export templates. + * + * Default template: book-node-export-html.html.twig. * * @param array $variables * An associative array containing the following keys: - * - node - * - children - * - * @see book-node-export-html.tpl.php + * - node: The node that will be output. + * - children: All the rendered child nodes within the current node. Defaults + * to an empty string. */ function template_preprocess_book_node_export_html(&$variables) { $variables['depth'] = $variables['node']->book['depth']; diff --git a/core/modules/book/templates/book-all-books-block.html.twig b/core/modules/book/templates/book-all-books-block.html.twig new file mode 100644 index 0000000..518c1e1 --- /dev/null +++ b/core/modules/book/templates/book-all-books-block.html.twig @@ -0,0 +1,24 @@ +{# +/** + * @file + * Default theme implementation for rendering book outlines within a block. + * + * This template is used only when the block is configured to "show block on all + * pages", which presents multiple independent books on all pages. + * + * Available variables: + * - book_menus: Book outlines. + * - book_id: The parent book ID. + * - menu: The top-level book links. + * + * @see template_preprocess() + * @see template_preprocess_book_all_books_block() + * + * @ingroup themeable + */ +#} +{% for book_id, menu in book_menus %} + +{% endfor %} diff --git a/core/modules/book/templates/book-all-books-block.tpl.php b/core/modules/book/templates/book-all-books-block.tpl.php deleted file mode 100644 index 8e5343b..0000000 --- a/core/modules/book/templates/book-all-books-block.tpl.php +++ /dev/null @@ -1,23 +0,0 @@ - - $menu): ?> - - diff --git a/core/modules/book/templates/book-export-html.html.twig b/core/modules/book/templates/book-export-html.html.twig new file mode 100644 index 0000000..95d5de3 --- /dev/null +++ b/core/modules/book/templates/book-export-html.html.twig @@ -0,0 +1,51 @@ +{# +/** + * @file + * Default theme implementation for printed version of book outline. + * + * Available variables: + * - title: Top level node title. + * - head: Header tags. + * - language: Language object. + * - language_rtl: A flag indicating whether the current display language is a + * right to left language. + * - base_url: URL to the home page. + * - contents: Nodes within the current outline rendered through + * book-node-export-html.html.twig. + * + * @see template_preprocess() + * @see template_preprocess_book_export_html() + * + * @ingroup themeable + */ +#} + + + + {{ title }}> + {{ head }} + + + {% if language_rtl %} + + {% endif %} + + + {# + The given node is embedded to its absolute depth in a top level section. + For example, a child node with depth 2 in the hierarchy is contained in + (otherwise empty) div elements corresponding to depth 0 and depth 1. This + is intended to support WYSIWYG output - e.g., level 3 sections always look + like level 3 sections, no matter their depth relative to the node selected + to be exported as printer-friendly HTML. + #} + + {% for i in 1..depth-1 if depth > 1 %} +
+ {% endfor %} + {{ contents }} + {% for i in 1..depth-1 if depth > 1 %} +
+ {% endfor %} + + diff --git a/core/modules/book/templates/book-export-html.tpl.php b/core/modules/book/templates/book-export-html.tpl.php deleted file mode 100644 index df04dab..0000000 --- a/core/modules/book/templates/book-export-html.tpl.php +++ /dev/null @@ -1,52 +0,0 @@ - - -> - - <?php print $title; ?> - - - - - - - - - - -
- '; ?> - - - - - diff --git a/core/modules/book/templates/book-navigation.html.twig b/core/modules/book/templates/book-navigation.html.twig new file mode 100644 index 0000000..82e02fd --- /dev/null +++ b/core/modules/book/templates/book-navigation.html.twig @@ -0,0 +1,59 @@ +{# +/** + * @file + * Default theme implementation to navigate books. + * + * Presented under nodes that are a part of book outlines. + * + * Available variables: + * - tree: The immediate children of the current node rendered as an unordered + * list. + * - current_depth: Depth of the current node within the book outline. Provided + * for context. + * - prev_url: URL to the previous node. + * - prev_title: Title of the previous node. + * - parent_url: URL to the parent node. + * - parent_title: Title of the parent node. Not printed by default. Provided + * as an option. + * - next_url: URL to the next node. + * - next_title: Title of the next node. + * - has_links: Flags TRUE whenever the previous, parent or next data has a + * value. + * - book_id: The book ID of the current outline being viewed. Same as the node + * ID containing the entire outline. Provided for context. + * - book_url: The book/node URL of the current outline being viewed. Provided + * as an option. Not used by default. + * - book_title: The book/node title of the current outline being viewed. + * Provided as an option. Not used by default. + * + * @see template_preprocess() + * @see template_preprocess_book_navigation() + * + * @ingroup themeable + */ +#} +{% if tree or has_links %} + +{% endif %} diff --git a/core/modules/book/templates/book-navigation.tpl.php b/core/modules/book/templates/book-navigation.tpl.php deleted file mode 100644 index cdc1278..0000000 --- a/core/modules/book/templates/book-navigation.tpl.php +++ /dev/null @@ -1,58 +0,0 @@ - - - - diff --git a/core/modules/book/templates/book-node-export-html.html.twig b/core/modules/book/templates/book-node-export-html.html.twig new file mode 100644 index 0000000..7168de6 --- /dev/null +++ b/core/modules/book/templates/book-node-export-html.html.twig @@ -0,0 +1,23 @@ +{# +/** + * @file + * Default theme implementation for a single node in a printer-friendly outline. + * + * Available variables: + * - node: Fully loaded node. + * - depth: Depth of the current node inside the outline. + * - title: Node title. + * - content: Node content. + * - children: All the child nodes recursively rendered through this file. + * + * @see template_preprocess() + * @see template_preprocess_book_node_export_html() + * + * @ingroup themeable + */ +#} +
+

{{ title }}

+ {{ content }} + {{ children }} +
diff --git a/core/modules/book/templates/book-node-export-html.tpl.php b/core/modules/book/templates/book-node-export-html.tpl.php deleted file mode 100644 index 50c878f..0000000 --- a/core/modules/book/templates/book-node-export-html.tpl.php +++ /dev/null @@ -1,25 +0,0 @@ - -
-

- - -
diff --git a/core/modules/comment/comment.api.php b/core/modules/comment/comment.api.php index 793d9ad..a27899e 100644 --- a/core/modules/comment/comment.api.php +++ b/core/modules/comment/comment.api.php @@ -113,8 +113,7 @@ function hook_comment_view(\Drupal\comment\Plugin\Core\Entity\Comment $comment, * If the module wishes to act on the rendered HTML of the comment rather than * the structured content array, it may use this hook to add a #post_render * callback. Alternatively, it could also implement hook_preprocess_HOOK() for - * comment.tpl.php. See drupal_render() and theme() documentation respectively - * for details. + * comment.html.twig. See drupal_render() documentation for details. * * @param $build * A renderable array representing the comment. diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 0c2cd55..b2d0190 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -1526,7 +1526,7 @@ function comment_preview(Comment $comment) { } /** - * Implements hook_preprocess_HOOK() for block.tpl.php. + * Implements hook_preprocess_HOOK() for block.html.twig. */ function comment_preprocess_block(&$variables) { if ($variables['configuration']['module'] == 'comment') { @@ -1553,9 +1553,14 @@ function comment_prepare_author(Comment $comment) { } /** - * Preprocesses variables for comment.tpl.php. + * Prepares variables for comment templates. * - * @see comment.tpl.php + * Default template: comment.html.twig. + * + * @param array $variables + * An associative array containing: + * - elements: An associative array containing the comment and node objects. + * Array keys: #comment, #node. */ function template_preprocess_comment(&$variables) { $comment = $variables['elements']['#comment']; @@ -1564,6 +1569,7 @@ function template_preprocess_comment(&$variables) { $variables['node'] = $node; $account = comment_prepare_author($comment); + // @todo Do not call theme() here. We do this for purposes of t(). $variables['author'] = theme('username', array('account' => $account)); $variables['new'] = $comment->new->value ? t('new') : ''; $variables['created'] = format_date($comment->created->value); @@ -1583,6 +1589,7 @@ function template_preprocess_comment(&$variables) { else { $variables['user_picture'] = array(); } + if (config('user.settings')->get('signatures') && !empty($account->signature)) { $variables['signature'] = check_markup($account->signature, $account->signature_format, '', TRUE) ; } @@ -1602,6 +1609,7 @@ function template_preprocess_comment(&$variables) { $comment_parent = $comment->pid->entity; $account_parent = comment_prepare_author($comment_parent); $variables['parent_comment'] = $comment_parent; + // @todo Do not call theme() here. We do this for purposes of t(). $variables['parent_author'] = theme('username', array('account' => $account_parent)); $variables['parent_created'] = format_date($comment_parent->created->value); // Avoid calling format_date() twice on the same timestamp. @@ -1664,6 +1672,10 @@ function template_preprocess_comment(&$variables) { $variables['attributes']['class'][] = 'by-viewer'; } } + // Add clearfix class. + $variables['attributes']['class'][] = 'clearfix'; + + $variables['content_attributes']['class'][] = 'content'; } /** @@ -1714,19 +1726,31 @@ function theme_comment_post_forbidden($variables) { } /** - * Preprocesses variables for comment-wrapper.tpl.php. + * Prepares variables for comment wrapper templates. + * + * Default template: comment-wrapper.html.twig. * - * @see comment-wrapper.tpl.php + * @param array $variables + * An associative array containing: + * - content: An associative array containing render arrays for the list of + * comments, and the comment form. Array keys: comments, comment_form. */ function template_preprocess_comment_wrapper(&$variables) { // Provide contextual information. $variables['node'] = $variables['content']['#node']; $variables['display_mode'] = variable_get('comment_default_mode_' . $variables['node']->type, COMMENT_MODE_THREADED); + // The comment form is optional and may not exist. $variables['content'] += array('comment_form' => array()); + $variables['attributes']['id'] = 'comments'; + // Add a comment wrapper class. $variables['attributes']['class'][] = 'comment-wrapper'; + + // Create separate variables for the comments and comment form. + $variables['comments'] = $variables['content']['comments']; + $variables['form'] = $variables['content']['comment_form']; } /** diff --git a/core/modules/comment/templates/comment-wrapper.html.twig b/core/modules/comment/templates/comment-wrapper.html.twig new file mode 100644 index 0000000..dbf37cd --- /dev/null +++ b/core/modules/comment/templates/comment-wrapper.html.twig @@ -0,0 +1,53 @@ +{# +/** + * @file + * Default theme implementation for a comments container. + * + * Available variables: + * - comments: List of comments rendered through comment.html.twig. + * - form: The 'Add new comment' form. + * - content: The content-related elements for the comment display. Use + * 'content' to print them all, or print a subset such as + * 'content.comment_form'. + * - attributes: Remaining HTML attributes for the containing element. + * It includes the 'class' information, which includes: + * - comment-wrapper: The current template type, i.e., "theming hook". + * - title_prefix: Additional output populated by modules, intended to be + * displayed in front of the main title tag that appears in the template. + * - title_suffix: Additional title output populated by modules, intended to + * be displayed after the main title tag that appears in the template. + * + * The following variables are provided for contextual information. + * - node: The node entity to which the comments belong. + * - display_mode: The display mode for the comment listing, flat or threaded. + * The constants below show the possible values and should be used for + * comparison, as in the following example: + * @code + * {% if display_mode is constant('COMMENT_MODE_THREADED') %} + *

{{ 'These comments are displayed in a threaded list.'|t }}

+ * {% endif %} + * @endcode + * - COMMENT_MODE_FLAT + * - COMMENT_MODE_THREADED + * + * @see template_preprocess() + * @see template_preprocess_comment_wrapper() + * + * @ingroup themeable + */ +#} + + {% if comments and node.type != 'forum' %} + {{ title_prefix }} +

{{ 'Comments'|t }}

+ {{ title_suffix }} + {% endif %} + + {{ comments }} + + {% if form %} +

{{ 'Add new comment'|t }}

+ {{ form }} + {% endif %} + + diff --git a/core/modules/comment/templates/comment-wrapper.tpl.php b/core/modules/comment/templates/comment-wrapper.tpl.php deleted file mode 100644 index ac1c27f..0000000 --- a/core/modules/comment/templates/comment-wrapper.tpl.php +++ /dev/null @@ -1,48 +0,0 @@ - -
> - type != 'forum'): ?> - -

- - - - - - -

- - -
diff --git a/core/modules/comment/templates/comment.html.twig b/core/modules/comment/templates/comment.html.twig new file mode 100644 index 0000000..4b441dd --- /dev/null +++ b/core/modules/comment/templates/comment.html.twig @@ -0,0 +1,106 @@ +{# +/** + * @file + * Default theme implementation for comments. + * + * Available variables: + * - author: Comment author. Can be a link or plain text. + * - content: The content-related items for the comment display. Use + * {{ content }} to print them all, or print a subset such as + * {{ content.field_example }}. Use hide(content.field_example) to temporarily + * suppress the printing of a given element. + * - created: Formatted date and time for when the comment was created. + * Preprocess functions can reformat it by calling format_date() with the + * desired parameters on the 'comment.created' variable. + * - changed: Formatted date and time for when the comment was last changed. + * Preprocess functions can reformat it by calling format_date() with the + * desired parameters on the 'comment.changed' variable. + * - new: New comment marker. + * - permalink: Comment permalink. + * - submitted: Submission information created from author and created + * during template_preprocess_comment(). + * - user_picture: The comment author's profile picture. + * - signature: The comment author's signature. + * - status: Comment status. Possible values are: + * unpublished, published, or preview. + * - title: Comment title, linked to the comment. + * - attributes.class: List of classes that can be used to style contextually + * through CSS. The default values can be one or more of the following: + * - comment: The current template type; e.g., 'theming hook'. + * - by-anonymous: Comment by an unregistered user. + * - by-node-author: Comment by the author of the parent node. + * - preview: When previewing a new or edited comment. + * The following applies only to viewers who are registered users: + * - unpublished: An unpublished comment visible only to administrators. + * - by-viewer: Comment by the user currently viewing the page. + * - new: New comment since the last visit. + * - title_prefix: Additional output populated by modules, intended to be + * displayed in front of the main title tag that appears in the template. + * - title_suffix: Additional output populated by modules, intended to be + * displayed after the main title tag that appears in the template. + * - content_attributes: List of classes for the styling of the comment content. + * + * These variables are provided to give context about the parent comment (if + * any): + * - comment_parent: Full parent comment entity (if any). + * - parent_author: Equivalent to author for the parent comment. + * - parent_created: Equivalent to created for the parent comment. + * - parent_changed: Equivalent to changed for the parent comment. + * - parent_title: Equivalent to title for the parent comment. + * - parent_permalink: Equivalent to permalink for the parent comment. + * - parent: A text string of parent comment submission information created from + * 'parent_author' and 'parent_created' during template_preprocess_comment(). + * This information is presented to help screen readers follow lengthy + * discussion threads. You can hide this from sighted users using the class + * element-invisible. + * + * These two variables are provided for context: + * - comment: Full comment object. + * - node: Node entity the comments are attached to. + * + * @see template_preprocess() + * @see template_preprocess_comment() + * + * @ingroup themeable + */ +#} + + {{ title_prefix }} + + {% if new %} + {{ new }} + {% endif %} + + {{ title }} + + {{ title_suffix }} + +
+ {{ user_picture }} + + + {# + Indicate the semantic relationship between parent and child comments + for accessibility. The list is difficult to navigate in a screen + reader without this information. + #} + {% if parent %} +

{{ parent }}

+ {% endif %} + + {{ permalink }} +
+ + + {# We hide the links now so that we can render them later. #} + {% hide(content.links) %} + {{ content }} + + {% if signature %} +
+ {{ signature }} +
+ {% endif %} +
+ {{ content.links }} + diff --git a/core/modules/comment/templates/comment.tpl.php b/core/modules/comment/templates/comment.tpl.php deleted file mode 100644 index 5a8a37e..0000000 --- a/core/modules/comment/templates/comment.tpl.php +++ /dev/null @@ -1,110 +0,0 @@ -created variable. - * - $changed: Formatted date and time for when the comment was last changed. - * Preprocess functions can reformat it by calling format_date() with the - * desired parameters on the $comment->changed variable. - * - $new: New comment marker. - * - $permalink: Comment permalink. - * - $submitted: Submission information created from $author and $created during - * template_preprocess_comment(). - * - $user_picture: The comment author's picture. Use render($user_picture) to - * print it. - * - $signature: Authors signature. - * - $status: Comment status. Possible values are: - * unpublished, published, or preview. - * - $title: Linked title. - * - $attributes: An instance of Attributes class that can be manipulated as an - * array and printed as a string. - * It includes the 'class' information, which includes: - * - comment: The current template type; e.g., 'theming hook'. - * - by-anonymous: Comment by an unregistered user. - * - by-node-author: Comment by the author of the parent node. - * - preview: When previewing a new or edited comment. - * The following applies only to viewers who are registered users: - * - unpublished: An unpublished comment visible only to administrators. - * - by-viewer: Comment by the user currently viewing the page. - * - new: New comment since the last visit. - * - $title_prefix (array): An array containing additional output populated by - * modules, intended to be displayed in front of the main title tag that - * appears in the template. - * - $title_suffix (array): An array containing additional output populated by - * modules, intended to be displayed after the main title tag that appears in - * the template. - * - * These variables are provided to give context about the parent comment (if - * any): - * - $comment_parent: Full parent comment object (if any). - * - $parent_author: Equivalent to $author for the parent comment. - * - $parent_created: Equivalent to $created for the parent comment. - * - $parent_changed: Equivalent to $changed for the parent comment. - * - $parent_title: Equivalent to $title for the parent comment. - * - $parent_permalink: Equivalent to $permalink for the parent comment. - * - $parent: A text string of parent comment submission information created - * from $parent_author and $parent_created during - * template_preprocess_comment(). This information is presented to help - * screen readers follow lengthy discussion threads. You can hide this from - * sighted users using the class element-invisible. - * - * These two variables are provided for context: - * - $comment: Full comment object. - * - $node: Node entity the comments are attached to. - * - * @see template_preprocess() - * @see template_preprocess_comment() - * @see template_process() - * @see theme_comment() - * - * @ingroup themeable - */ -?> -
> - - - - - - > - - -
- - - -

- - -
- -
> - - -
- -
- -
- - -
diff --git a/core/modules/edit/edit.module b/core/modules/edit/edit.module index 6a73d89..5b11560 100644 --- a/core/modules/edit/edit.module +++ b/core/modules/edit/edit.module @@ -137,7 +137,7 @@ function edit_preprocess_field(&$variables) { } /** - * Implements hook_preprocess_HOOK() for node.tpl.php. + * Implements hook_preprocess_HOOK() for node.html.twig. * * @todo Remove this, handle in generic way: http://drupal.org/node/1972514. */ @@ -157,7 +157,7 @@ function edit_preprocess_taxonomy_term(&$variables) { } /** - * Implements hook_preprocess_HOOK() for block.tpl.php. + * Implements hook_preprocess_HOOK() for block.html.twig. * * @todo Remove this, handle in generic way: http://drupal.org/node/1972514. */ diff --git a/core/modules/field/field.api.php b/core/modules/field/field.api.php index b159f59..75a99df 100644 --- a/core/modules/field/field.api.php +++ b/core/modules/field/field.api.php @@ -970,7 +970,7 @@ function hook_field_attach_update(\Drupal\Core\Entity\EntityInterface $entity) { /** * Alter field_attach_preprocess() variables. * - * This hook is invoked while preprocessing the field.tpl.php template file in + * This hook is invoked while preprocessing field templates in * field_attach_preprocess(). * * @param $variables diff --git a/core/modules/field/field.module b/core/modules/field/field.module index bf0ac56..0311d17 100644 --- a/core/modules/field/field.module +++ b/core/modules/field/field.module @@ -985,10 +985,17 @@ function field_page_build(&$page) { } /** - * Theme preprocess function for theme_field() and field.tpl.php. + * Prepares variables for field templates. * - * @see theme_field() - * @see field.tpl.php + * Default template: field.html.twig. + * + * @param array $variables + * An associative array containing: + * - element: A render element representing the field. + * - attributes: A string containing the attributes for the wrapping div. + * - title_attributes: A string containing the attributes for the title. + * - content_attributes: A string containing the attributes for the content's + * div. */ function template_preprocess_field(&$variables, $hook) { $element = $variables['element']; @@ -1008,12 +1015,21 @@ function template_preprocess_field(&$variables, $hook) { // those keys is faster than calling element_children() or looping on all keys // within $element, since that requires traversal of all element properties. $variables['items'] = array(); + $variables['item_attributes'] = array(); foreach ($element['#items'] as $delta => $item) { if (!empty($element[$delta])) { $variables['items'][$delta] = $element[$delta]; + $variables['item_attributes'][$delta] = new Attribute(array('class' => array('field-item'))); } } + // Map odd/even classes. + // @todo Remove after http://drupal.org/node/1649780 lands. + $i = 1; + foreach ($variables['item_attributes'] as $delta => $item_attributes) { + $variables['item_attributes'][$delta]['class'][] = ++$i % 2 == 0 ? 'even' : 'odd'; + } + // Add default CSS classes. Since there can be many fields rendered on a page, // save some overhead by calling strtr() directly instead of // drupal_html_class(). @@ -1038,13 +1054,16 @@ function template_preprocess_field(&$variables, $hook) { 'field__' . $element['#bundle'], 'field__' . $element['#field_name'] . '__' . $element['#bundle'], ); + + $variables['title_attributes']['class'][] = 'field-label'; + $variables['content_attributes']['class'][] = 'field-items'; } /** - * Theme process function for theme_field() and field.tpl.php. + * Theme process function for theme_field() and field.html.twig. * * @see theme_field() - * @see field.tpl.php + * @see field.html.twig */ function template_process_field(&$variables, $hook) { static $default_attributes; @@ -1084,23 +1103,23 @@ function template_process_field(&$variables, $hook) { * - THEMENAME_field() * * Theme developers who prefer to customize templates instead of overriding - * functions may copy the "field.tpl.php" from the "modules/field/theme" folder - * of the Drupal installation to somewhere within the theme's folder and + * functions may copy the "field.html.twig" from the "modules/field/theme" + * folder of the Drupal installation to somewhere within the theme's folder and * customize it, just like customizing other Drupal templates such as - * page.tpl.php or node.tpl.php. However, it takes longer for the server to + * page.html.twig or node.html.twig. However, it takes longer for the server to * process templates than to call a function, so for websites with many fields * displayed on a page, this can result in a noticeable slowdown of the website. - * For these websites, developers are discouraged from placing a field.tpl.php + * For these websites, developers are discouraged from placing a field.html.twig * file into the theme's folder, but may customize templates for specific * fields. For example, for a field named 'body' displayed on the 'article' * content type, any of the following templates will override this default * implementation. The first of these templates that exists is used: - * - field--body--article.tpl.php - * - field--article.tpl.php - * - field--body.tpl.php - * - field.tpl.php + * - field--body--article.html.twig + * - field--article.html.twig + * - field--body.html.twig + * - field.html.twig * So, if the body field on the article content type needs customization, a - * field--body--article.tpl.php file can be added within the theme's folder. + * field--body--article.html.twig file can be added within the theme's folder. * Because it's a template, it will result in slightly more time needed to * display that field, but it will not impact other fields, and therefore, is * unlikely to cause a noticeable change in website performance. A very rough @@ -1125,7 +1144,7 @@ function template_process_field(&$variables, $hook) { * * @see template_preprocess_field() * @see template_process_field() - * @see field.tpl.php + * @see field.html.twig * * @ingroup themeable */ @@ -1134,14 +1153,13 @@ function theme_field($variables) { // Render the label, if it's not hidden. if (!$variables['label_hidden']) { - $output .= '
' . $variables['label'] . '
'; + $output .= '' . $variables['label'] . ''; } // Render the items. - $output .= '
'; + $output .= ''; foreach ($variables['items'] as $delta => $item) { - $classes = 'field-item ' . ($delta % 2 ? 'odd' : 'even'); - $output .= '
' . drupal_render($item) . '
'; + $output .= '' . drupal_render($item) . '
'; } $output .= ''; diff --git a/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php b/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php index 7e7de46..19fe3e1 100644 --- a/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php +++ b/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php @@ -371,7 +371,7 @@ public function buildOptionsForm(&$form, &$form_state) { '#title' => t('Use field template'), '#type' => 'checkbox', '#default_value' => $this->options['field_api_classes'], - '#description' => t('If checked, field api classes will be added using field.tpl.php (or equivalent). This is not recommended unless your CSS depends upon these classes. If not checked, template will not be used.'), + '#description' => t('If checked, field api classes will be added by field templates. This is not recommended unless your CSS depends upon these classes. If not checked, template will not be used.'), '#fieldset' => 'style_settings', '#weight' => 20, ); diff --git a/core/modules/field/templates/field.html.twig b/core/modules/field/templates/field.html.twig new file mode 100644 index 0000000..9217075 --- /dev/null +++ b/core/modules/field/templates/field.html.twig @@ -0,0 +1,48 @@ +{# +/** + * @file + * Default theme implementation for a field. + * + * To override output, copy the "field.html.twig" from the templates directory + * to your theme's directory and customize it, just like customizing other + * Drupal templates such as page.html.twig or node.html.twig. + * + * For example, for a field named 'body' displayed on the 'article' content + * type, any of the following templates will override this default + * implementation. The first of these templates that exists is used: + * - field--body--article.html.twig + * - field--article.html.twig + * - field--body.html.twig + * - field.html.twig + * + * Available variables: + * - attributes: HTML attributes for the containing element. + * - label_hidden: Whether to show the field label or not. + * - title_attributes: HTML attributes for the title. + * - label: The label for the field. + * - content_attributes: HTML attributes for the content. + * - items: List of all the field items. + * - item_attributes: List of HTML attributes for each item. + * + * @see template_preprocess_field() + * @see theme_field() + * + * @ingroup themeable + */ +#} + + + {% if not label_hidden %} + {{ label }}:  + {% endif %} + + {% for delta, item in items %} + {{ item }} + {% endfor %} + + diff --git a/core/modules/field/templates/field.tpl.php b/core/modules/field/templates/field.tpl.php deleted file mode 100644 index a8ffe32..0000000 --- a/core/modules/field/templates/field.tpl.php +++ /dev/null @@ -1,59 +0,0 @@ - - -
> - -
>
- -
> - $item): ?> -
>
- -
-
diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index 20e8631..e5a0dbf 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -970,7 +970,7 @@ function forum_get_topics($tid, $sortby, $forum_per_page) { } /** - * Implements hook_preprocess_HOOK() for block.tpl.php. + * Implements hook_preprocess_HOOK() for block.html.twig. */ function forum_preprocess_block(&$variables) { if ($variables['configuration']['module'] == 'forum') { @@ -979,9 +979,11 @@ function forum_preprocess_block(&$variables) { } /** - * Preprocesses variables for forums.tpl.php. + * Prepares variables for forums templates. * - * @param $variables + * Default template: forums.html.twig. + * + * @param array $variables * An array containing the following elements: * - forums: An array of all forum objects to display for the given taxonomy * term ID. If tid = 0 then all the top-level forums are displayed. @@ -995,23 +997,32 @@ function forum_preprocess_block(&$variables) { * - 3: Posts with the most comments first. * - 4: Posts with the least comments first. * - forum_per_page: The maximum number of topics to display per page. - * - * @see forums.tpl.php */ function template_preprocess_forums(&$variables) { if ($variables['forums_defined'] = count($variables['forums']) || count($variables['parents'])) { if (!empty($variables['forums'])) { - $variables['forums'] = theme('forum_list', $variables); + $variables['forums'] = array( + '#theme' => 'forum_list', + '#forums' => $variables['forums'], + '#parents' => $variables['parents'], + '#tid' => $variables['tid'], + ); } else { - $variables['forums'] = ''; + $variables['forums'] = array(); } if ($variables['tid'] && array_search($variables['tid'], config('forum.settings')->get('containers')) === FALSE) { - $variables['topics'] = theme('forum_topic_list', $variables); + $variables['topics'] = array( + '#theme' => 'forum_topic_list', + '#tid' => $variables['tid'], + '#topics' => $variables['topics'], + '#sortby' => $variables['sortby'], + '#forum_per_page' => $variables['forum_per_page'], + ); } else { - $variables['topics'] = ''; + $variables['topics'] = array(); } // Provide separate template suggestions based on what's being output. Topic id is also accounted for. @@ -1032,24 +1043,23 @@ function template_preprocess_forums(&$variables) { } else { - $variables['forums'] = ''; - $variables['topics'] = ''; + $variables['forums'] = array(); + $variables['topics'] = array(); } } /** - * Preprocesses variables for forum-list.tpl.php. + * Prepares variables for forum list templates. * - * @param $variables + * Default template: forum-list.html.twig. + * + * @param array $variables * An array containing the following elements: * - forums: An array of all forum objects to display for the given taxonomy * term ID. If tid = 0 then all the top-level forums are displayed. * - parents: An array of taxonomy term objects that are ancestors of the * current term ID. * - tid: Taxonomy term ID of the current forum. - * - * @see forum-list.tpl.php - * @see theme_forum_list() */ function template_preprocess_forum_list(&$variables) { global $user; @@ -1081,22 +1091,26 @@ function template_preprocess_forum_list(&$variables) { } $variables['forums'][$id]->last_reply = theme('forum_submitted', array('topic' => $forum->last_post)); } - // Give meaning to $tid for themers. $tid actually stands for term id. + + $variables['pager'] = array( + '#theme' => 'pager', + ); + + // Give meaning to $tid for themers. $tid actually stands for term ID. $variables['forum_id'] = $variables['tid']; unset($variables['tid']); } /** - * Preprocesses variables for forum-topic-list.tpl.php. + * Prepares variables for forum topic list templates. * - * @param $variables + * Default template: forum-topic-list.html.twig. + * + * @param array $variables * An array containing the following elements: * - tid: Taxonomy term ID of the current forum. * - topics: An array of all the topics in the current forum. * - forum_per_page: The maximum number of topics to display per page. - * - * @see forum-topic-list.tpl.php - * @see theme_forum_topic_list() */ function template_preprocess_forum_topic_list(&$variables) { global $forum_topic_list_header; @@ -1113,7 +1127,14 @@ function template_preprocess_forum_topic_list(&$variables) { if (!empty($variables['topics'])) { $row = 0; foreach ($variables['topics'] as $id => $topic) { - $variables['topics'][$id]->icon = theme('forum_icon', array('new_posts' => $topic->new, 'num_posts' => $topic->comment_count, 'comment_mode' => $topic->comment_mode, 'sticky' => $topic->sticky, 'first_new' => $topic->first_new)); + $variables['topics'][$id]->icon = array( + '#theme' => 'forum_icon', + '#new_posts' => $topic->new, + '#num_posts' => $topic->comment_count, + '#comment_mode' => $topic->comment_mode, + '#sticky' => $topic->sticky, + '#first_new' => $topic->first_new, + ); $variables['topics'][$id]->zebra = $row % 2 == 0 ? 'odd' : 'even'; $row++; @@ -1150,13 +1171,17 @@ function template_preprocess_forum_topic_list(&$variables) { $variables['topic_id'] = $variables['tid']; unset($variables['tid']); - $variables['pager'] = theme('pager'); + $variables['pager'] = array( + '#theme' => 'pager', + ); } /** - * Preprocesses variables for forum-icon.tpl.php. + * Prepares variables for forum icon templates. * - * @param $variables + * Default template: forum-icon.html.twig. + * + * @param array $variables * An array containing the following elements: * - new_posts: Indicates whether or not the topic contains new posts. * - num_posts: The total number of posts in all topics. @@ -1164,44 +1189,45 @@ function template_preprocess_forum_topic_list(&$variables) { * or hidden. * - sticky: Indicates whether the topic is sticky. * - first_new: Indicates whether this is the first topic with new posts. - * - * @see forum-icon.tpl.php - * @see theme_forum_icon() */ function template_preprocess_forum_icon(&$variables) { $variables['hot_threshold'] = config('forum.settings')->get('topics.hot_threshold'); + if ($variables['num_posts'] > $variables['hot_threshold']) { - $variables['icon_class'] = $variables['new_posts'] ? 'hot-new' : 'hot'; + $icon_status_class = $variables['new_posts'] ? 'hot-new' : 'hot'; $variables['icon_title'] = $variables['new_posts'] ? t('Hot topic, new comments') : t('Hot topic'); } else { - $variables['icon_class'] = $variables['new_posts'] ? 'new' : 'default'; + $icon_status_class = $variables['new_posts'] ? 'new' : 'default'; $variables['icon_title'] = $variables['new_posts'] ? t('New comments') : t('Normal topic'); } if ($variables['comment_mode'] == COMMENT_NODE_CLOSED || $variables['comment_mode'] == COMMENT_NODE_HIDDEN) { - $variables['icon_class'] = 'closed'; + $icon_status_class = 'closed'; $variables['icon_title'] = t('Closed topic'); } if ($variables['sticky'] == 1) { - $variables['icon_class'] = 'sticky'; + $icon_status_class = 'sticky'; $variables['icon_title'] = t('Sticky topic'); } + + $variables['attributes']['class'][] = 'icon'; + $variables['attributes']['class'][] = 'topic-status-' . $icon_status_class; + $variables['attributes']['title'] = $variables['icon_title']; } /** - * Preprocesses variables for forum-submitted.tpl.php. + * Prepares variables for forum submission information templates. * * The submission information will be displayed in the forum list and topic * list. * - * @param $variables + * Default template: forum-submitted.html.twig. + * + * @param array $variables * An array containing the following elements: * - topic: The topic object. - * - * @see forum-submitted.tpl.php - * @see theme_forum_submitted() */ function template_preprocess_forum_submitted(&$variables) { $variables['author'] = isset($variables['topic']->uid) ? theme('username', array('account' => $variables['topic'])) : ''; diff --git a/core/modules/forum/templates/forum-icon.html.twig b/core/modules/forum/templates/forum-icon.html.twig new file mode 100644 index 0000000..eafbe06 --- /dev/null +++ b/core/modules/forum/templates/forum-icon.html.twig @@ -0,0 +1,26 @@ +{# +/** + * @file + * Default theme implementation to display a status icon for a forum post. + * + * Available variables: + * - attributes: HTML attributes to be applied to the wrapper element. + * - class: HTML classes that determine which icon to display. May be one of + * 'hot', 'hot-new', 'new', 'default', 'closed', or 'sticky'. + * - title: Text alternative for the forum icon. + * - icon_title: Text alternative for the forum icon, same as above. + * - new_posts: '1' when this topic contains new posts, otherwise '0'. + * - first_new: '1' when this is the first topic with new posts, otherwise '0'. + * + * @see template_preprocess() + * @see template_preprocess_forum_icon() + * + * @ingroup themeable + */ +#} + + {% if first_new -%} + + {%- endif %} + {{ icon_title }} + diff --git a/core/modules/forum/templates/forum-icon.tpl.php b/core/modules/forum/templates/forum-icon.tpl.php deleted file mode 100644 index 8b70eb3..0000000 --- a/core/modules/forum/templates/forum-icon.tpl.php +++ /dev/null @@ -1,26 +0,0 @@ - -
- - - - - - -
diff --git a/core/modules/forum/templates/forum-list.html.twig b/core/modules/forum/templates/forum-list.html.twig new file mode 100644 index 0000000..fd55a77 --- /dev/null +++ b/core/modules/forum/templates/forum-list.html.twig @@ -0,0 +1,82 @@ +{# +/** + * @file + * Default theme implementation to display a list of forums and containers. + * + * Available variables: + * - forums: A collection of forums and containers to display. It is keyed to + * the numeric IDs of all child forums and containers. Each forum in forums + * contains: + * - is_container: A flag indicating if the forum can contain other + * forums. Otherwise, the forum can only contain topics. + * - depth: How deep the forum is in the current hierarchy. + * - zebra: 'even' or 'odd', used for row class. + * - icon_class: 'default' or 'new', used for forum icon class. + * - icon_title: Text alternative for the forum icon. + * - name: The name of the forum. + * - link: The URL to link to this forum. + * - description: The description field for the forum, containing: + * - value: The descriptive text for the forum. + * - new_topics: A flag indicating if the forum contains unread posts. + * - new_url: A URL to the forum's unread posts. + * - new_text: Text for the above URL, which tells how many new posts. + * - old_topics: A count of posts that have already been read. + * - num_posts: The total number of posts in the forum. + * - last_reply: Text representing the last time a forum was posted or + * commented in. + * - forum_id: Forum ID for the current forum. Parent to all items within the + * forums array. + * + * @see template_preprocess() + * @see template_preprocess_forum_list() + * + * @ingroup themeable + */ +#} + + + + + + + + + + + {% for child_id, forum in forums %} + + + {% if forum.is_container == false %} + + + + {% endif %} + + {% endfor %} + +
{{ 'Forum'|t }}{{ 'Topics'|t }}{{ 'Posts'|t }}{{ 'Last post'|t }}
+ {# + Enclose the contents of this cell with X divs, where X is the + depth this forum resides at. This will allow us to use CSS + left-margin for indenting. + #} + {% for i in 1..forum.depth if forum.depth > 0 %}
{% endfor %} +
+ {{ forum.icon_title }} +
+ + {% if forum.description.value %} +
{{ forum.description.value }}
+ {% endif %} + {% for i in 1..forum.depth if forum.depth > 0 %}
{% endfor %} +
+ {{ forum.num_topics }} + {% if forum.new_topics == true %} +
+ {{ forum.new_text }} + {% endif %} +
{{ forum.num_posts }}{{ forum.last_reply }}
diff --git a/core/modules/forum/templates/forum-list.tpl.php b/core/modules/forum/templates/forum-list.tpl.php deleted file mode 100644 index da8a12d..0000000 --- a/core/modules/forum/templates/forum-list.tpl.php +++ /dev/null @@ -1,77 +0,0 @@ -is_container: TRUE if the forum can contain other forums. FALSE - * if the forum can contain only topics. - * - $forum->depth: How deep the forum is in the current hierarchy. - * - $forum->zebra: 'even' or 'odd' string used for row class. - * - $forum->icon_class: 'default' or 'new' string used for forum icon class. - * - $forum->icon_title: Text alternative for the forum icon. - * - $forum->name: The name of the forum. - * - $forum->link: The URL to link to this forum. - * - $forum->description: The description of this forum. - * - $forum->new_topics: TRUE if the forum contains unread posts. - * - $forum->new_url: A URL to the forum's unread posts. - * - $forum->new_text: Text for the above URL, which tells how many new posts. - * - $forum->old_topics: A count of posts that have already been read. - * - $forum->num_posts: The total number of posts in the forum. - * - $forum->last_reply: Text representing the last time a forum was posted or - * commented in. - * - $forum_id: Forum ID for the current forum. Parent to all items within the - * $forums array. - * - * @see template_preprocess_forum_list() - * @see theme_forum_list() - * - * @ingroup themeable - */ -?> - - - - - - - - - - - $forum): ?> - - - is_container): ?> - - - - - - - -
is_container ? 'colspan="4" class="container"' : 'class="forum"'; ?>> - - ', $forum->depth); ?> -
- icon_title; ?> -
- - description->value): ?> -
description->value; ?>
- - ', $forum->depth); ?> -
- num_topics ?> - new_topics): ?> -
- new_text; ?> - -
num_posts ?>last_reply ?>
diff --git a/core/modules/forum/templates/forum-submitted.html.twig b/core/modules/forum/templates/forum-submitted.html.twig new file mode 100644 index 0000000..ad059dc --- /dev/null +++ b/core/modules/forum/templates/forum-submitted.html.twig @@ -0,0 +1,24 @@ +{# +/** + * @file + * Default theme implementation for a forum post submission string. + * + * The submission string indicates when and by whom a topic was submitted. + * + * Available variables: + * - author: The author of the post. + * - time: How long ago the post was created. + * - topic: An object with the raw data of the post. Potentially unsafe. Be + * sure to clean this data before printing. + * + * @see template_preprocess() + * @see template_preprocess_forum_submitted() + * + * @ingroup themeable + */ +#} +{% if time %} + +{% else %} + {{ 'n/a'|t }} +{% endif %} diff --git a/core/modules/forum/templates/forum-submitted.tpl.php b/core/modules/forum/templates/forum-submitted.tpl.php deleted file mode 100644 index 18fea8f..0000000 --- a/core/modules/forum/templates/forum-submitted.tpl.php +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - diff --git a/core/modules/forum/templates/forum-topic-list.html.twig b/core/modules/forum/templates/forum-topic-list.html.twig new file mode 100644 index 0000000..32727ee --- /dev/null +++ b/core/modules/forum/templates/forum-topic-list.html.twig @@ -0,0 +1,69 @@ +{# +/** + * @file + * Default theme implementation to display a list of forum topics. + * + * Available variables: + * - header: The table header. This is pre-generated with click-sorting + * information. If you need to change this, see + * template_preprocess_forum_topic_list(). + * - pager: The pager to display beneath the table. + * - topics: A collection of topics to be displayed. Each topic in topics + * contains: + * - icon: The icon to display. + * - moved: A flag to indicate whether the topic has been moved to another + * forum. + * - title: The title of the topic. Safe to output. + * - message: If the topic has been moved, this contains an explanation and a + * link. + * - zebra: 'even' or 'odd', used for row class. + * - comment_count: The number of replies on this topic. + * - new_replies: A flag to indicate whether there are unread comments. + * - new_url: If there are unread replies, this is a link to them. + * - new_text: Text containing the translated, properly pluralized count. + * - created: Text representing when the topic was posted. Safe to output. + * - last_reply: Text representing when the topic was last replied to. + * - timestamp: The raw timestamp this topic was posted. + * - topic_id: Numeric ID for the current forum topic. + * + * @see template_preprocess() + * @see template_preprocess_forum_topic_list() + * + * @ingroup themeable + */ +#} + + + {{ header }} + + + {% for topic in topics %} + + + {% if topic.moved %} + + {% else %} + + + {% endif %} + + {% endfor %} + +
+ {{ topic.icon }} +
+
+ {{ topic.title }} +
+
+ {{ topic.created }} +
+
+
{{ topic.message }} + {{ topic.comment_count }} + {% if topic.new_replies %} +
+ {{ topic.new_text }} + {% endif %} +
{{ topic.last_reply }}
+{{ pager }} diff --git a/core/modules/forum/templates/forum-topic-list.tpl.php b/core/modules/forum/templates/forum-topic-list.tpl.php deleted file mode 100644 index 5130ed6..0000000 --- a/core/modules/forum/templates/forum-topic-list.tpl.php +++ /dev/null @@ -1,74 +0,0 @@ -icon: The icon to display. - * - $topic->moved: A flag to indicate whether the topic has been moved to - * another forum. - * - $topic->title: The title of the topic. Safe to output. - * - $topic->message: If the topic has been moved, this contains an - * explanation and a link. - * - $topic->zebra: 'even' or 'odd' string used for row class. - * - $topic->comment_count: The number of replies on this topic. - * - $topic->new_replies: A flag to indicate whether there are unread - * comments. - * - $topic->new_url: If there are unread replies, this is a link to them. - * - $topic->new_text: Text containing the translated, properly pluralized - * count. - * - $topic->created: A string representing when the topic was posted. Safe - * to output. - * - $topic->last_reply: An outputtable string representing when the topic was - * last replied to. - * - $topic->timestamp: The raw timestamp this topic was posted. - * - $topic_id: Numeric ID for the current forum topic. - * - * @see template_preprocess_forum_topic_list() - * @see theme_forum_topic_list() - * - * @ingroup themeable - */ -?> - - - - - - - - - moved): ?> - - - - - - - - -
- icon; ?> -
-
- title; ?> -
-
- created; ?> -
-
-
message; ?> - comment_count; ?> - new_replies): ?> -
- new_text; ?> - -
last_reply; ?>
- diff --git a/core/modules/forum/templates/forums.html.twig b/core/modules/forum/templates/forums.html.twig new file mode 100644 index 0000000..59fff7d --- /dev/null +++ b/core/modules/forum/templates/forums.html.twig @@ -0,0 +1,24 @@ +{# +/** + * @file + * Default theme implementation to display a forum. + * + * May contain forum containers as well as forum topics. + * + * Available variables: + * - forums: The forums to display (as processed by forum-list.html.twig). + * - topics: The topics to display (as processed by forum-topic-list.html.twig). + * - forums_defined: A flag to indicate that the forums are configured. + * + * @see template_preprocess() + * @see template_preprocess_forums() + * + * @ingroup themeable + */ +#} +{% if forums_defined %} +
+ {{ forums }} + {{ topics }} +
+{% endif %} diff --git a/core/modules/forum/templates/forums.tpl.php b/core/modules/forum/templates/forums.tpl.php deleted file mode 100644 index 6a0e02e..0000000 --- a/core/modules/forum/templates/forums.tpl.php +++ /dev/null @@ -1,24 +0,0 @@ - - -
- - -
- diff --git a/core/modules/help/help.module b/core/modules/help/help.module index d7042d3..4c347f9 100644 --- a/core/modules/help/help.module +++ b/core/modules/help/help.module @@ -66,7 +66,7 @@ function help_help($path, $arg) { } /** - * Implements hook_preprocess_HOOK() for block.tpl.php. + * Implements hook_preprocess_HOOK() for block.html.twig. */ function help_preprocess_block(&$variables) { if ($variables['plugin_id'] == 'system_help_block') { diff --git a/core/modules/language/language.module b/core/modules/language/language.module index 6294f31..1dd936f 100644 --- a/core/modules/language/language.module +++ b/core/modules/language/language.module @@ -760,7 +760,7 @@ function language_language_delete($language) { } /** - * Implements hook_preprocess_HOOK() for block.tpl.php. + * Implements hook_preprocess_HOOK() for block.html.twig. */ function language_preprocess_block(&$variables) { if ($variables['configuration']['module'] == 'language') { diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageSwitchingTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageSwitchingTest.php index 8088f6a..47a61e7 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageSwitchingTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageSwitchingTest.php @@ -59,7 +59,7 @@ function testLanguageBlock() { $this->assertText($block->label(), 'Language switcher block found.'); // Assert that only the current language is marked as active. - list($language_switcher) = $this->xpath('//div[@id=:id]/div[@class="content"]', array(':id' => 'block-test-language-block')); + list($language_switcher) = $this->xpath('//div[@id=:id]/div[contains(@class, "content")]', array(':id' => 'block-test-language-block')); $links = array( 'active' => array(), 'inactive' => array(), diff --git a/core/modules/layout/layouts/static/one-col/one-col.html.twig b/core/modules/layout/layouts/static/one-col/one-col.html.twig new file mode 100644 index 0000000..24a7140 --- /dev/null +++ b/core/modules/layout/layouts/static/one-col/one-col.html.twig @@ -0,0 +1,21 @@ +{# +/** + * @file + * Template for a 1 column layout. + * + * This template provides a simple one column display layout. + * + * Avaiable variables: + * - attributes: Attributes to be placed on the wrapping element. + * - content: All content items, each content item is keyed to one region of the + * layout. This layout supports only one section: + * - content.content: Content in the content column. + * + * @ingroup themeable + */ +#} +
+
+ {{ content.content }} +
+
diff --git a/core/modules/layout/layouts/static/one-col/one-col.tpl.php b/core/modules/layout/layouts/static/one-col/one-col.tpl.php deleted file mode 100644 index 61af832..0000000 --- a/core/modules/layout/layouts/static/one-col/one-col.tpl.php +++ /dev/null @@ -1,18 +0,0 @@ - -
> -
- -
-
diff --git a/core/modules/layout/layouts/static/twocol/two-col.html.twig b/core/modules/layout/layouts/static/twocol/two-col.html.twig new file mode 100644 index 0000000..ece30cf --- /dev/null +++ b/core/modules/layout/layouts/static/twocol/two-col.html.twig @@ -0,0 +1,27 @@ +{# +/** + * @file + * Template for a 2 column layout. + * + * This template provides a two column display layout, with each column equal in + * width. + * + * Available variables: + * - attributes: Attributes to be placed on the wrapping element. + * - content: All content items, each content item is keyed to one region of the + * layout. This layout supports the following sections: + * - content.first: Content in the first column. + * - content.second: Content in the second column. + * + * @ingroup themeable + */ +#} +
+
+ {{ content.first }} +
+ +
+ {{ content.second }} +
+
diff --git a/core/modules/layout/layouts/static/twocol/two-col.tpl.php b/core/modules/layout/layouts/static/twocol/two-col.tpl.php deleted file mode 100644 index 810a052..0000000 --- a/core/modules/layout/layouts/static/twocol/two-col.tpl.php +++ /dev/null @@ -1,24 +0,0 @@ - -
> -
- -
- -
- -
-
diff --git a/core/modules/layout/tests/layouts/static/one-col/one-col.html.twig b/core/modules/layout/tests/layouts/static/one-col/one-col.html.twig new file mode 100644 index 0000000..5e2c069 --- /dev/null +++ b/core/modules/layout/tests/layouts/static/one-col/one-col.html.twig @@ -0,0 +1,20 @@ +{# +/** + * @file + * Template for a one column layout. + * + * This template provides a very simple "one column" display layout. + * + * Avaiable variables: + * - content: All content items, each content item is keyed to one region of the + * layout. This layout supports the following sections: + * - content.middle: The only region in the layout. + * + * @ingroup themeable + */ +#} +
+
+
{{ content.middle }}
+
+
diff --git a/core/modules/layout/tests/layouts/static/one-col/one-col.tpl.php b/core/modules/layout/tests/layouts/static/one-col/one-col.tpl.php deleted file mode 100644 index e47f83e..0000000 --- a/core/modules/layout/tests/layouts/static/one-col/one-col.tpl.php +++ /dev/null @@ -1,18 +0,0 @@ - -
-
-
-
-
diff --git a/core/modules/layout/tests/themes/layout_test_theme/layouts/static/two-col/two-col.html.twig b/core/modules/layout/tests/themes/layout_test_theme/layouts/static/two-col/two-col.html.twig new file mode 100644 index 0000000..5c2d5e6 --- /dev/null +++ b/core/modules/layout/tests/themes/layout_test_theme/layouts/static/two-col/two-col.html.twig @@ -0,0 +1,26 @@ +{# +/** + * @file + * Template for a 2 column layout. + * + * This template provides a two column display layout, with each column equal in + * width. + * + * Available variables: + * - content: All content items, each content item is keyed to one region of the + * layout. This layout supports the following sections: + * - content.left: Content in the left column. + * - content.right: Content in the right column. + * + * @ingroup themeable + */ +#} +
+
+
{{ content.left }}
+
+ +
+
{{ content.right }}
+
+
diff --git a/core/modules/layout/tests/themes/layout_test_theme/layouts/static/two-col/two-col.tpl.php b/core/modules/layout/tests/themes/layout_test_theme/layouts/static/two-col/two-col.tpl.php deleted file mode 100644 index 1d8dbe4..0000000 --- a/core/modules/layout/tests/themes/layout_test_theme/layouts/static/two-col/two-col.tpl.php +++ /dev/null @@ -1,24 +0,0 @@ - -
-
-
-
- -
-
-
-
diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module index 75e0a22..31fd0fc 100644 --- a/core/modules/locale/locale.module +++ b/core/modules/locale/locale.module @@ -870,7 +870,7 @@ function locale_system_file_system_settings_submit(&$form, $form_state) { } /** - * Implements hook_preprocess_HOOK() for node.tpl.php. + * Implements hook_preprocess_HOOK() for node.html.twig. */ function locale_preprocess_node(&$variables) { if ($variables['node']->langcode != LANGUAGE_NOT_SPECIFIED) { diff --git a/core/modules/menu/menu.module b/core/modules/menu/menu.module index 93c2ed8..1b43a4e 100644 --- a/core/modules/menu/menu.module +++ b/core/modules/menu/menu.module @@ -713,7 +713,7 @@ function menu_get_menus($all = TRUE) { } /** - * Implements hook_preprocess_HOOK() for block.tpl.php. + * Implements hook_preprocess_HOOK() for block.html.twig. */ function menu_preprocess_block(&$variables) { if ($variables['configuration']['module'] == 'menu') { diff --git a/core/modules/node/node.api.php b/core/modules/node/node.api.php index 78a3139..b6cd024 100644 --- a/core/modules/node/node.api.php +++ b/core/modules/node/node.api.php @@ -898,8 +898,8 @@ function hook_node_view(\Drupal\Core\Entity\EntityInterface $node, \Drupal\entit * If the module wishes to act on the rendered HTML of the node rather than the * structured content array, it may use this hook to add a #post_render * callback. Alternatively, it could also implement hook_preprocess_HOOK() for - * node.tpl.php. See drupal_render() and theme() documentation respectively for - * details. + * node.html.twig. See drupal_render() and theme() documentation respectively + * for details. * * @param $build * A renderable array representing the node content. diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 5c934df..73557cb 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -174,7 +174,6 @@ function node_theme() { ), 'node_edit_form' => array( 'render element' => 'form', - 'path' => drupal_get_path('module', 'node') . '/templates', 'template' => 'node-edit-form', ), ); @@ -1075,7 +1074,7 @@ function node_is_page(EntityInterface $node) { } /** - * Implements hook_preprocess_HOOK() for block.tpl.php. + * Implements hook_preprocess_HOOK() for block.html.twig. */ function node_preprocess_block(&$variables) { if ($variables['configuration']['module'] == 'node') { @@ -1091,19 +1090,19 @@ function node_preprocess_block(&$variables) { } /** - * Processes variables for node.tpl.php. + * Prepares variables for node templates. * - * Most themes utilize their own copy of node.tpl.php. The default is located - * inside "modules/node/node.tpl.php". Look in there for the full list of - * variables. + * Default template: node.html.twig. * - * @param $variables + * Most themes utilize their own copy of node.html.twig. The default is located + * inside "modules/node/templates/node.html.twig". Look in there for the full + * list of variables. + * + * @param array $variables * An associative array containing: * - elements: An array of elements to display in view mode. * - node: The node object. * - view_mode: View mode; e.g., 'full', 'teaser'... - * - * @see node.tpl.php */ function template_preprocess_node(&$variables) { $variables['view_mode'] = $variables['elements']['#view_mode']; @@ -1112,25 +1111,18 @@ function template_preprocess_node(&$variables) { $variables['node'] = $variables['elements']['#node']; $node = $variables['node']; - $variables['date'] = format_date($node->created); - $variables['name'] = theme('username', array( + $variables['date'] = format_date($node->created); + // @todo Change 'name' to 'author' and also convert to a render array pending + // http://drupal.org/node/1941286. + $variables['name'] = theme('username', array( 'account' => $node, 'link_attributes' => array('rel' => 'author'), )); $uri = $node->uri(); $variables['node_url'] = url($uri['path'], $uri['options']); - $variables['label'] = check_plain($node->label()); - $variables['page'] = $variables['view_mode'] == 'full' && node_is_page($node); - - // Make useful flags and node data available. - // @todo: The comment properties only exist if comment.module is enabled, but - // are documented in node.tpl.php, so we make sure that they are set. - // Consider removing them. - $properties = array('type', 'comment_count', 'uid', 'created', 'promote', 'sticky', 'status', 'comment'); - foreach ($properties as $property) { - $variables[$property] = isset($node->$property) ? $node->$property : NULL; - } + $variables['label'] = check_plain($node->label()); + $variables['page'] = $variables['view_mode'] == 'full' && node_is_page($node); // Helpful $content variable for templates. $variables += array('content' => array()); @@ -1186,6 +1178,8 @@ function template_preprocess_node(&$variables) { // Clean up name so there are no underscores. $variables['theme_hook_suggestions'][] = 'node__' . $node->type; $variables['theme_hook_suggestions'][] = 'node__' . $node->nid; + + $variables['content_attributes']['class'][] = 'content'; } /** diff --git a/core/modules/node/templates/node-edit-form.html.twig b/core/modules/node/templates/node-edit-form.html.twig new file mode 100644 index 0000000..eee9ecc --- /dev/null +++ b/core/modules/node/templates/node-edit-form.html.twig @@ -0,0 +1,30 @@ +{# +/** + * @file + * Two column template for the node add/edit form. + * + * This template will be used when a node edit form specifies 'node_edit_form' + * as its #theme callback. Otherwise, by default, node add/edit forms will be + * themed by theme_form(). + * + * Available variables: + * - form: The node add/edit form. + * + * @see seven_form_node_form_alter() + * + * @ingroup themeable + */ +#} +{% hide(form.advanced) %} +{% hide(form.actions) %} +
+
+ {{ form }} +
+
+ {{ form.advanced }} +
+ +
diff --git a/core/modules/node/templates/node-edit-form.tpl.php b/core/modules/node/templates/node-edit-form.tpl.php deleted file mode 100644 index 7b76683..0000000 --- a/core/modules/node/templates/node-edit-form.tpl.php +++ /dev/null @@ -1,27 +0,0 @@ - -
-
- -
- -
- -
- - -
diff --git a/core/modules/node/templates/node.html.twig b/core/modules/node/templates/node.html.twig index 0b3a322..a99bf1c 100644 --- a/core/modules/node/templates/node.html.twig +++ b/core/modules/node/templates/node.html.twig @@ -4,8 +4,25 @@ * Default theme implementation to display a node. * * Available variables: - * - label: the title of the node. - * - content: node items. Use {{ content }} to print them all, + * - node: Full node entity. + * - type: The type of the node, for example, "page" or "article". + * - uid: The user ID of the node author. + * - created: Formatted creation date. Preprocess functions can reformat it by + * calling format_date() with the desired parameters on + * $variables['node']->created. + * - promote: Whether the node is promoted to the front page. + * - sticky: Whether the node is 'sticky'. Sticky nodes are ordered above + * other non-sticky nodes in teaser listings + * - status: Whether the node is published. + * - comment: A value representing the comment status of the current node. May + * be one of the following: + * - 0: The comment form and any existing comments are hidden. + * - 1: Comments are closed. No new comments may be posted, but existing + * comments are displayed. + * - 2: Comments are open on this node. + * - comment_count: Number of comments attached to the node. + * - label: The title of the node. + * - content: All node items. Use {{ content }} to print them all, * or print a subset such as {{ content.field_example }}. Use * {% hide(content.field_example) %} to temporarily suppress the printing * of a given element. @@ -18,40 +35,28 @@ * - display_submitted: Whether submission information should be displayed. * - submitted: Submission information created from name and date during * template_preprocess_node(). - * - attributes: HTML attributes for the surrounding element. - * Attributes include the 'class' information, which contains: - * - node: The current template type; for example, "theming hook". + * - attributes: HTML attributes for the containing element. + * The attributes.class element may contain one or more of the following + * classes: + * - node: The current template type (also known as a "theming hook"). * - node-[type]: The current node type. For example, if the node is a * "Article" it would result in "node-article". Note that the machine * name will often be in a short form of the human readable label. - * - view-mode-[view_mode]: The View Mode of the node; for example, "teaser" - * or "full". - * - preview: Nodes in preview mode. + * - view-mode-[view_mode]: The View Mode of the node; for example, a teaser + * would result in: "view-mode-teaser", and full: "view-mode-full". + * - preview: Whether a node is in preview mode. * The following are controlled through the node publishing options. - * - promoted: Nodes promoted to the front page. - * - sticky: Nodes ordered above other non-sticky nodes in teaser + * - promoted: Appears on nodes promoted to the front page. + * - sticky: Appears on nodes ordered above other non-sticky nodes in teaser * listings. - * - unpublished: Unpublished nodes visible only to administrators. + * - unpublished: Appears on unpublished nodes visible only to site admins. * - title_prefix: Additional output populated by modules, intended to be * displayed in front of the main title tag that appears in the template. * - title_suffix: Additional output populated by modules, intended to be * displayed after the main title tag that appears in the template. - * - * Other variables: - * - node: Fully loaded node entity. - * - type: Node type; for example, page, article, etc. - * - comment_count: Number of comments attached to the node. - * - uid: User ID of the node author. - * - created: Time the node was published formatted as a Unix timestamp. - * - * Node status variables: * - view_mode: View mode; for example, "teaser" or "full". * - teaser: Flag for the teaser state. Will be true if view_mode is 'teaser'. * - page: Flag for the full page state. Will be true if view_mode is 'full'. - * - promote: Flag for front page promotion state. - * - sticky: Flag for sticky post setting. - * - status: Flag for published status. - * - comment: State of comment settings for the node. * - readmore: Flag for more state. Will be true if the teaser content of the * node cannot hold the main body content. * - is_front: Flag for front. Will be true when presented on the front page. @@ -60,26 +65,28 @@ * - is_admin: Flag for admin user status. Will be true when the current user * is an administrator. * - * Field variables: for each field instance attached to the node a corresponding - * variable is defined; for example, $node->body becomes body. When needing to + * In field variables, each field instance attached to the node a corresponding + * variable is defined; for example, 'node.body' becomes 'body'. When needing to * access a field's raw values, developers/themers are strongly encouraged to * use these variables. Otherwise they will have to explicitly specify the - * desired field language; for example, $node->body['en'], thus overriding any - * language negotiation rule that was previously applied. + * desired field language; for example, 'node.body.en', thus overriding any + * language negotiation rule that may have been applied previously. * * @see template_preprocess() * @see template_preprocess_node() * + * @todo Remove the id attribute (or make it a class), because if that gets + * rendered twice on a page this is invalid CSS for example: two lists + * in different view modes. + * * @ingroup themeable */ #} -
+
{{ title_prefix }} {% if not page %} - - {{ label }} - + {{ label }} {% endif %} {{ title_suffix }} @@ -90,7 +97,7 @@ {% endif %} -
+ {# We hide the comments and links now so that we can render them later. #} {% hide(content.comments) %} {% hide(content.links) %} diff --git a/core/modules/node/templates/node.tpl.php b/core/modules/node/templates/node.tpl.php deleted file mode 100644 index 35cd730..0000000 --- a/core/modules/node/templates/node.tpl.php +++ /dev/null @@ -1,103 +0,0 @@ -body becomes $body. When needing to - * access a field's raw values, developers/themers are strongly encouraged to - * use these variables. Otherwise they will have to explicitly specify the - * desired field language; for example, $node->body['en'], thus overriding any - * language negotiation rule that was previously applied. - * - * @see template_preprocess() - * @see template_preprocess_node() - * @see template_process() - * - * @ingroup themeable - */ -?> -
> - - - - > - - - - -
- - -
- - -
> - -
- - - - -
diff --git a/core/modules/overlay/overlay.module b/core/modules/overlay/overlay.module index 1566740..d400a32 100644 --- a/core/modules/overlay/overlay.module +++ b/core/modules/overlay/overlay.module @@ -497,7 +497,7 @@ function overlay_preprocess_html(&$variables) { } /** - * Implements hook_preprocess_HOOK() for maintenance-page.tpl.php. + * Implements hook_preprocess_HOOK() for maintenance-page.html.twig. * * If the current page request is inside the overlay, add appropriate classes * to the element, and simplify the page title. @@ -520,9 +520,13 @@ function template_preprocess_overlay(&$variables) { $variables['title'] = drupal_get_title(); $variables['disable_overlay'] = overlay_disable_message(); - // Add atrributes for the overlay container. + // Add attributes for the overlay container. + $variables['attributes']['id'] = 'overlay'; $variables['attributes']['class'][] = 'overlay'; + // Add attributes for the overlay title. + $variables['title_attributes']['id'] = 'overlay-title'; // Add attributes for the overlay content. + $variables['content_attributes']['id'] = 'overlay-content'; $variables['content_attributes']['class'][] = 'clearfix'; } diff --git a/core/modules/overlay/templates/overlay.html.twig b/core/modules/overlay/templates/overlay.html.twig new file mode 100644 index 0000000..f54633e --- /dev/null +++ b/core/modules/overlay/templates/overlay.html.twig @@ -0,0 +1,38 @@ +{# +/** + * @file + * Default theme implementation to display a page in the overlay. + * + * Available variables: + * - attributes: HTML attributes for the containing element. + * - content_attributes: HTML attributes for the content. + * - title_attributes: HTML attributes for the title. + * - title: The (sanitized) title of the page. + * - page: The rendered page content. + * - tabs: Tabs linking to any sub-pages beneath the current page (e.g., the + * view and edit tabs when displaying a node). + * - disable_overlay: The message about how to disable the overlay. + * + * @see template_preprocess() + * @see template_preprocess_overlay() + * + * @ingroup themeable + */ +#} +{{ disable_overlay }} + +
+
+ {{ title }} +
+ + {% if tabs %} +

{{ 'Primary tabs'|t }}

    {{ tabs }}
+ {% endif %} +
+ + {{ page }} +
+ diff --git a/core/modules/overlay/templates/overlay.tpl.php b/core/modules/overlay/templates/overlay.tpl.php deleted file mode 100644 index 2b342ba..0000000 --- a/core/modules/overlay/templates/overlay.tpl.php +++ /dev/null @@ -1,38 +0,0 @@ - - - -
> -
-
-

>

-
-
- -
-

-
-
> - -
-
diff --git a/core/modules/rdf/rdf.module b/core/modules/rdf/rdf.module index a2f74a3..aaea6bb 100644 --- a/core/modules/rdf/rdf.module +++ b/core/modules/rdf/rdf.module @@ -492,7 +492,7 @@ function rdf_preprocess_html(&$variables) { } /** - * Implements hook_preprocess_HOOK() for node.tpl.php. + * Implements hook_preprocess_HOOK() for node.html.twig. */ function rdf_preprocess_node(&$variables) { // Adds RDFa markup to the node container. The about attribute specifies the @@ -509,7 +509,7 @@ function rdf_preprocess_node(&$variables) { $variables['title_attributes']['property'] = empty($variables['node']->rdf_mapping['title']['predicates']) ? NULL : $variables['node']->rdf_mapping['title']['predicates']; $variables['title_attributes']['datatype'] = ''; - // In full node mode, the title is not displayed by node.tpl.php so it is + // In full node mode, the title is not displayed by node.html.twig so it is // added in the tag of the HTML page. if ($variables['page']) { $element = array( @@ -557,7 +557,7 @@ function rdf_preprocess_node(&$variables) { $variables['content']['links']['comment']['#links']['comment-comments']['attributes'] += $comment_count_attributes; } // In full node view, the number of comments is not displayed by - // node.tpl.php so it is expressed in RDFa in the tag of the HTML + // node.html.twig so it is expressed in RDFa in the tag of the HTML // page. if ($variables['page'] && user_access('access comments')) { $element = array( @@ -701,7 +701,7 @@ function rdf_preprocess_username(&$variables) { } /** - * Implements hook_preprocess_HOOK() for comment.tpl.php. + * Implements hook_preprocess_HOOK() for comment.html.twig. */ function rdf_preprocess_comment(&$variables) { $comment = $variables['comment']; @@ -843,12 +843,12 @@ function rdf_preprocess_image(&$variables) { * - context: An array of context information about the content to be wrapped: * - hook: The theme hook that will use the wrapped content. This * corresponds to the key within the theme registry for this template. - * For example, if this content is about to be used in node.tpl.php or - * node-[type].tpl.php, then the 'hook' is 'node'. + * For example, if this content is about to be used in node.html.twig or + * node-[type].html.twig, then the 'hook' is 'node'. * - variable_name: The name of the variable by which the template will * refer to this content. Each template file has documentation about * the variables it uses. For example, if this function is called in - * preparing the $author variable for comment.tpl.php, then the + * preparing the $author variable for comment.html.twig, then the * 'variable_name' is 'author'. * - variables: The full array of variables about to be passed to the * template. diff --git a/core/modules/search/search.module b/core/modules/search/search.module index f31488b..efaf031 100644 --- a/core/modules/search/search.module +++ b/core/modules/search/search.module @@ -135,7 +135,7 @@ function search_permission() { } /** - * Implements hook_preprocess_HOOK() for block.tpl.php. + * Implements hook_preprocess_HOOK() for block.html.twig. */ function search_preprocess_block(&$variables) { if ($variables['plugin_id'] == 'search_form_block') { diff --git a/core/modules/shortcut/shortcut.module b/core/modules/shortcut/shortcut.module index d1458a8..2da3d26 100644 --- a/core/modules/shortcut/shortcut.module +++ b/core/modules/shortcut/shortcut.module @@ -447,7 +447,7 @@ function shortcut_renderable_links($shortcut_set = NULL) { } /** - * Implements hook_preprocess_HOOK() for block.tpl.php. + * Implements hook_preprocess_HOOK() for block.html.twig. */ function shortcut_preprocess_block(&$variables) { if ($variables['configuration']['module'] == 'shortcut') { diff --git a/core/modules/statistics/statistics.module b/core/modules/statistics/statistics.module index 9d0c19e..7b15281 100644 --- a/core/modules/statistics/statistics.module +++ b/core/modules/statistics/statistics.module @@ -234,7 +234,7 @@ function statistics_update_index() { } /** - * Implements hook_preprocess_HOOK() for block.tpl.php. + * Implements hook_preprocess_HOOK() for block.html.twig. */ function statistics_preprocess_block(&$variables) { if ($variables['configuration']['module'] == 'statistics') { diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTest.php index 664a73b..a773922 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTest.php @@ -154,10 +154,10 @@ function testListThemes() { $this->assertIdentical($themes['test_basetheme']->sub_themes, $sub_theme_list, 'Base theme\'s object includes list of subthemes.'); $this->assertIdentical($themes['test_subtheme']->base_themes, $base_theme_list, 'Subtheme\'s object includes list of base themes.'); // Check for theme engine in subtheme. - $this->assertIdentical($themes['test_subtheme']->engine, 'phptemplate', 'Subtheme\'s object includes the theme engine.'); + $this->assertIdentical($themes['test_subtheme']->engine, 'twig', 'Subtheme\'s object includes the theme engine.'); // Check for theme engine prefix. - $this->assertIdentical($themes['test_basetheme']->prefix, 'phptemplate', 'Base theme\'s object includes the theme engine prefix.'); - $this->assertIdentical($themes['test_subtheme']->prefix, 'phptemplate', 'Subtheme\'s object includes the theme engine prefix.'); + $this->assertIdentical($themes['test_basetheme']->prefix, 'twig', 'Base theme\'s object includes the theme engine prefix.'); + $this->assertIdentical($themes['test_subtheme']->prefix, 'twig', 'Subtheme\'s object includes the theme engine prefix.'); } /** @@ -232,7 +232,7 @@ public function testFindThemeTemplates() { _theme_process_registry($cache, $module, 'module', $module, drupal_get_path('module', $module)); } - $templates = drupal_find_theme_templates($cache, '.tpl.php', drupal_get_path('theme', 'test_theme')); - $this->assertEqual($templates['node__1']['template'], 'node--1', 'Template node--1.tpl.php was found in test_theme.'); + $templates = drupal_find_theme_templates($cache, '.html.twig', drupal_get_path('theme', 'test_theme')); + $this->assertEqual($templates['node__1']['template'], 'node--1', 'Template node--1.html.twig was found in test_theme.'); } } diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTestTwig.php b/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTestTwig.php index 5ac99e0..135a435 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTestTwig.php +++ b/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTestTwig.php @@ -31,7 +31,7 @@ public static function getInfo() { function setUp() { parent::setUp(); - theme_enable(array('test_theme_twig')); + theme_enable(array('test_theme')); } /** @@ -39,43 +39,18 @@ function setUp() { */ function testTemplateOverride() { config('system.theme') - ->set('default', 'test_theme_twig') + ->set('default', 'test_theme') ->save(); $this->drupalGet('theme-test/template-test'); $this->assertText('Success: Template overridden.', t('Template overridden by defined \'template\' filename.')); } /** - * Tests drupal_find_theme_templates - */ - function testFindThemeTemplates() { - - $cache = array(); - - // Prime the theme cache - foreach (module_implements('theme') as $module) { - _theme_process_registry($cache, $module, 'module', $module, drupal_get_path('module', $module)); - } - - // Check for correct content - // @todo Remove this tests once double engine code is removed - - $this->assertEqual($cache['node']['template_file'], 'core/modules/node/templates/node.html.twig', 'Node is using node.html.twig as template file'); - $this->assertEqual($cache['node']['engine'], 'twig', 'Node is using twig engine'); - - $this->assertEqual($cache['theme_test_template_test']['template_file'], 'core/modules/system/tests/modules/theme_test/templates/theme_test.template_test.tpl.php', 'theme_test is using theme_test.template_test.tpl.php as template file'); - $this->assertEqual($cache['theme_test_template_test']['engine'], 'phptemplate', 'theme_test is using phptemplate as engine.'); - - $templates = drupal_find_theme_templates($cache, '.html.twig', drupal_get_path('theme', 'test_theme_twig')); - $this->assertEqual($templates['node__1']['template'], 'node--1', 'Template node--1.html.twig was found in test_theme_twig.'); - } - - /** * Tests that the Twig engine handles PHP data correctly. */ function testTwigVariableDataTypes() { config('system.theme') - ->set('default', 'test_theme_twig') + ->set('default', 'test_theme') ->save(); $this->drupalGet('twig-theme-test/php-variables'); foreach (_test_theme_twig_php_values() as $type => $value) { diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/TwigDebugMarkupTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/TwigDebugMarkupTest.php index 0bcd1a6..38e183b 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Theme/TwigDebugMarkupTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Theme/TwigDebugMarkupTest.php @@ -34,8 +34,8 @@ public static function getInfo() { */ function testTwigDebugMarkup() { $extension = twig_extension(); - theme_enable(array('test_theme_twig')); - config('system.theme')->set('default', 'test_theme_twig')->save(); + theme_enable(array('test_theme')); + config('system.theme')->set('default', 'test_theme')->save(); // Enable debug, rebuild the service container, and clear all caches. $this->settingsSet('twig_debug', TRUE); $this->rebuildContainer(); @@ -47,7 +47,7 @@ function testTwigDebugMarkup() { _theme_process_registry($cache, $module, 'module', $module, drupal_get_path('module', $module)); } // Create array of Twig templates. - $templates = drupal_find_theme_templates($cache, $extension, drupal_get_path('theme', 'test_theme_twig')); + $templates = drupal_find_theme_templates($cache, $extension, drupal_get_path('theme', 'test_theme')); $templates += drupal_find_theme_templates($cache, $extension, drupal_get_path('module', 'node')); // Create a node and test different features of the debug markup. diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/TwigSettingsTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/TwigSettingsTest.php index 2e84924..f50f110 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Theme/TwigSettingsTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Theme/TwigSettingsTest.php @@ -77,9 +77,9 @@ function testTwigDebugOverride() { */ function testTwigCacheOverride() { $extension = twig_extension(); - theme_enable(array('test_theme_twig')); + theme_enable(array('test_theme')); config('system.theme') - ->set('default', 'test_theme_twig') + ->set('default', 'test_theme') ->save(); $cache = array(); @@ -89,7 +89,7 @@ function testTwigCacheOverride() { } // Load array of Twig templates. - $templates = drupal_find_theme_templates($cache, $extension, drupal_get_path('theme', 'test_theme_twig')); + $templates = drupal_find_theme_templates($cache, $extension, drupal_get_path('theme', 'test_theme')); // Get the template filename and the cache filename for // theme_test.template_test.html.twig. diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php index 5360a83..1f0c4a9 100644 --- a/core/modules/system/system.api.php +++ b/core/modules/system/system.api.php @@ -1589,8 +1589,8 @@ function hook_permission() { * - template: If specified, this theme implementation is a template, and * this is the template file without an extension. Do not put .tpl.php on * this file; that extension will be added automatically by the default - * rendering engine (which is PHPTemplate). If 'path', above, is specified, - * the template should also be in this path. + * rendering engine (which is Twig). If 'path' above is specified, the + * template should also be in this path. * - function: If specified, this will be the function name to invoke for * this implementation. If neither 'template' nor 'function' is specified, * a default function name will be assumed. For example, if a module @@ -1611,8 +1611,8 @@ function hook_permission() { * - preprocess functions: A list of functions used to preprocess this data. * Ordinarily this won't be used; it's automatically filled in. By default, * for a module this will be filled in as template_preprocess_HOOK. For - * a theme this will be filled in as phptemplate_preprocess and - * phptemplate_preprocess_HOOK as well as themename_preprocess and + * a theme this will be filled in as twig_preprocess and + * twig_preprocess_HOOK as well as themename_preprocess and * themename_preprocess_HOOK. * - override preprocess functions: Set to TRUE when a theme does NOT want * the standard preprocess functions to run. This can be used to give a diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 0d472e5..32a0559 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -2664,7 +2664,7 @@ function system_user_timezone(&$form, &$form_state) { } /** - * Implements hook_preprocess_HOOK() for block.tpl.php. + * Implements hook_preprocess_HOOK() for block.html.twig. */ function system_preprocess_block(&$variables) { // Derive the base plugin ID. @@ -2683,16 +2683,16 @@ function system_preprocess_block(&$variables) { } /** - * Implements hook_preprocess_HOOK() for system-plugin-ui-form.tpl.php. + * Prepares variables for system plugin UI form templates. * - * The $variables array contains the following arguments: - * - $form - */ + * Default template: system-plugin-ui-form.html.twig. + * + * @param array $variables + * An associative array containing: + * - form: The plugin form elements. +*/ function template_preprocess_system_plugin_ui_form(&$variables) { drupal_add_css(drupal_get_path('module', 'system') . '/system.plugin.ui.css'); - $variables['left'] = drupal_render($variables['form']['left']); - $variables['right'] = drupal_render($variables['form']['right']); - $variables['form_submit'] = drupal_render_children($variables['form']); } /** @@ -3006,7 +3006,7 @@ function _system_rebuild_theme_data() { // Set defaults for theme info. $defaults = array( - 'engine' => 'phptemplate', + 'engine' => 'twig', 'regions' => array( 'sidebar_first' => 'Left sidebar', 'sidebar_second' => 'Right sidebar', diff --git a/core/modules/system/templates/html.html.twig b/core/modules/system/templates/html.html.twig new file mode 100644 index 0000000..02a542b --- /dev/null +++ b/core/modules/system/templates/html.html.twig @@ -0,0 +1,49 @@ +{# +/** + * @file + * Default theme implementation for the basic structure of a single Drupal page. + * + * Variables: + * - css: A list of CSS files for the current page. + * - head: Markup for the HEAD element (including meta tags, keyword tags, and + * so on). + * - head_title: A modified version of the page title, for use in the TITLE tag. + * - head_title_array: List of text elements that make up the head_title + * variable. May contain or more of the following: + * - title: The title of the page. + * - name: The name of the site. + * - slogan: The slogan of the site. + * - page_top: Initial rendered markup. This should be printed before 'page'. + * - page: The rendered page markup. + * - page_bottom: Closing rendered markup. This variable should be printed after + * 'page'. + * - styles: Style tags necessary to import all necessary CSS files in the head. + * - scripts: Script tags necessary to load the JavaScript files and settings + * in the head. + * + * @see template_preprocess() + * @see template_preprocess_html() + * @see template_process_html() + * + * @ingroup themeable + */ +#} + + + + {{ head }} + {{ head_title }} + {{ styles }} + {{ scripts }} + + + + {{ page_top }} + {{ page }} + {{ page_bottom }} + + diff --git a/core/modules/system/templates/html.tpl.php b/core/modules/system/templates/html.tpl.php deleted file mode 100644 index 893d8a0..0000000 --- a/core/modules/system/templates/html.tpl.php +++ /dev/null @@ -1,60 +0,0 @@ -langcode contains its textual representation. - * $language->dir contains the language direction. - * It will either be 'ltr' or 'rtl'. - * - $head_title: A modified version of the page title, for use in the TITLE - * tag. - * - $head_title_array: (array) An associative array containing the string parts - * that were used to generate the $head_title variable, already prepared to be - * output as TITLE tag. The key/value pairs may contain one or more of the - * following, depending on conditions: - * - title: The title of the current page, if any. - * - name: The name of the site. - * - slogan: The slogan of the site, if any, and if there is no title. - * - $head: Markup for the HEAD section (including meta tags, keyword tags, and - * so on). - * - $styles: Style tags necessary to import all CSS files for the page. - * - $scripts: Script tags necessary to load the JavaScript files and settings - * for the page. - * - $page_top: Initial markup from any modules that have altered the - * page. This variable should always be output first, before all other dynamic - * content. - * - $page: The rendered page content. - * - $page_bottom: Final closing markup from any modules that have altered the - * page. This variable should always be output last, after all other dynamic - * content. - * - $classes String of classes that can be used to style contextually through - * CSS. - * - * @see template_preprocess() - * @see template_preprocess_html() - * @see template_process() - * - * @ingroup themeable - */ -?> -> - - - <?php print $head_title; ?> - - - - > - - - - - - diff --git a/core/modules/system/templates/maintenance-page.html.twig b/core/modules/system/templates/maintenance-page.html.twig new file mode 100644 index 0000000..a57b546 --- /dev/null +++ b/core/modules/system/templates/maintenance-page.html.twig @@ -0,0 +1,92 @@ +{# +/** + * @file + * Default theme implementation to display a single Drupal page while offline. + * + * All the available variables are mirrored in html.html.twig and + * page.html.twig. + * Some may be blank but they are provided for consistency. + * + * @see template_preprocess() + * @see template_preprocess_maintenance_page() + * + * @ingroup themeable + */ +#} + + + + {{ head_title }} + {{ head }} + {{ styles }} + {{ scripts }} + + +
+ + +
+ + {% if sidebar_first %} + + {% endif %} + +
+ +
+ {% if title %}

{{ title }}

{% endif %} + {% if messages %}{{ messages }}{% endif %} +
+ {{ content }} +
+
+ +
+ + {% if sidebar_second %} + + {% endif %} + +
+ + + +
+ + + diff --git a/core/modules/system/templates/maintenance-page.tpl.php b/core/modules/system/templates/maintenance-page.tpl.php deleted file mode 100644 index 5da7a1a..0000000 --- a/core/modules/system/templates/maintenance-page.tpl.php +++ /dev/null @@ -1,95 +0,0 @@ - - - - - - <?php print $head_title; ?> - - - - - -
- - -
- - - - - -
- -
-

- -
- -
-
- -
- - - - - -
- - - -
- - - diff --git a/core/modules/system/templates/page.html.twig b/core/modules/system/templates/page.html.twig new file mode 100644 index 0000000..ff7c010 --- /dev/null +++ b/core/modules/system/templates/page.html.twig @@ -0,0 +1,150 @@ +{# +/** + * @file + * Default theme implementation to display a single page. + * + * The doctype, html, head and body tags are not in this template. Instead they + * can be found in the html.html.twig template in this directory. + * + * Available variables: + * + * General utility variables: + * - base_path: The base URL path of the Drupal installation. Will usually be + * "/" unless you have installed Drupal in a sub-directory. + * - is_front: A flag indicating if the current page is the front page. + * - logged_in: A flag indicating if the user is registered and signed in. + * - is_admin: A flag indicating if the user has permission to access + * administration pages. + * + * Site identity: + * - front_page: The URL of the front page. Use this instead of base_path when + * linking to the front page. This includes the language domain or prefix. + * - logo: The url of the logo image, as defined in theme settings. + * - site_name: The name of the site. This is empty when displaying the site + * name has been disabled in the theme settings. + * - site_slogan: The slogan of the site. This is empty when displaying the site + * slogan has been disabled in theme settings. + * + * Navigation: + * - main_menu: The Main menu links for the site, if they have been configured. + * - secondary_menu: The Secondary menu links for the site, if they have been + * configured. + * - breadcrumb: The breadcrumb trail for the current page. + * + * Page content (in order of occurrence in the default page.html.twig): + * - title_prefix: Additional output populated by modules, intended to be + * displayed in front of the main title tag that appears in the template. + * - title: The page title, for use in the actual content. + * - title_suffix: Additional output populated by modules, intended to be + * displayed after the main title tag that appears in the template. + * - messages: Status and error messages. Should be displayed prominently. + * - tabs: Tabs linking to any sub-pages beneath the current page (e.g., the + * view and edit tabs when displaying a node). + * - action_links: Actions local to the page, such as "Add menu" on the menu + * administration interface. + * - feed_icons: All feed icons for the current page. + * - node: Fully loaded node, if there is an automatically-loaded node + * associated with the page and the node ID is the second argument in the + * page's path (e.g. node/12345 and node/12345/revisions, but not + * comment/reply/12345). + * + * Regions: + * - page.header: Items for the header region. + * - page.highlighted: Items for the highlighted content region. + * - page.help: Dynamic help text, mostly for admin pages. + * - page.content: The main content of the current page. + * - page.sidebar_first: Items for the first sidebar. + * - page.sidebar_second: Items for the second sidebar. + * - page.footer: Items for the footer region. + * + * @see template_preprocess() + * @see template_preprocess_page() + * @see template_process() + * @see template_process_page() + * @see html.html.twig + * + * @ingroup themeable + */ +#} +
+ + + + {% if main_menu or secondary_menu %} + + {% endif %} + + {{ breadcrumb }} + + {% if messages %} +
{{ messages }}
+ {% endif %} + +
+ + +
+ {% if page.highlighted %}
{{ page.highlighted }}
{% endif %} + {{ title_prefix }} + {% if title %}

{{ title }}

{% endif %} + {{ title_suffix }} + {% if tabs %}
{{ tabs }}
{% endif %} + {{ page.help }} + {% if action_links %}{% endif %} + {{ page.content }} + {{ feed_icons }} +
+ + {% if page.sidebar_first %} + + {% endif %} + + {% if page.sidebar_second %} + + {% endif %} + +
+ +
+ {{ page.footer }} +
+ +
diff --git a/core/modules/system/templates/page.tpl.php b/core/modules/system/templates/page.tpl.php deleted file mode 100644 index 6ddeeed..0000000 --- a/core/modules/system/templates/page.tpl.php +++ /dev/null @@ -1,155 +0,0 @@ - - -
- - - - - - - - - -
- - -
- - -
-
- -

- -
- - - - -
- - - - - - - - - -
- -
- -
- -
diff --git a/core/modules/system/templates/region.html.twig b/core/modules/system/templates/region.html.twig new file mode 100644 index 0000000..fe566fe --- /dev/null +++ b/core/modules/system/templates/region.html.twig @@ -0,0 +1,28 @@ +{# +/** + * @file + * Default theme implementation to display a region. + * + * Available variables: + * - content: The content for this region, typically blocks. + * - attributes: HTML attributes for the region div, including: + * - class: Classes that can be used to style contextually through CSS, + * including: + * - region: The current template type (also know as "theming hook"). + * - region-[name]: The name of the region with underscores replaced with + * dashes. For example, page_top region would have a region-page-top + * class. + * - region: The name of the region variable as defined in the theme's + * .info.yml file. + * + * @see template_preprocess() + * @see template_preprocess_region() + * + * @ingroup themeable + */ +#} +{% if content %} + + {{ content }} + +{% endif %} diff --git a/core/modules/system/templates/region.tpl.php b/core/modules/system/templates/region.tpl.php deleted file mode 100644 index 92f401e..0000000 --- a/core/modules/system/templates/region.tpl.php +++ /dev/null @@ -1,34 +0,0 @@ - - -
> - -
- diff --git a/core/modules/system/templates/system-plugin-ui-form.html.twig b/core/modules/system/templates/system-plugin-ui-form.html.twig new file mode 100644 index 0000000..415a6bf --- /dev/null +++ b/core/modules/system/templates/system-plugin-ui-form.html.twig @@ -0,0 +1,31 @@ +{# +/** + * @file + * Default theme implementation to configure blocks. + * + * Available variables: + * - form: The form elements which contains: + * - left: Form elements that appear in the left column. + * - right: Form elements that appear in the right column. + * + * @see template_preprocess() + * @see template_preprocess_system_plugin_ui_form() + * + * @ingroup themeable + */ +#} +
+
+
+ {{ form.left }} +
+
+
+
+ {{ form.right }} +
+
+ {% if form -%} +
{{ form }}
+ {%- endif -%} +
diff --git a/core/modules/system/templates/system-plugin-ui-form.tpl.php b/core/modules/system/templates/system-plugin-ui-form.tpl.php deleted file mode 100644 index 8179076..0000000 --- a/core/modules/system/templates/system-plugin-ui-form.tpl.php +++ /dev/null @@ -1,32 +0,0 @@ - -
-
-
- -
-
-
-
- -
-
- -
- -
diff --git a/core/modules/system/tests/modules/theme_test/templates/theme_test.template_test.html.twig b/core/modules/system/tests/modules/theme_test/templates/theme_test.template_test.html.twig new file mode 100644 index 0000000..cde8faa --- /dev/null +++ b/core/modules/system/tests/modules/theme_test/templates/theme_test.template_test.html.twig @@ -0,0 +1,2 @@ + +Fail: Template not overridden. diff --git a/core/modules/system/tests/modules/theme_test/templates/theme_test.template_test.tpl.php b/core/modules/system/tests/modules/theme_test/templates/theme_test.template_test.tpl.php deleted file mode 100644 index cde8faa..0000000 --- a/core/modules/system/tests/modules/theme_test/templates/theme_test.template_test.tpl.php +++ /dev/null @@ -1,2 +0,0 @@ - -Fail: Template not overridden. diff --git a/core/modules/system/tests/modules/theme_test/theme_test.module b/core/modules/system/tests/modules/theme_test/theme_test.module index d610a19..4204077 100644 --- a/core/modules/system/tests/modules/theme_test/theme_test.module +++ b/core/modules/system/tests/modules/theme_test/theme_test.module @@ -30,7 +30,7 @@ function theme_test_system_theme_info() { $themes['test_theme'] = drupal_get_path('module', 'system') . '/tests/themes/test_theme/test_theme.info.yml'; $themes['test_basetheme'] = drupal_get_path('module', 'system') . '/tests/themes/test_basetheme/test_basetheme.info.yml'; $themes['test_subtheme'] = drupal_get_path('module', 'system') . '/tests/themes/test_subtheme/test_subtheme.info.yml'; - $themes['test_theme_twig'] = drupal_get_path('module', 'system') . '/tests/themes/test_theme_twig/test_theme_twig.info.yml'; + $themes['test_theme_phptemplate'] = drupal_get_path('module', 'system') . '/tests/themes/test_theme_phptemplate/test_theme_phptemplate.info.yml'; return $themes; } diff --git a/core/modules/system/tests/themes/test_theme/node--1.html.twig b/core/modules/system/tests/themes/test_theme/node--1.html.twig new file mode 100644 index 0000000..046c02e --- /dev/null +++ b/core/modules/system/tests/themes/test_theme/node--1.html.twig @@ -0,0 +1,4 @@ +{# + // node--1.html.twig - Dummy file for finding the template +#} +Node Content Dummy diff --git a/core/modules/system/tests/themes/test_theme/node--1.tpl.php b/core/modules/system/tests/themes/test_theme/node--1.tpl.php deleted file mode 100644 index 81974ce..0000000 --- a/core/modules/system/tests/themes/test_theme/node--1.tpl.php +++ /dev/null @@ -1,4 +0,0 @@ - -Node Content Dummy diff --git a/core/modules/system/tests/themes/test_theme/test_theme.theme b/core/modules/system/tests/themes/test_theme/test_theme.theme index 8275818..62b5abf 100644 --- a/core/modules/system/tests/themes/test_theme/test_theme.theme +++ b/core/modules/system/tests/themes/test_theme/test_theme.theme @@ -1,6 +1,18 @@ -Success: Template overridden. diff --git a/core/modules/system/tests/themes/test_theme_phptemplate/node--1.tpl.php b/core/modules/system/tests/themes/test_theme_phptemplate/node--1.tpl.php new file mode 100644 index 0000000..81974ce --- /dev/null +++ b/core/modules/system/tests/themes/test_theme_phptemplate/node--1.tpl.php @@ -0,0 +1,4 @@ + +Node Content Dummy diff --git a/core/modules/system/tests/themes/test_theme_phptemplate/test_theme_phptemplate.info.yml b/core/modules/system/tests/themes/test_theme_phptemplate/test_theme_phptemplate.info.yml new file mode 100644 index 0000000..fa975b9 --- /dev/null +++ b/core/modules/system/tests/themes/test_theme_phptemplate/test_theme_phptemplate.info.yml @@ -0,0 +1,6 @@ +name: 'Test theme PHPTemplate' +type: theme +description: 'Theme for testing the theme system with the PHPTemplate engine' +core: 8.x +engine: phptemplate +hidden: true diff --git a/core/modules/system/tests/themes/test_theme_phptemplate/test_theme_phptemplate.theme b/core/modules/system/tests/themes/test_theme_phptemplate/test_theme_phptemplate.theme new file mode 100644 index 0000000..b3d9bbc --- /dev/null +++ b/core/modules/system/tests/themes/test_theme_phptemplate/test_theme_phptemplate.theme @@ -0,0 +1 @@ + +Success: Template overridden. diff --git a/core/modules/system/tests/themes/test_theme_twig/node--1.html.twig b/core/modules/system/tests/themes/test_theme_twig/node--1.html.twig deleted file mode 100644 index 046c02e..0000000 --- a/core/modules/system/tests/themes/test_theme_twig/node--1.html.twig +++ /dev/null @@ -1,4 +0,0 @@ -{# - // node--1.html.twig - Dummy file for finding the template -#} -Node Content Dummy diff --git a/core/modules/system/tests/themes/test_theme_twig/template.php b/core/modules/system/tests/themes/test_theme_twig/template.php deleted file mode 100644 index a4abe2d..0000000 --- a/core/modules/system/tests/themes/test_theme_twig/template.php +++ /dev/null @@ -1,2 +0,0 @@ -uri(); $variables['url'] = url($uri['path'], $uri['options']); - $variables['label'] = check_plain($term->label()); - $variables['page'] = $variables['view_mode'] == 'full' && taxonomy_term_is_page($term); + // We use name here because that is what appears in the UI. + $variables['name'] = check_plain($term->label()); + $variables['page'] = $variables['view_mode'] == 'full' && taxonomy_term_is_page($term); // Helpful $content variable for templates. $variables['content'] = array(); diff --git a/core/modules/taxonomy/templates/taxonomy-term.html.twig b/core/modules/taxonomy/templates/taxonomy-term.html.twig new file mode 100644 index 0000000..765cbcf --- /dev/null +++ b/core/modules/taxonomy/templates/taxonomy-term.html.twig @@ -0,0 +1,42 @@ +{# +/** + * @file + * Default theme implementation to display a taxonomy term. + * + * Available variables: + * - url: URL of the current term. + * - name: Name of the current term. + * - content: Items for the content of the term (fields and description). + * Use 'content' to print them all, or print a subset such as + * 'content.description'. Use the following code to temporarily suppress the + * printing of a given element: + * @code + * {% hide(content.description) %} + * @endcode + * - attributes: HTML attributes for the wrapper. The 'class' attribute + * contains the following classes by default: + * - taxonomy-term: The current template type, i.e. "theming hook". + * - vocabulary-[vocabulary-name]: The vocabulary that this term belongs to. + * For example, if the term belongs to a vocabulary called "Tags" then the + * class would be "vocabulary-tags". + * - page: Flag for the full page state. + * - term: The taxonomy term entity, including: + * - id: The ID of the taxonomy term. + * - view_mode: View mode, e.g. 'full', 'teaser', etc. + * + * @see template_preprocess() + * @see template_preprocess_taxonomy_term() + * + * @ingroup themeable + */ +#} +
+ {{ title_prefix }} + {% if not page %} +

{{ name }}

+ {% endif %} + {{ title_suffix }} +
+ {{ content }} +
+
diff --git a/core/modules/taxonomy/templates/taxonomy-term.tpl.php b/core/modules/taxonomy/templates/taxonomy-term.tpl.php deleted file mode 100644 index a7e58f6..0000000 --- a/core/modules/taxonomy/templates/taxonomy-term.tpl.php +++ /dev/null @@ -1,49 +0,0 @@ - -
> - - - -

- - - -
- -
- -
diff --git a/core/modules/user/templates/user-picture.tpl.php b/core/modules/user/templates/user-picture.tpl.php deleted file mode 100644 index ee82187..0000000 --- a/core/modules/user/templates/user-picture.tpl.php +++ /dev/null @@ -1,23 +0,0 @@ - - -
- -
- diff --git a/core/modules/user/templates/user.html.twig b/core/modules/user/templates/user.html.twig new file mode 100644 index 0000000..e011796 --- /dev/null +++ b/core/modules/user/templates/user.html.twig @@ -0,0 +1,31 @@ +{# +/** + * @file + * Default theme implementation to present all user data. + * + * This template is used when viewing a registered user's page, + * e.g., example.com/user/123. 123 being the user's ID. + * + * Available variables: + * - content: A list of content items. Use 'content' to print all content, or + * print a subset such as 'content.field_example'. + * - Field variables: For each field instance attached to the user a + * corresponding variable is defined; e.g., account.field_example has a + * variable 'field_example' defined. When needing to access a field's raw + * values, developers/themers are strongly encouraged to use these + * variables. Otherwise they will have to explicitly specify the desired + * field language, e.g. account.field_example.en, thus overriding any + * language negotiation rule that was previously applied. + * - attributes: HTML attributes for the container element. + * + * @see template_preprocess() + * @see template_preprocess_user() + * + * @ingroup themeable + */ +#} + + {% if content %} + {{- content -}} + {% endif %} +
diff --git a/core/modules/user/templates/user.tpl.php b/core/modules/user/templates/user.tpl.php deleted file mode 100644 index 617d310..0000000 --- a/core/modules/user/templates/user.tpl.php +++ /dev/null @@ -1,32 +0,0 @@ -field_example has a - * variable $field_example defined. When needing to access a field's raw - * values, developers/themers are strongly encouraged to use these - * variables. Otherwise they will have to explicitly specify the desired - * field language, e.g. $account->field_example['en'], thus overriding any - * language negotiation rule that was previously applied. - * - * @see template_preprocess_user() - * - * @ingroup themeable - */ -?> -
> - -
diff --git a/core/modules/user/user.module b/core/modules/user/user.module index 42a79db..0b884fa 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -93,8 +93,8 @@ function user_theme() { return array( 'user' => array( 'render element' => 'elements', - 'template' => 'user', 'file' => 'user.pages.inc', + 'template' => 'user', ), 'user_admin_permissions' => array( 'render element' => 'form', @@ -646,7 +646,7 @@ function user_validate_current_pass(&$form, &$form_state) { } /** - * Implements hook_preprocess_HOOK() for block.tpl.php. + * Implements hook_preprocess_HOOK() for block.html.twig. */ function user_preprocess_block(&$variables) { if ($variables['configuration']['module'] == 'user') { diff --git a/core/modules/user/user.pages.inc b/core/modules/user/user.pages.inc index 5f0cfab..5817d9c 100644 --- a/core/modules/user/user.pages.inc +++ b/core/modules/user/user.pages.inc @@ -179,12 +179,13 @@ function user_logout() { } /** - * Process variables for user.tpl.php. + * Prepares variables for user templates. * - * The $variables array contains the following arguments: - * - $account + * Default template: user.html.twig. * - * @see user.tpl.php + * @param array $variables + * An associative array containing: + * - account: The user account. */ function template_preprocess_user(&$variables) { $account = $variables['elements']['#user']; @@ -196,6 +197,9 @@ function template_preprocess_user(&$variables) { // Preprocess fields. field_attach_preprocess($account, $variables['elements'], $variables); + + // Set up attributes. + $variables['attributes']['class'][] = 'profile'; } /** diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php index d527836..1850a32 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php @@ -1777,7 +1777,7 @@ public function buildOptionsForm(&$form, &$form_state) { // If there's a theme engine involved, we also need to know its extension // so we can give the proper filename. - $this->theme_extension = '.tpl.php'; + $this->theme_extension = '.html.twig'; if (isset($theme_engine)) { $extension_function = $theme_engine . '_extension'; if (function_exists($extension_function)) { diff --git a/core/modules/views/templates/views-exposed-form.html.twig b/core/modules/views/templates/views-exposed-form.html.twig new file mode 100644 index 0000000..239b67d --- /dev/null +++ b/core/modules/views/templates/views-exposed-form.html.twig @@ -0,0 +1,87 @@ +{# +/** + * @file + * Default theme implementation of a views exposed form. + * + * Available variables: + * - widgets: A list of exposed form widgets. Each widget contains: + * - label: The sanitized label of the widget. + * - id: The ID of the widget, if available. + * - operator: The select element for the operator widget. + * - description: The sanitized description of the widget. + * - widget: The widget itself. + * - index: the widget's row index. + * - form: A render element representing the form. + * - sort_by: An optional select element to sort the view by fields. + * - sort_order: An optional select element with ascending or + * descending order options. + * - items_per_page: An optional select element for the available items per + * page. + * - offset: An optional textfield to define the offset of the view. + * - reset_button: An optional button to reset the exposed filter applied. + * + * @see template_preprocess() + * @see template_preprocess_views_exposed_form() + * + * @ingroup themeable + */ +#} +{% if q is not empty %} + {# + This ensures that, if clean URLs are off, the 'q' is added first, + as a hidden form element, so that it shows up first in the POST URL. + #} +{{ q }} +{% endif %} +
+
+ {% for index, widget in widgets %} +
+ {% if widget.label %} + + {% endif %} + {% if widget.operator %} +
+ {{ widget.operator }} +
+ {% endif %} +
+ {{ widget.widget }} +
+ {% if widget.description %} +
+ {{ widget.description }} +
+ {% endif %} +
+ {% endfor %} + {% if form.sort_by %} +
+ {{ form.sort_by }} +
+
+ {{ form.sort_order }} +
+ {% endif %} + {% if form.items_per_page %} +
+ {{ form.items_per_page }} +
+ {% endif %} + {% if form.offset %} +
+ {{ form.offset }} +
+ {% endif %} +
+ {{ form }} +
+ {% if form.reset_button %} +
+ {{ form.reset_button }} +
+ {% endif %} +
+
diff --git a/core/modules/views/templates/views-exposed-form.tpl.php b/core/modules/views/templates/views-exposed-form.tpl.php deleted file mode 100644 index bdd570c..0000000 --- a/core/modules/views/templates/views-exposed-form.tpl.php +++ /dev/null @@ -1,80 +0,0 @@ -label: The visible label to print. May be optional. - * - $widget->operator: The operator for the widget. May be optional. - * - $widget->widget: The widget itself. - * - $sort_by: The select box to sort the view using an exposed form. - * - $sort_order: The select box with the ASC, DESC options to define order. May be optional. - * - $items_per_page: The select box with the available items per page. May be optional. - * - $offset: A textfield to define the offset of the view. May be optional. - * - $reset_button: A button to reset the exposed filter applied. May be optional. - * - $button: The submit button for the form. - * - * @ingroup views_templates - */ -?> - - - -
-
- $widget): ?> -
- label)): ?> - - - operator)): ?> -
- operator; ?> -
- -
- widget; ?> -
- description)): ?> -
- description; ?> -
- -
- - -
- -
-
- -
- - -
- -
- - -
- -
- -
- -
- -
- -
- -
-
diff --git a/core/modules/views/templates/views-more.html.twig b/core/modules/views/templates/views-more.html.twig new file mode 100644 index 0000000..9ab8295 --- /dev/null +++ b/core/modules/views/templates/views-more.html.twig @@ -0,0 +1,20 @@ +{# +/** + * @file + * Default theme implementation for a views "more" link. + * + * Available variables: + * - view: The view object. + * - more_url: The URL for the views "more" link. + * - link_text: The text for the views "more" link. + * + * @see template_preprocess() + * + * @ingroup themeable + */ +#} + diff --git a/core/modules/views/templates/views-more.tpl.php b/core/modules/views/templates/views-more.tpl.php deleted file mode 100644 index 0b7080b..0000000 --- a/core/modules/views/templates/views-more.tpl.php +++ /dev/null @@ -1,19 +0,0 @@ - - - diff --git a/core/modules/views/templates/views-view-field.html.twig b/core/modules/views/templates/views-view-field.html.twig new file mode 100644 index 0000000..6b3f281 --- /dev/null +++ b/core/modules/views/templates/views-view-field.html.twig @@ -0,0 +1,26 @@ +{# +/** + * @file + * Default theme implementation for a single field in a view. + * + * Available variables: + * - view: The view that the field belongs to. + * - field: The field handler that can process the input. + * - row: The raw result of the database query that generated this field. + * - output: The processed output that will normally be used. + * + * When fetching output from the row this construct should be used: + * data = row[field.field_alias] + * + * The above will guarantee that you'll always get the correct data, regardless + * of any changes in the aliasing that might happen if the view is modified. + * + * @see template_preprocess() + * @see template_preprocess_views_view_field() + * + * @ingroup themeable + */ +#} +{% spaceless %} + {{ output }} +{% endspaceless %} diff --git a/core/modules/views/templates/views-view-field.tpl.php b/core/modules/views/templates/views-view-field.tpl.php deleted file mode 100644 index 91d92ee..0000000 --- a/core/modules/views/templates/views-view-field.tpl.php +++ /dev/null @@ -1,25 +0,0 @@ -{$field->field_alias} - * - * The above will guarantee that you'll always get the correct data, - * regardless of any changes in the aliasing that might happen if - * the view is modified. - */ -?> - diff --git a/core/modules/views/templates/views-view-fields.html.twig b/core/modules/views/templates/views-view-fields.html.twig new file mode 100644 index 0000000..03f97be --- /dev/null +++ b/core/modules/views/templates/views-view-fields.html.twig @@ -0,0 +1,36 @@ +{# +/** + * @file + * Default view template to display all the fields in a row. + * + * Available variables: + * - view: The view in use. + * - fields: A list of fields, each one contains: + * - content: The output of the field. + * - raw: The raw data for the field, if it exists. This is NOT output safe. + * - class: The safe class ID to use. + * - handler: The Views field handler controlling this field. + * - inline: Whether or not the field should be inline. + * - inline_html: Either div or span based on the 'inline' flag. + * - wrapper_prefix: A complete wrapper containing the inline_html to use. + * - wrapper_suffix: The closing tag for the wrapper. + * - separator: An optional separator that may appear before a field. + * - label: The field's label text. + * - label_html: The full HTML of the label to use including configured + * element type. + * - row: The raw result from the query, with all data it fetched. + * + * @see template_preprocess() + * @see template_preprocess_views_view_fields() + * + * @ingroup themeable + */ +#} +{% for field in fields %} + {{ field.separator }} + + {{ field.wrapper_prefix }} + {{ field.label_html }} + {{ field.content }} + {{ field.wrapper_suffix }} +{% endfor %} diff --git a/core/modules/views/templates/views-view-fields.tpl.php b/core/modules/views/templates/views-view-fields.tpl.php deleted file mode 100644 index ae3a4c6..0000000 --- a/core/modules/views/templates/views-view-fields.tpl.php +++ /dev/null @@ -1,36 +0,0 @@ -content: The output of the field. - * - $field->raw: The raw data for the field, if it exists. This is NOT output safe. - * - $field->class: The safe class id to use. - * - $field->handler: The Views field handler object controlling this field. Do not use - * var_export to dump this object, as it can't handle the recursion. - * - $field->inline: Whether or not the field should be inline. - * - $field->inline_html: either div or span based on the above flag. - * - $field->wrapper_prefix: A complete wrapper containing the inline_html to use. - * - $field->wrapper_suffix: The closing tag for the wrapper. - * - $field->separator: an optional separator that may appear before a field. - * - $field->label: The wrap label text to use. - * - $field->label_html: The full HTML of the label to use including - * configured element type. - * - $row: The raw result object from the query, with all data it fetched. - * - * @ingroup views_templates - */ -?> - $field): ?> - separator)): ?> - separator; ?> - - - wrapper_prefix; ?> - label_html; ?> - content; ?> - wrapper_suffix; ?> - diff --git a/core/modules/views/templates/views-view-grid.html.twig b/core/modules/views/templates/views-view-grid.html.twig new file mode 100644 index 0000000..8ba3003 --- /dev/null +++ b/core/modules/views/templates/views-view-grid.html.twig @@ -0,0 +1,36 @@ +{# +/** + * @file + * Default theme implementation for views to display rows in a grid. + * + * Available variables: + * - attributes: HTML attributes for the table element. + * - title: The title of this group of rows. + * - rows: A list of rows. Each row contains a list of columns. + * - row_classes: HTML classes for each row including the row number and first + * or last. + * - column_classes: HTML classes for each column including the row number and + * first or last. + * + * @see template_preprocess() + * @see template_preprocess_views_view_grid() + * + * @ingroup themeable + */ +#} +{% if title %} +

{{ title }}

+{% endif %} + + + {% for row_number, columns in rows %} + + {% for column_number, item in columns %} + + {{ item }} + + {% endfor %} + + {% endfor %} + + diff --git a/core/modules/views/templates/views-view-grid.tpl.php b/core/modules/views/templates/views-view-grid.tpl.php deleted file mode 100644 index 43ba37b..0000000 --- a/core/modules/views/templates/views-view-grid.tpl.php +++ /dev/null @@ -1,28 +0,0 @@ - - -

- -> - - $columns): ?> - > - $item): ?> - - - - - -
> - -
diff --git a/core/modules/views/templates/views-view-grouping.html.twig b/core/modules/views/templates/views-view-grouping.html.twig new file mode 100644 index 0000000..2375eaf --- /dev/null +++ b/core/modules/views/templates/views-view-grouping.html.twig @@ -0,0 +1,23 @@ +{# +/** + * @file + * Default theme implementation to display a single views grouping. + * + * Available variables: + * - view: The view object. + * - grouping: The grouping instruction. + * - grouping_level: A number indicating the hierarchical level of the grouping. + * - title: The group heading. + * - content: The content to be grouped. + * - rows: The rows returned from the view. + * + * @see template_preprocess() + * @see template_preprocess_views_view_grouping() + * + * @ingroup themeable + */ +#} +
+
{{ title }}
+
{{ content }}
+
diff --git a/core/modules/views/templates/views-view-grouping.tpl.php b/core/modules/views/templates/views-view-grouping.tpl.php deleted file mode 100644 index ebf7bc2..0000000 --- a/core/modules/views/templates/views-view-grouping.tpl.php +++ /dev/null @@ -1,25 +0,0 @@ - -
-
-
- -
-
diff --git a/core/modules/views/templates/views-view-list.html.twig b/core/modules/views/templates/views-view-list.html.twig new file mode 100644 index 0000000..5e2d2eb --- /dev/null +++ b/core/modules/views/templates/views-view-list.html.twig @@ -0,0 +1,44 @@ +{# +/** + * @file + * Default theme implementation for a view template to display a list of rows. + * + * Available variables: + * - rows: A list of rows for this list. + * - row_classes: The row's HTML attributes correlating with the row's 'id'. + * - title: The title of this group of rows. May be empty. + * - list: @todo. + * - type: Starting tag will be either a ul or ol. + * - attributes: HTML attributes for the list element. + * + * @see template_preprocess() + * @see template_preprocess_views_view_list() + * + * @ingroup themeable + */ +#} +{% if wrapper_attributes -%} + +{% endif %} + {% if title %} +

{{ title }}

+ {% endif %} + + {% if list.type == 'ul' %} + + {% else %} + + {% endif %} + + {% for id, row in rows %} + {{ row }} + {% endfor %} + + {% if list.type == 'ul' %} + + {% else %} + + {% endif %} +{% if wrapper_attributes -%} + +{% endif %} diff --git a/core/modules/views/templates/views-view-list.tpl.php b/core/modules/views/templates/views-view-list.tpl.php deleted file mode 100644 index 2c4b9c5..0000000 --- a/core/modules/views/templates/views-view-list.tpl.php +++ /dev/null @@ -1,21 +0,0 @@ - - - -

- - - $row): ?> -
  • >
  • - - - diff --git a/core/modules/views/templates/views-view-row-rss.html.twig b/core/modules/views/templates/views-view-row-rss.html.twig new file mode 100644 index 0000000..0622e09 --- /dev/null +++ b/core/modules/views/templates/views-view-row-rss.html.twig @@ -0,0 +1,23 @@ +{# +/** + * @file + * Default theme implementation to display an item in a views RSS feed. + * + * Available variables: + * - title: RSS item title. + * - link: RSS item link. + * - description: RSS body text. + * - item_elements: RSS item elements rendered as XML (pubDate, creator, guid). + * + * @see template_preprocess() + * @see template_preprocess_views_view_row_rss() + * + * @ingroup themeable + */ +#} + + {{ title }} + {{ link }} + {{ description }} + {{ item_elements }} + diff --git a/core/modules/views/templates/views-view-row-rss.tpl.php b/core/modules/views/templates/views-view-row-rss.tpl.php deleted file mode 100644 index 01e0696..0000000 --- a/core/modules/views/templates/views-view-row-rss.tpl.php +++ /dev/null @@ -1,15 +0,0 @@ - - - <?php print $title; ?> - - - - diff --git a/core/modules/views/templates/views-view-rss.html.twig b/core/modules/views/templates/views-view-rss.html.twig new file mode 100644 index 0000000..d223b05 --- /dev/null +++ b/core/modules/views/templates/views-view-rss.html.twig @@ -0,0 +1,31 @@ +{# +/** + * @file + * Default template for feed displays that use the RSS style. + * + * Available variables: + * - link: The link to the feed (the view path). + * - namespaces: The XML namespaces (added automatically). + * - title: The title of the feed (as set in the view). + * - description: The feed description (from feed settings). + * - langcode: The language encoding. + * - channel_elements: The formatted channel elements. + * - items: The feed items themselves. + * + * @see template_preprocess() + * @see template_preprocess_views_view_rss() + * + * @ingroup themeable + */ +#} + + + + {{ title }} + {{ link }} + {{ description }} + {{ langcode }} + {{ channel_elements }} + {{ items }} + + diff --git a/core/modules/views/templates/views-view-rss.tpl.php b/core/modules/views/templates/views-view-rss.tpl.php deleted file mode 100644 index 18ca73e..0000000 --- a/core/modules/views/templates/views-view-rss.tpl.php +++ /dev/null @@ -1,20 +0,0 @@ - - version="1.0" encoding="utf-8" "; ?> -> - - <?php print $title; ?> - - - - - - - diff --git a/core/modules/views/templates/views-view-summary-unformatted.html.twig b/core/modules/views/templates/views-view-summary-unformatted.html.twig new file mode 100644 index 0000000..77f68a8 --- /dev/null +++ b/core/modules/views/templates/views-view-summary-unformatted.html.twig @@ -0,0 +1,34 @@ +{# +/** + * @file + * Default theme implementation for unformatted summary links. + * + * Available variables: + * - rows: The rows contained in this view. + * - url: The URL to this row's content. + * - count: The number of items this summary item represents. + * - separator: A separator between each row. + * - row_classes: HTML attributes for a row, either containing an 'active' class + * or no attributes, that correlate to each row by ID. + * - options: Flags indicating how each row should be displayed. This contains: + * - count: A flag indicating whether the row's 'count' should be displayed. + * - inline: A flag indicating whether the item should be wrapped in an inline + * or block level HTML element. + * + * @see template_preprocess() + * @see template_preprocess_views_view_summary_unformatted() + * + * @ingroup themeable + */ +#} +{% for id, row in rows %} + {{ options.inline ? ' + {% if row.separator -%} + {{ row.separator }} + {%- endif %} + {{ row.link }} + {% if options.count %} + ({{ row.count }}) + {% endif %} + {{ options.inline ? '' : '' }} +{% endfor %} diff --git a/core/modules/views/templates/views-view-summary-unformatted.tpl.php b/core/modules/views/templates/views-view-summary-unformatted.tpl.php deleted file mode 100644 index 2280a71..0000000 --- a/core/modules/views/templates/views-view-summary-unformatted.tpl.php +++ /dev/null @@ -1,20 +0,0 @@ - - $row): ?> - '; ?> - separator)): ?>separator; ?> - >link; ?> - - (count; ?>) - - ' : ''; ?> - diff --git a/core/modules/views/templates/views-view-summary.html.twig b/core/modules/views/templates/views-view-summary.html.twig new file mode 100644 index 0000000..cffc2bc --- /dev/null +++ b/core/modules/views/templates/views-view-summary.html.twig @@ -0,0 +1,34 @@ +{# +/** + * @file + * Default theme implementation to display a list of summary lines. + * + * Available variables: + * - rows: The rows contained in this view. + * Each row contains: + * - url: The summary link URL. + * - link: The summary link text. + * - count: The number of items under this grouping. + * - row_classes: HTML classes to apply to each row, indexed by row ID. + * This matches the index in rows. + * - options: Flags indicating how the summary should be displayed. + * This contains: + * - count: A flag indicating whether the count should be displayed. + * + * @see template_preprocess() + * @see template_preprocess_views_view_summary() + * + * @ingroup themeable + */ +#} +
    +
      + {% for id, row in rows %} +
    • {{ row.link }} + {% if options.count %} + ({{ row.count }}) + {% endif %} +
    • + {% endfor %} +
    +
    diff --git a/core/modules/views/templates/views-view-summary.tpl.php b/core/modules/views/templates/views-view-summary.tpl.php deleted file mode 100644 index ce51e70..0000000 --- a/core/modules/views/templates/views-view-summary.tpl.php +++ /dev/null @@ -1,20 +0,0 @@ - -
    -
      - $row): ?> -
    • >link; ?> - - (count?>) - -
    • - -
    -
    diff --git a/core/modules/views/templates/views-view-table.html.twig b/core/modules/views/templates/views-view-table.html.twig new file mode 100644 index 0000000..50ae9d6 --- /dev/null +++ b/core/modules/views/templates/views-view-table.html.twig @@ -0,0 +1,54 @@ +{# +/** + * @file + * Default theme implementation for displaying a view as a table. + * + * Available variables: + * - attributes: Remaining HTML attributes for the element. + * - class: HTML classes that can be used to style contextually through CSS. + * - title : The title of this group of rows. + * - header: Header labels. + * - header_classes: HTML classes to apply to each header cell, indexed by + * the header's key. + * - rows: Table row items. Rows are keyed by row number, fields within rows + * are keyed by field ID. + * - field: Table data field ID. + * - content: Table data content. + * - row_classes: HTML classes to apply to each row, indexed by row number. + * This matches the index in rows. + * - field_classes: HTML classes to apply to each row, indexed by row number. + * This matches the index in columns and rows. + * + * @see template_preprocess() + * @see template_preprocess_views_view_table() + * + * @ingroup themeable + */ +#} + + {% if title is not empty %} + {{ title }} + {% endif %} + {% if header %} + + + {% for key, field in header %} + + {{ field }} + + {% endfor %} + + + {% endif %} + + {% for row_count, row in rows %} + + {% for field, content in row %} + + {{ content }} + + {% endfor %} + + {% endfor %} + + diff --git a/core/modules/views/templates/views-view-table.tpl.php b/core/modules/views/templates/views-view-table.tpl.php deleted file mode 100644 index 4d44d42..0000000 --- a/core/modules/views/templates/views-view-table.tpl.php +++ /dev/null @@ -1,48 +0,0 @@ - -> - - - - - - - $label): ?> - - - - - - - $row): ?> - > - $content): ?> - - - - - -
    scope="col"> - -
    > - -
    diff --git a/core/modules/views/templates/views-view-unformatted.html.twig b/core/modules/views/templates/views-view-unformatted.html.twig new file mode 100644 index 0000000..47a66cf --- /dev/null +++ b/core/modules/views/templates/views-view-unformatted.html.twig @@ -0,0 +1,24 @@ +{# +/** + * @file + * Default theme implementation to display a view of unformatted rows. + * + * Available variables: + * - title: The title of this group of rows. May be empty. + * - rows: A list of the view's row items. + * - row_classes: A list of row class attributes keyed by the row's ID. + * + * @see template_preprocess() + * @see template_preprocess_views_view_unformatted() + * + * @ingroup themeable + */ +#} +{% if title %} +

    {{ title }}

    +{% endif %} +{% for id, row in rows %} + + {{ row }} + +{% endfor %} diff --git a/core/modules/views/templates/views-view-unformatted.tpl.php b/core/modules/views/templates/views-view-unformatted.tpl.php deleted file mode 100644 index b7f63b9..0000000 --- a/core/modules/views/templates/views-view-unformatted.tpl.php +++ /dev/null @@ -1,17 +0,0 @@ - - -

    - - $row): ?> -
    > - -
    - diff --git a/core/modules/views/templates/views-view.html.twig b/core/modules/views/templates/views-view.html.twig new file mode 100644 index 0000000..06542aa --- /dev/null +++ b/core/modules/views/templates/views-view.html.twig @@ -0,0 +1,89 @@ +{# +/** + * @file + * Default theme implementation for main view template. + * + * Available variables: + * - attributes: Remaining HTML attributes for the element. + * - class: HTML classes that can be used to style contextually + * through CSS, including: + * - view + * - view-[css_name] + * - view-id-[view_name] + * - view-display-id-[display_name] + * - view-dom-id-[dom_id] + * - header: The optional header. + * - footer: The optional footer. + * - rows: The results of the view query, if any. + * - empty: The content to display if there are no rows. + * - pager: The optional pager next/prev links to display. + * - exposed: Exposed widget form/info to display. + * - feed_icon: An optional feed icon to display. + * - more: An optional link to the next page of results. + * - title: Title of the view, only used when displaying in the admin preview. + * title_prefix: Additional output populated by modules, intended to be + * displayed in front of the view title. + * title_prefix: Additional output populated by modules, intended to be + * displayed after the view title. + * - attachment_before: An optional attachment view to be displayed before the + * view content. + * - attachment_after: An optional attachment view to be displayed after the + * view content. + * + * @ingroup themeable + */ +#} + + {{ title_prefix }} + {% if title %} + {{ title }} + {% endif %} + {{ title_suffix }} + {% if header %} +
    + {{ header }} +
    + {% endif %} + {% if exposed %} +
    + {{ exposed }} +
    + {% endif %} + {% if attachment_before %} +
    + {{ attachment_before }} +
    + {% endif %} + + {% if rows %} +
    + {{ rows }} +
    + {% elseif empty %} +
    + {{ empty }} +
    + {% endif %} + + {% if pager %} + {{ pager }} + {% endif %} + {% if attachment_after %} +
    + {{ attachment_after }} +
    + {% endif %} + {% if more %} + {{ more }} + {% endif %} + {% if footer %} + + {% endif %} + {% if feed_icon %} +
    + {{ feed_icon }} +
    + {% endif %} + diff --git a/core/modules/views/templates/views-view.tpl.php b/core/modules/views/templates/views-view.tpl.php deleted file mode 100644 index ca8faef..0000000 --- a/core/modules/views/templates/views-view.tpl.php +++ /dev/null @@ -1,90 +0,0 @@ - -
    > - - - - - - -
    - -
    - - - -
    - -
    - - - -
    - -
    - - - -
    - -
    - -
    - -
    - - - - - - - -
    - -
    - - - - - - - - - - - -
    - -
    - - -
    diff --git a/core/modules/views/tests/views_test_data/templates/views-view--frontpage.html.twig b/core/modules/views/tests/views_test_data/templates/views-view--frontpage.html.twig new file mode 100644 index 0000000..10217e8 --- /dev/null +++ b/core/modules/views/tests/views_test_data/templates/views-view--frontpage.html.twig @@ -0,0 +1,77 @@ +{# +/** + * @file + * Default theme implementation for main view template. + * + * Available variables: + * - attributes: Remaining HTML attributes for the element. + * - attributes.class: HTML classes that can be used to style contextually + * through CSS, including: + * - view + * - view-[css_name] + * - view-id-[view_name] + * - view-display-id-[display_name] + * - view-dom-id-[dom_id] + * - css_name: A CSS-safe version of the view name. + * - css_class: The user-specified class names, if any. + * - header: The view header. + * - footer: The view footer. + * - rows: The results of the view query, if any. + * - empty: The empty text to display if the view is empty. + * - pager: The pager next/prev links to display, if any. + * - exposed: Exposed widget form/info to display. + * - feed_icon: Feed icon to display, if any. + * - more: A link to view more, if any. + * + * @ingroup views_templates + */ +#} + + {% if header %} +
    + {{ header }} +
    + {% endif %} + {% if exposed %} +
    + {{ exposed }} +
    + {% endif %} + {% if attachment_before %} +
    + {{ attachment_before }} +
    + {% endif %} + + {% if rows %} +
    + {{ rows }} +
    + {% elseif empty %} +
    + {{ empty }} +
    + {% endif %} + + {% if pager %} + {{ pager }} + {% endif %} + {% if attachment_after %} +
    + {{ attachment_after }} +
    + {% endif %} + {% if more %} + {{ more }} + {% endif %} + {% if footer %} + + {% endif %} + {% if feed_icon %} +
    + {{ feed_icon }} +
    + {% endif %} + diff --git a/core/modules/views/tests/views_test_data/templates/views-view--frontpage.tpl.php b/core/modules/views/tests/views_test_data/templates/views-view--frontpage.tpl.php deleted file mode 100644 index 5e6c8fa..0000000 --- a/core/modules/views/tests/views_test_data/templates/views-view--frontpage.tpl.php +++ /dev/null @@ -1,85 +0,0 @@ - -
    > - -
    - -
    - - - -
    - -
    - - - -
    - -
    - - - -
    - -
    - -
    - -
    - - - - - - - -
    - -
    - - - - - - - - - - - -
    - -
    - - -
    diff --git a/core/modules/views/views.module b/core/modules/views/views.module index 61826f8..09d8c6e 100644 --- a/core/modules/views/views.module +++ b/core/modules/views/views.module @@ -168,9 +168,8 @@ function views_theme($existing, $type, $theme, $path) { ); $hooks['views_more'] = $base + array( - 'template' => 'views-more', - 'pattern' => 'views_more__', 'variables' => array('more_url' => NULL, 'link_text' => 'more', 'view' => NULL), + 'template' => 'views-more', ); return $hooks; diff --git a/core/modules/views/views.theme.inc b/core/modules/views/views.theme.inc index e987ffd..87745b4 100644 --- a/core/modules/views/views.theme.inc +++ b/core/modules/views/views.theme.inc @@ -11,11 +11,11 @@ /** * Provide a full array of possible themes to try for a given hook. * - * @param $hook + * @param string $hook * The hook to use. This is the base theme/template name. - * @param $view + * @param Drupal\views\ViewExecutable $view * The view being rendered. - * @param $display + * @param string|null $display * The display being rendered, if applicable. */ function _views_theme_functions($hook, ViewExecutable $view, $display = NULL) { @@ -40,14 +40,20 @@ function _views_theme_functions($hook, ViewExecutable $view, $display = NULL) { } /** - * Preprocess the primary theme implementation for a view. + * Prepares variables for view templates. + * + * Default template: views-view.html.twig. + * + * @param array $vars + * An associative array containing: + * - view: The ViewExecutable object. */ function template_preprocess_views_view(&$vars) { global $base_path; $view = $vars['view']; - $vars['rows'] = (!empty($view->result) || $view->style_plugin->even_empty()) ? $view->style_plugin->render($view->result) : ''; + $vars['rows'] = (!empty($view->result) || $view->style_plugin->even_empty()) ? $view->style_plugin->render($view->result) : array(); // Force a render array so CSS/JS can be added. if (!is_array($vars['rows'])) { $vars['rows'] = array('#markup' => $vars['rows']); @@ -57,7 +63,7 @@ function template_preprocess_views_view(&$vars) { $vars['id'] = $view->storage->id(); $vars['display_id'] = $view->current_display; - // Basic classes + // Basic classes. $vars['css_class'] = ''; $vars['attributes']['class'] = array(); @@ -110,21 +116,21 @@ function template_preprocess_views_view(&$vars) { // attached to an array (not an object) in order to process them. For our // purposes, it doesn't matter what we attach them to, since once they are // processed by contextual_preprocess() they will appear in the $title_suffix - // variable (which we will then render in views-view.tpl.php). + // variable (which we will then render in views-view.html.twig). views_add_contextual_links($vars['view_array'], 'view', $view, $view->current_display); // Attachments are always updated with the outer view, never by themselves, // so they do not have dom ids. if (empty($view->is_attachment)) { - // Our JavaScript needs to have some means to find the HTML belonging to this - // view. + // Our JavaScript needs to have some means to find the HTML belonging to + // this view. // // It is true that the DIV wrapper has classes denoting the name of the view // and its display ID, but this is not enough to unequivocally match a view // with its HTML, because one view may appear several times on the page. So - // we set up a hash with the current time, $dom_id, to issue a "unique" identifier for - // each view. This identifier is written to both Drupal.settings and the DIV - // wrapper. + // we set up a hash with the current time, $dom_id, to issue a "unique" + // identifier for each view. This identifier is written to both + // Drupal.settings and the DIV wrapper. $vars['dom_id'] = $view->dom_id; $vars['attributes']['class'][] = 'view-dom-id-' . $vars['dom_id']; } @@ -153,7 +159,7 @@ function template_preprocess_views_view(&$vars) { $view->element['#attached']['library'][] = array('views', 'views.ajax'); } - // If form fields were found in the View, reformat the View output as a form. + // If form fields were found in the view, reformat the view output as a form. if (views_view_has_form_elements($view)) { // Copy the rows so as not to modify them by reference when rendering. $rows = $vars['rows']; @@ -175,11 +181,26 @@ function template_preprocess_views_view(&$vars) { } /** - * Preprocess theme function to print a single record from a row, with fields + * Prepares variables for views fields templates. + * + * Default template: views-view-fields.html.twig. + * + * @param array $vars + * An associative array containing: + * - view: The view object. + * - options: An array of options. Each option contains: + * - inline: An array that contains the fields that are to be + * displayed inline. + * - default_field_elements: If default field wrapper + * elements are to be provided. + * - hide_empty: Whether the field is to be hidden if empty. + * - element_default_classes: If the default classes are to be added. + * - separator: A string to be placed between inline fields to keep them + * visually distinct. + * - row: An array containing information about the current row. */ function template_preprocess_views_view_fields(&$vars) { $view = $vars['view']; - // Loop through the fields for this view. $previous_inline = FALSE; $vars['fields'] = array(); // ensure it's at least an empty array. @@ -296,8 +317,19 @@ function template_preprocess_views_view_fields(&$vars) { } /** - * Process a single grouping within a view. - */ + * Prepares variables for views single grouping templates. + * + * Default template: views-view-grouping.html.twig. + * + * @param array $vars + * An associative array containing: + * - view: The view object. + * - rows: The rows returned from the view. + * - grouping_level: Integer indicating the hierarchical level of the + * grouping. + * - content: The content to be grouped. + * - title: The group heading. + */ function template_preprocess_views_view_grouping(&$vars) { $vars['content'] = $vars['view']->style_plugin->render_grouping_sets($vars['rows'], $vars['grouping_level']); } @@ -317,21 +349,35 @@ function theme_views_view_field($vars) { } /** - * Process a single field within a view. + * Prepares variables for views field templates. * - * This preprocess function isn't normally run, as a function is used by - * default, for performance. However, by creating a template, this - * preprocess should get picked up. + * Default template: views-view-field.html.twig. + * + * @param array $variables + * An associative array containing: + * - field: The field handler object for the current field. + * - row: Object representing the raw result of the SQL query for the current + * field. + * - view: Instance of the ViewExecutable object for the parent view. */ -function template_preprocess_views_view_field(&$vars) { - $vars['output'] = $vars['field']->advanced_render($vars['row']); +function template_preprocess_views_view_field(&$variables) { + $variables['output'] = $variables['field']->advanced_render($variables['row']); } /** - * Preprocess theme function to print a single record from a row, with fields + * Prepares variables for views summary templates. + * + * The summary prints a single record from a row, with fields. + * + * Default template: views-view-summary.html.twig. + * + * @param array $vars + * An associative array containing: + * - view: A ViewExecutable object. + * - rows: The raw row data. */ function template_preprocess_views_view_summary(&$vars) { - $view = $vars['view']; + $view = $vars['view']; $argument = $view->argument[$view->build_info['summary_level']]; $vars['row_classes'] = array(); @@ -346,8 +392,9 @@ function template_preprocess_views_view_summary(&$vars) { url(current_path()), // could be an alias )); - // Collect all arguments foreach row, to be able to alter them for example by the validator. - // This is not done per single argument value, because this could cause performance problems. + // Collect all arguments foreach row, to be able to alter them for example + // by the validator. This is not done per single argument value, because this + // could cause performance problems. $row_args = array(); foreach ($vars['rows'] as $id => $row) { @@ -356,7 +403,6 @@ function template_preprocess_views_view_summary(&$vars) { $argument->process_summary_arguments($row_args); foreach ($vars['rows'] as $id => $row) { - $vars['rows'][$id]->link = $argument->summary_name($row); $args = $view->args; $args[$argument->position] = $row_args[$id]; @@ -367,7 +413,6 @@ function template_preprocess_views_view_summary(&$vars) { } $vars['rows'][$id]->url = url($view->getUrl($args, $base_path), $url_options); $vars['rows'][$id]->count = intval($row->{$argument->count_alias}); - $vars['row_classes'][$id] = array(); if (isset($active_urls[$vars['rows'][$id]->url])) { $vars['row_classes'][$id]['class'][] = 'active'; @@ -377,11 +422,20 @@ function template_preprocess_views_view_summary(&$vars) { } /** - * Template preprocess theme function to print summary basically - * unformatted. + * Prepares variables for unformatted summary view templates. + * + * Default template: views-view-summary-unformatted.html.twig. + * + * @param array $vars + * An associative array containing: + * - view: A ViewExecutable object. + * - rows: The raw row data. + * - options: An array of options. Each option contains: + * - separator: A string to be placed between inline fields to keep them + * visually distinct. */ function template_preprocess_views_view_summary_unformatted(&$vars) { - $view = $vars['view']; + $view = $vars['view']; $argument = $view->argument[$view->build_info['summary_level']]; $vars['row_classes'] = array(); @@ -393,12 +447,15 @@ function template_preprocess_views_view_summary_unformatted(&$vars) { $count = 0; $active_urls = drupal_map_assoc(array( - url(current_path(), array('alias' => TRUE)), // force system path - url(current_path()), // could be an alias + // Force system path. + url(current_path(), array('alias' => TRUE)), + // Could be an alias. + url(current_path()), )); - // Collect all arguments foreach row, to be able to alter them for example by the validator. - // This is not done per single argument value, because this could cause performance problems. + // Collect all arguments for each row, to be able to alter them for example + // by the validator. This is not done per single argument value, because + // this could cause performance problems. $row_args = array(); foreach ($vars['rows'] as $id => $row) { $row_args[$id] = $argument->summary_argument($row); @@ -406,7 +463,7 @@ function template_preprocess_views_view_summary_unformatted(&$vars) { $argument->process_summary_arguments($row_args); foreach ($vars['rows'] as $id => $row) { - // only false on first time: + // Only false on first time. if ($count++) { $vars['rows'][$id]->separator = filter_xss_admin($vars['options']['separator']); } @@ -429,44 +486,52 @@ function template_preprocess_views_view_summary_unformatted(&$vars) { } /** - * Display a view as a table style. + * Prepares variables for views table templates. + * + * Default template: views-view-table.html.twig. + * + * @param array $vars + * An associative array containing: + * - view: A ViewExecutable object. + * - rows: The raw row data. */ function template_preprocess_views_view_table(&$vars) { - $view = $vars['view']; + $view = $vars['view']; - // We need the raw data for this grouping, which is passed in as $vars['rows']. + // We need the raw data for this grouping, which is passed in + // as $vars['rows']. // However, the template also needs to use for the rendered fields. We // therefore swap the raw data out to a new variable and reset $vars['rows'] // so that it can get rebuilt. // Store rows so that they may be used by further preprocess functions. - $result = $vars['result'] = $vars['rows']; + $result = $vars['result'] = $vars['rows']; $vars['rows'] = array(); $vars['field_classes'] = array(); $vars['header'] = array(); - $options = $view->style_plugin->options; - $handler = $view->style_plugin; + $options = $view->style_plugin->options; + $handler = $view->style_plugin; $default_row_class = isset($options['default_row_class']) ? $options['default_row_class'] : TRUE; $row_class_special = isset($options['row_class_special']) ? $options['row_class_special'] : TRUE; - $fields = &$view->field; - $columns = $handler->sanitize_columns($options['columns'], $fields); + $fields = &$view->field; + $columns = $handler->sanitize_columns($options['columns'], $fields); - $active = !empty($handler->active) ? $handler->active : ''; - $order = !empty($handler->order) ? $handler->order : 'asc'; + $active = !empty($handler->active) ? $handler->active : ''; + $order = !empty($handler->order) ? $handler->order : 'asc'; // A boolean variable which stores whether the table has a responsive class. $responsive = FALSE; - $query = tablesort_get_query_parameters(); + $query = tablesort_get_query_parameters(); if (isset($view->exposed_raw_input)) { $query += $view->exposed_raw_input; } foreach ($columns as $field => $column) { - // Create a second variable so we can easily find what fields we have and what the - // CSS classes should be. + // Create a second variable so we can easily find what fields we have and + // what the CSS classes should be. $vars['fields'][$field] = drupal_clean_css_identifier($field); if ($active == $field) { $vars['fields'][$field] .= ' active'; @@ -516,11 +581,10 @@ function template_preprocess_views_view_table(&$vars) { $vars['header_classes'][$field]['class'][] = $options['info'][$field]['responsive']; $responsive = TRUE; } - // Add a CSS align class to each field if one was set + // Add a CSS align class to each field if one was set. if (!empty($options['info'][$field]['align'])) { $vars['header_classes'][$field]['class'][] = drupal_clean_css_identifier($options['info'][$field]['align']); } - // Add a header label wrapper if one was selected. if ($vars['header'][$field]) { $element_label_type = $fields[$field]->element_label_type(TRUE, TRUE); @@ -528,17 +592,16 @@ function template_preprocess_views_view_table(&$vars) { $vars['header'][$field] = '<' . $element_label_type . '>' . $vars['header'][$field] . ''; } } - } - // Add a CSS align class to each field if one was set + // Add a CSS align class to each field if one was set. if (!empty($options['info'][$field]['align'])) { $vars['fields'][$field] .= ' ' . drupal_clean_css_identifier($options['info'][$field]['align']); } // Render each field into its appropriate column. foreach ($result as $num => $row) { - // Add field classes + // Add field classes. $vars['field_classes'][$field][$num] = array(); if ($fields[$field]->options['element_default_classes']) { $vars['field_classes'][$field][$num]['class'][] = 'views-field'; @@ -575,12 +638,12 @@ function template_preprocess_views_view_table(&$vars) { else { $vars['rows'][$num][$column] = ''; } - $vars['rows'][$num][$column] .= $field_output; } } - // Remove columns if the option is hide empty column is checked and the field is not empty. + // Remove columns if the option is hide empty column is checked and the + // field is not empty. if (!empty($options['info'][$field]['empty_column'])) { $empty = TRUE; foreach ($vars['rows'] as $num => $columns) { @@ -639,7 +702,7 @@ function template_preprocess_views_view_table(&$vars) { $vars['attributes']['class'][] = 'cols-' . count($vars['header']); if (!empty($handler->options['summary'])) { - $vars['attributes_array'] = array('summary' => $handler->options['summary']); + $vars['attributes']['summary'] = $handler->options['summary']; } // If the table has headers and it should react responsively to columns hidden // with the classes represented by the constants RESPONSIVE_PRIORITY_MEDIUM @@ -653,17 +716,24 @@ function template_preprocess_views_view_table(&$vars) { } /** - * Display a view as a grid style. + * Prepares variables for views grid style templates. + * + * Default template: views-view-grid.html.twig. + * + * @param array $vars + * An associative array containing: + * - view: The view object. + * - rows: An array of row items. Each row is an array of content. */ function template_preprocess_views_view_grid(&$vars) { - $view = $vars['view']; - $result = $view->result; - $options = $view->style_plugin->options; - $handler = $view->style_plugin; + $view = $vars['view']; + $result = $view->result; + $options = $view->style_plugin->options; + $handler = $view->style_plugin; $default_row_class = isset($options['default_row_class']) ? $options['default_row_class'] : TRUE; $row_class_special = isset($options['row_class_special']) ? $options['row_class_special'] : TRUE; - $columns = $options['columns']; + $columns = $options['columns']; $vars['attributes']['class'][] = 'views-view-grid cols-' . $columns; $rows = array(); @@ -718,14 +788,14 @@ function template_preprocess_views_view_grid(&$vars) { } } for ($i = 0; $i < count($rows[0]); $i++) { - // This should be string so that's okay :) + // This should be a string so this is ok. if (!isset($rows[count($rows) - 1][$i])) { $rows[count($rows) - 1][$i] = ''; } } } - // Apply the row classes + // Apply the row classes. foreach ($rows as $row_number => $row) { $row_classes = array(); if ($default_row_class) { @@ -762,21 +832,19 @@ function template_preprocess_views_view_grid(&$vars) { } $vars['rows'] = $rows; if (!empty($handler->options['summary'])) { - $vars['attributes_array'] = array('summary' => $handler->options['summary']); - } - // If the table has headers and it should react responsively to columns hidden - // with the classes represented by the constants RESPONSIVE_PRIORITY_MEDIUM - // and RESPONSIVE_PRIORITY_LOW, add the tableresponsive behaviors. - if (count($vars['header']) && $responsive) { - $vars['view']->element['#attached']['library'][] = array('system', 'drupal.tableresponsive'); - // Add 'responsive-enabled' class to the table to identify it for JS. - // This is needed to target tables constructed by this function. - $vars['attributes']['class'][] = 'responsive-enabled'; + $vars['attributes']['summary'] = $handler->options['summary']; } } /** - * Display the simple view of rows one after another + * Prepares variables for views unformatted rows templates. + * + * Default template: views-view-unformatted.html.twig. + * + * @param array $vars + * An associative array containing: + * - view: The view object. + * - rows: An array of row items. Each row is an array of content. */ function template_preprocess_views_view_unformatted(&$vars) { $view = $vars['view']; @@ -816,10 +884,16 @@ function template_preprocess_views_view_unformatted(&$vars) { } /** - * Display the view as an HTML list element + * Prepares variables for Views HTML list templates. + * + * Default template: views-view-list.html.twig. + * + * @param array $variables + * An associative array containing: + * - view: A View object. */ -function template_preprocess_views_view_list(&$vars) { - $handler = $vars['view']->style_plugin; +function template_preprocess_views_view_list(&$variables) { + $handler = $variables['view']->style_plugin; // Fetch classes from handler options. $class = explode(' ', $handler->options['class']); @@ -829,33 +903,35 @@ function template_preprocess_views_view_list(&$vars) { $wrapper_class = explode(' ', $handler->options['wrapper_class']); $wrapper_class = array_map('drupal_clean_css_identifier', $wrapper_class); - // Initialize a new attribute class for $class. - $attributes = new Attribute(array('class' => $class)); - // Initialize a new attribute class for $wrapper_class. if ($wrapper_class) { - $wrapper_class = new Attribute(array('class' => $wrapper_class)); - $vars['wrapper_prefix'] = ''; - $vars['wrapper_suffix'] = ''; + $variables['wrapper_attributes'] = new Attribute(array('class' => $wrapper_class)); } - $vars['list_type_prefix'] = '<' . $handler->options['type'] . $attributes . '>'; - $vars['list_type_suffix'] = 'options['type'] . '>'; + // Initialize a new attribute class for $class. + $variables['list']['attributes'] = new Attribute(array('class' => $class)); + $variables['list']['type'] = $handler->options['type']; - template_preprocess_views_view_unformatted($vars); + template_preprocess_views_view_unformatted($variables); } /** - * Preprocess an RSS feed - */ + * Prepares variables for RSS feed templates. + * + * Default template: views-view-rss.html.twig. + * + * @param array $vars + * An associative array containing: + * - view: A ViewExecutable object. + * - rows: The raw row data. +*/ function template_preprocess_views_view_rss(&$vars) { global $base_url; - $view = &$vars['view']; - $options = &$vars['options']; - $items = &$vars['rows']; + $view = $vars['view']; + $items = $vars['rows']; - $style = &$view->style_plugin; + $style = $view->style_plugin; $config = config('system.site'); @@ -875,8 +951,8 @@ function template_preprocess_views_view_rss(&$vars) { } $vars['title'] = check_plain($title); - // Figure out which display which has a path we're using for this feed. If there isn't - // one, use the global $base_url + // Figure out which display which has a path we're using for this feed. If + // there isn't one, use the global $base_url $link_display_id = $view->display_handler->getLinkDisplay(); if ($link_display_id && $display = $view->displayHandlers->get($link_display_id)) { $path = $view->displayHandlers->get($link_display_id)->getPath(); @@ -889,7 +965,8 @@ function template_preprocess_views_view_rss(&$vars) { $url_options['query'] = $view->exposed_raw_input; } - // Compare the link to the default home page; if it's the default home page, just use $base_url. + // Compare the link to the default home page; if it's the default home page, + // just use $base_url. if ($path == $config->get('page.front')) { $path = ''; } @@ -910,12 +987,16 @@ function template_preprocess_views_view_rss(&$vars) { } /** - * Default theme function for all RSS rows. + * Prepares variables for views RSS item templates. + * + * Default template: views-view-row-rss.html.twig. + * + * @param array $vars + * An associative array containing: + * - row: The raw results rows. */ function template_preprocess_views_view_row_rss(&$vars) { - $view = &$vars['view']; - $options = &$vars['options']; - $item = &$vars['row']; + $item = $vars['row']; $vars['title'] = check_plain($item->title); $vars['link'] = check_url($item->link); @@ -924,49 +1005,57 @@ function template_preprocess_views_view_row_rss(&$vars) { } /** - * Default theme function for all filter forms. + * Prepares variables for views exposed form templates. + * + * Default template: views-exposed-form.html.twig. + * + * @param array $vars + * An associative array containing: + * - form: A render element representing the form. */ function template_preprocess_views_exposed_form(&$vars) { $form = &$vars['form']; // Put all single checkboxes together in the last spot. - $checkboxes = ''; + $checkboxes = array(); if (!empty($form['q'])) { - $vars['q'] = drupal_render($form['q']); + $vars['q'] = $form['q']; } $vars['widgets'] = array(); foreach ($form['#info'] as $id => $info) { // Set aside checkboxes. if (isset($form[$info['value']]['#type']) && $form[$info['value']]['#type'] == 'checkbox') { - $checkboxes .= drupal_render($form[$info['value']]); + $checkboxes[] = $form[$info['value']]; continue; } $widget = new stdClass(); // set up defaults so that there's always something there. - $widget->label = $widget->operator = $widget->widget = $widget->description = NULL; + $widget->label = $widget->operator = $widget->widget = $widget->description = ''; $widget->id = isset($form[$info['value']]['#id']) ? $form[$info['value']]['#id'] : ''; if (!empty($info['label'])) { $widget->label = check_plain($info['label']); } - if (!empty($info['operator'])) { - $widget->operator = drupal_render($form[$info['operator']]); + if (!empty($info['operator']) && isset($form[$info['operator']])) { + $widget->operator = $form[$info['operator']]; } - $widget->widget = drupal_render($form[$info['value']]); + $widget->widget = $form[$info['value']]; if (!empty($info['description'])) { $widget->description = check_plain($info['description']); } $vars['widgets'][$id] = $widget; + // Unset the widget, so that it doesn't get rendered twice. + unset($form[$info['value']]); } // Wrap up all the checkboxes we set aside into a widget. - if ($checkboxes) { + if (!empty($checkboxes)) { $widget = new stdClass(); // set up defaults so that there's always something there. $widget->label = $widget->operator = $widget->widget = NULL; @@ -974,22 +1063,6 @@ function template_preprocess_views_exposed_form(&$vars) { $widget->widget = $checkboxes; $vars['widgets']['checkboxes'] = $widget; } - - if (isset($form['sort_by'])) { - $vars['sort_by'] = drupal_render($form['sort_by']); - $vars['sort_order'] = drupal_render($form['sort_order']); - } - if (isset($form['items_per_page'])) { - $vars['items_per_page'] = drupal_render($form['items_per_page']); - } - if (isset($form['offset'])) { - $vars['offset'] = drupal_render($form['offset']); - } - if (isset($form['reset'])) { - $vars['reset_button'] = drupal_render($form['reset']); - } - // This includes the submit button. - $vars['button'] = drupal_render_children($form); } /** @@ -1092,14 +1165,14 @@ function theme_views_mini_pager($vars) { * or some combination thereof. * * For each view, there will be a minimum of two templates used. The first - * is used for all views: views-view.tpl.php. + * is used for all views: views-view.html.twig. * * The second template is determined by the style selected for the view. Note * that certain aspects of the view can also change which style is used; for * example, arguments which provide a summary view might change the style to * one of the special summary styles. * - * The default style for all views is views-view-unformatted.tpl.php + * The default style for all views is views-view-unformatted.html.twig. * * Many styles will then farm out the actual display of each row to a row * style; the default row style is views-view-fields.tpl.php. @@ -1112,12 +1185,12 @@ function theme_views_mini_pager($vars) { * - views-view--foobar--page.tpl.php * - views-view--page.tpl.php * - views-view--foobar.tpl.php - * - views-view.tpl.php + * - views-view.html.twig * - * - views-view-unformatted--foobar--page.tpl.php - * - views-view-unformatted--page.tpl.php - * - views-view-unformatted--foobar.tpl.php - * - views-view-unformatted.tpl.php + * - views-view-unformatted--foobar--page.html.twig + * - views-view-unformatted--page.html.twig + * - views-view-unformatted--foobar.html.twig + * - views-view-unformatted.html.twig * * - views-view-fields--foobar--page.tpl.php * - views-view-fields--page.tpl.php diff --git a/core/modules/views_ui/templates/views-ui-display-tab-bucket.html.twig b/core/modules/views_ui/templates/views-ui-display-tab-bucket.html.twig new file mode 100644 index 0000000..1c99ae8 --- /dev/null +++ b/core/modules/views_ui/templates/views-ui-display-tab-bucket.html.twig @@ -0,0 +1,26 @@ +{# +/** + * @file + * Default theme implementation for each "box" on the display query edit screen. + * + * Available variables: + * - attributes: HTML attributes to apply to the container element. + * - actions: Action links such as "Add", "And/Or, Rearrange" for the content. + * - title: The title of the bucket, e.g. "Fields", "Filter Criteria", etc. + * - content: Content items such as fields or settings in this container. + * + * @see template_preprocess() + * @see template_preprocess_views_ui_display_tab_bucket() + * + * @ingroup themeable + */ +#} + + {% if title -%} +

    {{ title }}

    + {%- endif %} + {{ content }} + {% if actions -%} + {{ actions }} + {%- endif %} + diff --git a/core/modules/views_ui/templates/views-ui-display-tab-bucket.tpl.php b/core/modules/views_ui/templates/views-ui-display-tab-bucket.tpl.php deleted file mode 100644 index 1f643ed..0000000 --- a/core/modules/views_ui/templates/views-ui-display-tab-bucket.tpl.php +++ /dev/null @@ -1,16 +0,0 @@ - -
    > - -

    - - - - - -
    diff --git a/core/modules/views_ui/templates/views-ui-display-tab-setting.html.twig b/core/modules/views_ui/templates/views-ui-display-tab-setting.html.twig new file mode 100644 index 0000000..1b44d68 --- /dev/null +++ b/core/modules/views_ui/templates/views-ui-display-tab-setting.html.twig @@ -0,0 +1,26 @@ +{# +/** + * @file + * Default theme implementation for Views UI display tab settings. + * + * Template for each row inside the "boxes" on the display query edit screen. + * + * Available variables: + * - attributes: HTML attributes such as class for the container. + * - description: The description or label for this setting. + * - settings_links: A list of links for this setting. + * + * @see template_preprocess() + * @see template_preprocess_views_ui_display_tab_setting() + * + * @ingroup themeable + */ +#} + + {% if description -%} + {{ description }} + {%- endif %} + {% if settings_links %} + {{ settings_links|join(' | ') }} + {% endif %} + diff --git a/core/modules/views_ui/templates/views-ui-display-tab-setting.tpl.php b/core/modules/views_ui/templates/views-ui-display-tab-setting.tpl.php deleted file mode 100644 index be294b6..0000000 --- a/core/modules/views_ui/templates/views-ui-display-tab-setting.tpl.php +++ /dev/null @@ -1,15 +0,0 @@ - -
    > - - - - - - -
    diff --git a/core/modules/views_ui/views_ui.module b/core/modules/views_ui/views_ui.module index 0d461be..ae12212 100644 --- a/core/modules/views_ui/views_ui.module +++ b/core/modules/views_ui/views_ui.module @@ -220,7 +220,15 @@ function views_ui_library_info() { } /** - * Theme preprocess for views-view.tpl.php. + * Implements hook_preprocess_views_view(). + * + * Prepares variables for container templates. + * + * Default template: views-view.html.twig. + * + * @param array $vars + * An associative array containing: + * - view: The view object. */ function views_ui_preprocess_views_view(&$vars) { $view = $vars['view']; @@ -232,11 +240,11 @@ function views_ui_preprocess_views_view(&$vars) { '#theme' => 'views_ui_view_preview_section', '#view' => $view, '#section' => $section, - '#content' => is_array($vars[$section]) ? drupal_render($vars[$section]) : $vars[$section], + '#content' => $vars[$section], '#theme_wrappers' => array('views_ui_container'), '#attributes' => array('class' => 'contextual-region'), ); - $vars[$section] = drupal_render($vars[$section]); + $vars[$section] = $vars[$section]; } } } diff --git a/core/modules/views_ui/views_ui.theme.inc b/core/modules/views_ui/views_ui.theme.inc index e19cefa..0377ff5 100644 --- a/core/modules/views_ui/views_ui.theme.inc +++ b/core/modules/views_ui/views_ui.theme.inc @@ -15,14 +15,34 @@ function theme_views_ui_container($variables) { return '' . $element['#children'] . ''; } +/** + * Prepares variables for Views UI display tab setting templates. + * + * Default template: views-ui-display-tab-setting.html.twig. + * + * @param array $variables + * An associative array containing: + * - link: The setting's primary link. + * - settings_links: An array of links for this setting. + * - defaulted: A boolean indicating the setting is in its default state. + * - overridden: A boolean indicating the setting has been overridden from + * the default. + * - description: The setting's description. + * - description_separator: A boolean indicating a separator colon should be + * appended to the setting's description. + */ function template_preprocess_views_ui_display_tab_setting(&$variables) { static $zebra = 0; - $variables['zebra'] = ($zebra % 2 === 0 ? 'odd' : 'even'); + + // Add default class attributes. + $variables['attributes']['class'][] = 'views-display-setting'; + $variables['attributes']['class'][] = ($zebra % 2 === 0 ? 'odd' : 'even'); + $variables['attributes']['class'][] = 'clearfix'; + $zebra++; - // Put the main link to the left side + // Put the primary link to the left side. array_unshift($variables['settings_links'], $variables['link']); - $variables['settings_links'] = implode(' | ', $variables['settings_links']); $variables['attributes']['class'][] = 'views-ui-display-tab-setting'; @@ -31,7 +51,7 @@ function template_preprocess_views_ui_display_tab_setting(&$variables) { } if (!empty($variables['overridden'])) { $variables['attributes']['class'][] = 'overridden'; - $variables['attributes_array']['title'][] = t('Overridden'); + $variables['attributes']['title'][] = t('Overridden'); } // Append a colon to the description, if requested. @@ -40,6 +60,16 @@ function template_preprocess_views_ui_display_tab_setting(&$variables) { } } +/** + * Prepares variables for Views UI display tab bucket templates. + * + * Default template: views-ui-display-tab-bucket.html.twig. + * + * @param array $variables + * An associative array containing: + * - element: An associative array containing the properties of the element. + * Properties used: #name, #overridden, #children, #title, #actions. + */ function template_preprocess_views_ui_display_tab_bucket(&$variables) { $element = $variables['element']; @@ -50,12 +80,12 @@ function template_preprocess_views_ui_display_tab_bucket(&$variables) { } if (!empty($element['#overridden'])) { $variables['attributes']['class'][] = 'overridden'; - $variables['attributes_array']['title'][] = t('Overridden'); + $variables['attributes']['title'][] = t('Overridden'); } $variables['content'] = $element['#children']; $variables['title'] = $element['#title']; - $variables['actions'] = !empty($element['#actions']) ? render($element['#actions']) : ''; + $variables['actions'] = !empty($element['#actions']) ? $element['#actions'] : array(); } /** diff --git a/core/themes/bartik/bartik.theme b/core/themes/bartik/bartik.theme index 6245b4d..b6534f4 100644 --- a/core/themes/bartik/bartik.theme +++ b/core/themes/bartik/bartik.theme @@ -40,7 +40,21 @@ function bartik_process_html(&$variables) { } /** - * Implements hook_process_HOOK() for page.tpl.php. + * Implements hook_preprocess_HOOK() for page.html.twig. + */ +function bartik_preprocess_page(&$variables) { + // Pass the main menu and secondary menu to the template as render arrays. + if (!empty($variables['main_menu'])) { + $variables['main_menu']['#attributes']['id'] = 'main-menu-links'; + $variables['main_menu']['#attributes']['class'] = array('links', 'clearfix'); + } + if (!empty($variables['secondary_menu'])) { + $variables['secondary_menu']['#attributes']['id'] = 'secondary-menu-links'; + } +} + +/** + * Implements hook_process_HOOK() for page.html.twig. */ function bartik_process_page(&$variables) { $site_config = config('system.site'); @@ -78,7 +92,7 @@ function bartik_process_page(&$variables) { } /** - * Implements hook_preprocess_HOOK() for maintenance-page.tpl.php. + * Implements hook_preprocess_HOOK() for maintenance-page.html.twig. */ function bartik_preprocess_maintenance_page(&$variables) { // By default, site_name is set to Drupal if no db connection is available @@ -92,7 +106,7 @@ function bartik_preprocess_maintenance_page(&$variables) { } /** - * Implements hook_process_HOOK() for maintenance-page.tpl.php. + * Implements hook_process_HOOK() for maintenance-page.html.twig. */ function bartik_process_maintenance_page(&$variables) { $site_config = config('system.site'); @@ -111,6 +125,23 @@ function bartik_process_maintenance_page(&$variables) { } /** + * Implements hook_preprocess_HOOK() for node.html.twig. + */ +function bartik_preprocess_node(&$variables) { + // Operate on a copy of links in order to preserve the original. + $links = $variables['content']['links']; + + // Remove the "Add new comment" link on the teaser page or if the comment + // form is being displayed on the same page. + if ($variables['teaser'] || !empty($variables['content']['comments']['comment_form'])) { + unset($links['comment']['#links']['comment-add']); + } + + // Render links to test if there is content present to display. + $variables['links'] = drupal_render($links); +} + +/** * Implements theme_menu_tree(). */ function bartik_menu_tree($variables) { diff --git a/core/themes/bartik/templates/comment-wrapper.tpl.php b/core/themes/bartik/templates/comment-wrapper.tpl.php deleted file mode 100644 index fd8dfa7..0000000 --- a/core/themes/bartik/templates/comment-wrapper.tpl.php +++ /dev/null @@ -1,48 +0,0 @@ - -
    > - type != 'forum'): ?> - -

    - - - - - - -

    - - -
    diff --git a/core/themes/bartik/templates/comment.html.twig b/core/themes/bartik/templates/comment.html.twig new file mode 100644 index 0000000..f671539 --- /dev/null +++ b/core/themes/bartik/templates/comment.html.twig @@ -0,0 +1,119 @@ +{# +/** + * @file + * Bartik's theme implementation for comments. + * + * Available variables: + * - author: Comment author. Can be a link or plain text. + * - content: An array of comment items. Use render_var(content) to print them + * all, or print a subset such as render_var(content.field_example). Use + * hide(content.field_example) to temporarily suppress the printing of a + * given element. + * - created: Formatted date and time for when the comment was created. + * Preprocess functions can reformat it by calling format_date() with the + * desired parameters on the comment->created variable. + * - changed: Formatted date and time for when the comment was last changed. + * Preprocess functions can reformat it by calling format_date() with the + * desired parameters on the comment->changed variable. + * - new: New comment marker. + * - permalink: Comment permalink. + * - submitted: Submission information created from author and created + * during template_preprocess_comment(). + * - picture: Authors picture. + * - signature: Authors signature. + * - status: Comment status. Possible values are: + * unpublished, published, or preview. + * - title: Linked title. + * - classes: String of classes that can be used to style contextually through + * CSS. It can be manipulated through the variable classes_array from + * preprocess functions. The default values can be one or more of the + * following: + * - comment: The current template type; e.g., 'theming hook'. + * - by-anonymous: Comment by an unregistered user. + * - by-node-author: Comment by the author of the parent node. + * - preview: When previewing a new or edited comment. + * The following applies only to viewers who are registered users: + * - unpublished: An unpublished comment visible only to administrators. + * - by-viewer: Comment by the user currently viewing the page. + * - new: New comment since the last visit. + * - title_prefix (array): An array containing additional output populated by + * modules, intended to be displayed in front of the main title tag that + * appears in the template. + * - title_suffix (array): An array containing additional output populated by + * modules, intended to be displayed after the main title tag that appears in + * the template. + * + * These two variables are provided for context: + * - comment: Full comment object. + * - node: Node entity the comments are attached to. + * + * @see template_preprocess() + * @see template_preprocess_comment() + * + * @ingroup themeable + */ +#} +
    + +
    + +
    + {{ user_picture }} + + +
    + +
    +
    + + {% if new %} + {{ new }} + {% endif %} + + {{ title_prefix }} + {{ title }} + {{ title_suffix }} +
    + +
    + + + {# We hide the links now so that we can render them later. #} + {% hide(content.links) %} + {{ content }} + + + +
    + {% if signature %} +
    + {{ signature }} +
    + {% endif %} + + +
    + +
    diff --git a/core/themes/bartik/templates/comment.tpl.php b/core/themes/bartik/templates/comment.tpl.php deleted file mode 100644 index a8c4924..0000000 --- a/core/themes/bartik/templates/comment.tpl.php +++ /dev/null @@ -1,135 +0,0 @@ -created variable. - * - $changed: Formatted date and time for when the comment was last changed. - * Preprocess functions can reformat it by calling format_date() with the - * desired parameters on the $comment->changed variable. - * - $new: New comment marker. - * - $permalink: Comment permalink. - * - $submitted: Submission information created from $author and $created - * during template_preprocess_comment(). - * - $signature: Authors signature. - * - $status: Comment status. Possible values are: - * unpublished, published, or preview. - * - $title: Linked title. - * - $attributes: An instance of Attributes class that can be manipulated as an - * array and printed as a string. - * It includes the 'class' information, which includes: - * - comment: The current template type; e.g., 'theming hook'. - * - by-anonymous: Comment by an unregistered user. - * - by-node-author: Comment by the author of the parent node. - * - preview: When previewing a new or edited comment. - * The following applies only to viewers who are registered users: - * - unpublished: An unpublished comment visible only to administrators. - * - by-viewer: Comment by the user currently viewing the page. - * - new: New comment since the last visit. - * - $title_prefix (array): An array containing additional output populated by - * modules, intended to be displayed in front of the main title tag that - * appears in the template. - * - $title_suffix (array): An array containing additional output populated by - * modules, intended to be displayed after the main title tag that appears in - * the template. - * - * These variables are provided to give context about the parent comment (if - * any): - * - $comment_parent: Full parent comment object (if any). - * - $parent_author: Equivalent to $author for the parent comment. - * - $parent_created: Equivalent to $created for the parent comment. - * - $parent_changed: Equivalent to $changed for the parent comment. - * - $parent_title: Equivalent to $title for the parent comment. - * - $parent_permalink: Equivalent to $permalink for the parent comment. - * - $parent: A text string of parent comment submission information created - * from $parent_author and $parent_created during - * template_preprocess_comment(). This information is presented to help - * screen readers follow lengthy discussion threads. You can hide this from - * sighted users using the class element-invisible. - * - * These two variables are provided for context: - * - $comment: Full comment object. - * - $node: Node entity the comments are attached to. - * - * @see template_preprocess() - * @see template_preprocess_comment() - * @see template_process() - * @see theme_comment() - * - * @ingroup themeable - */ -?> -
    role="article"> - -
    - -
    - - - -
    - -
    -
    - - - - - - - > - -
    - -
    - -
    > - -
    - -
    - -
    - -
    - - - -
    - -
    diff --git a/core/themes/bartik/templates/maintenance-page.html.twig b/core/themes/bartik/templates/maintenance-page.html.twig new file mode 100644 index 0000000..bd7f2a9 --- /dev/null +++ b/core/themes/bartik/templates/maintenance-page.html.twig @@ -0,0 +1,66 @@ +{# +/** + * @file + * Bartik's theme implementation to display a single Drupal page while offline. + * + * All of the available variables are mirrored in page.tpl.php. + * + * @see template_preprocess() + * @see template_preprocess_maintenance_page() + * @see bartik_process_maintenance_page() + * + * @ingroup themeable + */ + #} + + + + {{ head }} + {{ head_title }} + {{ styles }} + {{ scripts }} + + + + + +
    + + + +
    +
    + + {% if title %}

    {{ title }}

    {% endif %} + {{ content }} + {% if messages %} +
    + {{ messages }} +
    + {% endif %} +
    +
    + +
    + + + diff --git a/core/themes/bartik/templates/maintenance-page.tpl.php b/core/themes/bartik/templates/maintenance-page.tpl.php deleted file mode 100644 index 8e56378..0000000 --- a/core/themes/bartik/templates/maintenance-page.tpl.php +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - <?php print $head_title; ?> - - - -> - - - -
    - - - -
    -
    - -

    - - -
    - -
    - -
    -
    - -
    - - - diff --git a/core/themes/bartik/templates/node.html.twig b/core/themes/bartik/templates/node.html.twig new file mode 100644 index 0000000..09ec0a3 --- /dev/null +++ b/core/themes/bartik/templates/node.html.twig @@ -0,0 +1,111 @@ +{# +/** + * @file + * Bartik's theme implementation to display a node. + * + * Available variables: + * - label: the title of the node. + * - content: node items. Use {{ content }} to print them all, + * or print a subset such as {{ content.field_example }}. Use + * {% hide(content.field_example) %} to temporarily suppress the printing + * of a given element. + * - user_picture: The node author's picture from user-picture.html.twig. + * - date: Formatted creation date. Preprocess functions can reformat it by + * calling format_date() with the desired parameters on + * $variables['created']. + * - name: Themed username of node author output from theme_username(). + * - node_url: Direct URL of the current node. + * - display_submitted: Whether submission information should be displayed. + * - submitted: Submission information created from name and date during + * template_preprocess_node(). + * - attributes: HTML attributes for the surrounding element. + * Attributes include the 'class' information, which contains: + * - node: The current template type; for example, "theming hook". + * - node-[type]: The current node type. For example, if the node is a + * "Article" it would result in "node-article". Note that the machine + * name will often be in a short form of the human readable label. + * - view-mode-[view_mode]: The View Mode of the node; for example, "teaser" + * or "full". + * - preview: Nodes in preview mode. + * The following are controlled through the node publishing options. + * - promoted: Nodes promoted to the front page. + * - sticky: Nodes ordered above other non-sticky nodes in teaser + * listings. + * - unpublished: Unpublished nodes visible only to administrators. + * - title_prefix: Additional output populated by modules, intended to be + * displayed in front of the main title tag that appears in the template. + * - title_suffix: Additional output populated by modules, intended to be + * displayed after the main title tag that appears in the template. + * + * Other variables: + * - node: Fully loaded node entity. + * - type: Node type; for example, page, article, etc. + * - comment_count: Number of comments attached to the node. + * - uid: User ID of the node author. + * - created: Time the node was published formatted as a Unix timestamp. + * + * Node status variables: + * - view_mode: View mode; for example, "teaser" or "full". + * - teaser: Flag for the teaser state. Will be true if view_mode is 'teaser'. + * - page: Flag for the full page state. Will be true if view_mode is 'full'. + * - promote: Flag for front page promotion state. + * - sticky: Flag for sticky post setting. + * - status: Flag for published status. + * - comment: State of comment settings for the node. + * - readmore: Flag for more state. Will be true if the teaser content of the + * node cannot hold the main body content. + * - is_front: Flag for front. Will be true when presented on the front page. + * - logged_in: Flag for authenticated user status. Will be true when the + * current user is a logged-in member. + * - is_admin: Flag for admin user status. Will be true when the current user + * is an administrator. + * + * Field variables: for each field instance attached to the node a corresponding + * variable is defined; for example, $node->body becomes body. When needing to + * access a field's raw values, developers/themers are strongly encouraged to + * use these variables. Otherwise they will have to explicitly specify the + * desired field language; for example, $node->body['en'], thus overriding any + * language negotiation rule that was previously applied. + * + * @see template_preprocess() + * @see template_preprocess_node() + * @see template_process() + * + * @ingroup themeable + */ +#} +
    + +
    + {{ title_prefix }} + {% if not page %} + + {{ label }} + + {% endif %} + {{ title_suffix }} + + {% if display_submitted %} + + {% endif %} +
    + +
    + {# We hide the comments and links now so that we can render them later. #} + {% hide(content.comments) %} + {% hide(content.links) %} + {{ content }} +
    + + {% if links %} +
    + {{ links }} +
    + {% endif %} + + {{ content.comments }} + +
    diff --git a/core/themes/bartik/templates/node.tpl.php b/core/themes/bartik/templates/node.tpl.php deleted file mode 100644 index eb5cf17..0000000 --- a/core/themes/bartik/templates/node.tpl.php +++ /dev/null @@ -1,121 +0,0 @@ -body becomes $body. - * When needing to access a field's raw values, developers/themers are strongly - * encouraged to use these variables. Otherwise they will have to explicitly - * specify the desired field language; for example, $node->body['en'], thus - * overriding any language negotiation rule that was previously applied. - * - * @see template_preprocess() - * @see template_preprocess_node() - * @see template_process() - * - * @ingroup themeable - */ -?> -
    role="article"> - -
    - - - > - - - - - - - - -
    - -
    > - -
    - - -
    - -
    - - - - -
    diff --git a/core/themes/bartik/templates/page.html.twig b/core/themes/bartik/templates/page.html.twig new file mode 100644 index 0000000..1af8907 --- /dev/null +++ b/core/themes/bartik/templates/page.html.twig @@ -0,0 +1,216 @@ +{# +/** + * @file + * Bartik's theme implementation to display a single page. + * + * The doctype, html, head and body tags are not in this template. Instead they + * can be found in the html.html.twig template normally located in the + * core/modules/system directory. + * + * Available variables: + * + * General utility variables: + * - base_path: The base URL path of the Drupal installation. Will usually be + * "/" unless you have installed Drupal in a sub-directory. + * - is_front: A flag indicating if the current page is the front page. + * - logged_in: A flag indicating if the user is registered and signed in. + * - is_admin: A flag indicating if the user has permission to access + * administration pages. + * + * Site identity: + * - front_page: The URL of the front page. Use this instead of base_path when + * linking to the front page. This includes the language domain or prefix. + * - logo: The url of the logo image, as defined in theme settings. + * - site_name: The name of the site. This is empty when displaying the site + * name has been disabled in the theme settings. + * - site_slogan: The slogan of the site. This is empty when displaying the site + * slogan has been disabled in theme settings. + * - hide_site_name: A flag indicating if the site name has been toggled off on + * the theme settings page. If hidden, the "element-invisible" class is added + * to make the site name visually hidden, but still accessible. + * - hide_site_slogan: A flag indicating if the site slogan has been toggled off + * on the theme settings page. If hidden, the "element-invisible" class is + * added to make the site slogan visually hidden, but still accessible. + * + * Navigation: + * - main_menu: The Main menu links for the site, if they have been configured. + * - secondary_menu: The Secondary menu links for the site, if they have been + * configured. + * - breadcrumb: The breadcrumb trail for the current page. + * + * Page content (in order of occurrence in the default page.html.twig): + * - title_prefix: Additional output populated by modules, intended to be + * displayed in front of the main title tag that appears in the template. + * - title: The page title, for use in the actual content. + * - title_suffix: Additional output populated by modules, intended to be + * displayed after the main title tag that appears in the template. + * - messages: Status and error messages. Should be displayed prominently. + * - tabs: Tabs linking to any sub-pages beneath the current page (e.g., the + * view and edit tabs when displaying a node). + * - action_links: Actions local to the page, such as "Add menu" on the menu + * administration interface. + * - feed_icons: All feed icons for the current page. + * - node: Fully loaded node, if there is an automatically-loaded node + * associated with the page and the node ID is the second argument in the + * page's path (e.g. node/12345 and node/12345/revisions, but not + * comment/reply/12345). + * + * Regions: + * - page.header: Items for the header region. + * - page.featured: Items for the featured region. + * - page.highlighted: Items for the highlighted content region. + * - page.help: Dynamic help text, mostly for admin pages. + * - page.content: The main content of the current page. + * - page.sidebar_first: Items for the first sidebar. + * - page.sidebar_second: Items for the second sidebar. + * - page.triptych_first: Items for the first triptych. + * - page.triptych_middle: Items for the middle triptych. + * - page.triptych_last: Items for the last triptych. + * - page.footer_firstcolumn: Items for the first footer column. + * - page.footer_secondcolumn: Items for the second footer column. + * - page.footer_thirdcolumn: Items for the third footer column. + * - page.footer_fourthcolumn: Items for the fourth footer column. + * - page.footer: Items for the footer region. + * + * @see template_preprocess() + * @see template_preprocess_page() + * @see bartik_preprocess_page() + * @see template_process() + * @see template_process_page() + * @see bartik_process_page() + * @see html.html.twig + * + * @ingroup themeable + */ +#} +
    + + + + {% if messages %} +
    + {{ messages }} +
    + {% endif %} + + {% if page.featured %} + + {% endif %} + +
    + {{ breadcrumb }} + +
    + {% if page.highlighted %}
    {{ page.highlighted }}
    {% endif %} + + {{ title_prefix }} + {% if title %} +

    + {{ title }} +

    + {% endif %} + {{ title_suffix }} + {% if tabs %} + + {% endif %} + {{ page.help }} + {% if action_links %} + + {% endif %} + {{ page.content }} + {{ feed_icons }} +
    + + {% if page.sidebar_first %} + + {% endif %} + + {% if page.sidebar_second %} + + {% endif %} + +
    + + {% if page.triptych_first or page.triptych_middle or page.triptych_last %} +
    + {% endif %} + + + +
    diff --git a/core/themes/bartik/templates/page.tpl.php b/core/themes/bartik/templates/page.tpl.php deleted file mode 100644 index 8b31e55..0000000 --- a/core/themes/bartik/templates/page.tpl.php +++ /dev/null @@ -1,249 +0,0 @@ - -
    - - - - -
    - -
    - - - - - - -
    - - - -
    -
    - - - -

    - -

    - - - - - - - - - - - - -
    - - - - - - - - - -
    - - -
    - - - - -
    diff --git a/core/themes/engines/twig/twig.engine b/core/themes/engines/twig/twig.engine index 1ba60a5..b541cdc 100644 --- a/core/themes/engines/twig/twig.engine +++ b/core/themes/engines/twig/twig.engine @@ -10,7 +10,9 @@ * Implements hook_theme(). */ function twig_theme($existing, $type, $theme, $path) { - return drupal_find_theme_templates($existing, '.html.twig', $path); + $templates = drupal_find_theme_functions($existing, array($theme)); + $templates += drupal_find_theme_templates($existing, '.html.twig', $path); + return $templates; } /** diff --git a/core/themes/seven/seven.theme b/core/themes/seven/seven.theme index 61212fe..0360b6e 100644 --- a/core/themes/seven/seven.theme +++ b/core/themes/seven/seven.theme @@ -6,12 +6,12 @@ */ /** - * Implements hook_preprocess_HOOK() for maintenance-page.tpl.php. + * Implements hook_preprocess_HOOK() for maintenance-page.html.twig. */ function seven_preprocess_maintenance_page(&$vars) { // While markup for normal pages is split into page.tpl.php and html.tpl.php, // the markup for the maintenance page is all in the single - // maintenance-page.tpl.php template. So, to have what's done in + // maintenance-page.html.twig template. So, to have what's done in // seven_preprocess_html() also happen on the maintenance page, it has to be // called here. seven_preprocess_html($vars); diff --git a/core/themes/seven/templates/maintenance-page.html.twig b/core/themes/seven/templates/maintenance-page.html.twig new file mode 100644 index 0000000..02af912 --- /dev/null +++ b/core/themes/seven/templates/maintenance-page.html.twig @@ -0,0 +1,57 @@ +{# +/** + * @file + * Seven's theme implementation to display a single Drupal page while offline. + * + * All of the available variables are mirrored in page.html.twig. + * + * @see template_preprocess() + * @see template_preprocess_maintenance_page() + * @see seven_preprocess_maintenance_page() + * + * @ingroup themeable + */ +#} + + + + {{ head_title }} + {{ head }} + {{ styles }} + {{ scripts }} + + + + {{ page_top }} + +
    + {% if title %}

    {{ title }}

    {% endif %} +
    + +
    + + +
    + {% if messages %} +
    {{ messages }}
    + {% endif %} + {% if help %} +
    + {{ help }} +
    + {% endif %} + {{ content }} +
    +
    + +
    + {{ page_bottom }} +
    + + + diff --git a/core/themes/seven/templates/maintenance-page.tpl.php b/core/themes/seven/templates/maintenance-page.tpl.php deleted file mode 100644 index fff11d8..0000000 --- a/core/themes/seven/templates/maintenance-page.tpl.php +++ /dev/null @@ -1,62 +0,0 @@ - - - - - <?php print $head_title; ?> - - - - - - - - -
    -

    -
    - -
    - - - -
    - -
    - - -
    - -
    - - -
    - -
    - -
    - -
    - - - diff --git a/core/themes/seven/templates/page.html.twig b/core/themes/seven/templates/page.html.twig new file mode 100644 index 0000000..7020706 --- /dev/null +++ b/core/themes/seven/templates/page.html.twig @@ -0,0 +1,110 @@ +{# +/** + * @file + * Seven's theme implementation to display a single Drupal page. + * + * The doctype, html, head, and body tags are not in this template. Instead + * they can be found in the html.html.twig template normally located in the + * core/modules/system directory. + * + * Available variables: + * + * General utility variables: + * - base_path: The base URL path of the Drupal installation. Will usually be + * "/" unless you have installed Drupal in a sub-directory. + * - is_front: A flag indicating if the current page is the front page. + * - logged_in: A flag indicating if the user is registered and signed in. + * - is_admin: A flag indicating if the user has permission to access + * administration pages. + * + * Site identity: + * - front_page: The URL of the front page. Use this instead of base_path when + * linking to the front page. This includes the language domain or prefix. + * - logo: The url of the logo image, as defined in theme settings. + * - site_name: The name of the site. This is empty when displaying the site + * name has been disabled in the theme settings. + * - site_slogan: The slogan of the site. This is empty when displaying the site + * slogan has been disabled in theme settings. + * + * Navigation: + * - main_menu: The Main menu links for the site, if they have been configured. + * - secondary_menu: The Secondary menu links for the site, if they have been + * configured. + * - breadcrumb: The breadcrumb trail for the current page. + * + * Page content (in order of occurrence in the default page.html.twig): + * - title_prefix: Additional output populated by modules, intended to be + * displayed in front of the main title tag that appears in the template. + * - title: The page title, for use in the actual content. + * - title_suffix: Additional output populated by modules, intended to be + * displayed after the main title tag that appears in the template. + * - messages: Status and error messages. Should be displayed prominently. + * - tabs: Tabs linking to any sub-pages beneath the current page (e.g., the + * view and edit tabs when displaying a node). + * - action_links: Actions local to the page, such as "Add menu" on the menu + * administration interface. + * - feed_icons: All feed icons for the current page. + * - node: Fully loaded node, if there is an automatically-loaded node + * associated with the page and the node ID is the second argument in the + * page's path (e.g. node/12345 and node/12345/revisions, but not + * comment/reply/12345). + * + * Regions: + * - page.header: Items for the header region. + * - page.highlighted: Items for the highlighted content region. + * - page.help: Dynamic help text, mostly for admin pages. + * - page.content: The main content of the current page. + * - page.sidebar_first: Items for the first sidebar. + * - page.sidebar_second: Items for the second sidebar. + * - page.footer: Items for the footer region. + * + * @see template_preprocess() + * @see template_preprocess_page() + * @see seven_preprocess_page() + * @see template_process() + * @see template_process_page() + * @see html.html.twig + * + * @ingroup themeable + */ +#} + + +
    + {% if secondary_local_tasks %} + + {% endif %} + +
    +
    + {% if messages %} +
    {{ messages }}
    + {% endif %} + {% if page.help %} +
    + {{ page.help }} +
    + {% endif %} + {% if action_links %} + + {% endif %} + {{ page.content }} +
    + +
    + {{ feed_icons }} +
    + +
    diff --git a/core/themes/seven/templates/page.tpl.php b/core/themes/seven/templates/page.tpl.php deleted file mode 100644 index d1a290c..0000000 --- a/core/themes/seven/templates/page.tpl.php +++ /dev/null @@ -1,54 +0,0 @@ - - - -
    - - - - -
    -
    - -
    - - -
    - -
    - - - -
    - - - -