/** * Smarty truncate modifier plugin * * Type: modifier<br> * Name: truncate<br> * Purpose: Truncate a string to a certain length if necessary, * optionally splitting in the middle of a word, and * appending the $etc string or inserting $etc into the middle. * @link http://smarty.php.net/manual/en/language.modifier.truncate.php * truncate (Smarty online manual) * @author Monte Ohrt <monte at ohrt dot com> * @param string * @param integer * @param string * @param boolean * @param boolean * @return string */ function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_words = false, $middle = false) { if ($length == 0) { return ''; } if (mystrlen($string) > $length) { $length -= min($length, mystrlen($etc)); if (!$break_words && !$middle) { $string = preg_replace('//s+?(/S+)?$/', '', mysubstr($string, 0, $length + 1)); } if (!$middle) { return mysubstr($string, 0, $length) . $etc; } else { return mysubstr($string, 0, $length / 2) . $etc . mysubstr($string, -$length / 2); } } else { return $string; } }
echo "Wrong Format\n"; return; } $dayAvailable = array("lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi", "dimanche"); $monthAvailable = array("janvier", "fevrier", "mars", "avril", "mai", "juin", "juillet", "aout", "septembre", "octobre", "novembre", "decembre"); if (in_array(strtolower($tab[0]), $dayAvailable) == FALSE) { echo "Wrong Format\n"; return; } if (is_numeric($tab[1]) == FALSE || $tab[1] > 31 || $tab[1] < 0) { echo "Wrong Format\n"; return; } if (in_array(strtolower($tab[2]), $monthAvailable) == FALSE) { echo "Wrong Format\n"; return; } if (is_numeric($tab[3]) == FALSE || mystrlen($tab[3]) != 4) { echo "Wrong Format\n"; return; } if (preg_match("/([01][0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])/", $tab[4]) == FALSE) { echo "Wrong Format\n"; return; } date_default_timezone_set("Europe/Paris"); $index = array_search(strtolower($tab[2]), $monthAvailable) + 1; if ($index < 10) { $index = "0" . $index; } echo strtotime($tab[3] . ":" . $index . ":" . $tab[1] . " " . $tab[4]) . "\n";