Commit 4f910277 authored by Laurent's avatar Laurent
Browse files

dev #56107 ckeditor kiosk: add i18n and icons

parent 7e11fe25
......@@ -2,55 +2,55 @@
* @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or http://ckeditor.com/license
*/
CKEDITOR.plugins.addExternal('bokeh-kiosk' , CKEDITOR.basePath+'../public/opac/js/ckeditor_plugins/bokeh-kiosk/','plugin.js');
CKEDITOR.plugins.addExternal('bokeh_kiosk' , CKEDITOR.basePath+'../public/opac/js/ckeditor_plugins/bokeh_kiosk/','plugin.js');
CKEDITOR.stylesSet.add('default',[
{ name:'Normal', element:'p' },
{ name:'Titre 1', element:'h1' },
{ name:'Titre 2', element:'h2' },
{ name:'Titre 3', element:'h3' },
{ name:'Titre 4', element:'h4' },
{ name:'Titre 5', element:'h5' },
{ name:'Titre 6', element:'h6' },
{ name:'Grand', element:'span', styles:{'font-size': '1.5em'}},
{ name:'Petit', element:'small' },
{ name:'Machine à écrire', element:'tt' },
{ name:'Code informatique', element:'code' },
{ name:'Texte supprimé', element:'del' },
{ name:'Texte inséré', element:'ins' },
{ name:'Citation', element:'cite' },
{ name:'Mise en avant', element:'div', attributes:{'class':'mise_en_avant'}},
{ name:'Ecriture droite à gauche', element:'span', attributes:{'dir':'rtl'}},
{ name:'Ecriture gauche à droite', element:'span', attributes:{'dir':'ltr'}},
{ name:'Image à Gauche', element:'img', attributes:{'border':'2', 'align':'left'},
styles:{'padding': '5px', 'margin-right': '5px'}},
{ name:'Image à Droite', element:'img', attributes:{'border':'2', 'align':'right'},
styles:{'padding': '5px', 'margin-left': '5px'}}
{ name:'Normal', element:'p' },
{ name:'Titre 1', element:'h1' },
{ name:'Titre 2', element:'h2' },
{ name:'Titre 3', element:'h3' },
{ name:'Titre 4', element:'h4' },
{ name:'Titre 5', element:'h5' },
{ name:'Titre 6', element:'h6' },
{ name:'Grand', element:'span', styles:{'font-size': '1.5em'}},
{ name:'Petit', element:'small' },
{ name:'Machine à écrire', element:'tt' },
{ name:'Code informatique', element:'code' },
{ name:'Texte supprimé', element:'del' },
{ name:'Texte inséré', element:'ins' },
{ name:'Citation', element:'cite' },
{ name:'Mise en avant', element:'div', attributes:{'class':'mise_en_avant'}},
{ name:'Ecriture droite à gauche', element:'span', attributes:{'dir':'rtl'}},
{ name:'Ecriture gauche à droite', element:'span', attributes:{'dir':'ltr'}},
{ name:'Image à Gauche', element:'img', attributes:{'border':'2', 'align':'left'},
styles:{'padding': '5px', 'margin-right': '5px'}},
{ name:'Image à Droite', element:'img', attributes:{'border':'2', 'align':'right'},
styles:{'padding': '5px', 'margin-left': '5px'}}
]);
CKEDITOR.on( 'dialogDefinition', function( ev )
{
var dialogName = ev.data.name;
var dialogDefinition = ev.data.definition;
{
var dialogName = ev.data.name;
var dialogDefinition = ev.data.definition;
var tabsToRemove = {
"image": ['Link', 'Upload'],
"flash": ['Upload', 'properties'],
"link" : ['upload']};
var tabsToRemove = {
"image": ['Link', 'Upload'],
"flash": ['Upload', 'properties'],
"link" : ['upload']};
for (var i in tabsToRemove[dialogName])
{
dialogDefinition.removeContents(tabsToRemove[dialogName][i]);
}
for (var i in tabsToRemove[dialogName])
{
dialogDefinition.removeContents(tabsToRemove[dialogName][i]);
}
if (dialogName == 'templates')
{
var contents = dialogDefinition.getContents('selectTpl');
var insertCheckBox = contents.get('chkInsertOpt');
insertCheckBox.style = "display:none";
dialogDefinition.minHeight = 280;
}
});
if (dialogName == 'templates')
{
var contents = dialogDefinition.getContents('selectTpl');
var insertCheckBox = contents.get('chkInsertOpt');
insertCheckBox.style = "display:none";
dialogDefinition.minHeight = 280;
}
});
CKEDITOR.editorConfig = function( config ) {
config.plugins = 'dialogui,dialog,about,a11yhelp,dialogadvtab,basicstyles,bidi,blockquote,clipboard,button,panelbutton,panel,floatpanel,colorbutton,colordialog,templates,menu,contextmenu,div,resize,toolbar,elementspath,enterkey,entities,popup,filebrowser,find,fakeobjects,flash,floatingspace,listblock,richcombo,font,forms,format,horizontalrule,htmlwriter,iframe,wysiwygarea,image,indent,indentblock,indentlist,smiley,justify,menubutton,language,link,list,liststyle,magicline,maximize,newpage,pagebreak,pastetext,pastefromword,preview,print,removeformat,save,selectall,showblocks,showborders,sourcearea,specialchar,scayt,stylescombo,tab,table,tabletools,undo,wsc,iframedialog,slideshow,videodetector,lineutils,widget,oembed';
......
......@@ -24,7 +24,7 @@ class ZendAfi_View_Helper_Article_ReplaceWidgets extends ZendAfi_View_Helper_Bas
public function article_ReplaceWidgets($content) {
return preg_replace_callback(
'|(?P<alldiv><div[^>]+data-code="(?P<code>\w+)"[^>]+data-form="(?P<form>[^"]+)[^>]*>[^<]+</div>)|',
'|(?P<allimg><img[^>]+data-code="(?P<code>\w+)"[^>]+data-form="(?P<form>[^"]+)[^>]*>)|',
function ($matches) {
return $this->_renderWidget($matches['code'],$matches['form']);
......
......@@ -106,12 +106,12 @@ class ZendAfi_View_Helper_CkEditor extends ZendAfi_View_Helper_BaseHelper
['NumberedList','BulletedList','-','Outdent','Indent'],
['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock']
]);
$config['perso_var'] = Class_Url::assemble(['module' => 'admin',
'controller' => 'widget',
'action' => 'get-form',
'code' => 'KIOSQUE',
'render' => 'popup']);
$config['extraPlugins'] = 'colordialog,bokeh-kiosk';
$config['kiosk_widget_url'] = Class_Url::assemble(['module' => 'admin',
'controller' => 'widget',
'action' => 'get-form',
'code' => 'KIOSQUE',
'render' => 'popup']);
$config['extraPlugins'] = 'colordialog,bokeh_kiosk';
$oCKeditor = new CKeditor(CKBASEURL);
......
CKEDITOR.dialog.add( 'kioskDialog', function ( editor ) {
var icon_path = CKEDITOR.plugins.get( 'bokeh-kiosk' ).path + 'icons/kiosk.jpg';
var icon_path = CKEDITOR.plugins.get( 'bokeh_kiosk' ).path + 'icons/placeholder.jpg';
var lang = editor.lang.bokeh_kiosk;
var dialog = {
title: 'Bokeh Kiosk Properties',
title: lang.kioskProperties,
minWidth: 400,
minHeight: 200,
contents: [
......@@ -19,7 +21,7 @@ CKEDITOR.dialog.add( 'kioskDialog', function ( editor ) {
var htmlElement = this;
$.ajax({
url: editor.config['perso_var'],
url: editor.config['kiosk_widget_url'],
type: "POST",
data: this.getValue(),
datatype: 'json',
......@@ -46,7 +48,7 @@ CKEDITOR.dialog.add( 'kioskDialog', function ( editor ) {
isBokehKiosk: function(element) {
var jqel = $(element.$);
return ( jqel.hasClass('bokeh-kiosk') || jqel.closest('bokeh-kiosk').length );
return ( jqel.hasClass('bokeh_kiosk') || jqel.closest('bokeh_kiosk').length );
},
......@@ -55,8 +57,8 @@ CKEDITOR.dialog.add( 'kioskDialog', function ( editor ) {
var element = selection.getStartElement();
if (dialog.isBokehKiosk(element)) {
element = $(element.$).closest( 'bokeh-kiosk' );
return this.setupContent( element );
element = $(element.$).closest( 'bokeh_kiosk' );
return this.setupContent( element );
}
this.setupContent(null);
......@@ -67,16 +69,16 @@ CKEDITOR.dialog.add( 'kioskDialog', function ( editor ) {
var widget = selection.getStartElement();
if (!widget || !dialog.isBokehKiosk(widget)) {
widget = editor.document.createElement( 'img' );
widget.setAttribute('src', icon_path);
widget.setAttribute('src', icon_path);
editor.insertElement( widget );
}
$('.bokeh-kiosk-form form').triggerHandler('submit');
setTimeout(function() {
widget
.setAttribute('data-form', $('.bokeh-kiosk-form form').serialize())
.setAttribute('data-code', 'KIOSQUE')
.setAttribute('class','bokeh-kiosk');
widget
.setAttribute('data-form', $('.bokeh-kiosk-form form').serialize())
.setAttribute('data-code', 'KIOSQUE')
.setAttribute('class','bokeh_kiosk');
}, 10);
}
......
CKEDITOR.plugins.setLang( 'bokeh_kiosk', 'en', {
editKiosk: 'Edit kiosk',
addKiosk: 'Insert kiosk',
kioskProperties: 'Kiosk properties'
});
CKEDITOR.plugins.setLang( 'bokeh_kiosk', 'fr', {
editKiosk: 'Modifier le kiosque de notices',
addKiosk: 'Ins\351rer un kiosque de notices',
kioskProperties: 'Propri\351t\351s du kiosque'
});
CKEDITOR.plugins.add( 'bokeh-kiosk', {
CKEDITOR.plugins.add( 'bokeh_kiosk', {
icons: 'kiosk',
lang : [ 'en', 'fr' ],
init: function( editor ) {
var lang = editor.lang['bokeh_kiosk'];
CKEDITOR.dialog.add( 'kioskDialog', this.path + 'dialogs/kiosk.js' );
editor.addCommand( 'insertKiosk', new CKEDITOR.dialogCommand( 'kioskDialog'));
editor.addCommand( 'editKiosk', new CKEDITOR.dialogCommand( 'kioskDialog'));
......@@ -10,14 +13,14 @@ CKEDITOR.plugins.add( 'bokeh-kiosk', {
if ( editor.contextMenu ) {
editor.addMenuGroup( 'bokehKioskGroup' );
editor.addMenuItem( 'bokehKioskItem', {
label: 'Edit kiosk',
icon: this.path + 'icons/basket.png',
label: lang.editKiosk,
icon: this.path + 'icons/kiosk.png',
command: 'editKiosk',
group: 'bokehKioskGroup'
});
editor.contextMenu.addListener( function( element ) {
if ( $(element.$).hasClass('bokeh-kiosk') || $(element.$).closest('bokeh-kiosk').size ) {
if ( $(element.$).hasClass('bokeh_kiosk') || $(element.$).closest('bokeh_kiosk').size ) {
return { bokehKioskItem: CKEDITOR.TRISTATE_OFF };
}
});
......@@ -27,7 +30,7 @@ CKEDITOR.plugins.add( 'bokeh-kiosk', {
// Create a toolbar button that executes the above command.
editor.ui.addButton( 'Kiosk', {
label: 'Insert Bokeh kiosk',
label: lang.addKiosk,
command: 'insertKiosk',
toolbar: 'insert',
});
......
......@@ -1716,7 +1716,7 @@ class CmsControllerWithArticleWithWallKioskTest extends CmsControllerWithArticle
$this->fixture('Class_Article', [ 'id' => 55,
'titre' => 'Mes dvds',
'contenu' => '<img class="bokeh-kiosk" data-code="KIOSQUE" data-form="titre=Boite%20kiosque&amp;style_liste=mur&amp;styles_reload=0&amp;op_speed=100&amp;op_largeur_img=120&amp;op_hauteur_img=150&amp;profil_redirect=&amp;id_catalogue=0&amp;id_panier=&amp;aleatoire=1&amp;tri=1&amp;nb_notices=20&amp;nb_analyse=50&amp;only_img=1&amp;boite=&amp;rss_avis=0"/>']);
'contenu' => '<img class="bokeh_kiosk" data-code="KIOSQUE" data-form="titre=Boite%20kiosque&amp;style_liste=mur&amp;styles_reload=0&amp;op_speed=100&amp;op_largeur_img=120&amp;op_hauteur_img=150&amp;profil_redirect=&amp;id_catalogue=0&amp;id_panier=&amp;aleatoire=1&amp;tri=1&amp;nb_notices=20&amp;nb_analyse=50&amp;only_img=1&amp;boite=&amp;rss_avis=0">']);
$this->dispatch('/cms/articleview/id/55',true);
}
......@@ -1724,7 +1724,7 @@ class CmsControllerWithArticleWithWallKioskTest extends CmsControllerWithArticle
/** @test */
public function bokehKioskShouldBeRemoved() {
$this->assertNotXPath('//div[@class="bokeh-kiosk"]');
$this->assertNotXPath('//img[@class="bokeh_kiosk"]');
}
......@@ -1749,7 +1749,7 @@ class CmsControllerWithArticleWithCubeKioskTest extends CmsControllerWithArticle
$this->fixture('Class_Article', [ 'id' => 55,
'titre' => 'Mes dvds',
'contenu' => '<img class="bokeh-kiosk" data-code="KIOSQUE" data-form="titre=Boite%20kiosque&amp;style_liste=cube&amp;styles_reload=0&amp;op_speed=100&amp;op_largeur_img=120&amp;op_hauteur_img=150&amp;profil_redirect=&amp;id_catalogue=0&amp;id_panier=&amp;aleatoire=1&amp;tri=1&amp;nb_notices=20&amp;nb_analyse=50&amp;only_img=1&amp;boite=&amp;rss_avis=0"/>']);
'contenu' => '<img class="bokeh_kiosk" data-code="KIOSQUE" data-form="titre=Boite%20kiosque&amp;style_liste=cube&amp;styles_reload=0&amp;op_speed=100&amp;op_largeur_img=120&amp;op_hauteur_img=150&amp;profil_redirect=&amp;id_catalogue=0&amp;id_panier=&amp;aleatoire=1&amp;tri=1&amp;nb_notices=20&amp;nb_analyse=50&amp;only_img=1&amp;boite=&amp;rss_avis=0">']);
$this->dispatch('/cms/articleview/id/55',true);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment