Skip to content

Commit

Permalink
show ever, and is no provider set disable all
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimdoerr committed Mar 21, 2019
1 parent b6fb55f commit fd311ea
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 16 deletions.
1 change: 1 addition & 0 deletions lang/de_de.lang
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ cke5_media_category = Medienkagetorie
cke5_upload_default = Image-Drag&Drop-Upload
cke5_upload_default_description = Bilder können via drag+drop in das Textfeld gesetzt werden
cke5_mediapath = Medienpfad
cke5_mediaembed = MediaEmbed Provider

# profiles list & form actions
rex_cke5_profiles_cloned = Profile wurde dupliziert
Expand Down
1 change: 1 addition & 0 deletions lang/en_gb.lang
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ cke5_media_category = Media-category
cke5_upload_default = Image-Drag&Drop-Upload
cke5_upload_default_description = Pictures can be put into the textarea via drag + drop
cke5_mediapath = Mediapath
cke5_mediaembed = MediaEmbed Provider

# profiles list & form actions
rex_cke5_profiles_cloned = Profile was duplicated
Expand Down
1 change: 1 addition & 0 deletions lang/es_es.lang
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ cke5_media_category = Categoría de medios
cke5_upload_default = Imagen-Arrastrar y Soltar-Subir
cke5_upload_default_description = Las imágenes se pueden poner en textarea a través de arrastrar + soltar
cke5_mediapath = Mediapath
cke5_mediaembed = MediaEmbed Provider

# profiles list & form actions
rex_cke5_profiles_cloned = El perfil fue duplicado
Expand Down
1 change: 1 addition & 0 deletions lang/sv_se.lang
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ cke5_media_category = Mediakagetori
cke5_upload_default = Image-Drag&Drop-Upload
cke5_upload_default_description = Bilder kan läggas i textfältet via drag + drop
cke5_mediapath = Mediapath
cke5_mediaembed = MediaEmbed Provider

# profiles list & form actions
rex_cke5_profiles_cloned = Profilen duplicerades
Expand Down
20 changes: 8 additions & 12 deletions lib/Cke5/Creator/Cke5ProfilesCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ class Cke5ProfilesCreator
const TRANSLATION_PATH = 'vendor/ckeditor5-classic/translations/%s.js';

const EDITOR_SETTINGS = [
'cktypes' => ['heading', 'fontSize', 'fontFamily', 'alignment', 'link', 'highlight', 'insertTable', 'mediaEmbed'],
'cktypes' => ['heading', 'fontSize', 'fontFamily', 'alignment', 'link', 'highlight', 'insertTable'],
'ckimgtypes' => ['rexImage', 'imageUpload']
];

const ALLOWED_FIELDS = [
'toolbar' => ['|', 'heading', 'fontSize', 'fontFamily', 'alignment', 'bold', 'italic', 'underline', 'strikethrough', 'subscript','superscript', 'insertTable', 'code', 'link', 'rexImage', 'imageUpload', 'mediaEmbed', 'bulletedList', 'numberedList', 'blockQuote', 'undo', 'redo', 'highlight', 'emoji'],
'toolbar' => ['|', 'heading', 'fontSize', 'fontFamily', 'alignment', 'bold', 'italic', 'underline', 'strikethrough', 'subscript', 'superscript', 'insertTable', 'code', 'link', 'rexImage', 'imageUpload', 'mediaEmbed', 'bulletedList', 'numberedList', 'blockQuote', 'undo', 'redo', 'highlight', 'emoji'],
'alignment' => ['left', 'right', 'center', 'justify'],
'table_toolbar' => ['tableColumn', 'tableRow', 'mergeTableCells'],
'heading' => ['paragraph', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'],
Expand Down Expand Up @@ -140,29 +140,25 @@ public static function mapProfile(array $profile)
$jsonProfile['highlight'] = ['options' => self::getHighlight(self::toArray($profile['highlight']))];
}

// "mediaEmbed": {
// "removeProviders": [ 'instagram', 'twitter', 'googleMaps', 'flickr', 'facebook' ]
// }

if (in_array('mediaEmbed', $toolbar) && !empty($profile['mediaembed'])) {
if (!empty($profile['mediaembed'])) {
$remove = array();
$hold = self::toArray($profile['mediaembed']);
foreach (self::ALLOWED_FIELDS['providers'] as $value) {
if (!in_array($value, $hold)) {
$remove[] = $value;
}
}
$jsonProfile['mediaEmbed'] = ['removeProviders' => $remove];
$provider = $remove;
} else {
$provider = self::ALLOWED_FIELDS['providers'];
}

// "rexImage": {"media_type" : "testtype"},
// "ckfinder": {"uploadUrl": ".\/index.php?cke5upload=1&media_type=testtype&media_category=2"}
$jsonProfile['mediaEmbed'] = ['removeProviders' => $provider];

if (in_array('rexImage', $toolbar)) {
if (!empty($profile['mediatype'])) {
$jsonProfile['rexImage'] = ['media_type' => $profile['mediatype']];
} else {
$jsonProfile['rexImage'] = ['media_path' => '/'. $profile['mediapath'] . '/'];
$jsonProfile['rexImage'] = ['media_path' => '/' . $profile['mediapath'] . '/'];
}
}

Expand Down
4 changes: 0 additions & 4 deletions pages/profiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@
$profile = '';
$in_mediapath = '';
$mediapath = str_replace(['../', '/'], '', rex_url::media());
$in_mediaembed = '';

if ($func == 'add') {
$in_heading = 'in';
Expand All @@ -130,7 +129,6 @@
if (in_array('fontSize', $toolbar)) $in_fontsize = 'in';
if (in_array('link', $toolbar)) $in_rexlink = 'in';
if (in_array('highlight', $toolbar)) $in_highlight = 'in';
if (in_array('mediaEmbed', $toolbar)) $in_mediaembed = 'in';
if (in_array('rexImage', $toolbar) || in_array('imageUpload', $toolbar)) $in_imagetoolbar = 'in';

$min_height = (int)$result[$prefix . 'min_height'];
Expand Down Expand Up @@ -245,15 +243,13 @@
$form->addRawField('</div>');

// mediaEmbed
$form->addRawField('<div class="collapse ' . $in_mediaembed . '" id="cke5mediaEmbed-collapse">');
$field = $form->addTextField('mediaembed');
$field->setAttribute('id', 'cke5mediaEmbed-input');
$field->setAttribute('data-tag-init', 1);
$field->setAttribute('data-defaults', Cke5ProfilesCreator::DEFAULTS['mediaembed']);
$field->setAttribute('data-tags', '["' . implode('","', Cke5ProfilesCreator::ALLOWED_FIELDS['providers']) . '"]');
$field->setLabel(rex_i18n::msg('cke5_mediaembed'));
if ($default_value) $field->setAttribute('data-default-tags', 1);
$form->addRawField('</div>');

// default height
$field = $form->addCheckboxField('height_default');
Expand Down

0 comments on commit fd311ea

Please sign in to comment.