|
|
|
@ -4,13 +4,18 @@
|
|
|
|
|
if (!defined('_ECRIRE_INC_VERSION')) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* @param $flux |
|
|
|
|
* |
|
|
|
|
* @return string |
|
|
|
|
*/ |
|
|
|
|
function faq_insert_head_css($flux) { |
|
|
|
|
// On inclut systématiquement les CSS de base |
|
|
|
|
$flux .= '<link rel="stylesheet" href="' . find_in_path('css/faq.css') . '" type="text/css" media="all" />'; |
|
|
|
|
|
|
|
|
|
// On ajoute si la config le demande les CSS propres aux dl |
|
|
|
|
include_spip('inc/config'); |
|
|
|
|
$charger_css = lire_config('faq/charger_css') ? true : false; |
|
|
|
|
$charger_css = lire_config('faq/charger_css'); |
|
|
|
|
if ($charger_css) { |
|
|
|
|
$flux .= '<link rel="stylesheet" href="' . find_in_path('css/faq_dl.css') . '" type="text/css" media="all" />'; |
|
|
|
|
} |
|
|
|
@ -18,9 +23,14 @@ function faq_insert_head_css($flux) {
|
|
|
|
|
return $flux; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @param $flux |
|
|
|
|
* |
|
|
|
|
* @return mixed|string |
|
|
|
|
*/ |
|
|
|
|
function faq_insert_head($flux) { |
|
|
|
|
include_spip('inc/config'); |
|
|
|
|
$charger_js = lire_config('faq/charger_js') ? true : false; |
|
|
|
|
$charger_js = lire_config('faq/charger_js'); |
|
|
|
|
if ($charger_js) { |
|
|
|
|
$flux .= '<script src="' . find_in_path('js/faq.js') . '" type="text/javascript"></script>'; |
|
|
|
|
} |
|
|
|
@ -28,11 +38,19 @@ function faq_insert_head($flux) {
|
|
|
|
|
return $flux; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @param $barres |
|
|
|
|
* |
|
|
|
|
* @return mixed |
|
|
|
|
*/ |
|
|
|
|
function faq_porte_plume_barre_pre_charger($barres) { |
|
|
|
|
// on ajoute les boutons dans la barre d'édition seulement |
|
|
|
|
foreach (array('edition') as $nom) { |
|
|
|
|
$barre = &$barres[$nom]; |
|
|
|
|
$barre->ajouterPlusieursApres('grpCaracteres', array( |
|
|
|
|
$nom = 'edition'; |
|
|
|
|
$barre = &$barres[$nom]; |
|
|
|
|
|
|
|
|
|
$barre->ajouterPlusieursApres( |
|
|
|
|
'grpCaracteres', |
|
|
|
|
array( |
|
|
|
|
array( |
|
|
|
|
'id' => 'faq_sep', |
|
|
|
|
'separator' => '---------------', |
|
|
|
@ -69,47 +87,57 @@ function faq_porte_plume_barre_pre_charger($barres) {
|
|
|
|
|
), |
|
|
|
|
) |
|
|
|
|
) |
|
|
|
|
)); |
|
|
|
|
$barre->ajouterFonction("function outil_faq(h, c,recursif) { |
|
|
|
|
if(recursif){ |
|
|
|
|
// Cas de la sélection de click sur le bouton de création de faq complète |
|
|
|
|
s = h.selection; |
|
|
|
|
lines = h.selection.split(/\\r?\\n/); |
|
|
|
|
var lines_final = []; |
|
|
|
|
for (j = 0, n = lines.length, i = 0; i < n; i++) { |
|
|
|
|
// si une seule ligne, on se fiche de savoir qu'elle est vide, |
|
|
|
|
// c'est volontaire si on clique le bouton |
|
|
|
|
if (n == 1 || $.trim(lines[i]) !== '') { |
|
|
|
|
if(r = lines[i].match(/^([+-o]) (.*)$/)){ |
|
|
|
|
r[1] = r[1].replace(/[+-o]/g, c); |
|
|
|
|
lines_final[j] = r[1]+' '+r[2]; |
|
|
|
|
j++; |
|
|
|
|
} else { |
|
|
|
|
lines_final[j] = c + ' '+lines[i]; |
|
|
|
|
j++; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
$barre->ajouterFonction( |
|
|
|
|
"function outil_faq(h, c,recursif) { |
|
|
|
|
if(recursif){ |
|
|
|
|
// Cas de la sélection de click sur le bouton de création de faq complète |
|
|
|
|
s = h.selection; |
|
|
|
|
lines = h.selection.split(/\\r?\\n/); |
|
|
|
|
var lines_final = []; |
|
|
|
|
for (j = 0, n = lines.length, i = 0; i < n; i++) { |
|
|
|
|
// si une seule ligne, on se fiche de savoir qu'elle est vide, |
|
|
|
|
// c'est volontaire si on clique le bouton |
|
|
|
|
if (n == 1 || $.trim(lines[i]) !== '') { |
|
|
|
|
if(r = lines[i].match(/^([+-o]) (.*)$/)){ |
|
|
|
|
r[1] = r[1].replace(/[+-o]/g, c); |
|
|
|
|
lines_final[j] = r[1]+' '+r[2]; |
|
|
|
|
j++; |
|
|
|
|
} else { |
|
|
|
|
lines_final[j] = c + ' '+lines[i]; |
|
|
|
|
j++; |
|
|
|
|
} |
|
|
|
|
return lines_final.join('\\n'); |
|
|
|
|
} |
|
|
|
|
// Click sur les autres boutons |
|
|
|
|
if ((s = h.selection) && (r = s.match(/^([+-o]) (.*)$/))){ |
|
|
|
|
r[1] = r[1].replace(/[+-o]/g, c); |
|
|
|
|
s = r[1]+' '+r[2]; |
|
|
|
|
} else { |
|
|
|
|
s = c + ' '+s; |
|
|
|
|
} |
|
|
|
|
return s; |
|
|
|
|
}"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return lines_final.join('\\n'); |
|
|
|
|
} |
|
|
|
|
// Click sur les autres boutons |
|
|
|
|
if ((s = h.selection) && (r = s.match(/^([+-o]) (.*)$/))){ |
|
|
|
|
r[1] = r[1].replace(/[+-o]/g, c); |
|
|
|
|
s = r[1]+' '+r[2]; |
|
|
|
|
} else { |
|
|
|
|
s = c + ' '+s; |
|
|
|
|
} |
|
|
|
|
return s; |
|
|
|
|
}" |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
return $barres; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @param $flux |
|
|
|
|
* |
|
|
|
|
* @return array |
|
|
|
|
*/ |
|
|
|
|
function faq_porte_plume_lien_classe_vers_icone($flux) { |
|
|
|
|
return array_merge($flux, array( |
|
|
|
|
'outil_faq' => 'faq-16.png', |
|
|
|
|
'outil_faq_question'=> 'faq_question-16.png', |
|
|
|
|
'outil_faq_titre' => 'faq_titre-16.png' |
|
|
|
|
)); |
|
|
|
|
return array_merge( |
|
|
|
|
$flux, |
|
|
|
|
array( |
|
|
|
|
'outil_faq' => 'faq-xx.svg', |
|
|
|
|
'outil_faq_question'=> 'faq_question-xx.svg', |
|
|
|
|
'outil_faq_titre' => 'faq_titre-xx.svg' |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|