Galette API documentation
Gestionnaire d’Adhérents en Ligne Extrêmement Tarabiscoté mais Tellement Efficace
1.0.0
Galette\Core\Picture Class Reference
Inheritance diagram for Galette\Core\Picture:
Collaboration diagram for Galette\Core\Picture:

Public Member Functions

 __construct (string|int|null $id_adh=null)
 
 __wakeup ()
 
 getContents ()
 
 display (Response $response)
 
 delete (bool $transaction=true)
 
 store (array $file, bool $ajax=false, array $cropping=null)
 
 writeOnDisk (string $tmpfile, bool $ajax)
 
 getOptimalHeight ()
 
 getHeight ()
 
 getOptimalWidth ()
 
 getWidth ()
 
 getFormat ()
 
 hasPicture ()
 
 getPath ()
 
 getMime ()
 
 getErrorMessage (int $code)
 

Static Public Member Functions

static getMimeType (string $file)
 

Public Attributes

const SQL_ERROR = -10
 
const SQL_BLOB_ERROR = -11
 
const TABLE = 'pictures'
 
const PK = Adherent::PK
 
- Public Attributes inherited from Galette\IO\FileInterface
const INVALID_FILENAME = -1
 
const INVALID_EXTENSION = -2
 
const FILE_TOO_BIG = -3
 
const IMAGE_TOO_SMALL = -4
 
const MIME_NOT_ALLOWED = -5
 
const NEW_FILE_EXISTS = -6
 
const INVALID_FILE = -7
 
const CANT_WRITE = -8
 
const MAX_FILE_SIZE = 2048
 
const MIN_CROP_SIZE = 267
 

Protected Member Functions

 getCheckFileQuery ()
 
 getDefaultPicture ()
 
 buildDestPath ()
 

Protected Attributes

store as trait_store
 
getMimeType as trait_getMimeType
 
string $tbl_prefix = ''
 
string int $id
 
int $db_id
 
int $height
 
int $width
 
int $optimal_height
 
int $optimal_width
 
string $file_path
 
string $format
 
string $mime
 
bool $has_picture = false
 
string $store_path = GALETTE_PHOTOS_PATH
 
int $max_width = 200
 
int $max_height = 200
 

Detailed Description

Picture handling

Author
Frédéric Jacquot gna@l.nosp@m.ogee.nosp@m.k.com
Johan Cwiklinski johan.nosp@m.@x-t.nosp@m.nd.be

Constructor & Destructor Documentation

◆ __construct()

Galette\Core\Picture::__construct ( string|int|null  $id_adh = null)

Default constructor.

Parameters
string | int | null$id_adhthe id of the member

Member Function Documentation

◆ __wakeup()

Galette\Core\Picture::__wakeup ( )

"Magic" function called on unserialize

Returns
void

◆ buildDestPath()

Galette\Core\Picture::buildDestPath ( )
protected

Build destination path

Returns
string

◆ delete()

Galette\Core\Picture::delete ( bool  $transaction = true)

Deletes a picture, from both database and filesystem

Parameters
boolean$transactionWhether to use a transaction here or not
Returns
boolean true if image was successfully deleted, false otherwise

◆ display()

Galette\Core\Picture::display ( Response  $response)

Set header and displays the picture.

Parameters
Response$responseResponse
Returns
Response the binary file

◆ getCheckFileQuery()

Galette\Core\Picture::getCheckFileQuery ( )
protected

Returns the relevant query to check if picture exists in database.

Returns
Select SELECT query

Reimplemented in Galette\Core\Logo.

◆ getContents()

Galette\Core\Picture::getContents ( )

Get image file contents in stdOut

Returns
void

◆ getDefaultPicture()

Galette\Core\Picture::getDefaultPicture ( )
protected

Gets the default picture to show, anyway

Returns
void

Reimplemented in Galette\Core\PrintLogo, and Galette\Core\Logo.

◆ getErrorMessage()

Galette\Core\Picture::getErrorMessage ( int  $code)

Return textual error message

Parameters
int$codeThe error code
Returns
string Localized message

◆ getFormat()

Galette\Core\Picture::getFormat ( )

Returns current file format

Returns
string

◆ getHeight()

Galette\Core\Picture::getHeight ( )

Returns current file height

Returns
int current height

◆ getMime()

Galette\Core\Picture::getMime ( )

Returns current mime type

Returns
string

◆ getMimeType()

static Galette\Core\Picture::getMimeType ( string  $file)
static

Get file mime type

Parameters
string$fileFile
Returns
string

◆ getOptimalHeight()

Galette\Core\Picture::getOptimalHeight ( )

Returns current file optimal height (resized)

Returns
int optimal height

◆ getOptimalWidth()

Galette\Core\Picture::getOptimalWidth ( )

Returns current file optimal width (resized)

Returns
int optimal width

◆ getPath()

Galette\Core\Picture::getPath ( )

Returns current file full path

Returns
string full file path

◆ getWidth()

Galette\Core\Picture::getWidth ( )

Returns current file width

Returns
int current width

◆ hasPicture()

Galette\Core\Picture::hasPicture ( )

Have we got a picture ?

Returns
bool True if a picture matches adherent's id, false otherwise

◆ store()

Galette\Core\Picture::store ( array  $file,
bool  $ajax = false,
array  $cropping = null 
)

Stores an image on the disk and in the database

Parameters
array<string,mixed>$file The uploaded file
boolean$ajaxIf the image comes from an ajax call (dnd)
?array<string,mixed>$cropping Cropping properties
Returns
bool|int

◆ writeOnDisk()

Galette\Core\Picture::writeOnDisk ( string  $tmpfile,
bool  $ajax 
)

Write file on disk

Parameters
string$tmpfileTemporary file
bool$ajaxIf the file comes from an ajax call (dnd)
Returns
bool|int

FIXME: what if image cannot be resized? Should'nt we want to stop the process here?


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