diff --git a/README.md b/README.md index 065acd1..c274ac8 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # synimage - * Включить модуль - * Добавить 2 мультимедиа-кнопки в настройке редактора - * включить 2 фильтра: Сolorbox и Image References и убедиться что последний вниуз +* Включить модуль +* Добавить 2 мультимедиа-кнопки в настройке редактора +* включить 2 фильтра: Сolorbox и Image References и убедиться что + последний вниуз diff --git a/css/synimage.css b/css/synimage.css index 1c5dfd6..99fe6c4 100644 --- a/css/synimage.css +++ b/css/synimage.css @@ -1,24 +1,21 @@ -/** - * Fix ui dialog styles. - */ - -.ui-dialog {} -.ui-dialog .ui-dialog-titlebar { - padding-right: 1.5em; - position: relative; -} -.ui-dialog .ui-dialog-titlebar-close { - right: 14px; - top: 56%; -} - -#editor-image-dialog-form {} -#editor-image-dialog-form { - font-size: 1rem; -} -#editor-image-dialog-form .form-radios label::after { - content: none; -} -#editor-image-dialog-form select.form-select { - height: auto !important; -} +/** + * Fix ui dialog styles. + */ + +.ui-dialog .ui-dialog-titlebar { + padding-right: 1.5em; + position: relative; +} +.ui-dialog .ui-dialog-titlebar-close { + right: 14px; + top: 56%; +} +#editor-image-dialog-form { + font-size: 1rem; +} +#editor-image-dialog-form .form-radios label::after { + content: none; +} +#editor-image-dialog-form select.form-select { + height: auto !important; +} diff --git a/src/Controller/ImageRenderer.php b/src/Controller/ImageRenderer.php index 87d43b6..af5e9d0 100644 --- a/src/Controller/ImageRenderer.php +++ b/src/Controller/ImageRenderer.php @@ -19,7 +19,6 @@ class ImageRenderer extends ControllerBase { * Render. */ public function render($form_state) { - $synimage = $form_state->getValue('synimage'); $style = $form_state->getValue('style'); $fid = $form_state->getValue('file-id'); $img = 'fileStorage = $file_storage; + $this->entityTypeManager = $entity_type_manager; } /** @@ -33,7 +37,8 @@ class EditorImageSynboxDialog extends FormBase { */ public static function create(ContainerInterface $container) { return new static( - $container->get('entity.manager')->getStorage('file') + $container->get('entity.manager')->getStorage('file'), + $container->get('entity.manager') ); } @@ -80,11 +85,11 @@ class EditorImageSynboxDialog extends FormBase { 'fid' => $this->getFid($image_element), 'src' => isset($image_element['src']) ? $image_element['src'] : $image_element['src'] = '', 'alt' => isset($image_element['alt']) ? $image_element['alt'] : $image_element['alt'] = '', - 'align' => isset($image_element['align']) ? $image_element['align'] : $image_element['align']='', + 'align' => isset($image_element['align']) ? $image_element['align'] : $image_element['align'] = '', 'caption' => isset($synimage['caption']) ? $synimage['caption'] : $synimage['caption'] = '', 'style' => isset($synimage['style']) ? $synimage['style'] : $synimage['style'] = '', - 'colorbox' => isset($synimage['colorbox']) ? $synimage['colorbox'] : $synimage['colorbox']='', - 'watermark' => isset($synimage['watermark']) ? $synimage['watermark'] : $synimage['watermark'] ='', + 'colorbox' => isset($synimage['colorbox']) ? $synimage['colorbox'] : $synimage['colorbox'] = '', + 'watermark' => isset($synimage['watermark']) ? $synimage['watermark'] : $synimage['watermark'] = '', ]; } @@ -143,9 +148,9 @@ class EditorImageSynboxDialog extends FormBase { } $form['style'] = [ - '#title' => t('Image style'), + '#title' => $this->t('Image style'), '#type' => 'select', - '#empty_option' => t('None (original image)'), + '#empty_option' => $this->t('None (original image)'), '#options' => $this->getStyles('synimage'), '#default_value' => $defaults['style'], ]; @@ -247,7 +252,7 @@ class EditorImageSynboxDialog extends FormBase { $fid = NULL; if (isset($image_element['data-entity-uuid'])) { $uuid = trim($image_element['data-entity-uuid']); - $existing_file = \Drupal::entityManager()->loadEntityByUuid('file', $uuid); + $existing_file = $this->entityTypeManager->loadEntityByUuid('file', $uuid); $fid = [$existing_file->id()]; } return $fid; diff --git a/src/Plugin/CKEditorPlugin/SynImage.php b/src/Plugin/CKEditorPlugin/SynImage.php index b187c3f..c23dc50 100644 --- a/src/Plugin/CKEditorPlugin/SynImage.php +++ b/src/Plugin/CKEditorPlugin/SynImage.php @@ -47,7 +47,7 @@ class SynImage extends CKEditorPluginBase implements CKEditorPluginConfigurableI */ public function getConfig(Editor $editor) { $config = []; - $settings = $editor->getSettings(); + $config = $editor->getSettings(); return $config; } @@ -86,15 +86,15 @@ class SynImage extends CKEditorPluginBase implements CKEditorPluginConfigurableI '#title' => $this->t('Allow upload'), '#required' => FALSE, '#default_value' => $config['upload'], - '#description' => 'Позволять загружать картинки из виджета, лучше не юзать', + '#description' => t('Позволять загружать картинки из виджета, лучше не юзать'), ]; $form['watermark'] = [ '#type' => 'checkbox', '#title' => $this->t('Allow watermark'), '#required' => FALSE, '#default_value' => $config['watermark'], - '#description' => 'Дать возможность использвать watermark, - должет существовать соотвествующий стиль', + '#description' => t('Дать возможность использвать watermark, + должет существовать соотвествующий стиль'), ]; return $form; } diff --git a/src/Plugin/CKEditorPlugin/YoutubePlugin.php b/src/Plugin/CKEditorPlugin/YoutubePlugin.php index 390832a..7be18d3 100644 --- a/src/Plugin/CKEditorPlugin/YoutubePlugin.php +++ b/src/Plugin/CKEditorPlugin/YoutubePlugin.php @@ -20,10 +20,10 @@ class YoutubePlugin extends CKEditorPluginBase { */ public function getButtons() { return [ - 'Youtube' => array( + 'Youtube' => [ 'label' => t('YouTube'), 'image' => drupal_get_path('module', 'synimage') . '/js/plugins/youtube/icons/icon.png', - ), + ], ]; } @@ -38,14 +38,14 @@ class YoutubePlugin extends CKEditorPluginBase { * {@inheritdoc} */ public function getDependencies(Editor $editor) { - return array(); + return []; } /** * {@inheritdoc} */ public function getLibraries(Editor $editor) { - return array(); + return []; } /** diff --git a/src/Plugin/Filter/FilterColorbox.php b/src/Plugin/Filter/FilterColorbox.php index 92189e7..745e647 100644 --- a/src/Plugin/Filter/FilterColorbox.php +++ b/src/Plugin/Filter/FilterColorbox.php @@ -27,7 +27,7 @@ class FilterColorbox extends FilterBase { $settings = \Drupal::config('colorbox.settings'); $style = $settings->get('custom.style'); if ($settings->get('custom.activate')) { - $js_settings = array( + $js_settings = [ 'transition' => $settings->get('custom.transition_type'), 'speed' => $settings->get('custom.transition_speed'), 'opacity' => $settings->get('custom.opacity'), @@ -50,10 +50,10 @@ class FilterColorbox extends FilterBase { 'scrolling' => $settings->get('custom.scrolling') ? TRUE : FALSE, 'mobiledetect' => $settings->get('advanced.mobile_detect') ? TRUE : FALSE, 'mobiledevicewidth' => $settings->get('advanced.mobile_device_width'), - ); + ]; } else { - $js_settings = array( + $js_settings = [ 'opacity' => '0.85', 'current' => $this->t('{current} of {total}'), 'previous' => $this->t('« Prev'), @@ -64,7 +64,7 @@ class FilterColorbox extends FilterBase { 'fixed' => TRUE, 'mobiledetect' => $settings->get('advanced.mobile_detect') ? TRUE : FALSE, 'mobiledevicewidth' => $settings->get('advanced.mobile_device_width'), - ); + ]; } $result->addAttachments([ diff --git a/src/Plugin/Filter/ImageReference.php b/src/Plugin/Filter/ImageReference.php index c93d4da..23a7222 100644 --- a/src/Plugin/Filter/ImageReference.php +++ b/src/Plugin/Filter/ImageReference.php @@ -51,7 +51,7 @@ class ImageReference extends FilterBase implements ContainerFactoryPluginInterfa /** * {@inheritdoc} */ - static public function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { return new static( $configuration, $plugin_id, @@ -69,7 +69,7 @@ class ImageReference extends FilterBase implements ContainerFactoryPluginInterfa if (stristr($text, 'data-synimage="') !== FALSE) { $dom = Html::load($text); $xpath = new \DOMXPath($dom); - $processed_uuids = array(); + $processed_uuids = []; foreach ($xpath->query('//*[@data-entity-type="file" and @data-entity-uuid]') as $node) { $uuid = $node->getAttribute('data-entity-uuid'); $synimage_string = $node->getAttribute('data-synimage'); diff --git a/synimage.info.yml b/synimage.info.yml index 678995b..fadd975 100644 --- a/synimage.info.yml +++ b/synimage.info.yml @@ -2,5 +2,4 @@ name: Synapse Image Formatter description: 'Wysiwyg Colorbox image' type: module core: 8.x -version: 1.0 package: Synapse diff --git a/synimage.module b/synimage.module index 418dedb..7c967db 100644 --- a/synimage.module +++ b/synimage.module @@ -9,11 +9,11 @@ * Implements hook_ckeditor_plugin_info_alter(). */ function synimage_ckeditor_plugin_info_alter(array &$plugins) { - $plugins['synimage'] = array( + $plugins['synimage'] = [ 'id' => 'synimage', 'label' => t('Image insert'), 'module' => 'synimage', 'class' => 'Drupal\synimage\Plugin\CKEditorPlugin\SynImage', 'provider' => 'synimage', - ); + ]; }