[SPIP][PLUGINS] v3.0-->v3.2
[lhc/web/www.git] / www / plugins / verifier / inc / verifier.php
index 03ec6b3..8114727 100644 (file)
@@ -17,6 +17,7 @@ if (!defined('_ECRIRE_INC_VERSION')) {
  */
 function inc_verifier_dist($valeur, $type, $options = null, &$valeur_normalisee = null) {
 
+       $erreur = array();
        // On vérifie que les options sont bien un tableau
        if (!is_array($options)) {
                $options = array();
@@ -58,7 +59,7 @@ function inc_verifier_dist($valeur, $type, $options = null, &$valeur_normalisee
  * @param string $repertoire
  *             Dans quel repertoire chercher les yaml.
  *
- * @return Retourne un tableau listant les vérifications et leurs options
+ * @return array Retourne un tableau listant les vérifications et leurs options
  */
 function verifier_lister_disponibles($repertoire = 'verifier') {
        static $verifications = array();
@@ -86,6 +87,26 @@ function verifier_lister_disponibles($repertoire = 'verifier') {
        return $verifications[$repertoire];
 }
 
+/**
+ * Fonction de callback pour uasort()
+ * Afin de trier selon le titre
+ * @param array $array1 premier élèment
+ * @param array $array2 second élèment
+ * @return int 1,0,-1
+ **/
+function verifier_trier_par_titre($array1,$array2) {
+       if (isset($array1['titre']) and isset($array2['titre'])) {
+               if ($array1['titre'] == $array2['titre']) {
+                       return 0;
+               } elseif ($array1['titre'] > $array2['titre']) {
+                       return 1;
+               } else {
+                       return -1;
+               }
+       } else {
+               return 0;
+       }
+}
 
 /**
  * Charger les informations contenues dans le yaml d'une vérification
@@ -99,13 +120,18 @@ function verifier_lister_disponibles($repertoire = 'verifier') {
  * @return array Un tableau contenant le YAML décodé
  */
 function verifier_charger_infos($type_verif, $repertoire = 'verifier') {
-       include_spip('inc/yaml');
-       $fichier = find_in_path("$repertoire/$type_verif.yaml");
-       $verif = yaml_decode_file($fichier);
-       if (is_array($verif)) {
-               $verif['titre']       = (isset($verif['titre'])       and $verif['titre'])       ? _T_ou_typo($verif['titre']) : $type_verif;
-               $verif['description'] = (isset($verif['description']) and $verif['description']) ? _T_ou_typo($verif['description']) : '';
-               $verif['icone']       = (isset($verif['icone'])       and $verif['icone'])       ? _T_ou_typo($verif['icone']) : '';
+       $verif = array();       
+
+       if (defined('_DIR_PLUGIN_YAML')) {
+               include_spip('inc/yaml');
+               $fichier = find_in_path("$repertoire/$type_verif.yaml");
+
+               $verif = yaml_decode_file($fichier);
+               if (is_array($verif)) {
+                       $verif['titre']       = (isset($verif['titre'])       and $verif['titre'])       ? _T_ou_typo($verif['titre']) : $type_verif;
+                       $verif['description'] = (isset($verif['description']) and $verif['description']) ? _T_ou_typo($verif['description']) : '';
+                       $verif['icone']       = (isset($verif['icone'])       and $verif['icone'])       ? _T_ou_typo($verif['icone']) : '';
+               }
        }
        return $verif;
 }