Commit 5268d424 authored by cobalt74's avatar cobalt74

Plugins Title Clean et URL Clean by kraoc

https://github.com/ldleman/Leed/issues/294
parent d90c3da9
......@@ -33,7 +33,9 @@ wiki plugins : http://projet.idleman.fr/leed/?page=Plugins
* shaarleed - Partage un lien d’événement directement sur son script shaarli.
* social - Partage les articles avec son réseau social préféré (Facebook / Tweeter / Google+).
* squelette - Plugin d'exemple pour les créateurs de nouveaux plugins Leed.
* title clean - permet de nettoyer le titre d’un article et n’en conserver que le contenu textuel.
* themeswitcher - Changer de thème via la page de gestion.
* urlclean - permet de supprimer certains paramètres de tracking des liens des articles (xtor, utm_, …).
* ToggleEventContent - Ajoute un bouton permettant de cacher/afficher le contenu d'un événement.
* z_cssLeedMaker - Ce plugin permet de construire son propre thème en ajoutant du css.
......
<?php
/*
@name Title Clean
@author Olivier <http://olivierlebris.me>
@link http://cybride.net/olivier
@licence CC by nc sa http://creativecommons.org/licenses/by-nc-sa/2.0/fr/
@version 1.0.0
@description Used to cleanup title text just to keep textual information
*/
function filtercleanup($text='') {
$text = preg_replace("/http(s)?:\/\/(.*?)\s/i", '',$text);
$text = strip_tags($text);
$text = ltrim($text);
$text = rtrim($text);
return $text;
}
function titleclean_plugin_link(&$events){
foreach($events as $event){
$title = $event->getTitle();
$title = filtercleanup($title);
$event->setTitle($title);
}
}
Plugin::addHook("index_post_treatment", "titleclean_plugin_link");
?>
\ No newline at end of file
<?php
/*
@name Url Clean
@author Olivier <http://olivierlebris.me>
@link http://cybride.net/olivier
@licence CC by nc sa http://creativecommons.org/licenses/by-nc-sa/2.0/fr/
@version 1.0.0
@description Used to cleanup url from some crap (xtor, utm_)
*/
function urlclean_plugin_link(&$events){
foreach($events as $event){
$link = $event->getLink();
$link = preg_replace("/[&#?]xtor=(.)+/", "", $link);
$link = preg_replace("/&utm_[^&#]+/", "", $link);
$link = preg_replace("/\?&/", "", $link);
if ($link[strlen($link) -1] == '?')
$link = substr($link, 0, str_length($link) -1);
$event->setLink($link);
}
}
Plugin::addHook("index_post_treatment", "urlclean_plugin_link");
?>
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment