Skip to content

Instantly share code, notes, and snippets.

@mistergraphx
Last active February 8, 2018 13:16
Show Gist options
  • Save mistergraphx/f9380ea6f0eb8a4c7bdd4e667b7b305a to your computer and use it in GitHub Desktop.
Save mistergraphx/f9380ea6f0eb8a4c7bdd4e667b7b305a to your computer and use it in GitHub Desktop.
SPIP Déclarer une nouvelle wheel à TextWheel
<?php
if (!defined('_ECRIRE_INC_VERSION')) {
return;
}
// @see http://zone.spip.org/trac/spip-zone/browser/_plugins_/todo/trunk/wheels/todo.php
// test : http://lumadis.be/regex/test_regex.php?id=3254
// Extraction de lignes du texte
// La wheel renvoie un tableau à cette callback qui est le résultat d'un preg_match_all.
// Le contenu du tableau est le suivant :
// 0 - la chaine complète
// 1 - uverture de la boite
// 2 - Contenu
// 3 - balise fermante
function box($t){
// recuperer les css
$reg = '/class="(.*?)"/s';
if(preg_match_all($reg,$t[1],$styles)){
$css = $styles[1][0];
}
$box_content= $t[2];
$html = "<div class=\"$css\">".$box_content."<div>" ;
return $html;
}
--- # Syntaxe des raccourcis SPIP, version 0.0.1
#
# Si on nomme une regle, elle devient surchargeable
box:
# raccourcis <box>
# box
match: "#^([<box].*?[>])(.*?)(</box>)#ms"
is_callback: Y
replace: box
if_str: '<box'
priority: -100
<paquet
prefix="fragments_core"
categorie="divers"
version="1.1.2"
schema="1.0.0"
etat="dev"
compatibilite="[3.1.0;3.2.*]"
logo="fragments_core.png"
>
<nom>Fragments : core</nom>
<auteur>Arnaud B. (Mist. GraphX)</auteur>
<copyright>2016-2017</copyright>
<licence>GPL v3</licence>
<!-- Déclarer que l'on utilise textwheel -->
<necessite nom="tw" compatibilite="[0.3.1;[" /> <!--TextWheel-->
</paquet>
<?php
if (!defined('_ECRIRE_INC_VERSION')) {
return;
}
// Ajout des raccourcis dans la liste des wheels
$GLOBALS['spip_wheels']['raccourcis'][] = 'box.yaml';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment