mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
NOTFORMERGE: Merged 84085 from 2.3
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@84089 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
5c68bb3bde
commit
66543e6002
@ -41,10 +41,27 @@ class HtmlEditorConfig {
|
||||
return self::get($identifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the available configurations as a map of friendly_name to
|
||||
* configuration name.
|
||||
* @return array
|
||||
*/
|
||||
static function get_available_configs_map() {
|
||||
$configs = array();
|
||||
|
||||
foreach(self::$configs as $identifier => $config) {
|
||||
$configs[$identifier] = $config->getOption('friendly_name');
|
||||
}
|
||||
|
||||
return $configs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Holder for all TinyMCE settings _except_ plugins and buttons
|
||||
*/
|
||||
protected $settings = array(
|
||||
'friendly_name' => '(Please set a friendly name for this config)',
|
||||
'priority' => 0,
|
||||
'mode' => "specific_textareas",
|
||||
'editor_selector' => "htmleditor",
|
||||
'width' => "100%",
|
||||
|
@ -14,6 +14,7 @@ class Group extends DataObject {
|
||||
"Locked" => "Boolean",
|
||||
"Sort" => "Int",
|
||||
"IPRestrictions" => "Text",
|
||||
"HtmlEditorConfig" => "Varchar"
|
||||
);
|
||||
|
||||
static $has_one = array(
|
||||
@ -63,6 +64,7 @@ class Group extends DataObject {
|
||||
) .
|
||||
"</p>"
|
||||
),
|
||||
new DropdownField('HtmlEditorConfig', 'HTML Editor Configuration', HtmlEditorConfig::get_available_configs_map()),
|
||||
new TableField(
|
||||
"Permissions",
|
||||
"Permission",
|
||||
|
@ -1026,6 +1026,27 @@ class Member extends DataObject {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the HtmlEditorConfig for this user to be used in the CMS.
|
||||
* This is set by the group.
|
||||
* @return string
|
||||
*/
|
||||
function getHtmlEditorConfigForCMS() {
|
||||
$currentName = '';
|
||||
$currentPriority = 0;
|
||||
|
||||
foreach($this->Groups() as $group) {
|
||||
$configName = $group->HtmlEditorConfig;
|
||||
$config = HtmlEditorConfig::get($group->HtmlEditorConfig);
|
||||
if($config && $config->getOption('priority') > $currentPriority) {
|
||||
$currentName = $configName;
|
||||
}
|
||||
}
|
||||
|
||||
// If can't find a suitable editor, just default to cms
|
||||
return $currentName ? $currentName : 'cms';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user