X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=www%2Fplugins%2Fauto%2Fcouteau_suisse%2Fcouteau_suisse%2Foutils%2Ffilets_sep.php;fp=www%2Fplugins%2Fauto%2Fcouteau_suisse%2Fcouteau_suisse%2Foutils%2Ffilets_sep.php;h=d51dda73a39dd701c7ae0c94244b84aa6e146d16;hb=80b4d3e85f78d402ed2e73f8f5d1bf4c19962eed;hp=0000000000000000000000000000000000000000;hpb=aaf970bf4cdaf76689ecc10609048e18d073820c;p=velocampus%2Fweb%2Fwww.git diff --git a/www/plugins/auto/couteau_suisse/couteau_suisse/outils/filets_sep.php b/www/plugins/auto/couteau_suisse/couteau_suisse/outils/filets_sep.php new file mode 100644 index 0000000..d51dda7 --- /dev/null +++ b/www/plugins/auto/couteau_suisse/couteau_suisse/outils/filets_sep.php @@ -0,0 +1,171 @@ +'); +@define('_FILETS_SEP_BALISE_DEBUT', '
'); +@define('_FILETS_SEP_MAX_CSS', 7); +@define('_FILETS_REG_DEBUT', '#(?:\s*[\n\r]\s*)__('); +@define('_FILETS_REG_FIN', ')__(?=\s*[\n\r]\s*)#iU'); +@define('_FILETS_REG_EXT', '\.(?:png|gif|jpg)'); + +// cette fonction appelee automatiquement a chaque affichage de la page privee du Couteau Suisse renvoie un tableau +function filets_sep_installe_dist() { +//cs_log('filets_sep_installe_dist()'); + include_spip('inc/texte'); + // Tester si on echappe en span ou en div + $mode = ($bmode=preg_match(',<('._BALISES_BLOCS.'|p)(\W|$),iS', _FILETS_SEP_BALISE_DEBUT))?'div':'span'; + $bt = defined('_DIR_PLUGIN_PORTE_PLUME'); + $filets = array(); + // filets numeriques + for($i=0; $i<=_FILETS_SEP_MAX_CSS; $i++) { + $filets[6][] = $i; + $f = cs_code_echappement(_FILETS_SEP_BALISE_DEBUT." class='filet_sep filet_sep_$i'"._FILETS_SEP_BALISE_FIN, '', $mode); + $filets[1]["$i"] = $bmode?"\n\n".$f."\n\n":$f; + } + // filets image + $path = find_in_path('img/filets'); + $dossier = opendir($path); + if($path) while ($image = readdir($dossier)) { + if (preg_match(',^(([a-z0-9_-]+)'._FILETS_REG_EXT.'),', $image, $reg)) { + $filets[0][] = '__'.$reg[1].'__'; + $filets[6][] = preg_quote($reg[1]); + $filets[2][] = $reg[2]; + list(,$haut) = @getimagesize($path.'/'.$reg[1]); + if ($haut) $haut="height:{$haut}px;"; + $f = url_absolue($path).'/'.$reg[1]; + $f = cs_code_echappement(_FILETS_SEP_BALISE_DEBUT." class=\"filet_sep filet_sep_image\" style=\"$haut background-image: url($f);\""._FILETS_SEP_BALISE_FIN, '', $mode); + $filets[1][$reg[1]] = $bmode?"\n\n".$f."\n\n":$f; + if($bt) + $filets[4]['filet_'.str_replace('.','_',$reg[1])] = $reg[1]; + } + } + // RegExpr finale + $filets[6] = _FILETS_REG_DEBUT . join('|', $filets[6]) . _FILETS_REG_FIN; + if($bt) for($i=0; $i<=_FILETS_SEP_MAX_CSS; $i++) + $filets[5]['filet_'.$i] = $i; + return array($filets); +} + +// liste des nouveaux raccourcis ajoutes par l'outil +// si cette fonction n'existe pas, le plugin cherche alors _T('couteauprive:un_outil:aide'); +function filets_sep_raccourcis() { + $filets = cs_lire_data_outil('filets_sep'); + return _T('couteauprive:filets_sep:aide', + array('liste' => ''.join(', ', $filets[0]).'', 'max'=>_FILETS_SEP_MAX_CSS)); +} + +function filets_sep_callback($matches) { + global $filets_tmp; + return $filets_tmp[1][$matches[1]]; +} + +// Fonction pour generer des filets de separation selon les balises presentes dans le texte fourni. +// Cette fonction n'est pas appelee dans les balises html : html|code|cadre|frame|script +function filets_sep_rempl($texte) { + if (strpos($texte, '__')===false) return $texte; + + global $filets_tmp; + $filets_tmp = cs_lire_data_outil('filets_sep'); + + // On remplace les balises filets dans le texte par le code HTML correspondant + // le resultat a ete protege pour eviter que la typo de SPIP y touche + $texte = preg_replace_callback($filets_tmp[6], 'filets_sep_callback', $texte); + + // Nettoyage et retour + unset($filets_tmp); + return $texte; +} + +// fonction pipeline pre_typo +function filets_sep($texte) { + if (strpos($texte, '__')===false) return $texte; + return cs_echappe_balises('', 'filets_sep_rempl', $texte); +} + +// cette fonction renvoie une ligne de tableau entre'._T('couteauprive:filets_sep:nom')." $res