view includes/class.textutils.php @ 52:829d6b0d3d0b

Lorsqu'on édite un billet ou un brouillon, on éplingle la zone. Cela permet de ne pas voir la zone de texte disparaitre si le curseur ne survole plus le li correspondant. A noter que le parentNode.parentNode n'est pas des plus esthétiques, et qu'il y reste quelques problèmes relatifs à la non suppression de l'état épinglé.
author Franck Deroche <webmaster@defr.org>
date Tue, 29 Jan 2008 11:33:33 +0100
parents 8f1125d27079
children ec0c926a78a6
line wrap: on
line source
<?php
    class TextUtils
    {
	public static function SplitTags($str)
	{
	    $str = str_replace("\\\"", "\"", $str);
	    $tags = array();
	    preg_match_all('/"([a-zA-Z0-9 ]+)"/', $str, $tests);
	    $useful = $tests[1];
	    foreach($useful as $match)
	    {
		$tags[] = $match;
		$str = str_replace("\"{$match}\"", null, $str);
	    }
	    $str = preg_replace("/( )+/", " ", trim($str));
	    if(strlen($str) > 0)
		$tags = array_merge($tags, explode(" ", $str));
	    asort($tags);
	    return $tags;
	}
	
	public static function DiffTagLine($old, $new, &$ajout, &$suppr)
	{
	    $arOld = TextUtils::SplitTags($old);
	    $arNew = TextUtils::SplitTags($new);
	    $ajout = array_diff($arNew, $arOld);
	    $suppr = array_diff($arOld, $arNew);
	}

    public static function StripTitle($Titre) {
        $Titre_url = str_replace(" ", "_", strip_tags($Titre));
		$Titre_url = str_replace("-", "_", $Titre_url);
        $Titre_url = str_replace(array("é", "è"), "e", $Titre_url);
        $Titre_url = str_replace("à", "a", $Titre_url);
        $Titre_url = str_replace("ù", "u", $Titre_url);
        $Titre_url = str_replace(array("î", "ï"), "i", $Titre_url);
        return $Titre_url;
    }

    public static function getMonthName($monthNumber) {
        return ucfirst(strftime('%B', strtotime('2007-' . $monthNumber . '-01')));
    }
    }
?>