- Patch #40200 by Ax, Drewish, Zen et al: user_view() isn't merging view items correctly + CSS cleanup + form handling cleanup.
parent
8e47cc95c5
commit
d958fad0d6
|
@ -406,6 +406,13 @@ dl.multiselect .form-item {
|
|||
float: right;
|
||||
margin: 0 1em 1em 0;
|
||||
}
|
||||
.profile dt {
|
||||
margin: 1em 0 0.2em 0;
|
||||
font-weight: bold;
|
||||
}
|
||||
.profile dd {
|
||||
margin:0;
|
||||
}
|
||||
.node-form .poll-form fieldset {
|
||||
display: block;
|
||||
}
|
||||
|
|
|
@ -42,11 +42,11 @@ function blog_access($op, $node) {
|
|||
*/
|
||||
function blog_user($type, &$edit, &$user) {
|
||||
if ($type == 'view' && user_access('edit own blog', $user)) {
|
||||
$form['blog'] = array(
|
||||
'#type' => 'item', '#title' => t('Blog'),
|
||||
'#value' => l(t('view recent blog entries'), "blog/$user->uid", array('title' => t("Read %username's latest blog entries.", array('%username' => $user->name))))
|
||||
$items[] = array('title' => t('Blog'),
|
||||
'value' => l(t('view recent blog entries'), "blog/$user->uid", array('title' => t("Read %username's latest blog entries.", array('%username' => $user->name)))),
|
||||
'class' => 'blog',
|
||||
);
|
||||
return array(t('History') => $form);
|
||||
return array(t('History') => $items);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,11 +42,11 @@ function blog_access($op, $node) {
|
|||
*/
|
||||
function blog_user($type, &$edit, &$user) {
|
||||
if ($type == 'view' && user_access('edit own blog', $user)) {
|
||||
$form['blog'] = array(
|
||||
'#type' => 'item', '#title' => t('Blog'),
|
||||
'#value' => l(t('view recent blog entries'), "blog/$user->uid", array('title' => t("Read %username's latest blog entries.", array('%username' => $user->name))))
|
||||
$items[] = array('title' => t('Blog'),
|
||||
'value' => l(t('view recent blog entries'), "blog/$user->uid", array('title' => t("Read %username's latest blog entries.", array('%username' => $user->name)))),
|
||||
'class' => 'blog',
|
||||
);
|
||||
return array(t('History') => $form);
|
||||
return array(t('History') => $items);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -315,11 +315,13 @@ function profile_view_profile($user) {
|
|||
if ($value = profile_view_field($user, $field)) {
|
||||
$description = ($field->visibility == PROFILE_PRIVATE) ? t('The content of this field is private and only visible to yourself.') : '';
|
||||
$title = ($field->type != 'checkbox') ? check_plain($field->title) : '';
|
||||
$form = array('#title' => $title, '#value' => $value, '#description' => $description);
|
||||
$fields[$field->category][$field->name] = theme('item', $form);
|
||||
$item = array('title' => $title,
|
||||
'value' => $value,
|
||||
'class' => $field->name,
|
||||
);
|
||||
$fields[$field->category][] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
|
|
|
@ -315,11 +315,13 @@ function profile_view_profile($user) {
|
|||
if ($value = profile_view_field($user, $field)) {
|
||||
$description = ($field->visibility == PROFILE_PRIVATE) ? t('The content of this field is private and only visible to yourself.') : '';
|
||||
$title = ($field->type != 'checkbox') ? check_plain($field->title) : '';
|
||||
$form = array('#title' => $title, '#value' => $value, '#description' => $description);
|
||||
$fields[$field->category][$field->name] = theme('item', $form);
|
||||
$item = array('title' => $title,
|
||||
'value' => $value,
|
||||
'class' => $field->name,
|
||||
);
|
||||
$fields[$field->category][] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
|
|
|
@ -459,8 +459,12 @@ function user_search($op = 'search', $keys = null) {
|
|||
*/
|
||||
function user_user($type, &$edit, &$user, $category = NULL) {
|
||||
if ($type == 'view') {
|
||||
$form['member'] = array('#type' => 'item', '#title' => t('Member for'), '#value' => format_interval(time() - $user->created));
|
||||
return array(t('History') => array('history'=> drupal_get_form('member', $form)));
|
||||
$items[] = array('title' => t('Member for'),
|
||||
'value' => format_interval(time() - $user->created),
|
||||
'class' => 'member',
|
||||
);
|
||||
|
||||
return array(t('History') => $items);
|
||||
}
|
||||
|
||||
if ($type == 'form' && $category == 'account') {
|
||||
|
@ -612,19 +616,24 @@ function theme_user_picture($account) {
|
|||
/**
|
||||
* Theme a user page
|
||||
* @param $account the user object
|
||||
* @param $fields an mulidimensional array for the fields, in the form of
|
||||
* array('category1'=> array('name1' => field1, 'name2' => field2),
|
||||
* 'category2'=> array('name3' => field3, 'name4' => field4, 'name5' => field5),
|
||||
* .. etc);
|
||||
* @param $fields a multidimensional array for the fields, in the form of array (
|
||||
* 'category1' => array(item_array1, item_array2), 'category2' => array(item_array3,
|
||||
* .. etc.). Item arrays are formatted as array(array('title' => 'item title',
|
||||
* 'value' => 'item value', 'class' => 'class-name'), ... etc.). Module names are incorporated
|
||||
* into the CSS class.
|
||||
*
|
||||
* @ingroup themeable
|
||||
*/
|
||||
function theme_user_profile($account, $fields) {
|
||||
$output = "<div class=\"profile\">\n";
|
||||
$output .= theme('user_picture', $account);
|
||||
foreach ($fields as $category => $value) {
|
||||
$value = implode('', $value);
|
||||
$output .= theme('box', $category, $value);
|
||||
foreach ($fields as $category => $items) {
|
||||
$output .= "<h2 class=\"title\">$category</h2>\n";
|
||||
$output .= '<dl>';
|
||||
foreach ($items as $item) {
|
||||
$output .= sprintf('<dt class="%s">%s:</dt><dd class="%s">%s</dd>', $item['class'], $item['title'], $item['class'], $item['value']);
|
||||
}
|
||||
$output .= '</dl>';
|
||||
}
|
||||
$output .= "</div>\n";
|
||||
|
||||
|
@ -1304,8 +1313,11 @@ function user_view($uid = 0) {
|
|||
$fields = array();
|
||||
foreach (module_list() as $module) {
|
||||
if ($data = module_invoke($module, 'user', 'view', '', $account)) {
|
||||
foreach ($data as $category => $content) {
|
||||
$fields[$category] = $content;
|
||||
foreach ($data as $category => $items) {
|
||||
foreach ($items as $item) {
|
||||
$item['class'] = "$module-". $item['class'];
|
||||
$fields[$category][] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1942,5 +1954,3 @@ function user_autocomplete($string) {
|
|||
print drupal_implode_autocomplete($matches);
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -459,8 +459,12 @@ function user_search($op = 'search', $keys = null) {
|
|||
*/
|
||||
function user_user($type, &$edit, &$user, $category = NULL) {
|
||||
if ($type == 'view') {
|
||||
$form['member'] = array('#type' => 'item', '#title' => t('Member for'), '#value' => format_interval(time() - $user->created));
|
||||
return array(t('History') => array('history'=> drupal_get_form('member', $form)));
|
||||
$items[] = array('title' => t('Member for'),
|
||||
'value' => format_interval(time() - $user->created),
|
||||
'class' => 'member',
|
||||
);
|
||||
|
||||
return array(t('History') => $items);
|
||||
}
|
||||
|
||||
if ($type == 'form' && $category == 'account') {
|
||||
|
@ -612,19 +616,24 @@ function theme_user_picture($account) {
|
|||
/**
|
||||
* Theme a user page
|
||||
* @param $account the user object
|
||||
* @param $fields an mulidimensional array for the fields, in the form of
|
||||
* array('category1'=> array('name1' => field1, 'name2' => field2),
|
||||
* 'category2'=> array('name3' => field3, 'name4' => field4, 'name5' => field5),
|
||||
* .. etc);
|
||||
* @param $fields a multidimensional array for the fields, in the form of array (
|
||||
* 'category1' => array(item_array1, item_array2), 'category2' => array(item_array3,
|
||||
* .. etc.). Item arrays are formatted as array(array('title' => 'item title',
|
||||
* 'value' => 'item value', 'class' => 'class-name'), ... etc.). Module names are incorporated
|
||||
* into the CSS class.
|
||||
*
|
||||
* @ingroup themeable
|
||||
*/
|
||||
function theme_user_profile($account, $fields) {
|
||||
$output = "<div class=\"profile\">\n";
|
||||
$output .= theme('user_picture', $account);
|
||||
foreach ($fields as $category => $value) {
|
||||
$value = implode('', $value);
|
||||
$output .= theme('box', $category, $value);
|
||||
foreach ($fields as $category => $items) {
|
||||
$output .= "<h2 class=\"title\">$category</h2>\n";
|
||||
$output .= '<dl>';
|
||||
foreach ($items as $item) {
|
||||
$output .= sprintf('<dt class="%s">%s:</dt><dd class="%s">%s</dd>', $item['class'], $item['title'], $item['class'], $item['value']);
|
||||
}
|
||||
$output .= '</dl>';
|
||||
}
|
||||
$output .= "</div>\n";
|
||||
|
||||
|
@ -1304,8 +1313,11 @@ function user_view($uid = 0) {
|
|||
$fields = array();
|
||||
foreach (module_list() as $module) {
|
||||
if ($data = module_invoke($module, 'user', 'view', '', $account)) {
|
||||
foreach ($data as $category => $content) {
|
||||
$fields[$category] = $content;
|
||||
foreach ($data as $category => $items) {
|
||||
foreach ($items as $item) {
|
||||
$item['class'] = "$module-". $item['class'];
|
||||
$fields[$category][] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1942,5 +1954,3 @@ function user_autocomplete($string) {
|
|||
print drupal_implode_autocomplete($matches);
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue