Commit 79d8390f authored by Dries's avatar Dries

- Patch #161510 by dvessel: tplified user.module.

parent 99276849
<?php
// $Id
/**
* @file user-picture.tpl.php
* Default theme implementation to present an picture configured for the
* user's account.
*
* Available variables:
* - $picture: Image set by the user or the site's default. Will be linked
* depending on the viewer's permission to view the users profile page.
* - $account: Array of account information. Potentially unsafe. Be sure to
* check_plain() before use.
*
* @see template_preprocess_user_picture()
*/
?>
<div class="picture">
<?php print $picture; ?>
</div>
<?php
// $Id
/**
* @file user-profile-category.tpl.php
* Default theme implementation to present profile categories (groups of
* profile items).
*
* Categories are defined when configuring user profile fields for the site.
* It can also be defined by modules. All profile items for a category will be
* output through the $profile_items variable.
*
* @see user-profile-item.tpl.php
* where each profile item is rendered. It is implemented as a definition
* list by default.
* @see user-profile.tpl.php
* where all items and categories are collected and printed out.
*
* Available variables:
* - $title: Category title for the group of items.
* - $profile_items: All the items for the group rendered through
* user-profile-item.tpl.php.
* - $attributes: HTML attributes. Usually renders classes.
*
* @see template_preprocess_user_profile_category()
*/
?>
<?php if ($title) : ?>
<h3><?php print $title; ?></h3>
<?php endif; ?>
<dl<?php print $attributes; ?>>
<?php print $profile_items; ?>
</dl>
<?php
// $Id
/**
* @file user-profile-item.tpl.php
* Default theme implementation to present profile items (values from user
* account profile fields or modules).
*
* This template is used to loop through and render each field configured
* for the user's account. It can also be the data from modules. The output is
* grouped by categories.
*
* @see user-profile-category.tpl.php
* for the parent markup. Implemented as a definition list by default.
* @see user-profile.tpl.php
* where all items and categories are collected and printed out.
*
* Available variables:
* - $title: Field title for the profile item.
* - $value: User defined value for the profile item or data from a module.
* - $attributes: HTML attributes. Usually renders classes.
*
* @see template_preprocess_user_profile_item()
*/
?>
<dt<?php print $attributes; ?>><?php print $title; ?></dt>
<dd<?php print $attributes; ?>><?php print $value; ?></dd>
<?php
// $Id
/**
* @file user-profile.tpl.php
* 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.
*
* By default, all user profile data is printed out with the $user_profile
* variable. If there is a need to break it up you can use $profile instead.
* It is keyed to the name of each category or other data attached to the
* account. If it is a category it will contain all the profile items. By
* default $profile['summary'] is provided which contains data on the user's
* history. Other data can be included by modules. $profile['picture'] is
* available by default showing the account picture.
*
* Also keep in mind that profile items and their categories can be defined by
* site administrators. They are also available within $profile. For example,
* if a site is configured with a category of "contact" with
* fields for of addresses, phone numbers and other related info, then doing a
* straight print of $profile['contact'] will output everything in the
* category. This is useful for altering source order and adding custom
* markup for the group.
*
* To check for all available data within $profile, use the code below.
*
* <?php print '<pre>'. check_plain(print_r($profile, 1)) .'</pre>'; ?>
*
* @see user-profile-category.tpl.php
* where the html is handled for the group.
* @see user-profile-field.tpl.php
* where the html is handled for each item in the group.
*
* Available variables:
* - $user_profile: All user profile data. Ready for print.
* - $profile: Keyed array of profile categories and their items or other data
* provided by modules.
*
* @see template_preprocess_user_profile()
*/
?>
<div class="profile">
<?php print $user_profile; ?>
</div>
......@@ -31,18 +31,19 @@ function user_theme() {
return array(
'user_picture' => array(
'arguments' => array('account' => NULL),
'file' => 'user-picture',
),
'user_profile' => array(
'arguments' => array('account' => NULL),
'file' => 'user_profile',
'file' => 'user-profile',
),
'user_profile_category' => array(
'arguments' => array('element' => NULL),
'file' => 'user_profile_category',
'file' => 'user-profile-category',
),
'user_profile_item' => array(
'arguments' => array('element' => NULL),
'file' => 'user_profile_item',
'file' => 'user-profile-item',
),
'user_list' => array(
'arguments' => array('users' => NULL, 'title' => NULL),
......@@ -729,8 +730,18 @@ function user_block($op = 'list', $delta = 0, $edit = array()) {
}
}
function theme_user_picture($account) {
/**
* Process variables for user-picture.tpl.php.
*
* The $variables array contains the following arguments:
* - $account
*
* @see user-picture.tpl.php
*/
function template_preprocess_user_picture(&$variables) {
$variables['picture'] = '';
if (variable_get('user_pictures', 0)) {
$account = $variables['account'];
if (!empty($account->picture) && file_exists($account->picture)) {
$picture = file_create_url($account->picture);
}
......@@ -740,19 +751,22 @@ function theme_user_picture($account) {
if (isset($picture)) {
$alt = t("@user's picture", array('@user' => $account->name ? $account->name : variable_get('anonymous', t('Anonymous'))));
$picture = theme('image', $picture, $alt, $alt, '', FALSE);
$variables['picture'] = theme('image', $picture, $alt, $alt, '', FALSE);
if (!empty($account->uid) && user_access('access user profiles')) {
$picture = l($picture, "user/$account->uid", array('attributes' => array('title' => t('View user profile.')), 'html' => TRUE));
$attributes = array('attributes' => array('title' => t('View user profile.')), 'html' => TRUE);
$variables['picture'] = l($variables['picture'], "user/$account->uid", $attributes);
}
return "<div class=\"picture\">$picture</div>";
}
}
}
/**
* Make a list of users.
* @param $items an array with user objects. Should contain at least the name and uid
*
* @param $users
* An array with user objects. Should contain at least the name and uid.
* @param $title
* (optional) Title to pass on to theme_item_list().
*
* @ingroup themeable
*/
......@@ -765,6 +779,58 @@ function theme_user_list($users, $title = NULL) {
return theme('item_list', $items, $title);
}
/**
* Process variables for user-profile.tpl.php.
*
* The $variables array contains the following arguments:
* - $account
*
* @see user-picture.tpl.php
*/
function template_preprocess_user_profile(&$variables) {
$variables['profile'] = array();
// Provide keyed variables so themers can print each section independantly.
foreach (element_children($variables['account']->content) as $key) {
$variables['profile'][$key] = drupal_render($variables['account']->content[$key]);
}
// Collect all profiles to make it easier to print all items at once.
$variables['user_profile'] = implode($variables['profile']);
}
/**
* Process variables for user-profile-item.tpl.php.
*
* The $variables array contains the following arguments:
* - $element
*
* @see user-profile-item.tpl.php
*/
function template_preprocess_user_profile_item(&$variables) {
$variables['title'] = $variables['element']['#title'];
$variables['value'] = $variables['element']['#value'];
$variables['attributes'] = '';
if (isset($variables['element']['#attributes'])) {
$variables['attributes'] = drupal_attributes($variables['element']['#attributes']);
}
}
/**
* Process variables for user-profile-category.tpl.php.
*
* The $variables array contains the following arguments:
* - $element
*
* @see user-profile-category.tpl.php
*/
function template_preprocess_user_profile_category(&$variables) {
$variables['title'] = $variables['element']['#title'];
$variables['profile_items'] = $variables['element']['#children'];
$variables['attributes'] = '';
if (isset($variables['element']['#attributes'])) {
$variables['attributes'] = drupal_attributes($variables['element']['#attributes']);
}
}
function user_is_anonymous() {
return !$GLOBALS['user']->uid;
}
......@@ -1718,11 +1784,9 @@ function user_edit_submit($form, &$form_state) {
}
function user_view($account) {
global $user;
// Retrieve all profile fields and store data in content element.
$account->content = user_build_content($account);
drupal_set_title(check_plain($account->name));
// Retrieve all profile fields and attach to $account->content.
user_build_content($account);
/**
* To theme user profiles, copy modules/user/user_profile.tpl.php
* to your theme directory, and edit it as instructed in that file's comments.
......
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