BalloonPanelPlugin.php in CKEditor Balloon Panel 2.0.x
File
src/Plugin/CKEditorPlugin/BalloonPanelPlugin.php
View source
<?php
namespace Drupal\ckeditor_balloonpanel\Plugin\CKEditorPlugin;
use Drupal\ckeditor\CKEditorPluginBase;
use Drupal\editor\Entity\Editor;
class BalloonPanelPlugin extends CKEditorPluginBase {
public function getFile() {
if ($library_path = $this
->librariesGetPath('balloonpanel')) {
return $library_path . '/plugin.js';
}
}
public function getConfig(Editor $editor) {
return [];
}
public function getButtons() {
return [];
}
private function librariesGetPath($name, $base_path = FALSE) {
$libraries =& drupal_static(__FUNCTION__);
if (!isset($libraries)) {
$libraries = $this
->getLibraryPaths();
}
$path = $base_path ? base_path() : '';
if (!isset($libraries[$name])) {
return FALSE;
}
else {
$path .= $libraries[$name];
}
return $path;
}
private function getLibraryPaths() {
$searchdir = [];
$config = DrupalKernel::findSitePath(\Drupal::request());
if ($profile = \Drupal::installProfile()) {
$profile_path = drupal_get_path('profile', $profile);
$searchdir[] = "{$profile_path}/libraries";
$searchdir[] = "{$profile_path}/libraries/ckeditor/plugins";
}
$searchdir[] = 'sites/all/libraries';
$searchdir[] = 'sites/all/libraries/ckeditor/plugins';
$searchdir[] = 'libraries';
$searchdir[] = 'libraries/ckeditor/plugins';
$searchdir[] = "{$config}/libraries";
$searchdir[] = "{$config}/libraries/ckeditor/plugins";
$directories = [];
$nomask = [
'CVS',
];
foreach ($searchdir as $dir) {
if (is_dir($dir) && ($handle = opendir($dir))) {
while (FALSE !== ($file = readdir($handle))) {
if (!in_array($file, $nomask) && $file[0] != '.') {
if (is_dir("{$dir}/{$file}")) {
$directories[$file] = "{$dir}/{$file}";
}
}
}
closedir($handle);
}
}
return $directories;
}
}