DrupalImageCaption.php in Zircon Profile 8.0
File
core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalImageCaption.php
View source
<?php
namespace Drupal\ckeditor\Plugin\CKEditorPlugin;
use Drupal\Component\Plugin\PluginBase;
use Drupal\editor\Entity\Editor;
use Drupal\ckeditor\CKEditorPluginInterface;
use Drupal\ckeditor\CKEditorPluginContextualInterface;
class DrupalImageCaption extends PluginBase implements CKEditorPluginInterface, CKEditorPluginContextualInterface {
public function isInternal() {
return FALSE;
}
public function getDependencies(Editor $editor) {
return array();
}
public function getLibraries(Editor $editor) {
return array(
'ckeditor/drupal.ckeditor.plugins.drupalimagecaption',
);
}
public function getFile() {
return drupal_get_path('module', 'ckeditor') . '/js/plugins/drupalimagecaption/plugin.js';
}
public function getConfig(Editor $editor) {
$format = $editor
->getFilterFormat();
return array(
'image2_captionedClass' => 'caption caption-img',
'image2_alignClasses' => array(
'align-left',
'align-center',
'align-right',
),
'drupalImageCaption_captionPlaceholderText' => t('Enter caption here'),
'drupalImageCaption_captionFilterEnabled' => $format
->filters('filter_caption')->status,
'drupalImageCaption_alignFilterEnabled' => $format
->filters('filter_align')->status,
);
}
function isEnabled(Editor $editor) {
if (!$editor
->hasAssociatedFilterFormat()) {
return FALSE;
}
$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 === 'DrupalImage') {
$enabled = TRUE;
}
}
}
}
return $enabled;
}
return FALSE;
}
}