PHP Class FileUploadPlugin, addons

Inheritance: extends Gdn_Plugin
Mostra file Open project: vanilla/addons Class Usage Examples

Protected Properties

Property Type Description
$_MediaCache array

Public Methods

Method Description
__construct ( ) Permission checks & property prep.
apcAvailable ( ) : boolean
assetModel_styleCss_handler ( AssetModel $sender ) Add our CSS.
base_transformDiscussionToComment_handler ( object $sender, array $args ) Update Gdn_Media when a discussion is transformed into a comment due to a merge.
commentModel_deleteComment_handler ( CommentModel $Sender )
controller_delete ( $Sender )
discussionController_afterCommentBody_handler ( DiscussionController $Sender, $Args ) : void
discussionController_afterDiscussionBody_handler ( DiscussionController $Sender )
discussionController_beforeFormButtons_handler ( DiscussionController $Sender )
discussionController_download_create ( DiscussionController $Sender )
discussionController_render_before ( DiscussionController $Sender ) Calls FileUploadPlugin::PrepareController
discussionModel_deleteDiscussion_handler ( DiscussionModel $Sender )
drawAttachFile ( mixed $Sender ) DrawAttachFile function.
findLocalMedia ( mixed $Media, $Absolute = false, $ReturnString = false ) : array
findLocalMediaFolder ( mixed $MediaID, mixed $UserID, $Absolute = false, $ReturnString = false ) : array
logModel_afterInsert_handler ( object $Sender, array $Args ) Attach files to a log entry; used when new content is sent to moderation queue.
logModel_afterRestore_handler ( LogModel $Sender, array $Args ) Attach files to record created by restoring a log entry.
mediaCache ( ) : array | null Get our cache.
mediaModel ( ) : MediaModel Get instance of MediaModel.
pluginController_fileUpload_create ( PluginController $Sender )
postController_afterBodyField_handler ( $sender ) Add "Attach a file" to edit comment form.
postController_afterCommentBody_handler ( PostController $Sender ) : void
postController_afterCommentSave_handler ( PostController $Sender, array $Args ) Attach files to a comment during save.
postController_afterDiscussionFormOptions_handler ( PostController $Sender ) Calls FileUploadPlugin::DrawAttachFile
postController_afterDiscussionSave_handler ( PostController $Sender, array $Args ) Attach files to a discussion during save.
postController_checkUpload_create ( object $Sender ) Controller method that allows an AJAX call to check the progress of a file upload that is currently in progress.
postController_render_before ( PostController $Sender ) Calls FileUploadPlugin::PrepareController
postController_upload_create ( object $Sender ) Allows plugin to handle ajax file uploads.
settingsController_addEditCategory_handler ( SettingsController $Sender )
setup ( ) Run once on enable.
structure ( ) Database update.
utilityController_thumbnail_create ( UtilityController $Sender, array $Args = [] ) Create and display a thumbnail of an uploaded file.

Protected Methods

Method Description
attachAllFiles ( mixed $AttachedFilesData, mixed $AllFilesData, mixed $ForeignID, mixed $ForeignTable ) : void AttachAllFiles function.
attachFile ( integer $FileID, integer $ForeignID, string $ForeignType ) : boolean Attach a file to a foreign table and ID.
attachUploadsToComment ( Gdn_Controller $Controller, string $Type = 'comment' ) : void
cacheAttachedMedia ( mixed $Sender ) : void CacheAttachedMedia function.
placeMedia ( &$Media, mixed $UserID ) : boolean
prepareController ( mixed $Controller ) Adds CSS and JS includes to the header of the discussion or post.
trashFile ( integer $MediaID ) Delete an uploaded file & its media record.

Method Details

__construct() public method

Permission checks & property prep.
public __construct ( )

apcAvailable() public static method

public static apcAvailable ( ) : boolean
return boolean

assetModel_styleCss_handler() public method

Add our CSS.
public assetModel_styleCss_handler ( AssetModel $sender )
$sender AssetModel

attachAllFiles() protected method

AttachAllFiles function.
protected attachAllFiles ( mixed $AttachedFilesData, mixed $AllFilesData, mixed $ForeignID, mixed $ForeignTable ) : void
$AttachedFilesData mixed
$AllFilesData mixed
$ForeignID mixed
$ForeignTable mixed
return void

attachFile() protected method

Attach a file to a foreign table and ID.
protected attachFile ( integer $FileID, integer $ForeignID, string $ForeignType ) : boolean
$FileID integer
$ForeignID integer
$ForeignType string Lowercase.
return boolean Whether attach was successful.

attachUploadsToComment() protected method

protected attachUploadsToComment ( Gdn_Controller $Controller, string $Type = 'comment' ) : void
$Controller Gdn_Controller
$Type string
return void

base_transformDiscussionToComment_handler() public method

Update Gdn_Media when a discussion is transformed into a comment due to a merge.
public base_transformDiscussionToComment_handler ( object $sender, array $args )
$sender object Sending controller instance
$args array Event's arguments

cacheAttachedMedia() protected method

CacheAttachedMedia function.
protected cacheAttachedMedia ( mixed $Sender ) : void
$Sender mixed
return void

commentModel_deleteComment_handler() public method

public commentModel_deleteComment_handler ( CommentModel $Sender )
$Sender CommentModel

controller_delete() public method

public controller_delete ( $Sender )
$Sender

discussionController_afterCommentBody_handler() public method

public discussionController_afterCommentBody_handler ( DiscussionController $Sender, $Args ) : void
$Sender DiscussionController
return void

discussionController_afterDiscussionBody_handler() public method

public discussionController_afterDiscussionBody_handler ( DiscussionController $Sender )
$Sender DiscussionController

discussionController_beforeFormButtons_handler() public method

public discussionController_beforeFormButtons_handler ( DiscussionController $Sender )
$Sender DiscussionController

discussionController_download_create() public method

public discussionController_download_create ( DiscussionController $Sender )
$Sender DiscussionController

discussionController_render_before() public method

Calls FileUploadPlugin::PrepareController
public discussionController_render_before ( DiscussionController $Sender )
$Sender DiscussionController The hooked controller

discussionModel_deleteDiscussion_handler() public method

public discussionModel_deleteDiscussion_handler ( DiscussionModel $Sender )
$Sender DiscussionModel

drawAttachFile() public method

Helper method that allows the plugin to insert the file uploader UI into the Post Discussion and Post Comment forms.
public drawAttachFile ( mixed $Sender )
$Sender mixed

findLocalMedia() public static method

public static findLocalMedia ( mixed $Media, $Absolute = false, $ReturnString = false ) : array
$Media mixed
return array

findLocalMediaFolder() public static method

public static findLocalMediaFolder ( mixed $MediaID, mixed $UserID, $Absolute = false, $ReturnString = false ) : array
$MediaID mixed
$UserID mixed
return array

logModel_afterInsert_handler() public method

Attach files to a log entry; used when new content is sent to moderation queue.
public logModel_afterInsert_handler ( object $Sender, array $Args )
$Sender object
$Args array

logModel_afterRestore_handler() public method

This happens when a discussion or comment is approved.
public logModel_afterRestore_handler ( LogModel $Sender, array $Args )
$Sender LogModel
$Args array

mediaCache() public method

Get our cache.
public mediaCache ( ) : array | null
return array | null

mediaModel() public method

Get instance of MediaModel.
public mediaModel ( ) : MediaModel
return MediaModel MediaModel

placeMedia() protected method

protected placeMedia ( &$Media, mixed $UserID ) : boolean
$UserID mixed
return boolean

pluginController_fileUpload_create() public method

public pluginController_fileUpload_create ( PluginController $Sender )
$Sender PluginController

postController_afterBodyField_handler() public method

Add "Attach a file" to edit comment form.
public postController_afterBodyField_handler ( $sender )
$sender

postController_afterCommentBody_handler() public method

public postController_afterCommentBody_handler ( PostController $Sender ) : void
$Sender PostController
return void

postController_afterCommentSave_handler() public method

Attach files to a comment during save.
public postController_afterCommentSave_handler ( PostController $Sender, array $Args )
$Sender PostController
$Args array

postController_afterDiscussionFormOptions_handler() public method

Calls FileUploadPlugin::DrawAttachFile
public postController_afterDiscussionFormOptions_handler ( PostController $Sender )
$Sender PostController

postController_afterDiscussionSave_handler() public method

Attach files to a discussion during save.
public postController_afterDiscussionSave_handler ( PostController $Sender, array $Args )
$Sender PostController
$Args array

postController_checkUpload_create() public method

Controller method that allows an AJAX call to check the progress of a file upload that is currently in progress.
public postController_checkUpload_create ( object $Sender )
$Sender object

postController_render_before() public method

Calls FileUploadPlugin::PrepareController
public postController_render_before ( PostController $Sender )
$Sender PostController The hooked controller

postController_upload_create() public method

Allows plugin to handle ajax file uploads.
public postController_upload_create ( object $Sender )
$Sender object

prepareController() protected method

Adds CSS and JS includes to the header of the discussion or post.
protected prepareController ( mixed $Controller )
$Controller mixed The hooked controller

settingsController_addEditCategory_handler() public method

public settingsController_addEditCategory_handler ( SettingsController $Sender )
$Sender SettingsController

setup() public method

Run once on enable.
public setup ( )

structure() public method

Database update.
public structure ( )

trashFile() protected method

Delete an uploaded file & its media record.
protected trashFile ( integer $MediaID )
$MediaID integer Unique ID on Media table.

utilityController_thumbnail_create() public method

Create and display a thumbnail of an uploaded file.
public utilityController_thumbnail_create ( UtilityController $Sender, array $Args = [] )
$Sender UtilityController
$Args array

Property Details

$_MediaCache protected_oe property

protected array $_MediaCache
return array