Stud.IP  trunk Revision
Avatar Class Reference
Inheritance diagram for Avatar:
Inheritance graph
Collaboration diagram for Avatar:
Collaboration graph

Public Member Functions

 getAvatarDirectoryUrl ()
 
 getAvatarDirectoryPath ()
 
 getCustomAvatarUrl ($size, $ext='png')
 
 getCustomAvatarPath ($size, $ext='png', $retina=false)
 
 getFilename ($size, $ext='png')
 
 getURL ($size, $ext='png')
 
 is_customized ()
 
 getImageTag ($size=Avatar::MEDIUM, $opt=array())
 
 createFromUpload ($userfile)
 
 createFrom ($filename)
 
 reset ()
 
 getDimension ($size)
 
 getDefaultTitle ()
 

Static Public Member Functions

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

Data Fields

const ORIGINAL = 'original'
 
const NORMAL = 'normal'
 
const MEDIUM = 'medium'
 
const SMALL = 'small'
 
const MAX_FILE_SIZE = 10485760
 
const NOBODY = 'nobody'
 

Protected Member Functions

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

Protected Attributes

 $user_id
 
 $username
 

Constructor & Destructor Documentation

◆ __construct()

__construct (   $user_id,
  $username = null 
)
protected

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

Parameters
stringthe user's id
stringthe user's username (optional)
Returns
void

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

Reimplemented in CourseAvatar, and InstituteAvatar.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ createFrom()

createFrom (   $filename)

Creates thumbnails from an image.

Parameters
stringfilename of the image to create thumbnails from
Returns
void
Here is the call graph for this function:
Here is the caller graph for this function:

◆ createFromUpload()

createFromUpload (   $userfile)

Creates all the different sized thumbnails for an uploaded file.

Parameters
stringthe key of the uploaded file, see documentation about $_FILES
Returns
void
Exceptions
severalExceptions if the uploaded file does not satisfy the requirements
Here is the call graph for this function:

◆ error_handler()

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

◆ getAvatar()

static getAvatar (   $id)
static

Returns an avatar object of the appropriate class.

Parameters
stringthe user's id
stringthe user's username (optional)
Returns
mixed the user's avatar.

Reimplemented in StudygroupAvatar, CourseAvatar, and InstituteAvatar.

Here is the caller graph for this function:

◆ getAvatarDirectoryPath()

getAvatarDirectoryPath ( )

Reimplemented in CourseAvatar, and InstituteAvatar.

Here is the caller graph for this function:

◆ getAvatarDirectoryUrl()

getAvatarDirectoryUrl ( )

Reimplemented in CourseAvatar, and InstituteAvatar.

Here is the caller graph for this function:

◆ getCssClass()

getCssClass (   $size)
protected

Returns the CSS class to use for this avatar image.

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

Reimplemented in CourseAvatar.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCustomAvatarPath()

getCustomAvatarPath (   $size,
  $ext = 'png',
  $retina = false 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCustomAvatarUrl()

getCustomAvatarUrl (   $size,
  $ext = 'png' 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getDefaultTitle()

getDefaultTitle ( )

Return the default title of the avatar.

Returns
string the default title

Reimplemented in CourseAvatar, and InstituteAvatar.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getDimension()

getDimension (   $size)

Return the dimension of a size

Parameters
stringthe dimension of a size
Returns
array a tupel of integers [width, height]

◆ getFilename()

getFilename (   $size,
  $ext = 'png' 
)

Returns the file name of a user's avatar.

Parameters
stringone of the constants Avatar::(NORMAL|MEDIUM|SMALL)
stringan optional extension of the avatar
Returns
string the absolute file path to the avatar
Here is the call graph for this function:

◆ getImageTag()

getImageTag (   $size = Avatar::MEDIUM,
  $opt = array() 
)

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

Parameters
stringone of the constants Avatar::(NORMAL|MEDIUM|SMALL)
arrayarray of attributes to add to the HTML image tag
Returns
string returns the HTML image tag
Here is the call graph for this function:

◆ getNobody()

static getNobody ( )
static

Returns an avatar object for "nobody".

Returns
mixed the user's avatar.

Reimplemented in CourseAvatar, InstituteAvatar, and StudygroupAvatar.

Here is the caller graph for this function:

◆ getURL()

getURL (   $size,
  $ext = 'png' 
)

Returns the URL of a user's picture.

Parameters
stringone of the constants Avatar::(NORMAL|MEDIUM|SMALL)
stringan optional extension of the user's picture
Returns
string the URL to the user's picture
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset()

reset ( )

Removes all uploaded pictures of a user.

Returns
void
Here is the call graph for this function:

◆ 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
Here is the caller graph for this function:

Field Documentation

◆ $user_id

$user_id
protected

◆ $username

$username
protected

◆ 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'

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: