UNA
Loading...
Searching...
No Matches
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 ()
 
 getNameJsInstanceUploader ()
 
 getIdContainerResult ()
 
 getIdContainerUploadInProgress ()
 
 getIdContainerPopup ()
 
 getIdContainerErrors ()
 
 handleUploads ($iProfileId, $mixedFiles, $isMultiple=true, $iContentId=false, $bPrivate=true)
 
 getUploadErrorMessages ($sFormat='HTML')
 
 getUploaderButton ($aParams=array())
 
 getUploaderJsParams ()
 
 getUploaderJs ($mixedGhostTemplate, $isMultiple=true, $aParams=array(), $bDynamic=false)
 
 addCssJs ($bDynamic=false)
 
 addJs ($mixedFile)
 
 addCss ($mixedFile)
 
 getUploaderButtonTitle ($mixed=false)
 
 getUploaderForm ($isMultiple=true, $iContentId=false, $isPrivate=true)
 
 getGhosts ($iProfileId, $sFormat, $sImagesTranscoder=false, $iContentId=false)
 
 getGhostsWithOrder ($iProfileId, $sFormat, $sImagesTranscoder=false, $iContentId=false)
 
 reorderGhosts ($iProfileId, $sFormat, $aGhosts, $iContentId=false)
 
 deleteGhost ($iFileId, $iProfileId)
 
 deleteGhostsForProfile ($iProfileId, $iContentId=false)
 
 appendUploadErrorMessage ($s)
 

Static Public Member Functions

static getObjectInstance ($sObject, $sStorageObject, $sResultContainerId, $oTemplate=false)
 

Protected Member Functions

 __construct ($aObject, $sStorageObject, $sUniqId, $oTemplate)
 
 cleanUploadErrorMessages ()
 
 getRestrictionsText ()
 
 getMaxUploadFileSize ()
 
 getAcceptedFilesExtensions ()
 
 getGhostTemplateVars ($aFile, $iProfileId, $iContentId, $oStorage, $oImagesTranscoder)
 
 isUseTranscoderForPreview ($oImagesTranscoder, $aFile)
 
 isAdmin ($iContentId=0)
 

Protected Attributes

 $_oTemplate
 
 $_aObject
 
 $_sStorageObject
 
 $_sUniqId
 
 $_sUploaderJsInstance
 
 $_sUploadInProgressContainerId
 
 $_sPopupContainerId
 
 $_sResultContainerId
 
 $_sErrorsContainerId
 
 $_sFormContainerId
 
 $_sUploadErrorMessages
 
 $_sButtonTemplate
 
 $_sJsTemplate
 
 $_sUploaderFormTemplate
 
 $_aJs
 
 $_aCss
 

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');
Definition BxDolFormNestedGhost.php:16
  • '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

Reimplemented in BxAdsUploaderHTML5, BxAdsUploaderHTML5Attach, BxAdsUploaderRecordVideo, BxAdsUploaderRecordVideoAttach, BxAlbumsUploaderCrop, BxAlbumsUploaderHTML5, BxAlbumsUploaderRecordVideo, BxBaseCmtsUploaderHTML5, BxBaseModFilesUploaderHTML5, BxBaseModGroupsUploaderCoverCrop, BxBaseModGroupsUploaderPictureCrop, BxBaseModProfileUploaderCoverCrop, BxBaseModProfileUploaderPictureCrop, BxBaseModTextUploaderHTML5, BxBaseModTextUploaderHTML5Attach, BxBaseModTextUploaderRecordVideo, BxBaseModTextUploaderRecordVideoAttach, BxBaseStudioBuilderPageUploaderHTML5, BxBaseStudioSettingsUploaderHTML5, BxBaseStudioUploaderCropCover, BxBaseUploaderCrop, BxBaseUploaderHTML5, BxBaseUploaderRecordVideo, BxBaseUploaderSimple, BxClssUploaderHTML5, BxClssUploaderHTML5Attach, BxClssUploaderRecordVideo, BxClssUploaderRecordVideoAttach, BxCnlUploaderCoverCrop, BxCnlUploaderPictureCrop, BxCoursesUploaderCoverCrop, BxCoursesUploaderPictureCrop, BxEventsUploaderCoverCrop, BxEventsUploaderPictureCrop, BxFilesUploaderHTML5, BxForumUploaderHTML5, BxForumUploaderHTML5Attach, BxForumUploaderRecordVideo, BxForumUploaderRecordVideoAttach, BxGlsrUploaderHTML5, BxGroupsUploaderCoverCrop, BxGroupsUploaderPictureCrop, BxJobsUploaderCoverCrop, BxJobsUploaderPictureCrop, BxMarketUploaderHTML5, BxOrgsUploaderCoverCrop, BxOrgsUploaderPictureCrop, BxPersonsUploaderCoverCrop, BxPersonsUploaderPictureCrop, BxPhotosUploaderHTML5, BxPostsUploaderHTML5, BxPostsUploaderHTML5Attach, BxPostsUploaderRecordVideo, BxPostsUploaderRecordVideoAttach, BxReviewsUploaderHTML5, BxReviewsUploaderHTML5Attach, BxReviewsUploaderRecordVideo, BxReviewsUploaderRecordVideoAttach, BxSpacesUploaderCoverCrop, BxSpacesUploaderPictureCrop, BxStrmUploaderHTML5, BxTasksUploaderHTML5, BxTasksUploaderHTML5Attach, BxTasksUploaderRecordVideo, BxTasksUploaderRecordVideoAttach, BxTemplCmtsUploaderHTML5, BxTemplStudioBuilderPageUploaderHTML5, BxTemplStudioSettingsUploaderHTML5, BxTemplStudioUploaderCropCover, BxTemplUploaderCrop, BxTemplUploaderHTML5, BxTemplUploaderRecordVideo, BxTimelineUploaderHTML5Attach, BxTimelineUploaderRecordVideoAttach, BxVideosUploaderHTML5, and BxVideosUploaderRecordVideo.

Member Function Documentation

◆ addCssJs()

BxDolUploader::addCssJs ( $bDynamic = false)

add necessary js, css files and js translations

Reimplemented in BxBaseUploaderCrop, and BxBaseUploaderRecordVideo.

◆ deleteGhost()

BxDolUploader::deleteGhost ( $iFileId,
$iProfileId )

Delete file by file id, usually ghost file

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

Reimplemented in BxBaseStudioSettingsUploaderHTML5.

◆ deleteGhostsForProfile()

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

Delete all ghosts files for the specified profile

Returns
number of delete ghost files

Reimplemented in BxBaseModProfileUploaderCoverCrop, and BxBaseModProfileUploaderPictureCrop.

◆ 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

Reimplemented in BxBaseModProfileUploaderCoverCrop, BxBaseModProfileUploaderPictureCrop, and BxBaseStudioSettingsUploaderHTML5.

◆ getUploaderButton()

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

Show uploader button.

Returns
HTML string

Reimplemented in BxBaseUploaderHTML5.

◆ getUploaderButtonTitle()

BxDolUploader::getUploaderButtonTitle ( $mixed = false)

Get uploader button title

Reimplemented in BxBaseUploaderCrop, BxBaseUploaderHTML5, BxBaseUploaderRecordVideo, and BxBaseUploaderSimple.

◆ getUploaderForm()

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

Show uploader form.

Returns
HTML string

Reimplemented in BxBaseUploaderCrop, BxBaseUploaderHTML5, and BxBaseUploaderSimple.

◆ getUploaderJs()

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

Show uploader JS.

Returns
HTML string

Reimplemented in BxBaseUploaderRecordVideo, and BxTimelineUploaderHTML5Attach.

◆ 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()

Reimplemented in BxBaseStudioSettingsUploaderHTML5, BxBaseUploaderCrop, BxBaseUploaderHTML5, and BxBaseUploaderRecordVideo.

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