commit 9253a2283ce6547319828296bfd15d93b8f7c0d1 Author: Joel Pittet Date: Tue Apr 2 00:27:02 2013 -0700 removed type=table conversions and extra twig templates diff --git a/core/modules/user/templates/user-admin-permissions.html.twig b/core/modules/user/templates/user-admin-permissions.html.twig deleted file mode 100644 index 0e19b14..0000000 --- a/core/modules/user/templates/user-admin-permissions.html.twig +++ /dev/null @@ -1,21 +0,0 @@ -{# -/** - * @file - * Default theme implementation for the administer permissions page. - * - * Available variables: - * - system_compact_link: A rendered link to show or hide inline help - * descriptions. - * - table: table of permissions - * - attributes: An array of html attributes to apply to the table tag. - * - form: Rendered form children elements. - * - * @see template_preprocess() - * @see template_preprocess_user_admin_permissions() - * - * @ingroup themeable - */ -#} -{{ system_compact_link }} -{{ table }} -{{ form }} diff --git a/core/modules/user/templates/user-admin-roles.html.twig b/core/modules/user/templates/user-admin-roles.html.twig deleted file mode 100644 index 90cf85a..0000000 --- a/core/modules/user/templates/user-admin-roles.html.twig +++ /dev/null @@ -1,18 +0,0 @@ -{# -/** - * @file - * Default theme implementation for the role order and new role form. - * - * Available variables - * - table: table of roles - * - attributes: An array of html attributes to apply to the table tag. - * - form: Remaining form elements for user roles table. - * - * @see template_preprocess() - * @see template_preprocess_user_admin_roles() - * - * @ingroup themeable - */ -#} -{{ table }} -{{ form }} diff --git a/core/modules/user/templates/user-permission-description.html.twig b/core/modules/user/templates/user-permission-description.html.twig index 9285fb6..d1d5562 100644 --- a/core/modules/user/templates/user-permission-description.html.twig +++ b/core/modules/user/templates/user-permission-description.html.twig @@ -17,10 +17,10 @@ */ #} {% if not hide %} - {% if description is defined %} + {% if description %} {{- description -}} {% endif %} - {% if warning is defined %} + {% if warning %} {{ warning }} {% endif %} {% endif %} diff --git a/core/modules/user/templates/user-picture.html.twig b/core/modules/user/templates/user-picture.html.twig deleted file mode 100644 index 1a70920..0000000 --- a/core/modules/user/templates/user-picture.html.twig +++ /dev/null @@ -1,22 +0,0 @@ -{# -/** - * @file - * Default theme implementation to display a picture for the user's account. - * - * Available variables: - * - user_picture: Image set by the user or the site's default. Will be linked - * depending on the viewer's permission to view the user's profile page. - * - account: Array of account information. Potentially unsafe. Be sure to - * check_plain() before use. - * - * @see template_preprocess() - * @see template_preprocess_user_picture() - * - * @ingroup themeable - */ -#} -{% if user_picture %} -
- {{ user_picture }} -
-{% endif %} diff --git a/core/modules/user/templates/user-profile.html.twig b/core/modules/user/templates/user-profile.html.twig deleted file mode 100644 index a23d69d..0000000 --- a/core/modules/user/templates/user-profile.html.twig +++ /dev/null @@ -1,32 +0,0 @@ -{# -/** - * @file - * Default theme implementation to present all user profile data. - * - * This template is used when viewing a registered member's profile page, - * e.g., example.com/user/123. 123 being the users ID. - * - * Use user_profile to print all profile items, or print a subset such as - * user_profile.user_picture. Always print user_profile at the end of the - * template in order to print all remaining items. - * - * If the item is a category, it will contain all its profile items. By - * default, user_profile.member_for is provided, which contains data on the - * user's history. user_profile.user_picture is available for showing the - * account picture. Other data can be included by modules. - * - * Available variables: - * - user_profile: Profile items. - * - Field variables: for each field attached to the user a corresponding - * variable is defined; e.g., account.field_example has a variable - * field_example defined. - * - * @see template_preprocess() - * @see template_preprocess_user_profile() - * - * @ingroup themeable - */ -#} - - {{ user_profile }} - diff --git a/core/modules/user/templates/user-signature.html.twig b/core/modules/user/templates/user-signature.html.twig index 024cd0a..9f490ef 100644 --- a/core/modules/user/templates/user-signature.html.twig +++ b/core/modules/user/templates/user-signature.html.twig @@ -15,4 +15,4 @@ * @ingroup themeable */ #} -
{{ signature }}
+{{ signature }} diff --git a/core/modules/user/templates/user.html.twig b/core/modules/user/templates/user.html.twig index c85b191..d8b8242 100644 --- a/core/modules/user/templates/user.html.twig +++ b/core/modules/user/templates/user.html.twig @@ -6,19 +6,19 @@ * This template is used when viewing a registered user's page, * e.g., example.com/user/123. 123 being the users ID. * - * Use render($content) to print all content, or print a subset - * such as render($content['field_example']). + * Use {{ content }} to print all content, or print a subset + * such as {{ content.field_example }}. * By default, $user_profile['summary'] is provided, which contains data on the * user's history. Other data can be included by modules. * * Available variables: - * - $content: An array of content items. Use render() to print them. + * - content: A list of content items. * - 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 + * 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 + * field language, e.g. account.field_example['en'], thus overriding any * language negotiation rule that was previously applied. * * @see template_preprocess() @@ -27,6 +27,8 @@ * @ingroup themeable */ #} -
- {{ content }} + + {% if content is not empty %} + {{- content -}} + {% endif %}
diff --git a/core/modules/user/templates/username.html.twig b/core/modules/user/templates/username.html.twig index c76eaa7..4524dba 100644 --- a/core/modules/user/templates/username.html.twig +++ b/core/modules/user/templates/username.html.twig @@ -28,5 +28,5 @@ in the output. Additional classes may be added as array elements like {% set attributes.class = attributes.class|merge(["myclass"]) %} #} - {{ name }}{{ extra }} + {{ name }}{{ extra }} {% endif %} diff --git a/core/modules/user/user.admin.inc b/core/modules/user/user.admin.inc index 3804763..aee6ea1 100644 --- a/core/modules/user/user.admin.inc +++ b/core/modules/user/user.admin.inc @@ -775,15 +775,15 @@ function user_admin_permissions_submit($form, &$form_state) { } /** - * Preprocess variables for the administer permissions page. + * Returns HTML for the administer permissions page. * - * Default template: user-admin-permissions.html.twig. - * - * @param array $variables + * @param $variables * An associative array containing: * - form: A render element representing the form. + * + * @ingroup themeable */ -function template_preprocess_user_admin_permissions(&$variables) { +function theme_user_admin_permissions($variables) { $form = $variables['form']; $roles = user_role_names(); @@ -811,9 +811,10 @@ function template_preprocess_user_admin_permissions(&$variables) { foreach (element_children($form['role_names']) as $rid) { $header[] = array('data' => drupal_render($form['role_names'][$rid]), 'class' => array('checkbox')); } - $variables['system_compact_link'] = theme('system_compact_link'); - $variables['table'] = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'permissions'))); - $variables['form'] = drupal_render_children($form); + $output = theme('system_compact_link'); + $output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'permissions'))); + $output .= drupal_render_children($form); + return $output; } /** @@ -920,15 +921,15 @@ function user_admin_roles_order_submit($form, &$form_state) { } /** - * Preprocess variables for user admin roles template. + * Returns HTML for the role order and new role form. * - * Default template: user-admin-roles.html.twig. - * - * @param array $variables + * @param $variables * An associative array containing: * - form: A render element representing the form. + * + * @ingroup themeable */ -function template_preprocess_user_admin_roles(&$variables) { +function theme_user_admin_roles($variables) { $form = $variables['form']; $header = array(t('Name'), t('Weight'), t('Operations')); @@ -937,10 +938,7 @@ function template_preprocess_user_admin_roles(&$variables) { foreach (element_children($form['roles'][$rid]) as $column) { $row[] = drupal_render($form['roles'][$rid][$column]); } - $rows[] = array( - 'data' => $row, - 'class' => array('draggable'), - ); + $rows[] = array('data' => $row, 'class' => array('draggable')); } // Distribute the role add form into table columns. @@ -955,16 +953,15 @@ function template_preprocess_user_admin_roles(&$variables) { $row[] = drupal_render($form['role']); // Empty placeholder for the weight column. $row[] = ''; - $row[] = array( - 'data' => drupal_render($actions), - 'colspan' => 2, - ); + $row[] = array('data' => drupal_render($actions), 'colspan' => 2); $rows[] = array('data' => $row); drupal_add_tabledrag('user-roles', 'order', 'sibling', 'role-weight'); - $variables['table'] = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'user-roles'))); - $variables['form'] = drupal_render_children($form); + $output = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'user-roles'))); + $output .= drupal_render_children($form); + + return $output; } /** diff --git a/core/modules/user/user.module b/core/modules/user/user.module index 15bf5ff..7330d95 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -98,12 +98,10 @@ function user_theme() { 'user_admin_permissions' => array( 'render element' => 'form', 'file' => 'user.admin.inc', - 'template' => 'user-admin-permissions', ), 'user_admin_roles' => array( 'render element' => 'form', 'file' => 'user.admin.inc', - 'template' => 'user-admin-roles', ), 'user_permission_description' => array( 'variables' => array('permission_item' => NULL, 'hide' => NULL), @@ -813,8 +811,14 @@ function template_process_username(&$variables) { // This purposefully does not use // \Drupal\Component\Utility\NestedArray::mergeDeep() for performance // reasons, since it is potentially called very often. - $attrs = (array) $variables['attributes']; - $variables['link_options']['attributes'] = new Attribute(array_merge_recursive($variables['link_attributes'], $attrs)); + $attributes = (array) $variables['attributes']; + $variables['link_options']['attributes'] = new Attribute(array_merge_recursive($variables['link_attributes'], $attributes)); + $variables['link'] = array( + '#theme' => 'link', + '#text' => $variables['name'] . $variables['extra'], + '#path' => $variables['link_path'], + '#options' => $variables['link_options'], + ); } }