reorganisation des dossiers
[mtweb] / mw / out / default / functions.php
diff --git a/mw/out/default/functions.php b/mw/out/default/functions.php
new file mode 100644 (file)
index 0000000..6d94ffa
--- /dev/null
@@ -0,0 +1,56 @@
+<?php
+
+  if(!function_exists("mw_navig")) :
+  function mw_navig($current, $total, $max, $base_url, $start_param, $legende = null){
+    $navig = "";
+    if($max && $total > $max){
+      if(isset($legende)){
+        $navig .=
+         $legende." ".($current + 1)." &agrave; "
+        .(($current + $max) > $total ? $total : $current + $max)
+        ." sur ".$total." - aller &agrave; la ";
+      }
+      $get_params = array();
+      if(($q = strpos($base_url, "?")) !== false){
+        $v_query = explode("&", substr($base_url, $q + 1));
+        $base_url = substr($base_url, 0, $q);
+        foreach($v_query as $query){
+          if($query){
+            $v = explode("=", $query);
+            $get_params[$v[0]] = $v[1];
+          }
+        }
+      }
+      if(isset($get_params[$start_param])) unset($get_params[$start_param]);
+      $base_url .= "?";
+      foreach($get_params as $key => $value) $base_url .= $key."=".$value."&";
+      $nb_pages = ceil($total / $max);
+      $navig .=
+       "page : "
+      ."<select onchange=\"document.location=this.options[this.selectedIndex].value;\">\n";
+      $np = 1;
+      $ni = 0;
+      while($ni < $total){
+        $navig .=
+         "  <option value=\"".$base_url.$start_param."=".$ni."\"".($current >= $ni && $current <= $ni ? " SELECTED" : "").">"
+        .$np
+        ."</option>\n";
+        $np++;
+        $ni += $max;
+      }
+      $navig .=
+       "</select>\n";
+      if($current >= $max){
+        $navig .=
+          "<a href=\"".$base_url.$start_param."=".($current - $max)."\">&laquo;</a>\n";
+      }
+      if($current < $total - $max){
+        $navig .=
+          "<a href=\"".$base_url.$start_param."=".($current + $max)."\">&raquo;</a>\n";
+      }
+    }
+    return $navig;
+  }
+  endif;
+
+?>
\ No newline at end of file