UNA
BxDolUploader Class Reference
Inheritance diagram for BxDolUploader:
BxDolFactory BxBaseUploaderCrop BxBaseUploaderHTML5 BxBaseUploaderSimple BxTemplUploaderCrop BxTemplUploaderHTML5 BxBaseUploaderRecordVideo BxAlbumsUploaderCrop BxBaseModProfileUploaderPictureCrop BxBaseStudioUploaderCropCover BxAlbumsUploaderHTML5 BxBaseCmtsUploaderHTML5 BxBaseModFilesUploaderHTML5 BxBaseModProfileUploaderCoverCrop BxBaseModTextUploaderHTML5 BxBaseModTextUploaderHTML5Attach BxBaseStudioBuilderPageUploaderHTML5 BxBaseStudioSettingsUploaderHTML5 BxGlsrUploaderHTML5 BxMarketUploaderHTML5 BxTimelineUploaderHTML5Attach BxVideosUploaderHTML5 BxTemplUploaderRecordVideo

Public Member Functions

 isAvailable ()
 
 isInstalled ()
 
 handleUploads ($iProfileId, $mixedFiles, $isMultiple=true, $iContentId=false, $bPrivate=true)
 
 getUploaderButton ($aParams=array())
 
 getUploaderJs ($mixedGhostTemplate, $isMultiple=true, $aParams=array(), $bDynamic=false)
 
 addCssJs ($bDynamic=false)
 
 getUploaderButtonTitle ($mixed=false)
 
 getUploaderForm ($isMultiple=true, $iContentId=false, $isPrivate=true)
 
 getGhosts ($iProfileId, $sFormat, $sImagesTranscoder=false, $iContentId=false)
 
 reorderGhosts ($iProfileId, $sFormat, $aGhosts, $iContentId=false)
 
 deleteGhost ($iFileId, $iProfileId)
 
 deleteGhostsForProfile ($iProfileId, $iContentId=false)
 

Protected Member Functions

 __construct ($aObject, $sStorageObject, $sUniqId, $oTemplate)
 

Detailed Description

Uploaders are disigned to work as form field in forms.

See also
BxDolForm.

To add file to any form, use the following form field array:

'attachment' => array(
'type' => 'files', // this is new form type, which enable upholders automatically
'storage_object' => 'sample', // the storage object, where uploaded files are going to be saved
'images_transcoder' => 'sample2', // images transcoder object to use for images preview
'uploaders' => array ('sys_simple', 'sys_html5'), // the set of uploaders to use to upload files
'upload_buttons_titles' => array('Simple' => 'Upload one by one', 'HTML5' => 'Upload several files in bulk'); // change default button titles, array with button names, or string to assign to all bnuttons
'multiple' => true, // allow to upload multiple files per one upload
'storage_private' => 0, // private or public storage (by default - private), if file is provate generated link will expire, for public storage the link is always persistent
'content_id' => 4321, // content id to associate ghost files with
'ghost_template' => $mixedGhostTemplate, // template for nested form
'name' => 'attachment', // name of file form field, resulted file id is assigned to this field name
'caption' => _t('Attachments'), // form field caption
),

Available uploaders:

  • sys_simple - upload files using standard HTML forms.
  • sys_html5 - upload files using AJAX uploader with multiple files selection support (without flash), it works in Firefox and WebKit(Safari, Chrome) browsers only, but has fallback for other browsers (IE, Opera).

Uploaded files are showed as "nested" forms. You can pass nested form in 'ghost_template' parameter. If you don't pass anything in 'ghost_template' parameter, then only file id is passed upon form submission. The nested form can be declared using the different ways:

  1. Pass template as string - just plain string with HTML, for example:
<div id="bx-uploader-file-{storage_object}-{file_id}" class="bx-uploader-ghost">
<div style="border:2px dotted green; padding:10px; margin-bottom:10px;">
<input type="hidden" name="f[]" value="{file_id}" />
{file_name} <br />
<a href="javascript:void(0);" onclick="{js_instance_name}.deleteGhost('{file_id}')">delete</a>
</div>
</div>
  1. Pass form array - regular form array, but with inputs array only, for example:
array (
'inputs' => array (
'file_name' => array (
'type' => 'text',
'name' => 'file_name[]',
'value' => '{file_title}',
'caption' => _t('Caption'),
),
'file_desc' => array (
'type' => 'textarea',
'name' => 'file_desc[]',
'caption' => _t('Description'),
),
),
);

Array is automatically modified to add necessary form attributes to work as nested form, file id field is added automatically as hidden input as well.

  1. Pass instance of BxDolFormNestedGhost class - use BxDolFormNestedGhost class or its custom subclass; to create instance use the same form array as in the previous variant, for example:
$oFormNested = new BxDolFormNestedGhost('attachment', $aFormNested, 'do_submit');
  • 'attachment' is the name of file form field from main form.
  • $aFormNested is form array from previous example.
  • 'do_submit' is main form submit_name; field name of submit form input to determine if form is submitted or not.

All 3 variants can have the following replace markers to substitute with real values:

  • {file_id} - uploaded file id
  • {file_name} - uploaded file name with extension
  • {file_title} - uploaded file name without extension
  • {file_icon} - URL to file icon automatically determined by file extension
  • {file_url} - URL to the original file
  • {js_instance_name} - instance of BxDolUploader javascript class

Constructor & Destructor Documentation

◆ __construct()

BxDolUploader::__construct (   $aObject,
  $sStorageObject,
  $sUniqId,
  $oTemplate 
)
protected

constructor

Member Function Documentation

◆ addCssJs()

BxDolUploader::addCssJs (   $bDynamic = false)

add necessary js, css files and js translations

◆ deleteGhost()

BxDolUploader::deleteGhost (   $iFileId,
  $iProfileId 
)

Delete file by file id, usually ghost file

Returns
'ok' string on success or error string on error

◆ deleteGhostsForProfile()

BxDolUploader::deleteGhostsForProfile (   $iProfileId,
  $iContentId = false 
)

Delete all ghosts files for the specified profile

Returns
number of delete ghost files

◆ getGhosts()

BxDolUploader::getGhosts (   $iProfileId,
  $sFormat,
  $sImagesTranscoder = false,
  $iContentId = false 
)

Display uploaded, but not saved files - ghosts

Parameters
$iProfileId- profile id to get orphaned files from
$sFormat- output format, only 'json' output formt is supported
$sImagesTranscoder- transcoder object for files preview for images and videos, false by default - no preview
$iContentId- content id to get orphaned files from, false by default
Returns
JSON string

◆ getUploaderButton()

BxDolUploader::getUploaderButton (   $aParams = array())

Show uploader button.

Returns
HTML string

◆ getUploaderButtonTitle()

BxDolUploader::getUploaderButtonTitle (   $mixed = false)

Get uploader button title

◆ getUploaderForm()

BxDolUploader::getUploaderForm (   $isMultiple = true,
  $iContentId = false,
  $isPrivate = true 
)

Show uploader form.

Returns
HTML string

◆ getUploaderJs()

BxDolUploader::getUploaderJs (   $mixedGhostTemplate,
  $isMultiple = true,
  $aParams = array(),
  $bDynamic = false 
)

Show uploader JS.

Returns
HTML string

◆ handleUploads()

BxDolUploader::handleUploads (   $iProfileId,
  $mixedFiles,
  $isMultiple = true,
  $iContentId = false,
  $bPrivate = true 
)

Handle uploads here.

Parameters
$mixedFilesas usual $_FILES['some_name'] array, but maybe some other params depending on the uploader
Returns
nothing, but if some files failed to upload, the actual error message can be determined by calling BxDolUploader::getUploadErrorMessages()

◆ isAvailable()

BxDolUploader::isAvailable ( )

Is uploader available?

Returns
boolean

◆ isInstalled()

BxDolUploader::isInstalled ( )

Are required php modules installed for this uploader ?

Returns
boolean

◆ reorderGhosts()

BxDolUploader::reorderGhosts (   $iProfileId,
  $sFormat,
  $aGhosts,
  $iContentId = false 
)

Reorder uploaded ghosts.

Parameters
$iProfileId- profile id to get orphaned files from
$sFormat- output format, only 'json' output formt is supported
$aGhosts- an array of ordered ghosts' IDs.
$iContentId- content id to order orphaned files for, false by default
Returns
JSON string

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