BEdita API doc | 4-cactus
  • Class
  • Tree
  • Deprecated
  • Download

Classes

  • Addon
  • AddressbookController
  • AddressbookShell
  • AdminController
  • Alias
  • Annotation
  • ApiAuthComponent
  • ApiBaseController
  • ApiFormatterComponent
  • ApiUploadComponent
  • ApiValidatorComponent
  • AppController
  • AppError
  • AppHelper
  • Application
  • AppModel
  • Area
  • AreasController
  • Audio
  • AuthenticationsController
  • BannedIp
  • BEAppModel
  • BEAppObjectModel
  • BeAuthComponent
  • BeAuthFacebookComponent
  • BeAuthGoogleComponent
  • BeAuthTwitterComponent
  • BeCallbackManager
  • BeConfigure
  • BeCustomPropertyComponent
  • BeditaAnnotationModel
  • BeditaBaseShell
  • BeditaCollectionModel
  • BeditaContentModel
  • BeditaExportFilter
  • BeditaImportFilter
  • BeditaObjectModel
  • BeditaProductModel
  • BeditaShell
  • BeditaSimpleObjectModel
  • BeditaSimpleStreamModel
  • BeditaStreamModel
  • BeEmbedFlashHelper
  • BeEmbedHtml5Helper
  • BeEmbedMediaHelper
  • BeErrorCode
  • BeExceptionHandler
  • BEFile
  • BeFileHandlerComponent
  • BeFormHelper
  • BeFrontHelper
  • BeHashComponent
  • BeHtmlHelper
  • BeLangTextComponent
  • BeLib
  • BeMailComponent
  • BEObject
  • BeObjectCache
  • BePaginatorToolbarHelper
  • BeSchema
  • BeSecurityComponent
  • BeSystem
  • BeSystemComponent
  • BeThumb
  • BeTimeHelper
  • BeToolbarHelper
  • BeTreeComponent
  • BeTreeHelper
  • BeUploadToObjComponent
  • BeurlHelper
  • BeVimeoComponent
  • BeYoutubeComponent
  • BuildFilterBehavior
  • CacheableBehavior
  • CacheShell
  • CallbackBehavior
  • CaptchaComponent
  • Caption
  • CaptionsBehavior
  • Card
  • CardsImportFilter
  • Category
  • CleanupDataTask
  • CleanupTask
  • Comment
  • CommentsController
  • CompactResultBehavior
  • Content
  • CreateIndexFieldsBehavior
  • DataShell
  • DataTransfer
  • DateItem
  • DbadminShell
  • DeleteDependentObjectBehavior
  • DeleteObjectBehavior
  • DeployShell
  • Document
  • DocumentsController
  • DumpModel
  • EditorialContentsShell
  • EditorNote
  • Event
  • EventLog
  • EventsController
  • FilesController
  • ForeignDependenceSaveBehavior
  • FrontendController
  • FrontendShell
  • GalleriesController
  • Gallery
  • GeoTag
  • GettextShell
  • Git
  • GravatarHelper
  • Group
  • HashJob
  • History
  • HomeController
  • Image
  • ImageInfoHelper
  • JsonExportFilter
  • JsonImportFilter
  • JsonView
  • LangText
  • Link
  • MailGroup
  • MailGroupCard
  • MailJob
  • MailLog
  • MailMessage
  • MailShell
  • MailTemplate
  • Mask
  • MediaShell
  • MigrateDumpModel
  • MigrateShell
  • Migration
  • MigrationBase
  • MigrationDateItemsShell
  • Module
  • ModulesController
  • ModuleShell
  • MultimediaController
  • NewsController
  • NewsletterController
  • NewsletterShell
  • NotifyBehavior
  • ObjectEditor
  • ObjectProperty
  • ObjectRelation
  • ObjectType
  • ObjectUser
  • PagesController
  • Permission
  • PermissionModule
  • PermsHelper
  • Product
  • Property
  • PropertyOption
  • PublicationShell
  • RedisShell
  • RelationCheck
  • RelationRepair
  • RelationShell
  • RelationStats
  • RemoveDummyNameBehavior
  • ResponseHandlerComponent
  • RestClientModel
  • Revision
  • RevisionObjectBehavior
  • SearchText
  • SearchTextSaveBehavior
  • Section
  • SectionDummy
  • SessionFilterComponent
  • SessionFilterHelper
  • ShortNews
  • SmartyView
  • SoapClientModel
  • SplitterSql
  • StatisticsController
  • Stream
  • StreamLog
  • StreamsController
  • Svn
  • TagsController
  • ThemeSmartyView
  • ThumbnailHelper
  • ThumbShell
  • TransactionComponent
  • TransactionFS
  • TranslationsController
  • Tree
  • TrHelper
  • User
  • UserProperty
  • UsersController
  • Utility
  • Version
  • Video
  • VimeoHelper
  • WebmarksController
  • XmlExportFilter
  • XmlImportFilter
  • XmlJsonConverter
  • XmlView
  • YoutubeHelper

Interfaces

  • ApiAuthInterface
  • MediaProviderInterface
  • UploadableInterface

Exceptions

  • BeditaAjaxException
  • BEditaAllowURLException
  • BeditaBadRequestException
  • BeditaConflictException
  • BEditaDeleteStreamObjException
  • BeditaException
  • BEditaFileExistException
  • BeditaForbiddenException
  • BeditaFrontAccessException
  • BeditaHashException
  • BEditaInfoException
  • BeditaInternalErrorException
  • BEditaIOException
  • BeditaLengthRequiredException
  • BeditaMailException
  • BEditaMediaProviderException
  • BeditaMethodNotAllowedException
  • BEditaMIMEException
  • BeditaNotFoundException
  • BeditaNotImplementedException
  • BeditaPublicationException
  • BeditaRuntimeException
  • BEditaSaveStreamObjException
  • BeditaServiceUnavailableException
  • BeditaUnauthorizedException
  • BEditaUploadPHPException
  • BEditaURLException

Class BeFileHandlerComponent

File upload, save, modify, delete, manage (remote as well). Uses Transaction component.

Data to be passed to save an object with a file:

    path        temporary file path or URL
    name        Name of original file
    mime_type       MIME type, if not set, try to get from file name (@todo)
    file_size       file size, if URL, try to read remote file size

Exceptions: BEditaFileExistException // File already exists (thrown in creation) BEditaInfoException // File info not readable (access denied or no data) BEditaMIMEException // MIME type not found or not corresponding to object type BEditaURLRxception // URL rules violated BEditaSaveStreamObjException // Error creating/modifying object BEditaDeleteStreamObjException // Error deleting object

If paranoid == false: remote info not loaded ['allow_php_fopen' not necessary]. Mime info should be passed with data for URLs.

File paths saved on DB are relative to $config['mediaRoot']

Object
Extended by BeFileHandlerComponent
Version: $Revision$
Modifiedby: $LastChangedBy$
Lastmodified:

$LastChangedDate$

$Id$


Located at controllers/components/be_file_handler.php

Methods summary

public
# __construct( )
public
# startup( & $controller )
public integer
# save( array & $data, $clone = false, $getInfoUrl = true )

Save object $data If $data['id'] modify otherwise create If file is already present, throw an exception. File data: path: local path or URL (.+//:.+) [remote file] if "allow_url_fopen" is not activated, remote file is not accepted name Name of file. Empty if path == URL mime_type MIME type. Empty if path == URL file_size File size. Empty if path == URL

Save object $data If $data['id'] modify otherwise create If file is already present, throw an exception. File data: path: local path or URL (.+//:.+) [remote file] if "allow_url_fopen" is not activated, remote file is not accepted name Name of file. Empty if path == URL mime_type MIME type. Empty if path == URL file_size File size. Empty if path == URL

Parameters

$data
object data
$clone
$getInfoUrl

Returns

integer
or false (id of the object created or modified)
public boolean
# del( integer $id )

Delete object

Delete object

Parameters

$id
object id

Returns

boolean

Throws

BEditaDeleteStreamObjException
public string
# url( integer $id )

Return URL of file object

Return URL of file object

Parameters

$id
object id

Returns

string
public string
# path( integer $id )

Return object path, URL if remote file

Return object path, URL if remote file

Parameters

$id
object id

Returns

string
public integer
# isPresent( string $path, $id = null )

Return object id (object that contains file $path)

Return object id (object that contains file $path)

Parameters

$path
File name or URL
$id

Returns

integer
private integer
# _createFromURL( array & $data, boolean $clone, boolean $getInfoUrl )

Create (or clone) data for file identified by url

Create (or clone) data for file identified by url

Parameters

$data
$clone
$getInfoUrl

Returns

integer
(int or other type, according to primaryKey type for model)

Throws

BEditaURLException
BEditaAllowURLException
BEditaFileExistException
private mixed
# _createFromFile( array & $data, boolean $clone )

Create (or clone) data for file

Create (or clone) data for file

Parameters

$data
$clone

Returns

mixed
boolean|int (int or other type, according to primaryKey type for model)

Throws

BeditaException
BEditaFileExistException
public string
# getHashFile( string $sourcePath )

Given a file path return its hash (md5)

Given a file path return its hash (md5)

Parameters

$sourcePath
The file path

Returns

string
public integer|false
# hashFileExists( string $hash )

Check if an hash is already present in streams. Return the streams.id if exists, false otherwise

Check if an hash is already present in streams. Return the streams.id if exists, false otherwise

Parameters

$hash
The file hash

Returns

integer|false
private integer
# _create( array & $data )

Create object for $data

Create object for $data

Parameters

$data

Returns

integer
(or other type, according to primaryKey type for model)

Throws

BEditaMIMEException
BEditaSaveStreamObjException
public
# setImageData( & $data )

Set image size for $data

Set image size for $data

Parameters

$data
private
# setApplicationData( array & $data, string $application_name )

Set application data (name, type, label)

Set application data (name, type, label)

Parameters

$data
$application_name
private
# getImageSize( array & $data )

get image size for $data

get image size for $data

Parameters

$data
private array
# getCategoryMediaType( array $data, string $modelType )

get category data for media $data

get category data for media $data

Parameters

$data
$modelType

Returns

array
category
private boolean
# _isURL( string $path )

If $path is an URL, return TRUE

If $path is an URL, return TRUE

Parameters

$path

Returns

boolean
private boolean
# _regularURL( string $URL )

If $URL is valid, return TRUE

If $URL is valid, return TRUE

Parameters

$URL

Returns

boolean
public
# getInfoURL( array & $data )

put mime type checking uri

put mime type checking uri

Parameters

$data

Throws

BEditaInfoException
public string
# getMimeType( array $data )

get mime type of stream

get mime type of stream

Parameters

$data

Returns

string
public mixed
# putFile( string $sourcePath, string $targetPath )

Create target with source (temporary file), through transactional object

Create target with source (temporary file), through transactional object

Parameters

$sourcePath
$targetPath

Returns

mixed
boolean|string
private boolean
# _removeFile( string $path )

Delete a file from file system with transactional object

Delete a file from file system with transactional object

Parameters

$path

Returns

boolean
public string
# getPathTargetFile( string & $name, string $prefix = null )

Get path where to save uploaded file

Get path where to save uploaded file

Parameters

$name
The file name
$prefix
The prefix used for building path

Returns

string
public string
# buildNameFromFile( string $filename )

build friendly url name from filename nameFile.ext become name-file.jpg nameFile become name-file

build friendly url name from filename nameFile.ext become name-file.jpg nameFile become name-file

Parameters

$filename

Returns

string
public array
# splitFilename( string $filename )

Split file name by dot [to separate file name from file extension]

Split file name by dot [to separate file name from file extension]

Parameters

$filename

Returns

array

Properties summary

public array $components
# array('Transaction')
public boolean $paranoid
# true
public boolean $validateErrors
# false
BEdita API doc | 4-cactus API documentation generated by ApiGen