Stud.IP  6.0
Avatar Class Reference
Inheritance diagram for Avatar:
CourseAvatar LicenseAvatar InstituteAvatar StudygroupAvatar

Public Member Functions

 getAvatarDirectoryUrl ()
 
 getAvatarDirectoryPath ()
 
 getDefaultAvatarDirectoryUrl ()
 
 getDefaultAvatarDirectoryPath ()
 
 getCustomAvatarUrl ($size)
 
 getCustomAvatarPath ($size)
 
 getFilename ($size)
 
 getURL ($size)
 
 isNobody ()
 
 customizedFileExists ()
 
 is_customized ()
 
 getImageTag ($size=self::MEDIUM, $opt=[])
 
 createFromUpload ($userfile)
 
 createFrom ($filename)
 
 reset ()
 
 getDefaultTitle ()
 
 getId ()
 

Static Public Member Functions

static getAvatar ($id)
 
static getNobody ()
 
static getDimension ($size)
 
static error_handler ($errno, $errstr, $errfile, $errline)
 

Data Fields

const AVATAR_TYPE = 'user'
 
const EXTENSION = 'webp'
 
const IMAGE_QUALITY = 90
 
const ORIGINAL = 'original'
 
const NORMAL = 'normal'
 
const MEDIUM = 'medium'
 
const SMALL = 'small'
 
const MAX_FILE_SIZE = 10485760
 

Protected Member Functions

 __construct ($user_id, $username=null)
 
 getCssClass ($size)
 
 checkAvatarVisibility ()
 
 sanitizeOrientation ($filename)
 

Protected Attributes

const CREATE_CHUNKED_FOLDERS = true
 
const NOBODY = 'nobody'
 
 $user_id
 
 $username
 

Detailed Description

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. *

Author
André Klaßen (aklassen)
Marcus Lunzenauer (mlunzena)
Jan-Hendirk Willms tleil.nosp@m.ax+s.nosp@m.tudip.nosp@m.@gma.nosp@m.il.co.nosp@m.m GPL2 or any later version
Since
1.7

Constructor & Destructor Documentation

◆ __construct()

__construct (   $user_id,
  $username = null 
)
finalprotected

Constructs a new Avatar object belonging to a user with the given id.

Parameters
string$user_idthe user's id
string$usernamethe user's username (optional)

Member Function Documentation

◆ checkAvatarVisibility()

checkAvatarVisibility ( )
protected

Return if avatar is visible to the current user. Also set the user_id of avatar to nobody if not visible to current user.

Returns
boolean: true if visible

◆ createFrom()

createFrom (   $filename)

Creates thumbnails from an image.

Parameters
string$filenamefilename of the image to create thumbnails from
Returns
void

◆ createFromUpload()

createFromUpload (   $userfile)

Creates all the different sized thumbnails for an uploaded file.

Parameters
string$userfilethe key of the uploaded file, see documentation about $_FILES
Returns
void

◆ customizedFileExists()

customizedFileExists ( )

Returns whether a customized file exists

◆ error_handler()

static error_handler (   $errno,
  $errstr,
  $errfile,
  $errline 
)
static

◆ getAvatar()

static getAvatar (   $id)
static

Returns an avatar object of the appropriate class.

Parameters
string$idthe user's id
string$usernamethe user's username (optional)
Returns
static the user's avatar.

◆ getAvatarDirectoryPath()

getAvatarDirectoryPath ( )

Returns the path to the customized avatars

Returns
string

◆ getAvatarDirectoryUrl()

getAvatarDirectoryUrl ( )

Returns the url to the customized avatars

Returns
string

◆ getCssClass()

getCssClass (   $size)
protected

Returns the CSS class to use for this avatar image.

Parameters
string$sizeone of the constants Avatar::(NORMAL|MEDIUM|SMALL)
Returns
string CSS class to use for the avatar

◆ getCustomAvatarPath()

getCustomAvatarPath (   $size)

Returns the path to a customized avatar

Returns
string

◆ getCustomAvatarUrl()

getCustomAvatarUrl (   $size)

Returns the url to a customized avatar

Returns
string

◆ getDefaultAvatarDirectoryPath()

getDefaultAvatarDirectoryPath ( )

Returns the path to the default avatars

◆ getDefaultAvatarDirectoryUrl()

getDefaultAvatarDirectoryUrl ( )

Returns the url to the default avatars

◆ getDefaultTitle()

getDefaultTitle ( )

Return the default title of the avatar.

Returns
string the default title

◆ getDimension()

static getDimension (   $size)
static

Return the dimension of a size

Parameters
string$sizethe dimension of a size
Returns
array{0: int, 1: int} a tupel of integers [width, height]

◆ getFilename()

getFilename (   $size)

Returns the file name of a user's avatar.

Parameters
string$sizeone of the constants Avatar::(NORMAL|MEDIUM|SMALL)
Returns
string the absolute file path to the avatar

◆ getId()

getId ( )

◆ getImageTag()

getImageTag (   $size = self::MEDIUM,
  $opt = [] 
)

Constructs a desired HTML image tag for an Avatar. Additional html attributes may also be specified using the $opt parameter.

Parameters
string$sizeone of the constants Avatar::(NORMAL|MEDIUM|SMALL)
array$optarray of attributes to add to the HTML image tag
Returns
string returns the HTML image tag

◆ getNobody()

static getNobody ( )
static

Returns an avatar object for "nobody".

Returns
Avatar the user's avatar.

◆ getURL()

getURL (   $size)

Returns the URL of a user's picture.

Parameters
string$sizeone of the constants Avatar::(NORMAL|MEDIUM|SMALL)
Returns
string the URL to the user's picture

◆ is_customized()

is_customized ( )

Returns whether a user has uploaded a custom picture.

Returns
boolean returns TRUE if the user customized her picture, FALSE otherwise.

◆ isNobody()

isNobody ( )

Returns whether this avatar is a default/"nobody" avatar.

◆ reset()

reset ( )

Removes all uploaded pictures of a user.

◆ sanitizeOrientation()

sanitizeOrientation (   $filename)
protected

Corrects the orientation of images from iOS/OS X devices which might lead to a rotated image. EXIF information is checked and when the orientation is set by EXIF data, we rotate the image accordingly.

Parameters
string$filenameFilename of the image to correct

Field Documentation

◆ $user_id

$user_id
protected

◆ $username

$username
protected

◆ AVATAR_TYPE

const AVATAR_TYPE = 'user'

◆ CREATE_CHUNKED_FOLDERS

const CREATE_CHUNKED_FOLDERS = true
protected

◆ EXTENSION

const EXTENSION = 'webp'

◆ IMAGE_QUALITY

const IMAGE_QUALITY = 90

◆ MAX_FILE_SIZE

const MAX_FILE_SIZE = 10485760

This constant represents the maximal size of a user picture in bytes.

◆ MEDIUM

const MEDIUM = 'medium'

This constant stands for a medium size of a user picture.

◆ NOBODY

const NOBODY = 'nobody'
protected

This constant holds the username and ID of the "nobody" avatar.

◆ NORMAL

const NORMAL = 'normal'

This constant stands for the maximal size of a user picture.

◆ ORIGINAL

const ORIGINAL = 'original'

This constant stands for the maximal size of a user picture.

◆ SMALL

const SMALL = 'small'

This constant stands for an icon size of a user picture.


The documentation for this class was generated from the following file: