This repository has been archived by the owner on May 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0598b2b
commit 68714e5
Showing
13 changed files
with
321 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
// This is a SPIP language file -- Ceci est un fichier langue de SPIP | ||
|
||
if (!defined('_ECRIRE_INC_VERSION')) return; | ||
|
||
$GLOBALS[$GLOBALS['idx_lang']] = array( | ||
|
||
// P | ||
'porte_plume_intertitres_description' => 'Ajoute aux raccourcis de spip, le niveaux de titre', | ||
'porte_plume_intertitres_nom' => 'Intertitres hierarchiques', | ||
'porte_plume_intertitres_slogan' => 'Intertitres hierarchiques', | ||
); | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
// This is a SPIP language file -- Ceci est un fichier langue de SPIP | ||
|
||
if (!defined('_ECRIRE_INC_VERSION')) return; | ||
|
||
$GLOBALS[$GLOBALS['idx_lang']] = array( | ||
// B | ||
// Aide des boutons supplémentaires de la barre typo | ||
'barre_intertitre2' => 'Transformer en {{{** intertitre niveau deux }}}', | ||
'barre_intertitre3' => 'Transformer en {{{*** intertitre niveau trois }}}', | ||
'barre_intertitre4' => 'Transformer en {{{**** intertitre niveau quatre }}}', | ||
// P | ||
'porte_plume_intertitres_titre' => 'Intertitres hierarchiques', | ||
); | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<paquet | ||
prefix="porte_plume_intertitres" | ||
categorie="edition" | ||
version="1.0.0" | ||
etat="dev" | ||
compatibilite="[3.0.16;3.1.*]" | ||
logo="" | ||
documentation="" | ||
> | ||
<nom>Intertitres hierarchiques</nom> | ||
|
||
<auteur>Mist. GraphX</auteur> | ||
|
||
<licence>GNU/GPL</licence> | ||
|
||
<pipeline nom="pre_propre" inclure="porte_plume_intertitres_pipelines.php" /> | ||
|
||
<pipeline nom="porte_plume_barre_pre_charger" inclure="porte_plume_intertitres_pipelines.php" /> | ||
<pipeline nom="porte_plume_lien_classe_vers_icone" inclure="porte_plume_intertitres_pipelines.php" /> | ||
|
||
<necessite nom="tw" compatibilite="[0.3.1;[" /> | ||
|
||
</paquet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
/** | ||
* Fonctions utiles au plugin Intertitres hierarchiques | ||
* | ||
* @plugin Intertitres hierarchiques | ||
* @copyright 2016 | ||
* @author Mist. GraphX | ||
* @licence GNU/GPL | ||
* @package SPIP\Porte_plume_intertitres\Fonctions | ||
*/ | ||
|
||
if (!defined('_ECRIRE_INC_VERSION')) return; | ||
|
||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
/** | ||
* Options du plugin Intertitres hierarchiques au chargement | ||
* | ||
* @plugin Intertitres hierarchiques | ||
* @copyright 2016 | ||
* @author Mist. GraphX | ||
* @licence GNU/GPL | ||
* @package SPIP\Porte_plume_intertitres\Options | ||
*/ | ||
|
||
if (!defined('_ECRIRE_INC_VERSION')) return; | ||
|
||
// Ajout des raccourcis dans la liste des wheels | ||
$GLOBALS['spip_wheels']['raccourcis'][] = 'porte_plume_intertitres.yaml'; | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,177 @@ | ||
<?php | ||
/** | ||
* Utilisations de pipelines par Intertitres hierarchiques | ||
* | ||
* @plugin Intertitres hierarchiques | ||
* @copyright 2016 | ||
* @author Mist. GraphX | ||
* @licence GNU/GPL | ||
* @package SPIP\Porte_plume_intertitres\Pipelines | ||
*/ | ||
|
||
if (!defined('_ECRIRE_INC_VERSION')) return; | ||
|
||
// http://www.spip-contrib.net/Porte-Plume-documentation-technique | ||
function porte_plume_intertitres_porte_plume_barre_pre_charger($barres){ | ||
$barre = &$barres['edition']; | ||
|
||
$barre->set('header1', array( | ||
// groupe formatage paragraphe | ||
"dropMenu" => array( | ||
// bouton <cadre> | ||
array( | ||
"id" => 'intertitre', | ||
"name" => _T('barre_intertitre'), | ||
"className" => 'outil_intertitre1', | ||
"openWith" => "\n{{{ ", | ||
"closeWith" => "}}}\n", | ||
"display" => true, | ||
"selectionType" => "line", | ||
), | ||
array( | ||
"id" => 'intertitre2', | ||
"name" => _T('porte_plume_intertitres:barre_intertitre2'), | ||
"className" => 'outil_intertitre2', | ||
"openWith" => "\n{{{** ", | ||
"closeWith" => "}}}\n", | ||
"display" => true, | ||
"selectionType" => "line", | ||
), | ||
array( | ||
"id" => 'intertitre3', | ||
"name" => _T('porte_plume_intertitres:barre_intertitre3'), | ||
"className" => 'outil_intertitre3', | ||
"openWith" => "\n{{{*** ", | ||
"closeWith" => "}}}\n", | ||
"display" => true, | ||
"selectionType" => "line", | ||
), | ||
array( | ||
"id" => 'intertitre4', | ||
"name" => _T('porte_plume_intertitres:barre_intertitre4'), | ||
"className" => 'outil_intertitre4', | ||
"openWith" => "\n{{{**** ", | ||
"closeWith" => "}}}\n", | ||
"display" => true, | ||
"selectionType" => "line", | ||
), | ||
|
||
) | ||
)); | ||
|
||
$barre->ajouterApres('header1', array( | ||
"id" => "sepgrp1", | ||
"separator" => "---------------", | ||
"display" => true, | ||
)); | ||
|
||
|
||
return $barres; | ||
} | ||
|
||
function porte_plume_intertitres_porte_plume_lien_classe_vers_icone($flux){ | ||
return array_merge($flux, array( | ||
'outil_header1' => array('intertitre.png','0'), //'intertitre.png' | ||
'outil_intertitre1' => array('intertitre_2.png','0'), //'intertitre.png' | ||
'outil_intertitre2' => array('intertitre_3.png','0'), | ||
'outil_intertitre3' => array('intertitre_4.png','0'), | ||
'outil_intertitre4' => array('intertitre_5.png','0') | ||
)); | ||
} | ||
// http://contrib.spip.net/Generation-automatique-de | ||
function porte_plume_intertitres_pre_propre($texte) { | ||
|
||
// on cherche les noms de section commençant par des # | ||
// http://lumadis.be/regex/test_regex.php?id=2929 | ||
/* | ||
[0]=> array | ||
[0]=>{{{# Reference H4 }}} | ||
[1]=>{{{## Reference sub }}} | ||
[2]=>{{{# Reference H4 }}} | ||
[3]=>{{{## Reference sub }}} | ||
[1]=> array | ||
[0]=>{{{ | ||
[1]=>{{{ | ||
[2]=>{{{ | ||
[3]=>{{{ | ||
[2]=> array | ||
[0]=># | ||
[1]=>## | ||
[2]=># | ||
[3]=>## | ||
[3]=> array | ||
[0]=> Reference H4 | ||
[1]=> Reference sub | ||
[2]=> Reference H4 | ||
[3]=> Reference sub | ||
[4]=> array | ||
[0]=>}}} | ||
[1]=>}}} | ||
[2]=>}}} | ||
[3]=>}}} | ||
*/ | ||
// retourne le nombre de matches | ||
$count = preg_match_all("/({{{)(\#{1,4})(.*)(}}})/i", $texte, $matches); | ||
|
||
//initialisation du compteur | ||
$cnt[0] = 0; | ||
$lastlevel = 1; | ||
$cite[''] = ''; | ||
|
||
//pour chaque titre trouvé | ||
for ($j=0; $j < $count; $j++) { | ||
|
||
$level = $matches[2][$j]; | ||
$titre = $matches[3][$j]; | ||
|
||
//on est au niveau de base {{{# }}} | ||
if(strlen($level) == 1) { | ||
|
||
//on réinitialise le compteur de ce titre | ||
for ($i=1; $i < count($cnt); $i++) { | ||
$cnt[$i] = 0; | ||
} | ||
//on incrémente cnt[0] | ||
$numeros = ++$cnt[0]; | ||
|
||
$titre = $numeros.' - '.$titre; | ||
|
||
|
||
} else { | ||
//on est à un niveau plus profond | ||
// on construit le numéros | ||
$numeros = $cnt[0].'.'; | ||
for ($i=1; $i < strlen($level)-1; $i++) { | ||
$numeros .= $cnt[$i]."."; | ||
} | ||
$numeros = $numeros.(++$cnt[$i]); | ||
//on génère le titre | ||
$titre = $numeros.' - '.$titre; | ||
} | ||
|
||
$debut_markup = $matches[1][$j].$matches[2][$j]; | ||
$fin_markup = $matches[4][$j]; | ||
|
||
$haystack = $texte; | ||
$needle = $matches[0][$j]; | ||
$replace = $debut_markup.$titre.$fin_markup ; | ||
// Ne remplacer que la première occurence trouvé, au cas ou des titres soient identique | ||
// http://stackoverflow.com/questions/1252693/using-str-replace-so-that-it-only-acts-on-the-first-match/1252710#1252710 | ||
$pos = strpos($haystack, $needle); | ||
if ($pos !== false) { | ||
$texte = substr_replace($haystack, $replace, $pos, strlen($needle)); | ||
} | ||
|
||
//$texte = str_replace($matches[0][$j], $debut_markup.$titre.$fin_markup, $texte); | ||
} | ||
|
||
//on remplace les raccourcis par les numéros des sections. | ||
// foreach ($cite as $ref => $num) { | ||
// $texte = str_replace("<$ref>","<a href=\"#$num\">$num</a>",$texte); | ||
// } | ||
|
||
|
||
return $texte; | ||
} | ||
|
||
?> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
--- # Syntaxe des raccourcis SPIP, version 0.0.1 | ||
# | ||
# Si on nomme une regle, elle devient surchargeable | ||
intertitre4: | ||
# raccourcis en {{{..}}} | ||
# intertitres | ||
match: ['{{{***', '}}}'] | ||
replace: ["\n\n\n<h4>", "</h4>\n\n\n"] | ||
if_str: '{{{***' | ||
type: str | ||
priority: -40 | ||
|
||
intertitre3: | ||
# raccourcis en {{{..}}} | ||
# intertitres | ||
match: ['{{{**', '}}}'] | ||
replace: ["\n\n\n<h3>", "</h3>\n\n\n"] | ||
if_str: '{{{**' | ||
type: str | ||
priority: -40 | ||
|
||
intertitre2: | ||
# raccourcis en {{{..}}} | ||
# intertitres | ||
match: ['{{{*', '}}}'] | ||
replace: ["\n\n\n<h2 class='coucou'>", "</h2>\n\n\n"] | ||
if_str: '{{{*' | ||
type: str | ||
priority: -40 | ||
|
||
reference4: | ||
match: ['{{{###', '}}}'] | ||
replace: ["\n\n\n<h4>", "</h4>\n\n\n"] | ||
if_str: '{{{###' | ||
type: str | ||
priority: -40 | ||
|
||
reference3: | ||
match: ['{{{##', '}}}'] | ||
replace: ["\n\n\n<h3>", "</h3>\n\n\n"] | ||
if_str: '{{{##' | ||
type: str | ||
priority: -40 | ||
|
||
reference2: | ||
match: ['{{{#', '}}}'] | ||
replace: ["\n\n\n<h2>", "</h2>\n\n\n"] | ||
if_str: '{{{#' | ||
type: str | ||
priority: -40 | ||
|
||
intertitres: | ||
# raccourcis en {{{..}}} | ||
# intertitres | ||
match: ['{{{', '}}}'] | ||
replace: ["\n\n\n<h3 class=\"spip\">", "</h3>\n\n\n"] | ||
if_str: '{{{' | ||
type: str | ||
priority: -10 |