Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
225
Merge Requests
225
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
79d8390f
Commit
79d8390f
authored
Aug 02, 2007
by
Dries
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Patch
#161510
by dvessel: tplified user.module.
parent
99276849
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
200 additions
and
13 deletions
+200
-13
modules/user/user-picture.tpl.php
modules/user/user-picture.tpl.php
+19
-0
modules/user/user-profile-category.tpl.php
modules/user/user-profile-category.tpl.php
+33
-0
modules/user/user-profile-item.tpl.php
modules/user/user-profile-item.tpl.php
+26
-0
modules/user/user-profile.tpl.php
modules/user/user-profile.tpl.php
+45
-0
modules/user/user.module
modules/user/user.module
+77
-13
No files found.
modules/user/user-picture.tpl.php
0 → 100644
View file @
79d8390f
<?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>
modules/user/user-profile-category.tpl.php
0 → 100644
View file @
79d8390f
<?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>
modules/user/user-profile-item.tpl.php
0 → 100644
View file @
79d8390f
<?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>
modules/user/user-profile.tpl.php
0 → 100644
View file @
79d8390f
<?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>
modules/user/user.module
View file @
79d8390f
...
...
@@ -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.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment