Commit dcdb584f authored by Dries's avatar Dries

- Patch #595982 by moshe, chx: use #tableselect instead of ugly theming on...

- Patch #595982 by moshe, chx: use #tableselect instead of ugly theming on admin users and admin nodes.
parent 0feb34c6
......@@ -392,23 +392,18 @@ function node_admin_nodes() {
$multilanguage = (module_exists('translation') || db_query("SELECT COUNT(*) FROM {node} WHERE language <> ''")->fetchField());
// Build the sortable table header.
$header = array();
$header[] = theme('table_select_header_cell');
$header[] = array('data' => t('Title'), 'field' => 'n.title');
$header[] = array('data' => t('Type'), 'field' => 'n.type');
$header[] = array('data' => t('Author'), 'field' => 'u.name');
$header[] = array('data' => t('Status'), 'field' => 'n.status');
$header[] = array('data' => t('Updated'), 'field' => 'n.changed', 'sort' => 'desc');
$header = array(
'title' => array('data' => t('Title'), 'field' => 'n.title'),
'type' => array('data' => t('Type'), 'field' => 'n.type'),
'author' => array('data' => t('Author'), 'field' => 'u.name'),
'status' => array('data' => t('Status'), 'field' => 'n.status'),
'changed' => array('data' => t('Updated'), 'field' => 'n.changed', 'sort' => 'desc')
);
if ($multilanguage) {
$header[] = array('data' => t('Language'), 'field' => 'n.language');
$header['language'] = array('data' => t('Language'), 'field' => 'n.language');
}
$header[] = array('data' => t('Operations'));
$form['header'] = array(
'#type' => 'value',
'#value' => $header,
);
$header['operations'] = array('data' => t('Operations'));
$query = db_select('node', 'n')->extend('PagerDefault')->extend('TableSort');
$query->join('users', 'u', 'n.uid = u.uid');
node_build_filter_query($query);
......@@ -435,6 +430,7 @@ function node_admin_nodes() {
'#options' => $options,
'#default_value' => 'approve',
);
unset($options);
$form['options']['submit'] = array(
'#type' => 'submit',
'#value' => t('Update'),
......@@ -445,24 +441,26 @@ function node_admin_nodes() {
$destination = drupal_get_destination();
$nodes = array();
foreach ($result as $node) {
$nodes[$node->nid] = '';
$options = empty($node->language) ? array() : array('language' => $languages[$node->language]);
$form['title'][$node->nid] = array('#markup' => l($node->title, 'node/' . $node->nid, $options) . ' ' . theme('mark', node_mark($node->nid, $node->changed)));
$form['name'][$node->nid] = array('#markup' => check_plain(node_type_get_name($node)));
$form['username'][$node->nid] = array('#markup' => theme('username', $node));
$form['status'][$node->nid] = array('#markup' => ($node->status ? t('published') : t('not published')));
$form['changed'][$node->nid] = array('#markup' => format_date($node->changed, 'short'));
$l_options = empty($node->language) ? array() : array('language' => $languages[$node->language]);
$options[$node->nid] = array(
'title' => l($node->title, 'node/' . $node->nid, $l_options) . ' ' . theme('mark', node_mark($node->nid, $node->changed)),
'type' => check_plain(node_type_get_name($node)),
'author' => theme('username', $node),
'status' => $node->status ? t('published') : t('not published'),
'changed' => format_date($node->changed, 'short'),
);
if ($multilanguage) {
$form['language'][$node->nid] = array('#markup' => empty($node->language) ? t('Language neutral') : t($languages[$node->language]->name));
$options[$node->nid]['language'] = empty($node->language) ? t('Language neutral') : t($languages[$node->language]->name);
}
$form['operations'][$node->nid] = array('#markup' => l(t('edit'), 'node/' . $node->nid . '/edit', array('query' => $destination)));
$options[$node->nid]['operations'] = l(t('edit'), 'node/' . $node->nid . '/edit', array('query' => $destination));
}
$form['nodes'] = array(
'#type' => 'checkboxes',
'#options' => $nodes,
'#type' => 'tableselect',
'#header' => $header,
'#options' => $options,
'#empty' => t('No content available.'),
);
$form['pager'] = array('#markup' => theme('pager', NULL));
$form['#theme'] = 'node_admin_nodes';
return $form;
}
......@@ -508,53 +506,6 @@ function node_admin_nodes_submit($form, &$form_state) {
}
}
/**
* Theme node administration overview.
*
* @ingroup themeable
*/
function theme_node_admin_nodes($form) {
$output = '';
$output .= drupal_render($form['options']);
$header = $form['header']['#value'];
$has_posts = isset($form['title']) && is_array($form['title']);
if ($has_posts) {
$rows = array();
foreach (element_children($form['title']) as $key) {
$row = array();
$row[] = drupal_render($form['nodes'][$key]);
$row[] = drupal_render($form['title'][$key]);
$row[] = drupal_render($form['name'][$key]);
$row[] = drupal_render($form['username'][$key]);
$row[] = drupal_render($form['status'][$key]);
$row[] = drupal_render($form['changed'][$key]);
if (isset($form['language'])) {
$row[] = drupal_render($form['language'][$key]);
}
$row[] = drupal_render($form['operations'][$key]);
$rows[] = $row;
}
}
else {
$rows[] = array(
array('data' => t('No content available.'), 'colspan' => count($header)),
);
}
$output .= theme('table', $header, $rows);
if ($form['pager']['#markup']) {
$output .= drupal_render($form['pager']);
}
$output .= drupal_render_children($form);
return $output;
}
function node_multiple_delete_confirm($form, &$form_state, $nodes) {
$form['nodes'] = array('#prefix' => '<ul>', '#suffix' => '</ul>', '#tree' => TRUE);
// array_filter returns only elements with TRUE values
......
......@@ -139,10 +139,6 @@ function node_theme() {
'arguments' => array('form' => NULL),
'file' => 'node.admin.inc',
),
'node_admin_nodes' => array(
'arguments' => array('form' => NULL),
'file' => 'node.admin.inc',
),
'node_add_list' => array(
'arguments' => array('content' => NULL),
'file' => 'node.pages.inc',
......
......@@ -128,13 +128,12 @@ function user_filter_form_submit($form, &$form_state) {
function user_admin_account() {
$header = array(
array(),
array('data' => t('Username'), 'field' => 'u.name'),
array('data' => t('Status'), 'field' => 'u.status'),
t('Roles'),
array('data' => t('Member for'), 'field' => 'u.created', 'sort' => 'desc'),
array('data' => t('Last access'), 'field' => 'u.access'),
t('Operations')
'username' => array('data' => t('Username'), 'field' => 'u.name'),
'status' => array('data' => t('Status'), 'field' => 'u.status'),
'roles' => array('data' => t('Roles')),
'member_for' => array('data' => t('Member for'), 'field' => 'u.created', 'sort' => 'desc'),
'access' => array('data' => t('Last access'), 'field' => 'u.access'),
'operations' => array('data' => t('Operations')),
);
$query = db_select('users', 'u');
......@@ -168,6 +167,7 @@ function user_admin_account() {
'#options' => $options,
'#default_value' => 'unblock',
);
$options = array();
$form['options']['submit'] = array(
'#type' => 'submit',
'#value' => t('Update'),
......@@ -179,23 +179,28 @@ function user_admin_account() {
$roles = user_roles(TRUE);
$accounts = array();
foreach ($result as $account) {
$accounts[$account->uid] = '';
$form['name'][$account->uid] = array('#markup' => theme('username', $account));
$form['status'][$account->uid] = array('#markup' => $status[$account->status]);
$users_roles = array();
$roles_result = db_query('SELECT rid FROM {users_roles} WHERE uid = :uid', array(':uid' => $account->uid));
foreach ($roles_result as $user_role) {
$users_roles[] = $roles[$user_role->rid];
}
asort($users_roles);
$form['roles'][$account->uid][0] = array('#markup' => theme('item_list', $users_roles));
$form['member_for'][$account->uid] = array('#markup' => format_interval(REQUEST_TIME - $account->created));
$form['last_access'][$account->uid] = array('#markup' => $account->access ? t('@time ago', array('@time' => format_interval(REQUEST_TIME - $account->access))) : t('never'));
$form['operations'][$account->uid] = array('#markup' => l(t('edit'), "user/$account->uid/edit", array('query' => $destination)));
$options[$account->uid] = array(
'username' => theme('username', $account),
'status' => $status[$account->status],
'roles' => theme('item_list', $users_roles),
'member_for' => format_interval(REQUEST_TIME - $account->created),
'access' => $account->access ? t('@time ago', array('@time' => format_interval(REQUEST_TIME - $account->access))) : t('never'),
'operations' => l(t('edit'), "user/$account->uid/edit", array('query' => $destination)),
);
}
$form['accounts'] = array(
'#type' => 'checkboxes',
'#options' => $accounts
'#type' => 'tableselect',
'#header' => $header,
'#options' => $options,
'#empty' => t('No people available.'),
);
$form['pager'] = array('#markup' => theme('pager', NULL));
......@@ -798,51 +803,6 @@ function user_admin_role_submit($form, &$form_state) {
return;
}
/**
* Theme user administration overview.
*
* @ingroup themeable
*/
function theme_user_admin_account($form) {
// Overview table:
$header = array(
theme('table_select_header_cell'),
array('data' => t('Username'), 'field' => 'u.name'),
array('data' => t('Status'), 'field' => 'u.status'),
t('Roles'),
array('data' => t('Member for'), 'field' => 'u.created', 'sort' => 'desc'),
array('data' => t('Last access'), 'field' => 'u.access'),
t('Operations')
);
$output = drupal_render($form['options']);
if (!empty($form['name'])) {
foreach (element_children($form['name']) as $key) {
$rows[] = array(
drupal_render($form['accounts'][$key]),
drupal_render($form['name'][$key]),
drupal_render($form['status'][$key]),
drupal_render($form['roles'][$key]),
drupal_render($form['member_for'][$key]),
drupal_render($form['last_access'][$key]),
drupal_render($form['operations'][$key]),
);
}
}
else {
$rows[] = array(array('data' => t('No users available.'), 'colspan' => '7'));
}
$output .= theme('table', $header, $rows);
if ($form['pager']['#markup']) {
$output .= drupal_render($form['pager']);
}
$output .= drupal_render_children($form);
return $output;
}
/**
* Theme the new-role form.
*
......
......@@ -65,10 +65,6 @@ function user_theme() {
'arguments' => array('form' => NULL),
'file' => 'user.admin.inc',
),
'user_admin_account' => array(
'arguments' => array('form' => NULL),
'file' => 'user.admin.inc',
),
'user_filter_form' => array(
'arguments' => array('form' => NULL),
'file' => 'user.admin.inc',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment