[SPIP] ~v3.0.20-->v3.0.25
[lhc/web/clavette_www.git] / www / prive / objets / liste / articles_fonctions.php
diff --git a/www/prive/objets/liste/articles_fonctions.php b/www/prive/objets/liste/articles_fonctions.php
new file mode 100644 (file)
index 0000000..14f66dc
--- /dev/null
@@ -0,0 +1,46 @@
+<?php
+
+/***************************************************************************\
+ *  SPIP, Systeme de publication pour l'internet                           *
+ *                                                                         *
+ *  Copyright (c) 2001-2014                                                *
+ *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
+ *                                                                         *
+ *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
+ *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
+\***************************************************************************/
+
+if (!defined('_ECRIRE_INC_VERSION')) return;
+
+function defaut_tri_defined($defaut) {
+       if (!defined('_TRI_ARTICLES_RUBRIQUE')) {
+               return $defaut;
+       }
+
+       $sens = 1;
+       $tri = trim(_TRI_ARTICLES_RUBRIQUE);
+       $tri = explode(' ', $tri);
+       if (strncasecmp(end($tri), 'DESC', 4) == 0) {
+               $sens = -1;
+               array_pop($tri);
+       } elseif (strncasecmp(end($tri), 'ASC', 3) == 0) {
+               $sens = 1;
+               array_pop($tri);
+       }
+       $tri = implode(' ', $tri);
+       $tri = array($tri => $sens);
+       foreach ($defaut as $n => $s) {
+               if (!isset($tri[$n])) {
+                       $tri[$n] = $s;
+               }
+       }
+
+       return $tri;
+}
+
+function defaut_tri_par($par, $defaut){
+       if (!defined('_TRI_ARTICLES_RUBRIQUE'))
+               return $par;
+       $par = array_keys($defaut);
+       return reset($par);
+}
\ No newline at end of file