QuickEditEditorSelector.php in Quick Edit 7
File
includes/QuickEditEditorSelector.php
View source
<?php
module_load_include('php', 'quickedit', 'includes/QuickEditEditorSelectorInterface');
class QuickEditEditorSelector implements QuickEditEditorSelectorInterface {
protected $alternatives;
public function __construct() {
}
public function getEditor($formatter_type, array $instance, array $items) {
$editors = quickedit_editor_list();
if (!isset($this->alternatives)) {
foreach ($editors as $alternative_editor_id => $editor) {
if (isset($editor['alternativeTo'])) {
foreach ($editor['alternativeTo'] as $original_editor_id) {
$this->alternatives[$original_editor_id][] = $alternative_editor_id;
}
}
}
}
$formatter_settings = $formatter_type['settings'];
$editor_id = $formatter_settings['quickedit']['editor'];
if ($editor_id === 'disabled') {
return;
}
elseif ($editor_id === 'form') {
return 'form';
}
$editor_choices = array(
$editor_id,
);
if (isset($this->alternatives[$editor_id])) {
$editor_choices = array_merge($editor_choices, $this->alternatives[$editor_id]);
}
foreach ($editor_choices as $editor_id) {
$editor_plugin = _quickedit_get_editor_plugin($editor_id);
if ($editor_plugin
->isCompatible($instance, $items)) {
return $editor_id;
}
}
return 'form';
}
public function getEditorAttachments(array $editor_ids) {
$attachments = array();
$editor_ids = array_unique($editor_ids);
foreach ($editor_ids as $editor_id) {
$editor_plugin = _quickedit_get_editor_plugin($editor_id);
$attachments[$editor_id] = $editor_plugin
->getAttachments();
drupal_alter('quickedit_editor_attachments', $attachments[$editor_id], $editor_id);
}
return drupal_array_merge_deep_array($attachments);
}
}