Browse Source

fix: insertion du code CKEDITOR en partie privée ou publique que si nécessaire (http://contrib.spip.net/CKeditor-3-0?lang=fr#forum469576)

fix: correction (j'espère réelle) du problème lié à ajax (en particulier : http://contrib.spip.net/CKeditor-3-0?lang=fr#forum469117)
fix: retour de la compatibilité avec les crayons en partie publique mais un bug persiste, il faut corriger le fichier crayons_fonctions.php (du plugin crayons), en remplaçant ligne 137, $(...) par jQuery(...)
svn/root/tags/v0.17.1
fredlefred@gmail.com 10 years ago
parent
commit
dbdbc143db
  1. 217
      ckeditor4spip.js.html
  2. 207
      ckeditor_fonctions.php
  3. 2
      paquet.xml
  4. 2
      plugin.xml

217
ckeditor4spip.js.html

@ -23,29 +23,29 @@ if (sansConversion) {
} else {
spipDataProcessor={
toDataFormat:function(html, fixForBody){
return $.ajax({url:CKEDITOR.spipurl+'?page=ckspip_convert',data:{text_area:html.replace(/<span\s+data-scayt[^>]*>\s*(.*?)\s*<\/span>/g,'$1'),cvt:'html2spip',fix:fixForBody},global:false,type:'POST',dataType:'text',async:false}).responseText;
return jQuery.ajax({url:CKEDITOR.spipurl+'?page=ckspip_convert',data:{text_area:html.replace(/<span\s+data-scayt[^>]*>\s*(.*?)\s*<\/span>/g,'$1'),cvt:'html2spip',fix:fixForBody},global:false,type:'POST',dataType:'text',async:false}).responseText;
},
toHtml:function(data, fixForBody){
return $.ajax({url:CKEDITOR.spipurl+'?page=ckspip_convert',data:{text_area:data.replace(/<span\s+data-scayt[^>]*>\s*(.*?)\s*<\/span>/g,'$1'),cvt:'spip2html',fix:fixForBody},global:false,type:'POST',dataType:'text',async:false}).responseText;
return jQuery.ajax({url:CKEDITOR.spipurl+'?page=ckspip_convert',data:{text_area:data.replace(/<span\s+data-scayt[^>]*>\s*(.*?)\s*<\/span>/g,'$1'),cvt:'spip2html',fix:fixForBody},global:false,type:'POST',dataType:'text',async:false}).responseText;
}
};
}
function htmldecode(s){
return $('<div/>').html(s).text();
return jQuery('<div/>').html(s).text();
}
function HideSpipUI(editor_id){
if($(editor_id).size()==0){return;}
if(jQuery(editor_id).size()==0){return;}
var crayon=editor_id.match(/^(#crayon_\d+)\s/), item, editor_id_light = editor_id ;
if(crayon) {
editor_id_light='textarea.crayon-active' ;
stack[editor_id].crborder=$(crayon[1]+' .formulaire_spip').css('border');
stack[editor_id].crbg=$(crayon[1]+' .formulaire_spip').css('background-color');
$(crayon[1]+' .formulaire_spip')
stack[editor_id].crborder=jQuery(crayon[1]+' .formulaire_spip').css('border');
stack[editor_id].crbg=jQuery(crayon[1]+' .formulaire_spip').css('background-color');
jQuery(crayon[1]+' .formulaire_spip')
.css('border','none')
.css('background-color','white');
item=$(crayon+' div.edition');
item=jQuery(crayon+' div.edition');
} else {
editor_id_light = editor_id.match(/^#\S*\s+(.*)$/) ;
if (editor_id_light) {
@ -54,17 +54,17 @@ function HideSpipUI(editor_id){
editor_id_light = editor_id ;
}
item=$(editor_id_light).parents().find('div.forum, div.edition:has('+editor_id_light+')');
item=jQuery(editor_id_light).parents().find('div.forum, div.edition:has('+editor_id_light+')');
}
item.each(function() {
if ($(this).find(editor_id_light).length == 1) {
if (jQuery(this).find(editor_id_light).length == 1) {
if (editor_id.match(/^#formulaire_forum\s/)) {
stack[editor_id].fobd=$(this).css('border');
stack[editor_id].fobg=$(this).css('background');
$(this).css('border','none');
$(this).css('background','none');
stack[editor_id].fobd=jQuery(this).css('border');
stack[editor_id].fobg=jQuery(this).css('background');
jQuery(this).css('border','none');
jQuery(this).css('background','none');
}
$(this).find('.spip_barre').css('display','none').end()
jQuery(this).find('.spip_barre').css('display','none').end()
.find('.explication').css('display','none').end()
.find('.markItUpHeader').css('display','none').end()
.find('.markItUpTabs').css('display','none').end()
@ -75,34 +75,34 @@ function HideSpipUI(editor_id){
}
function ShowSpipUI(editor_id){
if($(editor_id).size()==0){return;}
if(jQuery(editor_id).size()==0){return;}
if (! stack[editor_id].nobarre) {
$(editor_id).removeClass('no_barre') ;
jQuery(editor_id).removeClass('no_barre') ;
barrebouilles_editor(editor_id) ;
stack[editor_id].nobarre = false ;
}
var crayon=editor_id.match(/^(#crayon_\d+)\s/), item ;
if(crayon) {
item=$(crayon+' div.edition');
item=jQuery(crayon+' div.edition');
} else {
item=$(editor_id).parents().find('div.forum, div.edition:has('+editor_id+')');
item=jQuery(editor_id).parents().find('div.forum, div.edition:has('+editor_id+')');
}
item.each(function() {
if (editor_id.match(/^#formulaire_forum\s/)) {
$(this).css('border',stack[editor_id].fobd);
$(this).css('background',stack[editor_id].fobg);
jQuery(this).css('border',stack[editor_id].fobd);
jQuery(this).css('background',stack[editor_id].fobg);
}
if(crayon) {
$(crayon[1]+' .formulaire_spip')
jQuery(crayon[1]+' .formulaire_spip')
.css('border',stack[editor_id].crborder)
.css('background-color',stack[editor_id].crbg);
}
if($(this).find('.markItUpTabs .previsuVoir').hasClass('on')){
$(this).find('.markItUpTabs').css('display','').end()
if(jQuery(this).find('.markItUpTabs .previsuVoir').hasClass('on')){
jQuery(this).find('.markItUpTabs').css('display','').end()
.find('.markItUpPreview').css('display','block').end()
.find('.markItUpEditor').css('display','none');
}else{
$(this).find('.spip_barre').css('display','').end()
jQuery(this).find('.spip_barre').css('display','').end()
.find('.explication').css('display','').end()
.find('.markItUpHeader').css('display','').end()
.find('.markItUpTabs').css('display','').end()
@ -116,26 +116,17 @@ function ShowSpipUI(editor_id){
var stack=[];
function SpipEditor2CKEditor(editor_id){
if ($(editor_id).size()==0) {return;}
$('#swapeditor_'+stack[editor_id].ndx)
if (jQuery(editor_id).size()==0) {return;}
jQuery('#swapeditor_'+stack[editor_id].md5)
.attr('disabled',true)
.attr('title',htmldecode('<:ckeditor:loading:>'))
.find('img')
.attr('src','[(#CHEMIN{images/searching.gif}|url_absolue)]');
$(editor_id).attr('disabled',true);
var EdConfig={};$.extend(EdConfig,CKEDITOR.ckConfig) ;
jQuery(editor_id).attr('disabled',true);
var EdConfig={};jQuery.extend(EdConfig,CKEDITOR.ckConfig) ;
EdConfig.toolbar='Spip'+stack[editor_id].tb;
try { [(#REM) // fix les problèmes des instances de ckeditor répertoriées, mais non visibles/accessibles du fait du rechargement via ajax ]
var id = $(editor_id).attr('id') ;
if (id) {
var instance = CKEDITOR.instances[id] ;
if (instance) {
instance.destroy() ;
}
}
} catch (E) { /* rien */ }
try {
$(editor_id).ckeditor(function(){
jQuery(editor_id).ckeditor(function(){
HideSpipUI(editor_id);
stack[editor_id].n='#'+this.container.getId();
stack[editor_id].editor=this.name ;
@ -148,31 +139,28 @@ function SpipEditor2CKEditor(editor_id){
var pc=0,parent_trouve=false ;
do {
stack[editor_id].parent_id = parent_ids[pc++] ;
if ($(stack[editor_id].parent_id).length>0) {
if (jQuery(stack[editor_id].parent_id).length>0) {
parent_trouve=true ;
stack[editor_id].marges=$(editor_id).parents(stack[editor_id].parent_id).width()-$(stack[editor_id].n).width() ;
stack[editor_id].marges=jQuery(editor_id).parents(stack[editor_id].parent_id).width()-jQuery(stack[editor_id].n).width() ;
}
} while ((pc<parent_ids.length) && (!parent_trouve)) ;
if (parent_trouve) {
this.on('resize', function(e) {
$(editor_id).parents(stack[editor_id].parent_id).width($(stack[editor_id].n).width()+stack[editor_id].marges);
jQuery(editor_id).parents(stack[editor_id].parent_id).width(jQuery(stack[editor_id].n).width()+stack[editor_id].marges);
});
}
contexteChange(editor_id);
$(editor_id).attr('disabled',false);
$('#swapeditor_'+stack[editor_id].ndx)
jQuery(editor_id).attr('disabled',false);
jQuery('#swapeditor_'+stack[editor_id].md5)
.attr('title',htmldecode('<:ckeditor:use_spip_editor:>'))
.find('img')
.attr('src','[(#CHEMIN{images/ckeditor_spip.png}|url_absolue)]') ;
$('#swapeditor_'+stack[editor_id].ndx).attr('disabled',false);
jQuery('#swapeditor_'+stack[editor_id].md5).attr('disabled',false);
this.setReadOnly(false);
this.on('dataReady', function(e){
this.resize(CKEDITOR.ckConfig.minwidth,CKEDITOR.ckConfig.height);
});
$(editor_id).parents().find('input[class=submit]') [(#REM) // fix: a priori ceci n'est nécessaire que pour les forums, mais il semble que cela fonctionne aussi pour les autres formulaires]
.attr('onclick', 'javacript:CKEditor2SpipEditor(\''+editor_id+'\');') ;
},EdConfig);
} catch (E) { /* rien */ }
}
@ -184,52 +172,52 @@ function barrebouilles_editor(editor_id){
// fonction generique appliquee aux classes CSS :
// inserer_barre_forum, inserer_barre_edition, inserer_previsualisation
]
if ($(editor_id).hasClass('inserer_barre_forum'))
$(editor_id).barre_outils('forum');
if ($(editor_id).hasClass('inserer_barre_edition'))
$(editor_id).barre_outils('edition');
if ($(editor_id).hasClass('inserer_previsualisation'))
$(editor_id).barre_previsualisation();
if (jQuery(editor_id).hasClass('inserer_barre_forum'))
jQuery(editor_id).barre_outils('forum');
if (jQuery(editor_id).hasClass('inserer_barre_edition'))
jQuery(editor_id).barre_outils('edition');
if (jQuery(editor_id).hasClass('inserer_previsualisation'))
jQuery(editor_id).barre_previsualisation();
[(#REM) // fonction specifique aux formulaires de SPIP :
// barre de forum
]
if ($(editor_id).hasClass('textarea_forum'))
$(editor_id).barre_outils('forum');
if($(editor_id).attr('name').match(/^(texte|\w+_texte)$/)) {
if (jQuery(editor_id).hasClass('textarea_forum'))
jQuery(editor_id).barre_outils('forum');
if(jQuery(editor_id).attr('name').match(/^(texte|\w+_texte)$/)) {
if (!editor_id.match(/\b#formulaire_forum\b/)) {
$(editor_id).barre_outils('edition').barre_previsualisation();
jQuery(editor_id).barre_outils('edition').barre_previsualisation();
}
[(#CONFIG{forums_afficher_barre}|=={non}|non)
else {
$(editor_id).barre_outils('forum');
jQuery(editor_id).barre_outils('forum');
}]
}
}
function CKEditor2SpipEditor(editor_id){
if($(editor_id).size()==0){return;}
$('#swapeditor_'+stack[editor_id].ndx)
if(jQuery(editor_id).size()==0){return;}
jQuery('#swapeditor_'+stack[editor_id].md5)
.attr('disabled',true)
.attr('title',htmldecode('<:ckeditor:loading:>'))
.find('img')
.attr('src','[(#CHEMIN{images/searching.gif}|url_absolue)]');
$(editor_id)
jQuery(editor_id)
.attr('disabled',true)
.css('display','block')
.ckeditorGet().destroy();
ShowSpipUI(editor_id);
$('#swapeditor_'+stack[editor_id].ndx)
jQuery('#swapeditor_'+stack[editor_id].md5)
.attr('title',htmldecode('<:ckeditor:use_ckeditor:>'))
.find('img')
.attr('src','[(#CHEMIN{images/ckeditor.png}|url_absolue)]')
.end()
.attr('disabled',false);
$(editor_id)
jQuery(editor_id)
.attr('disabled',false);
}
function SwapEditor(editor_id){
if($(editor_id).size()==0){return;}
if(jQuery(editor_id).size()==0){return;}
try{
CKEditor2SpipEditor(editor_id);
}catch(e){
@ -238,41 +226,49 @@ function SwapEditor(editor_id){
}
function contexteChange(editor_id){
if($(editor_id).size()==0){return;}
if($("#contexte_"+stack[editor_id].ndx).length){
var contexte=$("#contexte_"+stack[editor_id].ndx).val().match(/^([\.#])(.*)$/);
if(jQuery(editor_id).size()==0){return;}
if(jQuery("#contexte_"+stack[editor_id].md5).length){
var contexte=jQuery("#contexte_"+stack[editor_id].md5).val().match(/^([\.#])(.*)$/);
if(stack[editor_id].ctx){[(#REM)// on supprime l'ancien contexte]
if(stack[editor_id].ctx[1]=="#"){[(#REM)// le contexte est donné via un identifiant]
$(stack[editor_id].n+' iframe').contents().find('body').attr('id','');
jQuery(stack[editor_id].n+' iframe').contents().find('body').attr('id','');
}else{
$(stack[editor_id].n+' iframe').contents().find('body').removeClass(stack[editor_id].ctx[2]);
jQuery(stack[editor_id].n+' iframe').contents().find('body').removeClass(stack[editor_id].ctx[2]);
}
}
stack[editor_id].ctx=contexte;
if(contexte){[(#REM)// on affecte le nouveau contexte]
if(contexte[1]=="#"){[(#REM)// le contexte est donné via un identifiant]
$(stack[editor_id].n+' iframe').contents().find('body').attr('id', contexte[2]);
jQuery(stack[editor_id].n+' iframe').contents().find('body').attr('id', contexte[2]);
}else{[(#REM)// le contexte est donné via une class]
$(stack[editor_id].n+' iframe').contents().find('body').addClass(contexte[2]);
jQuery(stack[editor_id].n+' iframe').contents().find('body').addClass(contexte[2]);
}
}
}
}
function on_submit_destroy_cke() {
for(name in CKEDITOR.instances) {
CKEDITOR.instances[name].destroy()
}
}
function cke_crayon_submit(editor_id){
if($(editor_id).size()==0){return;}
if(jQuery(editor_id).size()==0){return;}
try{[(#REM)// si on est en mode 'ckeditor', on synchronise le textarea]
$(editor_id).ckeditorGet().updateElement();
jQuery(editor_id).ckeditorGet().updateElement();
}catch(e){ /* rien */ }
$(this).parents('.formulaire_crayon').submit();
jQuery(this).parents('.formulaire_crayon').submit();
}
function fullInitCKEDITOR(editor_ids){
if(!editor_ids)editor_ids=[["textarea[name=texte]","Full"]];
CKEDITOR.ckConfig.on={
'pluginsLoaded':function(ev){ckeDataProcessor=ev.editor.dataProcessor;ev.editor.dataProcessor=spipDataProcessor;}
};
jQuery("input[type=submit]").click(on_submit_destroy_cke) ;
if (!CKEDITOR.fullInitDone) {
CKEDITOR.fullInitDone=true;
CKEDITOR.ckConfig.on={
'pluginsLoaded':function(ev){ckeDataProcessor=ev.editor.dataProcessor;ev.editor.dataProcessor=spipDataProcessor;}
};
CKEDITOR.on('dialogDefinition',function(ev){
var dialogName=ev.data.name,
dialogDefinition=ev.data.definition;
@ -295,34 +291,38 @@ function fullInitCKEDITOR(editor_ids){
for(var plugin in CKEDITOR.ckConfig.loadExtraPlugins){
CKEDITOR.plugins.addExternal(plugin, CKEDITOR.ckConfig.loadExtraPlugins[plugin]);
}
CKEDITOR.fullInitDone=true;
}
for(var id in editor_ids){
if (($(editor_ids[id][0]).length > 0) && ($(editor_ids[id][0]).css('display') != 'none')) {
if ((jQuery(editor_ids[id][0]).length > 0) && (jQuery(editor_ids[id][0]).css('display') != 'none')) {
var editor_id=editor_ids[id][0], editor_tb=editor_ids[id][1], crayon=null, editor_md5=editor_ids[id][3] ;
if (jQuery(editor_id).parents("[id^=crayon_]").length>0) { // sommes-nous appelé depuis un crayon ?
crayon = jQuery(editor_id).parents("[id^=crayon_]").attr('id') ;
if (! editor_id.match(/^\s*#/)) {
editor_id = "#"+crayon+" "+editor_id ;
}
}
try {
$(editor_ids[id][0]).ckeditorGet() ;
jQuery(editor_id).ckeditorGet() ;
} catch(e) {
var editor_id=editor_ids[id][0], editor_tb=editor_ids[id][1], crayon=editor_ids[id][2], editor_md5=editor_ids[id][3] ;
var ndx=$('[id^=cke_cpt_]').size(),buttons='';
while ($('[id=cke_cpt_'+ndx+']').size()>0) { ndx++ ; }
var buttons='';
if (typeof stack[editor_id] == 'undefined') {
stack[editor_id] = {} ;
}
stack[editor_id].crayons = 0 ;
stack[editor_id].ndx = ndx ;
stack[editor_id].tb = editor_tb ;
stack[editor_id].nobarre = ($(editor_id).hasClass('no_barre') || CKEDITOR.ckeditmode == 'spip') ;
stack[editor_id].nobarre = (jQuery(editor_id).hasClass('no_barre') || CKEDITOR.ckeditmode == 'spip') ;
stack[editor_id].md5 = editor_md5 ;
if (! stack[editor_id].nobarre)
$(editor_id).addClass('no_barre');[(#REM) // on fait en sorte de désactiver l'affichage du porte plume avant qu'il n'entre en scène ...]
jQuery(editor_id).addClass('no_barre');[(#REM) // on fait en sorte de désactiver l'affichage du porte plume avant qu'il n'entre en scène ...]
if ($('.after_'+editor_md5).length==0) {
$(editor_id).after('<span id="cke_cpt_'+ndx+'" class="after_'+editor_md5+'"></span>');
if (jQuery('#after_'+editor_md5).length==0) {
jQuery(editor_id).after('<span id="after_'+editor_md5+'"></span>');
[(#CONFIG{ckeditor/ignoreversion}|=={'on'}|non)
if(CKEDITOR.version<CKEDITOR.ckpreferedversion){
var pref='<:ckeditor:version_preferee:>';
$('#cke_cpt_'+ndx).prepend(
jQuery('#after_'+editor_md5).prepend(
'<div class="erreur_message">'+pref.replace(/%2/,CKEDITOR.ckpreferedversion).replace(/%1/,CKEDITOR.version)+'</div>'
);
}
@ -331,46 +331,29 @@ function fullInitCKEDITOR(editor_ids){
if(CKEDITOR.ckeditmode!='ckeditor-exclu'){
buttons=buttons +
'<button style="margin:0;width:40px;height:24px;" type="button" id="swapeditor_'+ndx+'" onclick="javascript:SwapEditor(\''+editor_id+'\');" title="'
'<button style="margin:0;width:40px;height:24px;" type="button" id="swapeditor_'+editor_md5+'" onclick="javascript:SwapEditor(\''+editor_id+'\');" title="'
+htmldecode(CKEDITOR.ckeditmode=='spip'?'<:ckeditor:use_ckeditor:>':'<:ckeditor:use_spip_editor:>')
+'"><img src="[(#CHEMIN{images/ckeditor.png}|url_absolue)]"/></button>';
}
[(#REM) // on insère le menu déroulant de changement de contexte s'il existe des contextes]
<B_options> buttons=buttons+'<span style="padding-right:5px;"><:ckeditor:changer_de_contexte:></span>'
+'<select id="contexte_'+ndx+'" name="contexte_'+ndx+'" onchange="contexteChange(\''+editor_id+'\');" style="width:33%;"><option value="" selected><:ckeditor:sans_contexte:></option><BOUCLE_options(POUR){tableau #CONFIG{ckeditor/contextes}|ck_enliste{1}}><option value="[(#VALEUR|table_valeur{0})]">[(#VALEUR|table_valeur{1}|replace{(\.|#)})]</option></BOUCLE_options></select>';</B_options>;
if(buttons && ($('.before_'+editor_md5).length == 0)) {
var div ;
+'<select id="contexte_'+editor_md5+'" name="contexte_'+editor_md5+'" onchange="contexteChange(\''+editor_id+'\');" style="width:33%;"><option value="" selected><:ckeditor:sans_contexte:></option><BOUCLE_options(POUR){tableau #CONFIG{ckeditor/contextes}|ck_enliste{1}}><option value="[(#VALEUR|table_valeur{0})]">[(#VALEUR|table_valeur{1}|replace{(\.|#)})]</option></BOUCLE_options></select>';</B_options>;
if(buttons && (jQuery('#before_'+editor_md5).length == 0)) {
var div = jQuery(editor_id) ;
var style = "width;100%;text-align:right;position:relative;top:-24px;height:0px;" ;
if (crayon) {
div = $('textarea.crayon-active').closest('.formulaire_crayon') ;
} else {
editor_id_light = editor_id.match(/^#\S*\s+(.*)$/) ;
if (editor_id_light) {
editor_id_light = editor_id_light[1] ;
} else {
editor_id_light = editor_id ;
}
div = $(editor_id_light).closest('.markItUpContainer') ;
if (div.length == 0) { [(#REM) // cas où le porteplume n'est pas là... ]
div = $(editor_id).siblings('label:first') ;
style = "width;100%;text-align:right;position:relative;top:-8px;height:0px;" ;
}
}
if (div.length != 0) {
div.prepend('<div id="cke_buttons_'+ndx+'" class="before_'+editor_md5+'" style="'+style+'"><a name="cke_buttons_ancre_'+ndx+'"></a>'+buttons+'</div>');
div.before('<div id="before_'+editor_md5+'" style="'+style+'"><a name="ancre_'+editor_md5+'"></a>'+buttons+'</div>');
}
}
[(#REM) // gestion des crayons :]
[(#REM) // gestion des crayons :]
if(crayon){
$('#'+crayon+' .crayon-submit')
.after('<button id="save" style=\'background:url("[(#CHEMIN{images/ok.png}|url_absolue)]") no-repeat scroll left top transparent;\' onclick="javascript:return cke_crayon_submit(\''+editor_id+'\');" title="<:bouton_enregistrer:>"><:bouton_enregistrer:></button>')[(#REM)// on ajoute notre bouton qui synchronisera le textarea avant l'editeur avec de soumettre le formulaire]
jQuery('#'+crayon+' .crayon-submit')
.after('<button class="crayon-submit" onclick="javascript:return cke_crayon_submit(\''+editor_id+'\');" title="<:bouton_enregistrer:>"><:bouton_enregistrer:></button>')[(#REM)// on ajoute notre bouton qui synchronisera le textarea avant l'editeur avec de soumettre le formulaire]
.remove();[(#REM)// on supprime le bouton original]
}
if(CKEDITOR.ckeditmode!='spip'){
SpipEditor2CKEditor(editor_ids[id][0]) ;
SpipEditor2CKEditor(editor_id) ;
}
}}
}

207
ckeditor_fonctions.php

@ -81,6 +81,9 @@ function ckeditor_prepare_champs($type, $default_tb = 'Full') {
$champs[] = array($item, $tb) ;
}
}
if ((_request('page')=='cisf_article')&&ckeditor_lire_config('cisf', _CKE_CISF_DEF)) {
$champs[] = array('article',ckeditor_lire_config('cisf_tb',_CKE_CISF_TB_DEF));
}
$ckeditor_prepare_champs_post = charger_fonction('ckeditor_prepare_champs_post','');
$champs = $ckeditor_prepare_champs_post($champs, $default_tb) ;
@ -115,101 +118,101 @@ function ckeditor_get_scaytlang($type, $id_type) {
}
function ckeditor_header_prive($flux) {
$flux .= "\n<!-- début de : ckeditor_header_prive -->\n" ;
$exec = _request('exec') ;
if (version_compare($GLOBALS['spip_version_affichee'],'3.0','<') && preg_match('~^configurer_ckeditor~',$exec)) {
$head = inclure_page("prive/squelettes/head/".$exec."-v2",null) ;
$flux .= "<!-- fond=prive/squelettes/head/".$exec."-v2 -->\n" ;
$flux .= $head['texte'] ;
}
if (ckeditor_lire_config('insertcssprivee', _CKE_INSERT_CSSPRIVEE_DEF)) {
$flux .= ckeditor_getcss() ;
}
$flux .= "<link rel='stylesheet' href='".find_in_path('css/cked-cfg.css')."' type='text/css' />\n" ;
$config = array('ajaxload'=>array());
$exec = _request('exec') ;
if(preg_match('~^(\w+)s?_(edit)$~', $exec, $match) || preg_match('~^(\w+)s$~', $exec, $match)) {
$type = $match[1] ;
$id_type = _request('id_'.$type) ;
if ($id_type) {
$config['type']=$type;
$config['id']=$id_type;
switch($type) {
case 'article':
case 'rubrique':
$config['scayt_sLang'] = ckeditor_get_scaytlang($type, $id_type) ;
break ;
}
}
}
if (!$config['type'] && !$config['id']) {
$type = $exec ;
switch($type) {
case 'article':
case 'rubrique':
$config['type'] = $type ;
$id_type = _request('id_'.$type) ;
if ($id_type) {
$config['id'] = $id_type ;
$config['scayt_sLang'] = ckeditor_get_scaytlang($type, $id_type) ;
}
break;
default:
}
}
if($champs = ckeditor_prepare_champs(ckeditor_lire_config('selecteurs_prive',_CKE_PRIVE_DEF)))
$config['ajaxload']=$champs;
if(_request('exec') == 'configurer_ckeditor_p6') {
if($exec == 'configurer_ckeditor_p6') {
$config['ajaxload'][] = array('textarea#champ_modele','Full') ;
}
if (count($config['ajaxload']))
$flux .= ckeditor_preparescript($config) ;
return $flux."\n<!-- fin de : ckeditor_header_prive -->\n" ;
}
function ckeditor_insert_head($flux) {
$flux .= "\n<!-- début de : ckeditor_insert_head -->\n" ;
if (ckeditor_lire_config('insertcsspublic', _CKE_INSERT_CSSPUBLIC_DEF)) {
$flux .= ckeditor_getcss() ;
}
$config=array('ajaxload'=>array());
if ((_request('page')=='cisf_article')&&ckeditor_lire_config('cisf', _CKE_CISF_DEF)) {
$config['ajaxload']=ckeditor_prepare_champs('article',ckeditor_lire_config('cisf_tb',_CKE_CISF_TB_DEF));
$config['type'] = 'article' ;
$id = _request('id_article') ;
if ($id) {
$config['id'] = $id ;
switch($type) {
if (count($config['ajaxload'])) {
$flux .= "\n<!-- début de : ckeditor_header_prive -->\n" ;
$exec = _request('exec') ;
if (version_compare($GLOBALS['spip_version_affichee'],'3.0','<') && preg_match('~^configurer_ckeditor~',$exec)) {
$head = inclure_page("prive/squelettes/head/".$exec."-v2",null) ;
$flux .= "<!-- fond=prive/squelettes/head/".$exec."-v2 -->\n" ;
$flux .= $head['texte'] ;
}
if (ckeditor_lire_config('insertcssprivee', _CKE_INSERT_CSSPRIVEE_DEF)) {
$flux .= ckeditor_getcss() ;
}
$flux .= "<link rel='stylesheet' href='".find_in_path('css/cked-cfg.css')."' type='text/css' />\n" ;
if(preg_match('~^(\w+)s?_(edit)$~', $exec, $match) || preg_match('~^(\w+)s$~', $exec, $match)) {
$type = $match[1] ;
$id_type = _request('id_'.$type) ;
if ($id_type) {
$config['type']=$type;
$config['id']=$id_type;
switch($type) {
case 'article':
case 'rubrique':
$config['scayt_sLang'] = ckeditor_get_scaytlang($type, $id_type) ;
break ;
}
}
}
if (!$config['type'] && !$config['id']) {
$type = $exec ;
switch($type) {
case 'article':
case 'rubrique':
$res = sql_select('lang', 'spip_'.$type.'s', 'id_'.$type.' = '.$id_type) ;
if ($row = sql_fetch($res)) {
$config['scayt_sLang'] = ckeditor_spiplang_to_scayt($row['lang']) ;
$config['type'] = $type ;
$id_type = _request('id_'.$type) ;
if ($id_type) {
$config['id'] = $id_type ;
$config['scayt_sLang'] = ckeditor_get_scaytlang($type, $id_type) ;
}
break ;
}
}
} else // on essaie quand même de déterminer le contexte d'édition :
if (is_array($GLOBALS['page']) && is_array($GLOBALS['page']['contexte'])) {
$type=$GLOBALS['page']['contexte']['type'] ;
$id=$GLOBALS['page']['contexte']['id_'.$type];
if ($id) {
$config['type']=$type;
$config['id']=$id;
break;
default:
}
}
$flux .= ckeditor_preparescript($config) ;
$flux .= "\n<!-- fin de : ckeditor_header_prive -->\n" ;
}
return $flux ;
}
function ckeditor_insert_head($flux) {
$config=array('ajaxload'=>array());
if($champs = ckeditor_prepare_champs(ckeditor_lire_config('selecteurs_public',_CKE_PUBLIC_DEF)))
$config['ajaxload']=$champs;
if (count($config['ajaxload'])) // s'il y a quelque chose à charger :
if (count($config['ajaxload'])) {// s'il y a quelque chose à charger :
$flux .= "\n<!-- début de : ckeditor_insert_head -->\n" ;
if (ckeditor_lire_config('insertcsspublic', _CKE_INSERT_CSSPUBLIC_DEF)) {
$flux .= ckeditor_getcss() ;
}
if ((_request('page')=='cisf_article')&&ckeditor_lire_config('cisf', _CKE_CISF_DEF)) {
$config['type'] = 'article' ;
$id = _request('id_article') ;
if ($id) {
$config['id'] = $id ;
switch($type) {
case 'article':
case 'rubrique':
$res = sql_select('lang', 'spip_'.$type.'s', 'id_'.$type.' = '.$id_type) ;
if ($row = sql_fetch($res)) {
$config['scayt_sLang'] = ckeditor_spiplang_to_scayt($row['lang']) ;
}
break ;
}
}
} else // on essaie quand même de déterminer le contexte d'édition :
if (is_array($GLOBALS['page']) && is_array($GLOBALS['page']['contexte'])) {
$type=$GLOBALS['page']['contexte']['type'] ;
$id=$GLOBALS['page']['contexte']['id_'.$type];
if ($id) {
$config['type']=$type;
$config['id']=$id;
}
}
$flux .= ckeditor_preparescript($config) ;
return $flux."\n<!-- fin de : ckeditor_insert_head -->\n" ;
$flux .= "\n<!-- fin de : ckeditor_insert_head -->\n" ;
}
return $flux ;
}
function ckeditor_prepare_champs_post_dist($editer_champs, $default_tb) {
@ -271,6 +274,7 @@ function ckeditor_preparescript($config) {
global $visiteur_session ;
global $auteur_session ;
static $init_done = false ;
if (!$init_done) {
$cke_cfg= array() ;
$removePlugins = array() ;
@ -617,39 +621,22 @@ function ckeditor_preparescript($config) {
$config['ajaxload'][$ndx][3] = md5($row[0]) ;
}
$script .= " <script type=\"text/javascript\">
function loadCKEditor() {
// la configuration de ckeditor :
CKEDITOR.ckeditorpath=".$ckeditor_json_encode(url_absolue(_CKE_JS)).";
CKEDITOR.spipurl=".$ckeditor_json_encode(url_absolue(_DIR_RACINE.'spip.php')).";
CKEDITOR.ckpreferedversion='"._CKE_PREFERED_VERSION."';
CKEDITOR.ckeditmode='$editmode';
CKEDITOR.cache_redim=".$ckeditor_json_encode(ckeditor_lire_config('cache_redim', _CKE_CACHE_REDIM_DEF)?true:false).";
CKEDITOR.ckConfig = ".$ckeditor_json_encode($ckeditor_config_post($cke_cfg)).";
var ajaxload=".$ckeditor_json_encode($config['ajaxload']).";
try {
var prefix_id = $(this).attr('id');
if ((prefix_id != undefined) && prefix_id.match(/^\w+$/)){
$.each(ajaxload, function(i){
ajaxload[i][2]=prefix_id;
ajaxload[i][0]='#'+prefix_id+' '+ajaxload[i][0];
});
for(name in CKEDITOR.instances) {
CKEDITOR.instances[name].destroy()
}
CKEDITOR.instances = [] ;
}
} catch (E) {}
fullInitCKEDITOR(ajaxload) ;
}
$(document).ready(function(){
function loadCKEditor() {
// la configuration de ckeditor :
CKEDITOR.ckeditorpath=".$ckeditor_json_encode(url_absolue(_CKE_JS)).";
CKEDITOR.spipurl=".$ckeditor_json_encode(url_absolue(_DIR_RACINE.'spip.php')).";
CKEDITOR.ckpreferedversion='"._CKE_PREFERED_VERSION."';
CKEDITOR.ckeditmode='$editmode';
CKEDITOR.cache_redim=".$ckeditor_json_encode(ckeditor_lire_config('cache_redim', _CKE_CACHE_REDIM_DEF)?true:false).";
CKEDITOR.ckConfig = ".$ckeditor_json_encode($ckeditor_config_post($cke_cfg)).";
var ajaxload=".$ckeditor_json_encode($config['ajaxload']).";
CKEDITOR.instances = [] ; // normalement aucune instances de CKEDITOR n'est valide à cet instant, on les vide.
fullInitCKEDITOR(ajaxload) ;
}
// fix: http://contrib.spip.net/CKeditor-3-0#forum468153
function ajaxLoadCKEditor() {
CKEDITOR = window.parent.document.CKEDITOR ;
loadCKEditor() ;
}
$(window).load(function(){
if(typeof onAjaxLoad == 'function') onAjaxLoad(ajaxLoadCKEditor);
if(typeof onAjaxLoad == 'function') onAjaxLoad(loadCKEditor);
loadCKEditor();
}) ;

2
paquet.xml

@ -1,7 +1,7 @@
<paquet
prefix="ckeditor"
categorie="edition"
version="0.16.12"
version="0.16.13"
etat="dev"
compatibilite="[3.0.5;3.0.*]"
logo="images/ckspip-logo.png"

2
plugin.xml

@ -1,7 +1,7 @@
<plugin>
<nom><multi>[fr]CKEditor pour SPIP[en]CKEditor for SPIP[ar]CKEDITOR &#1604; SPIP</multi></nom>
<auteur>Auteurs : [Fr&#233;d&#233;ric Bonnaud->mailto:fred@lea-linux.org], [Mehdi Cherifi (Superyms)->mailto:superyms@gmail.com], [Emmanuel Dreyfus->mailto:manu@netbsd.org]</auteur>
<version>0.16.12</version>
<version>0.16.13</version>
<etat>test</etat>
<description>
<h3><multi>[fr]Int&#233;gration de l'&#233;diteur WYSIWYG CKEditor à SPIP 2.0.9+[en]Integration of WYSIWYG editor CKEditor with SPIP 2.0.9+[ar]&#1578;&#1603;&#1575;&#1605;&#1604; CKEditor &#1606;&#1575;&#1588;&#1585; &#1604;SPIP 2.0.9+ et SPIP 3.0.4+</multi></h3>

Loading…
Cancel
Save