LlamaContextualAndButton.php in Zircon Profile 8.0
File
core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaContextualAndButton.php
View source
<?php
namespace Drupal\ckeditor_test\Plugin\CKEditorPlugin;
use Drupal\ckeditor\CKEditorPluginButtonsInterface;
use Drupal\ckeditor\CKEditorPluginContextualInterface;
use Drupal\ckeditor\CKEditorPluginConfigurableInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\editor\Entity\Editor;
class LlamaContextualAndButton extends Llama implements CKEditorPluginContextualInterface, CKEditorPluginButtonsInterface, CKEditorPluginConfigurableInterface {
function isEnabled(Editor $editor) {
$settings = $editor
->getSettings();
foreach ($settings['toolbar']['rows'] as $row) {
foreach ($row as $group) {
if (in_array('Strike', $group['items'])) {
return TRUE;
}
}
}
return FALSE;
}
function getButtons() {
return array(
'Llama' => array(
'label' => t('Insert Llama'),
),
);
}
function getFile() {
return drupal_get_path('module', 'ckeditor_test') . '/js/llama_contextual_and_button.js';
}
function settingsForm(array $form, FormStateInterface $form_state, Editor $editor) {
$config = array(
'ultra_llama_mode' => FALSE,
);
$settings = $editor
->getSettings();
if (isset($settings['plugins']['llama_contextual_and_button'])) {
$config = $settings['plugins']['llama_contextual_and_button'];
}
$form['ultra_llama_mode'] = array(
'#title' => t('Ultra llama mode'),
'#type' => 'checkbox',
'#default_value' => $config['ultra_llama_mode'],
);
return $form;
}
}
Classes
Name |
Description |
LlamaContextualAndButton |
Defines a "LlamaContextualAndbutton" plugin, with a contextually OR toolbar
builder-enabled "llama" feature. |