Beispiel #1
0
$Form = new Form(NULL, 'settings_checkchanges');
$Form->begin_form('fform', '', array('onsubmit' => 'var es=this.elements; for( var i=0; i < es.length; i++ ) { es[i].disabled=false; };'));
$Form->add_crumb('display');
$Form->hidden('ctrl', 'display');
$Form->hidden('action', 'update');
$Form->hidden('tab', 'display');
if (isset($GLOBALS['files_Module'])) {
    load_funcs('files/model/_image.funcs.php');
    $params['force_keys_as_values'] = true;
}
// --------------------------------------------
$Form->begin_fieldset(T_('Profile pictures') . get_manual_link('profile-picture-settings'));
$Form->checkbox_input('use_gravatar', $Settings->get('use_gravatar'), T_('Use gravatar'), array('note' => T_('Fall back to Gravatar if a user has not uploaded a profile picture.')));
$default_avatar_unknown = get_default_avatar_url();
$default_avatar_men = get_default_avatar_url('M');
$default_avatar_women = get_default_avatar_url('F');
$default_images_info = '<br />' . T_('For unknown gender') . ': <a href="' . $default_avatar_unknown . '" target="_blank">' . $default_avatar_unknown . '</a>';
$default_images_info .= '<br />' . T_('For men') . ': <a href="' . $default_avatar_men . '" target="_blank">' . $default_avatar_men . '</a>';
$default_images_info .= '<br />' . T_('For women') . ': <a href="' . $default_avatar_women . '" target="_blank">' . $default_avatar_women . '</a>';
$Form->radio('default_gravatar', $Settings->get('default_gravatar'), array(array('b2evo', T_('Default image'), $default_images_info), array('', 'Gravatar'), array('identicon', 'Identicon'), array('monsterid', 'Monsterid'), array('wavatar', 'Wavatar'), array('retro', 'Retro')), T_('Default gravatars'), true, T_('Gravatar users can choose to set up a unique icon for themselves, and if they don\'t, they will be assigned a default image.'));
$Form->end_fieldset();
// --------------------------------------------
$Form->begin_fieldset(T_('Username display options') . get_manual_link('user-username-display-options'));
$Form->radio('username_display', $Settings->get('username_display'), array(array('login', T_('Usernames/Logins'), T_('Secure options')), array('name', T_('Friendly names (Nickname or Firstname if available)'), T_('WARNING: this may allow users to fake their identity'))), T_('What to display'), true);
$Form->checkbox_input('gender_colored', $Settings->get('gender_colored'), T_('Display gender in back-office'), array('note' => T_('Use colored usernames to differentiate men & women.')));
$Form->end_fieldset();
// --------------------------------------------
$Form->begin_fieldset(T_('Username display in back-office') . get_manual_link('user-bubble-tips-settings'));
$Form->checkbox_input('bubbletip', $Settings->get('bubbletip'), T_('Username bubble tips'), array('note' => T_('Check to enable bubble tips on usernames')));
if (isset($GLOBALS['files_Module'])) {
    $Form->select_input_array('bubbletip_size_admin', $Settings->get('bubbletip_size_admin'), get_available_thumb_sizes(), T_('Bubble tip image format'), '', $params);
Beispiel #2
0
/**
 * Get avatar <img> tag with default picture
 *
 * @param string Avatar size
 * @param string Style class of image
 * @param string Image align
 * @param array Params
 * @return string <img> tag
 */
function get_avatar_imgtag_default($size = 'crop-top-15x15', $class = '', $align = '', $params = array())
{
    global $Settings, $thumbnail_sizes;
    if (!$Settings->get('allow_avatars')) {
        // Avatars are not allowed, Exit here
        return '';
    }
    // Default params:
    $params = array_merge(array('email' => '', 'username' => '', 'default' => '', 'gender' => '', 'tag_size' => NULL), $params);
    if (!$Settings->get('use_gravatar')) {
        // Gravatars are not allowed, Use default avatars instead
        $img_url = get_default_avatar_url($params['gender'], $size);
        $gravatar_width = isset($thumbnail_sizes[$size]) ? $thumbnail_sizes[$size][1] : '15';
        $gravatar_height = isset($thumbnail_sizes[$size]) ? $thumbnail_sizes[$size][2] : '15';
    } else {
        // Gravatars are enabled
        $default_gravatar = $Settings->get('default_gravatar');
        if (empty($params['default'])) {
            // Set default gravatar
            if ($default_gravatar == 'b2evo') {
                // Use gravatar from b2evo default avatar image
                $params['default'] = get_default_avatar_url($params['gender']);
            } else {
                // Use a selected gravatar type
                $params['default'] = $default_gravatar;
            }
        }
        if (empty($img_url)) {
            $img_url = '//www.gravatar.com/avatar/' . md5($params['email']);
            $gravatar_width = isset($thumbnail_sizes[$size]) ? $thumbnail_sizes[$size][1] : '15';
            $gravatar_height = $gravatar_width;
            $img_url_params = array();
            if (!empty($params['rating'])) {
                // Rating
                $img_url_params[] = 'rating=' . $params['rating'];
            }
            if (!empty($gravatar_width)) {
                // Size
                $img_url_params[] = 'size=' . $gravatar_width;
            }
            if (!empty($params['default'])) {
                // Type
                $img_url_params[] = 'default=' . urlencode($params['default']);
            }
            if (count($img_url_params) > 0) {
                // Append url params to request gravatar
                $img_url .= '?' . implode('&', $img_url_params);
            }
        }
    }
    if ($params['tag_size'] !== NULL) {
        // Change tag size
        $tag_size = explode('x', $params['tag_size']);
        $gravatar_width = $tag_size[0];
        $gravatar_height = empty($tag_size[1]) ? $tag_size[0] : $tag_size[1];
    }
    $img_params = array('src' => $img_url, 'width' => $gravatar_width, 'height' => $gravatar_height);
    if (!empty($params['username'])) {
        // Add alt & title
        $img_params['alt'] = $params['username'];
        $img_params['title'] = $params['username'];
    }
    if (!empty($class)) {
        // Add class
        $img_params['class'] = $class;
    }
    if (!empty($align)) {
        // Add align
        $img_params['align'] = $align;
    }
    return '<img' . get_field_attribs_as_string($img_params) . ' />';
}