PHP Class EditorPlugin, vanilla

Inheritance: extends Gdn_Plugin
Afficher le fichier Open project: vanilla/vanilla

Méthodes publiques

Свойство Type Description
$ForceWysiwyg integer | mixed

Protected Properties

Свойство Type Description
$AssetPath Asset path for this plugin, set in Gdn_Form_BeforeBodyBox_Handler.
$Format Default format being used for current rendering. Can be one of the formats listed in $Formats.
$Formats List of possible formats the editor supports.
$canUpload boolean
$editorBaseUploadDestinationDir string
$editorFileInputName This is used as the input name for file uploads. It will be passed to JS as well. Note that it can be defined as an array, by adding square brackets, e.g., editorupload[], but that will make all the Vanilla upload classes incompatible because they are hardcoded to handle only single files at a time, not an array of files. Perhaps in future make core upload classes more flexible.
$mediaCache This will cache the discussion media results for the page request. Populated from either the db or memcached.
$mediaCacheExpire How long memcached holds data until it expires.
$pluginInfo Give class access to PluginInfo

Méthodes publiques

Méthode Description
__construct ( ) Setup some variables for instance.
assetModel_styleCss_handler ( $Sender ) Load CSS into head for editor
base_render_before ( $Sender ) Placed these components everywhere due to some Web sites loading the editor in some areas where the values were not yet injected into HTML.
discussionController_afterCommentBody_handler ( $Sender, $Args )
discussionController_afterDiscussionBody_handler ( $Sender, $Args )
gdn_form_beforeBodyBox_handler ( Gdn_Form $Sender, $Args ) Attach editor anywhere 'BodyBox' is used.
getAbsoluteDestinationFilePath ( $tmpFilePath, $fileExtension, $uploadDestinationDir = '' ) Instead of using Gdn_Upload->GenerateTargetName, create one that depends on SHA1s, to reduce space for duplicates, and use smarter folder sorting based off the SHA1s.
getAllowedEditorActions ( ) : array Set the editor actions to true or false to enable or disable the action from displaying in the editor toolbar.
getBaseUploadDestinationDir ( $subdir = false ) Specific to editor upload paths
getFontFamilyOptions ( ) : array Generate list of font families. Remember to create corresponding CSS.
isEmbeddedComment ( Controller $Sender ) : boolean Check if comments are embedded.
mediaCache ( $Sender ) Get media list for inserting into discussion and comments.
messagesController_afterConversationMessageBody_handler ( $Sender, $Args )
messagesController_afterConversationSave_handler ( object $Sender, array $Args ) Attach files to a message during conversation save.
messagesController_afterMessageSave_handler ( object $Sender, array $Args ) Attach files to a message during save.
postController_afterCommentBody_handler ( $Sender, $Args )
postController_afterCommentSave_handler ( object $Sender, array $Args ) Attach files to a comment during save.
postController_afterDiscussionSave_handler ( object $Sender, array $Args ) Attach files to a discussion during save.
postController_discussionFormOptions_handler ( $Sender, $Args )
postController_editorUpload_create ( PostController $Sender, array $Args = [] )
preloadDiscussionMedia ( integer $discussionID, array $commentIDList, $type = 'discussion' ) : array Query the Media table for any media related to the current discussion, including all the comments. This will be cached per discussion.
saveUploads ( $id, $type ) Save uploads.
settingsController_addEditCategory_handler ( Gdn_Controller $Sender ) Add upload option checkbox to custom permissions for categories.
settingsController_editor_create ( SettingsController $Sender, array $Args )
setup ( ) When enabled, disable other known editors that may clash with this one.
sortWeightedOptions ( &$options ) Sort dropdown options by given weight.
structure ( )
utilityController_mediaThumbnail_create ( $sender, $media_id ) Create and display a thumbnail of an uploaded file.
validateUploadDestinationPath ( string $path ) Check if provided path is valid, creates it if it does not exist, and verifies that it is writable.

Méthodes protégées

Méthode Description
attachEditorUploads ( integer $FileID, integer $ForeignID, string $ForeignType ) : boolean Attach a file to a foreign table and ID.
attachUploadsToComment ( $Sender, string $Type = 'comment', array | object $row = null ) Attach image to each discussion or comment.
cacheAttachedMedia ( mixed $Sender ) Called to prepare data grab, and then cache the results on the software level for the request.
canUpload ( ) : boolean Checks whether the canUpload property is set and if not, calculates it value.
deleteEditorUploads ( $MediaID, type $ForeignID = '', type $ForeignType = '' ) : boolean Remove file from filesystem, and clear db entry.
getConversationMessageIDList ( $id ) : array
getEditorToolbar ( $attributes = [] ) : array This method will grab the permissions array from getAllowedEditorActions, build the "kitchen sink" editor toolbar, then filter out the allowed ones and return it.
getFontColorList ( ) : array To enable more colors in the dropdown, simply expand the array to include more human-readable font color names.
getFontFormatOptions ( ) : array Default formatting options available in the formatting dropdown.

Method Details

__construct() public méthode

Setup some variables for instance.
public __construct ( )

assetModel_styleCss_handler() public méthode

Load CSS into head for editor
public assetModel_styleCss_handler ( $Sender )

attachEditorUploads() protected méthode

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

attachUploadsToComment() protected méthode

It will first perform a single request against the Media table, then filter out the ones that exist per discussion or comment.
protected attachUploadsToComment ( $Sender, string $Type = 'comment', array | object $row = null )
$Type string The type of row, either discussion or comment.
$row array | object The row of data being attached to.

base_render_before() public méthode

Placed these components everywhere due to some Web sites loading the editor in some areas where the values were not yet injected into HTML.
public base_render_before ( $Sender )

cacheAttachedMedia() protected méthode

This will call PreloadDiscussionMedia, which will either query the db, or query memcached.
protected cacheAttachedMedia ( mixed $Sender )
$Sender mixed

canUpload() protected méthode

The calculation is based on config, user permissions, and category permissions.
protected canUpload ( ) : boolean
Résultat boolean Whether the session user is allowed to upload a file.

deleteEditorUploads() protected méthode

Remove file from filesystem, and clear db entry.
protected deleteEditorUploads ( $MediaID, type $ForeignID = '', type $ForeignType = '' ) : boolean
$ForeignID type
$ForeignType type
Résultat boolean

discussionController_afterCommentBody_handler() public méthode

discussionController_afterDiscussionBody_handler() public méthode

gdn_form_beforeBodyBox_handler() public méthode

It is not being used for editing a posted reply, so find another event to hook into.
public gdn_form_beforeBodyBox_handler ( Gdn_Form $Sender, $Args )
$Sender Gdn_Form

getAbsoluteDestinationFilePath() public méthode

Instead of using Gdn_Upload->GenerateTargetName, create one that depends on SHA1s, to reduce space for duplicates, and use smarter folder sorting based off the SHA1s.
public getAbsoluteDestinationFilePath ( $tmpFilePath, $fileExtension, $uploadDestinationDir = '' )

getAllowedEditorActions() public méthode

This will also let you toggle the separators from appearing between the loosely grouped actions.
public getAllowedEditorActions ( ) : array
Résultat array List of allowed editor actions

getBaseUploadDestinationDir() public méthode

Specific to editor upload paths
public getBaseUploadDestinationDir ( $subdir = false )

getConversationMessageIDList() protected méthode

protected getConversationMessageIDList ( $id ) : array
$id
Résultat array

getEditorToolbar() protected méthode

This method will grab the permissions array from getAllowedEditorActions, build the "kitchen sink" editor toolbar, then filter out the allowed ones and return it.
protected getEditorToolbar ( $attributes = [] ) : array
Résultat array Returns the array of allowed editor toolbar actions

getFontColorList() protected méthode

Note: in building the dropdown, each color is styled inline, but it will still be required to add the appropriate post-color-* CSS class selectors in the external stylesheet, so that when viewing a posted comment, the color will appear. In addition, the class names must be whitelisted in advanced.js. Not all colors in the CSS stylesheet are included here. Note: use these http://clrs.cc/ and purple: #7b11d0
protected getFontColorList ( ) : array
Résultat array Returns array of font colors to use in dropdown

getFontFamilyOptions() public méthode

Generate list of font families. Remember to create corresponding CSS.
public getFontFamilyOptions ( ) : array
Résultat array

getFontFormatOptions() protected méthode

Visit https://github.com/xing/wysihtml5/wiki/Supported-Commands for a list of default commands and their allowed values. The array below has custom commands that must exist in the JavaScript, whitelist, and CSS to function. Formatting options can be ordered after the default list has been added. This is done by providing a sort weight to each editor action. If one weight is greater than another, it will be displayed higher than the other.
protected getFontFormatOptions ( ) : array
Résultat array

isEmbeddedComment() public méthode

When editing embedded comments, the editor will still load its assets and render. This method will check whether content is embedded or not. This might not be the best way to do this, but there does not seem to be any easy way to determine whether content is embedded or not.
public isEmbeddedComment ( Controller $Sender ) : boolean
$Sender Controller
Résultat boolean

mediaCache() public méthode

Get media list for inserting into discussion and comments.
public mediaCache ( $Sender )

messagesController_afterConversationMessageBody_handler() public méthode

messagesController_afterConversationSave_handler() public méthode

Attach files to a message during conversation save.

messagesController_afterMessageSave_handler() public méthode

Attach files to a message during save.
public messagesController_afterMessageSave_handler ( object $Sender, array $Args )
$Sender object
$Args array

postController_afterCommentBody_handler() public méthode

public postController_afterCommentBody_handler ( $Sender, $Args )

postController_afterCommentSave_handler() public méthode

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

postController_afterDiscussionSave_handler() public méthode

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

postController_discussionFormOptions_handler() public méthode

postController_editorUpload_create() public méthode

public postController_editorUpload_create ( PostController $Sender, array $Args = [] )
$Sender PostController
$Args array

preloadDiscussionMedia() public méthode

Query the Media table for any media related to the current discussion, including all the comments. This will be cached per discussion.
public preloadDiscussionMedia ( integer $discussionID, array $commentIDList, $type = 'discussion' ) : array
$discussionID integer
$commentIDList array
Résultat array

saveUploads() public méthode

Save uploads.
public saveUploads ( $id, $type )
$id
$type

settingsController_addEditCategory_handler() public méthode

Add upload option checkbox to custom permissions for categories.
public settingsController_addEditCategory_handler ( Gdn_Controller $Sender )
$Sender Gdn_Controller

settingsController_editor_create() public méthode

public settingsController_editor_create ( SettingsController $Sender, array $Args )
$Sender SettingsController
$Args array

setup() public méthode

If editor is loaded, then the other editors loaded after, there are CSS rules that hide them. This way, the editor plugin always takes precedence.
public setup ( )

sortWeightedOptions() public méthode

Currently this is only in use for the formatting options.
public sortWeightedOptions ( &$options )

structure() public méthode

public structure ( )

utilityController_mediaThumbnail_create() public méthode

Create and display a thumbnail of an uploaded file.
public utilityController_mediaThumbnail_create ( $sender, $media_id )

validateUploadDestinationPath() public méthode

Check if provided path is valid, creates it if it does not exist, and verifies that it is writable.
public validateUploadDestinationPath ( string $path )
$path string Path to validate

Property Details

$AssetPath protected_oe property

Asset path for this plugin, set in Gdn_Form_BeforeBodyBox_Handler.
protected $AssetPath

$ForceWysiwyg public_oe property

public int|mixed $ForceWysiwyg
Résultat integer | mixed

$Format protected_oe property

Default format being used for current rendering. Can be one of the formats listed in $Formats.
protected $Format

$Formats protected_oe property

List of possible formats the editor supports.
protected $Formats

$canUpload protected_oe property

protected bool $canUpload
Résultat boolean

$editorBaseUploadDestinationDir protected_oe property

protected string $editorBaseUploadDestinationDir
Résultat string

$editorFileInputName protected_oe property

This is used as the input name for file uploads. It will be passed to JS as well. Note that it can be defined as an array, by adding square brackets, e.g., editorupload[], but that will make all the Vanilla upload classes incompatible because they are hardcoded to handle only single files at a time, not an array of files. Perhaps in future make core upload classes more flexible.
protected $editorFileInputName

$mediaCache protected_oe property

This will cache the discussion media results for the page request. Populated from either the db or memcached.
protected $mediaCache

$mediaCacheExpire protected_oe property

How long memcached holds data until it expires.
protected $mediaCacheExpire

$pluginInfo protected_oe property

Give class access to PluginInfo
protected $pluginInfo