/**
* Get the editor extended buttons (usually from plugins)
*
* @param string $editor The name of the editor.
* @param mixed $buttons Can be boolean or array, if boolean defines if the buttons are
* displayed, if array defines a list of buttons not to show.
*
* @return array
*
* @since 1.5
*/
public function getButtons($editor, $buttons = true)
{
$result = array();
if (\is_bool($buttons) && !$buttons) {
return $result;
}
// Get plugins
$plugins = PluginHelper::getPlugin('editors-xtd');
foreach ($plugins as $plugin) {
if (\is_array($buttons) && \in_array($plugin->name, $buttons)) {
continue;
}
PluginHelper::importPlugin('editors-xtd', $plugin->name, false);
$className = 'PlgEditorsXtd' . $plugin->name;
if (!class_exists($className)) {
$className = 'PlgButton' . $plugin->name;
}
if (class_exists($className)) {
$dispatcher = $this->getDispatcher();
$plugin = new $className($dispatcher, (array) $plugin);
}
// Try to authenticate
if (!method_exists($plugin, 'onDisplay')) {
continue;
}
$button = $plugin->onDisplay($editor, $this->asset, $this->author);
if (empty($button)) {
continue;
}
if (\is_array($button)) {
$result = array_merge($result, $button);
continue;
}
$result[] = $button;
}
return $result;
}