diff --git a/includes/common.inc b/includes/common.inc index f54f29a..20c3c4e 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -6446,7 +6446,7 @@ function drupal_common_theme() { 'variables' => array(), ), 'table' => array( - 'variables' => array('header' => NULL, 'rows' => NULL, 'attributes' => array(), 'caption' => NULL, 'colgroups' => array(), 'sticky' => TRUE, 'empty' => ''), + 'variables' => array('header' => NULL, 'rows' => NULL, 'attributes' => array(), 'caption' => NULL, 'colgroups' => array(), 'rowgroup' => array(), 'rowgroups' => array(), 'sticky' => TRUE, 'empty' => ''), ), 'tablesort_indicator' => array( 'variables' => array('style' => NULL), diff --git a/includes/theme.inc b/includes/theme.inc index 6c2b640..2bac089 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -1579,6 +1579,8 @@ function theme_breadcrumb($variables) { * ) * ); * @endcode + * Note that when rowgroups are used rows need to grouped using an extra + * associative array. See colgroups variable for more info. * - attributes: An array of HTML attributes to apply to the table tag. * - caption: A localized string to use for the tag. * - colgroups: An array of column groups. Each element of the array can be @@ -1589,9 +1591,9 @@ function theme_breadcrumb($variables) { * include a "data" attribute. To add attributes to COL elements, set the * "data" attribute with an array of columns, each of which is an * associative array of HTML attributes. - * Here's an example for $colgroup: + * Here's an example for $colgroups: * @code - * $colgroup = array( + * $colgroups = array( * // COLGROUP with one COL element. * array( * array( @@ -1612,6 +1614,43 @@ function theme_breadcrumb($variables) { * These optional tags are used to group and set properties on columns * within a table. For example, one may easily group three columns and * apply same background style to all. + * - rowgroup: An array of attributes applied to the TBODY element(s). + * Rowgroup specific attributes set in rowgroups override these attributes. + * - rowgroups: An associative array of row groups. Each element represents a + * rowgroup identifiable by it's key. When this variable is set, rows are + * expected to be grouped by rowgroup using an associative array while their + * keys point to the keys of this variable. Elements of this variable are + * expected to be an array of attributes which will be applied to the TBODY + * element representing that rowgroup. + * Here's an example for $rows combined with $rowgroups: + * @code + * $rowgroups = array( + * 'funky' => array( // Attributes for the TBODY element. + * 'title' => 'Funky rows', + * 'class' => array('funky'), + * ), + * 'jazzy' => array( // Attributes for the TBODY element. + * 'title' => 'Jazzy rows', + * 'class' => array('jazzy'), + * ), + * ); + * $rows = array( + * // Rows of the funky rowgroup. + * 'funky' => array( + * // Simple row + * array( + * 'Cell 1', 'Cell 2', 'Cell 3' + * ), + * ), + * // Rows of the jazzy rowgroup. + * 'jazzy' => array( + * // Row with attributes on the row and some of its cells. + * array( + * 'data' => array('Cell 1', array('data' => 'Cell 2', 'colspan' => 2)), 'class' => array('funky') + * ), + * ), + * ); + * @endcode * - sticky: Use a "sticky" table header. * - empty: The message to display in an extra row if table does not have any * rows. @@ -1622,6 +1661,8 @@ function theme_table($variables) { $attributes = $variables['attributes']; $caption = $variables['caption']; $colgroups = $variables['colgroups']; + $rowgroup = $variables['rowgroup']; + $rowgroups = $variables['rowgroups']; $sticky = $variables['sticky']; $empty = $variables['empty']; @@ -1705,46 +1746,58 @@ function theme_table($variables) { $ts = array(); } - // Format the table rows: - if (count($rows)) { - $output .= "\n"; - $flip = array('even' => 'odd', 'odd' => 'even'); - $class = 'even'; - foreach ($rows as $number => $row) { - $attributes = array(); + if (!count($rowgroups)) { + $rowgroups = array(); + $rows_by_groups = array($rows); + } + else { + $rows_by_groups = $rows; + } - // Check if we're dealing with a simple or complex row - if (isset($row['data'])) { - foreach ($row as $key => $value) { - if ($key == 'data') { - $cells = $value; - } - else { - $attributes[$key] = $value; + // Format the table rows: + foreach ($rows_by_groups as $rowgroup_id => $rows) { + if (count($rows)) { + $attributes = isset($rowgroups[$rowgroup_id]) ? $rowgroup + $rowgroups[$rowgroup_id] : $rowgroup; + $output .= '\n"; + + $flip = array('even' => 'odd', 'odd' => 'even'); + $class = 'even'; + foreach ($rows as $number => $row) { + $attributes = array(); + + // Check if we're dealing with a simple or complex row + if (isset($row['data'])) { + foreach ($row as $key => $value) { + if ($key == 'data') { + $cells = $value; + } + else { + $attributes[$key] = $value; + } } } - } - else { - $cells = $row; - } - if (count($cells)) { - // Add odd/even class - if (empty($row['no_striping'])) { - $class = $flip[$class]; - $attributes['class'][] = $class; + else { + $cells = $row; } + if (count($cells)) { + // Add odd/even class + if (empty($row['no_striping'])) { + $class = $flip[$class]; + $attributes['class'][] = $class; + } - // Build row - $output .= ' '; - $i = 0; - foreach ($cells as $cell) { - $cell = tablesort_cell($cell, $header, $ts, $i++); - $output .= _theme_table_cell($cell); + // Build row + $output .= ' '; + $i = 0; + foreach ($cells as $cell) { + $cell = tablesort_cell($cell, $header, $ts, $i++); + $output .= _theme_table_cell($cell); + } + $output .= " \n"; } - $output .= " \n"; } + $output .= "\n"; } - $output .= "\n"; } $output .= "\n"; diff --git a/modules/file/tests/file.test b/modules/file/tests/file.test index 32de9dc..4ba6a5f 100644 --- a/modules/file/tests/file.test +++ b/modules/file/tests/file.test @@ -518,7 +518,7 @@ class FileFieldWidgetTestCase extends FileFieldTestCase { // Remove access comments permission from anon user. $edit = array( - '1[access comments]' => FALSE, + '1[comment][access comments]' => FALSE, ); $this->drupalPost('admin/people/permissions', $edit, t('Save permissions')); diff --git a/modules/search/search.test b/modules/search/search.test index 488a45e..7204407 100644 --- a/modules/search/search.test +++ b/modules/search/search.test @@ -751,9 +751,9 @@ class SearchCommentTestCase extends DrupalWebTestCase { $this->drupalPost('admin/config/content/formats/' . $filtered_html_format_id, $edit, t('Save configuration')); // Allow anonymous users to search content. $edit = array( - DRUPAL_ANONYMOUS_RID . '[search content]' => 1, - DRUPAL_ANONYMOUS_RID . '[access comments]' => 1, - DRUPAL_ANONYMOUS_RID . '[post comments]' => 1, + DRUPAL_ANONYMOUS_RID . '[search][search content]' => 1, + DRUPAL_ANONYMOUS_RID . '[comment][access comments]' => 1, + DRUPAL_ANONYMOUS_RID . '[comment][post comments]' => 1, ); $this->drupalPost('admin/people/permissions', $edit, t('Save permissions')); diff --git a/modules/system/system.admin.inc b/modules/system/system.admin.inc index 9dffd59..b5ae574 100644 --- a/modules/system/system.admin.inc +++ b/modules/system/system.admin.inc @@ -783,6 +783,30 @@ function system_modules($form, $form_state = array()) { return system_modules_confirm_form($visible_files, $form_state['storage']); } + $form['modulesfilter'] = array( + '#type' => 'textfield', + '#title' => t('Filter modules'), + '#description' => t('Enter keywords to filter the list of modules.'), + ); + + $form['modulesfilter']['#attached']['library'][] = array('system', 'instantfilter'); + $form['modulesfilter']['#attached']['js'][] = array('type' => 'setting', 'data' => array( + 'instantfilter' => array( + 'edit-modulesfilter' => array( + 'container' => '#system-modules', + 'groups' => array( + 'fieldset' => array(), + 'fieldset table > tbody' => array('items' => 'tr', 'zebra' => TRUE) + ), + 'items' => array( + 'table > tbody > tr' => array( + 'ignore' => 'td.version, .admin-requirements, td.help, td.permissions, td.configure', + ) + ) + ) + ), + )); + $modules = array(); $form['modules'] = array('#tree' => TRUE); @@ -2541,7 +2565,7 @@ function theme_system_modules_fieldset($variables) { $label .= ' for="' . $module['enable']['#id'] . '"'; } $row[] = $label . '>' . drupal_render($module['name']) . ''; - $row[] = drupal_render($module['version']); + $row[] = array('data' => drupal_render($module['version']), 'class' => 'version'); // Add the description, along with any modules it requires. $description = drupal_render($module['description']); if ($module['#requires']) { diff --git a/modules/system/system.module b/modules/system/system.module index 3737af1..f77b679 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -1221,6 +1221,16 @@ function system_library() { ), ); + // Instant Filter. + $libraries['instantfilter'] = array( + 'title' => 'Instant Filter', + 'website' => 'http://drupal.org/node/396478', + 'version' => '1.0', + 'js' => array( + 'misc/instantfilter.js' => array(), + ), + ); + // Farbtastic. $libraries['farbtastic'] = array( 'title' => 'Farbtastic', diff --git a/modules/user/user.admin.inc b/modules/user/user.admin.inc index 4789e7e..9b256e5 100644 --- a/modules/user/user.admin.inc +++ b/modules/user/user.admin.inc @@ -655,6 +655,27 @@ function user_admin_settings() { */ function user_admin_permissions($form, $form_state, $rid = NULL) { + $form['permissionsfilter'] = array( + '#type' => 'textfield', + '#title' => t('Permissions modules'), + '#description' => t('Enter keywords to filter the list of permissions.'), + ); + + $form['permissionsfilter']['#attached']['library'][] = array('system', 'instantfilter'); + $form['permissionsfilter']['#attached']['js'][] = array('type' => 'setting', 'data' => array( + 'instantfilter' => array( + 'edit-permissionsfilter' => array( + 'container' => '#user-admin-permissions', + 'groups' => array( + 'table > tbody' => array('items' => 'tr:has(td.permission)', 'zebra' => TRUE) + ), + 'items' => array( + 'table > tbody > tr:has(td.permission)' => array() + ) + ) + ), + )); + // Retrieve role names for columns. $role_names = user_roles(); if (is_numeric($rid)) { @@ -683,10 +704,12 @@ function user_admin_permissions($form, $form_state, $rid = NULL) { foreach ($modules as $module => $display_name) { if ($permissions = module_invoke($module, 'permission')) { - $form['permission'][] = array( - '#markup' => $module_info[$module]['name'], + $form['permission'][$module] = array( '#id' => $module, ); + $form['permission'][$module][] = array( + '#markup' => $module_info[$module]['name'], + ); foreach ($permissions as $perm => $perm_item) { // Fill in default values for the permission. $perm_item += array( @@ -695,7 +718,7 @@ function user_admin_permissions($form, $form_state, $rid = NULL) { 'warning' => !empty($perm_item['restrict access']) ? t('Warning: Give to trusted roles only; this permission has security implications.') : '', ); $options[$perm] = ''; - $form['permission'][$perm] = array( + $form['permission'][$module][$perm] = array( '#type' => 'item', '#markup' => $perm_item['title'], '#description' => theme('user_permission_description', array('permission_item' => $perm_item, 'hide' => $hide_descriptions)), @@ -758,32 +781,36 @@ function theme_user_admin_permissions($variables) { $form = $variables['form']; $roles = user_roles(); - foreach (element_children($form['permission']) as $key) { - $row = array(); - // Module name - if (is_numeric($key)) { - $row[] = array('data' => drupal_render($form['permission'][$key]), 'class' => array('module'), 'id' => 'module-' . $form['permission'][$key]['#id'], 'colspan' => count($form['role_names']['#value']) + 1); - } - else { - // Permission row. - $row[] = array( - 'data' => drupal_render($form['permission'][$key]), - 'class' => array('permission'), - ); - foreach (element_children($form['checkboxes']) as $rid) { - $form['checkboxes'][$rid][$key]['#title'] = $roles[$rid] . ': ' . $form['permission'][$key]['#markup']; - $form['checkboxes'][$rid][$key]['#title_display'] = 'invisible'; - $row[] = array('data' => drupal_render($form['checkboxes'][$rid][$key]), 'class' => array('checkbox')); + foreach (element_children($form['permission']) as $module) { + $rowgroups[$module] = array('id' => 'module-' . $form['permission'][$module]['#id']); + foreach (element_children($form['permission'][$module]) as $key) { + $row = array(); + // Module name + if (is_numeric($key)) { + $row[] = array('data' => drupal_render($form['permission'][$module][$key]), 'class' => array('module'), 'id' => 'module-' . $form['permission'][$module][$key]['#id'], 'colspan' => count($form['role_names']['#value']) + 1); + } + else { + // Permission row. + $row[] = array( + 'data' => drupal_render($form['permission'][$module][$key]), + 'class' => array('permission'), + ); + foreach (element_children($form['checkboxes']) as $rid) { + $form['checkboxes'][$rid][$key]['#title'] = $roles[$rid] . ': ' . $form['permission'][$module][$key]['#markup']; + $form['checkboxes'][$rid][$key]['#title_display'] = 'invisible'; + $row[] = array('data' => drupal_render($form['checkboxes'][$rid][$key]), 'class' => array('checkbox')); + } } } - $rows[] = $row; + $rows[$module][] = $row; } $header[] = (t('Permission')); foreach (element_children($form['role_names']) as $rid) { $header[] = array('data' => drupal_render($form['role_names'][$rid]), 'class' => array('checkbox')); } $output = theme('system_compact_link'); - $output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'permissions'))); + $output .= drupal_render($form['permissionsfilter']); + $output .= theme('table', array('header' => $header, 'rows' => $rows, 'rowgroups' => $rowgroups, 'attributes' => array('id' => 'permissions'))); $output .= drupal_render_children($form); return $output; } diff --git a/modules/user/user.test b/modules/user/user.test index 6ecbfac..21c8a7e 100644 --- a/modules/user/user.test +++ b/modules/user/user.test @@ -1125,7 +1125,7 @@ class UserPermissionsTestCase extends DrupalWebTestCase { // Add a permission. $this->assertFalse(user_access('administer nodes', $account), t('User does not have "administer nodes" permission.')); $edit = array(); - $edit[$rid . '[administer nodes]'] = TRUE; + $edit[$rid . '[node][administer nodes]'] = TRUE; $this->drupalPost('admin/people/permissions', $edit, t('Save permissions')); $this->assertText(t('The changes have been saved.'), t('Successful save message displayed.')); drupal_static_reset('user_access'); @@ -1135,7 +1135,7 @@ class UserPermissionsTestCase extends DrupalWebTestCase { // Remove a permission. $this->assertTrue(user_access('access user profiles', $account), t('User has "access user profiles" permission.')); $edit = array(); - $edit[$rid . '[access user profiles]'] = FALSE; + $edit[$rid . '[user][access user profiles]'] = FALSE; $this->drupalPost('admin/people/permissions', $edit, t('Save permissions')); $this->assertText(t('The changes have been saved.'), t('Successful save message displayed.')); drupal_static_reset('user_access');