elFinder.php in elFinder file manager 8.2
File
src/Plugin/BUEditorPlugin/elFinder.php
View source
<?php
namespace Drupal\elfinder\Plugin\BUEditorPlugin;
use Drupal\Core\Form\FormStateInterface;
use Drupal\editor\Entity\Editor;
use Drupal\bueditor\BUEditorPluginBase;
use Drupal\bueditor\Entity\BUEditorEditor;
use Drupal\elfinder\Controller\elFinderPageController;
class elFinder extends BUEditorPluginBase {
public function alterEditorJS(array &$js, BUEditorEditor $bueditor_editor, Editor $editor = NULL) {
if (isset($js['settings']['fileBrowser']) && $js['settings']['fileBrowser'] === 'elfinder') {
$js['libraries'][] = 'elfinder/drupal.elfinder';
$js['libraries'][] = 'elfinder/drupal.elfinder.bueditor';
$browserpage = elFinderPageController::buildBrowserPage(TRUE);
$js['settings']['elfinder'] = $browserpage['#attached']['drupalSettings']['elfinder'];
}
}
public function alterEditorForm(array &$form, FormStateInterface $form_state, BUEditorEditor $bueditor_editor) {
$fb =& $form['settings']['fileBrowser'];
$fb['#options']['elfinder'] = $this
->t('elFinder');
$form['settings']['elfinder'] = array(
'#type' => 'container',
'#states' => array(
'visible' => array(
':input[name="settings[fileBrowser]"]' => array(
'value' => 'elfinder',
),
),
),
'#attributes' => array(
'class' => array(
'description',
),
),
'content' => array(
'#markup' => $this
->t('Configure <a href="!url">elFinder File Manager</a>.', array(
'!url' => \Drupal::url('elfinder.admin'),
)),
),
);
if (isset($fb['#weight'])) {
$form['settings']['elfinder']['#weight'] = $fb['#weight'] + 0.1;
}
drupal_set_message('99');
}
}
Classes
Name |
Description |
elFinder |
Defines elFinder as a BUEditor plugin. |