- <?php
- * @file
- * Theme functions for the User module.
- */
-
- * Returns HTML for a list of users.
- *
- * @param $variables
- * An associative array containing:
- * - users: An array with user objects. Should contain at least the name and
- * uid.
- * - title: (optional) Title to pass on to theme_item_list().
- *
- * @ingroup themeable
- */
- function theme_user_list($variables) {
- $users = $variables['users'];
- $title = $variables['title'];
- $items = array();
-
- if (!empty($users)) {
- foreach ($users as $user) {
- $items[] = theme('username', array('account' => $user));
- }
- }
- return theme('item_list', array('items' => $items, 'title' => $title));
- }
-
- * Returns HTML for a user signature.
- *
- * @param $variables
- * An associative array containing:
- * - signature: The user's signature.
- *
- * @ingroup themeable
- */
- function theme_user_signature($variables) {
- $signature = $variables['signature'];
- $output = '';
-
- if ($signature) {
- $output .= '<div class="clear">';
- $output .= '<div>—</div>';
- $output .= $signature;
- $output .= '</div>';
- }
-
- return $output;
- }
-
- * Returns HTML for a username, potentially linked to the user's page.
- *
- * @param $variables
- * An associative array containing:
- * - account: The user object to format.
- * - name: The user's name, sanitized.
- * - extra: Additional text to append to the user's name, sanitized.
- * - link_path: The path or URL of the user's profile page, home page, or
- * other desired page to link to for more information about the user.
- * - link_options: An array of options to pass to the l() function's $options
- * parameter if linking the user's name to the user's page.
- * - attributes: An array of attributes to pass to the
- * backdrop_attributes() function if not linking to the user's page.
- *
- * @see template_preprocess_username()
- */
- function theme_username($variables) {
- if (isset($variables['link_path'])) {
-
-
-
-
-
-
-
-
-
-
- $variables['link_options']['attributes'] = array_merge_recursive($variables['link_attributes'], $variables['attributes']);
-
- $output = l($variables['name'] . $variables['extra'], $variables['link_path'], $variables['link_options']);
- }
- else {
- $output = '<span' . backdrop_attributes($variables['attributes']) . '>' . $variables['name'] . $variables['extra'] . '</span>';
- }
- return $output;
- }
-
- * Returns HTML for the administer permissions page.
- *
- * @param $variables
- * An associative array containing:
- * - form: A render element representing the form.
- *
- * @ingroup themeable
- */
- function theme_user_admin_permissions($variables) {
- $form = $variables['form'];
-
- $roles = user_roles();
- foreach (element_children($form['permission']) as $key) {
- $row = array();
-
- if (is_numeric($key)) {
- $row[] = array('data' => backdrop_render($form['permission'][$key]), 'class' => array('module'), 'id' => 'module-' . $form['permission'][$key]['#id'], 'colspan' => count($form['roles']['#value']) + 1);
- }
- else {
-
- $row[] = array(
- 'data' => backdrop_render($form['permission'][$key]),
- 'class' => array('permission'),
- );
- foreach (element_children($form['checkboxes']) as $role_name) {
- $form['checkboxes'][$role_name][$key]['#title'] = $roles[$role_name] . ': ' . $form['permission'][$key]['#markup'];
- $form['checkboxes'][$role_name][$key]['#title_display'] = 'attribute';
- $row[] = array('data' => backdrop_render($form['checkboxes'][$role_name][$key]), 'class' => array('checkbox'));
- }
- }
- $rows[] = $row;
- }
- $header[] = (t('Permission'));
- foreach (element_children($form['role_names']) as $role_name) {
- $header[] = array('data' => backdrop_render($form['role_names'][$role_name]), 'class' => array('checkbox'));
- }
- $output = '';
- $output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'permissions')));
- $output .= backdrop_render_children($form);
- return $output;
- }
-
- * Returns HTML for an individual permission description.
- *
- * @param $variables
- * An associative array containing:
- * - permission_item: An associative array representing the permission whose
- * description is being themed. Useful keys include:
- * - description: The text of the permission description.
- * - warning: A security-related warning message about the permission (if
- * there is one).
- *
- * @ingroup themeable
- */
- function theme_user_permission_description($variables) {
- $description = array();
- $permission_item = $variables['permission_item'];
- if (!empty($permission_item['description'])) {
- $description[] = $permission_item['description'];
- }
- if (!empty($permission_item['warning'])) {
- $description[] = '<em class="permission-warning">' . $permission_item['warning'] . '</em>';
- }
- if (!empty($description)) {
- return implode(' ', $description);
- }
- }
-
- * Returns HTML for the role order form.
- *
- * @param $variables
- * An associative array containing:
- * - form: A render element representing the form.
- *
- * @ingroup themeable
- */
- function theme_user_admin_roles($variables) {
- $form = $variables['form'];
-
- $header = array(t('Name'), t('Weight'), t('Operations'));
- foreach (element_children($form['roles']) as $role_name) {
- $label = $form['roles'][$role_name]['#role']->label;
- if (in_array($role_name, array(BACKDROP_ANONYMOUS_ROLE, BACKDROP_AUTHENTICATED_ROLE))) {
- $label .= ' ' . t('(required)');
- }
-
- $row = array();
- $row[] = theme('label_machine_name__role', array(
- 'label' => $label,
- 'machine_name' => $form['roles'][$role_name]['#role']->name,
- ));
- $row[] = backdrop_render($form['roles'][$role_name]['weight']);
- $row[] = backdrop_render($form['roles'][$role_name]['operations']);
- $rows[] = array('data' => $row, 'class' => array('draggable'));
- }
-
- backdrop_add_tabledrag('user-roles', 'order', 'sibling', 'role-weight');
-
- $output = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'user-roles')));
- $output .= backdrop_render_children($form);
-
- return $output;
- }
-
- * Process variables for user-picture.tpl.php.
- *
- * The $variables array contains the following arguments:
- * - $account: A user, node or comment object with 'name', 'uid' and 'picture'
- * fields.
- *
- * @see user-picture.tpl.php
- */
- function template_preprocess_user_picture(&$variables) {
- $site_config = config('system.core');
- $variables['user_picture'] = '';
- if ($site_config->get('user_pictures')) {
- $account = $variables['account'];
- if (!empty($account->picture)) {
-
-
-
-
-
-
-
- if (is_numeric($account->picture)) {
- $account->picture = file_load($account->picture);
- }
- if (!empty($account->picture->uri)) {
- $filepath = $account->picture->uri;
- }
- }
- elseif ($site_config->get('user_picture_default')) {
- $filepath = $site_config->get('user_picture_default');
- }
- if (isset($filepath)) {
- $alt = t("@user's picture", array('@user' => user_format_name($account)));
-
-
- if (module_exists('image') && file_valid_uri($filepath) && $style = $site_config->get('user_picture_style')) {
- $variables['user_picture'] = theme('image_style', array('style_name' => $style, 'uri' => $filepath, 'alt' => $alt, 'title' => $alt));
- }
- else {
- $variables['user_picture'] = theme('image', array('path' => $filepath, 'alt' => $alt, 'title' => $alt));
- }
- if (!empty($account->uid) && user_access('access user profiles')) {
- $attributes = array('attributes' => array('title' => t('View user profile.')), 'html' => TRUE);
- $variables['user_picture'] = l($variables['user_picture'], "user/$account->uid", $attributes);
- }
- }
- }
- }
-
- * Preprocesses variables for theme_username().
- *
- * Modules that make any changes to variables like 'name' or 'extra' must insure
- * that the final string is safe to include directly in the output by using
- * check_plain() or filter_xss().
- */
- function template_preprocess_username(&$variables) {
- $account = $variables['account'];
-
- $variables['extra'] = '';
- if (empty($account->uid)) {
- $variables['uid'] = 0;
- $variables['extra'] = ' (' . t('not verified') . ')';
- }
- else {
- $variables['uid'] = (int) $account->uid;
- }
-
-
-
-
-
-
- $name = $variables['name_raw'] = user_format_name($account);
- if (backdrop_strlen($name) > 20) {
- $name = backdrop_substr($name, 0, 15) . '...';
- }
- $variables['name'] = check_plain($name);
- $variables['profile_access'] = user_access('access user profiles');
-
-
- if ($variables['uid'] && $variables['profile_access']) {
-
- $variables['link_attributes']['title'] = t('View user profile.');
- $variables['link_path'] = 'user/' . $variables['uid'];
- }
- elseif (!empty($account->homepage)) {
-
-
-
- $variables['link_attributes']['rel'] = 'nofollow';
- $variables['link_path'] = $account->homepage;
- $variables['homepage'] = $account->homepage;
- }
-
- $variables['link_options']['html'] = TRUE;
-
- $variables['attributes'] = array('class' => array('username'));
- }
-
- * Process variables for user-profile.tpl.php.
- *
- * The $variables array contains the following arguments:
- * - $account
- *
- * @see user-profile.tpl.php
- */
- function template_preprocess_user_profile(&$variables) {
- $view_mode = $variables['elements']['#view_mode'];
- $bundle = $variables['elements']['#bundle'];
- $account = $variables['elements']['#account'];
-
-
- foreach (element_children($variables['elements']) as $key) {
- $variables['user_profile'][$key] = $variables['elements'][$key];
- }
-
-
- field_attach_preprocess('user', $account, $variables['elements'], $variables);
- }