class DrupalUploadImageImce in CKEditor Upload Image 8.2
Same name and namespace in other branches
- 8 src/Plugin/CKEditorPlugin/DrupalUploadImageImce.php \Drupal\ckeditor_uploadimage\Plugin\CKEditorPlugin\DrupalUploadImageImce
Defines the "templates" plugin.
Plugin annotation
@CKEditorPlugin(
id = "drupaluploadimageimce",
label = @Translation("CKEditor Drupal Upload Image IMCE"),
module = "ckeditor_uploadimage"
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\ckeditor_uploadimage\Plugin\CKEditorPlugin\DrupalUploadImageImce implements CKEditorPluginContextualInterface, CKEditorPluginInterface
Expanded class hierarchy of DrupalUploadImageImce
File
- src/
Plugin/ CKEditorPlugin/ DrupalUploadImageImce.php, line 26 - Contains \Drupal\ckeditor_uploadimage\Plugin\CKEditorPlugin\DrupalUploadImageImce.
Namespace
Drupal\ckeditor_uploadimage\Plugin\CKEditorPluginView source
class DrupalUploadImageImce extends PluginBase implements CKEditorPluginInterface, CKEditorPluginContextualInterface {
/**
* {@inheritdoc}
*/
function getDependencies(Editor $editor) {
return [
'uploadimage',
'uploadwidget',
'filetools',
'notificationaggregator',
'notification',
];
}
/**
* {@inheritdoc}
*/
function getFile() {
return drupal_get_path('module', 'ckeditor_uploadimage') . '/js/plugins/drupaluploadimage/plugin.js';
}
/**
* {@inheritdoc}
*/
function isEnabled(Editor $editor) {
$has_access = \Drupal::currentUser()
->hasPermission('use ckeditor_uploadimage');
if (!$editor
->hasAssociatedFilterFormat() || !$has_access) {
return FALSE;
}
// Automatically enable this plugin if the text format associated with this
// text editor uses the filter_align or filter_caption filter and the
// ImceImage button is enabled.
$format = $editor
->getFilterFormat();
if ($format
->filters('filter_align')->status || $format
->filters('filter_caption')->status) {
$enabled = FALSE;
$settings = $editor
->getSettings();
foreach ($settings['toolbar']['rows'] as $row) {
foreach ($row as $group) {
foreach ($group['items'] as $button) {
if ($button === 'ImceImage') {
$enabled = TRUE;
}
}
}
}
return $enabled;
}
return FALSE;
}
/**
* {@inheritdoc}
*/
function isInternal() {
return FALSE;
}
/**
* {@inheritdoc}
*/
public function getConfig(Editor $editor) {
$filterFormatId = $editor
->getFilterFormat()
->id();
$editorObj = editor_load($filterFormatId);
$imageUploadSettings = $editorObj
->getImageUploadSettings();
$maxFilesize = min(Bytes::toInt($imageUploadSettings['max_size']), Environment::getUploadMaxSize());
return [
'maxImageFilesize' => $maxFilesize,
'imageUploadUrl' => Url::fromRoute('ckeditor_uploadimage.save', [
'filterFormatId' => $filterFormatId,
])
->toString(),
];
}
/**
* {@inheritdoc}
*/
function getLibraries(Editor $editor) {
return [];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DrupalUploadImageImce:: |
public | function |
Returns the additions to CKEDITOR.config for a specific CKEditor instance. Overrides CKEditorPluginInterface:: |
|
DrupalUploadImageImce:: |
function |
Returns a list of plugins this plugin requires. Overrides CKEditorPluginInterface:: |
||
DrupalUploadImageImce:: |
function |
Returns the Drupal root-relative file path to the plugin JavaScript file. Overrides CKEditorPluginInterface:: |
||
DrupalUploadImageImce:: |
function |
Returns a list of libraries this plugin requires. Overrides CKEditorPluginInterface:: |
||
DrupalUploadImageImce:: |
function |
Checks if this plugin should be enabled based on the editor configuration. Overrides CKEditorPluginContextualInterface:: |
||
DrupalUploadImageImce:: |
function |
Indicates if this plugin is part of the optimized CKEditor build. Overrides CKEditorPluginInterface:: |
||
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
PluginBase:: |
public | function | Constructs a \Drupal\Component\Plugin\PluginBase object. | 92 |