3 class mw_data_utils extends mw_data{
5 public function eq($content){
6 return isset($content) ? "'".str_replace("'", "\'", $content)."'" : "NULL";
9 public function ordonne($list, $key, $order = "ASC"){
10 $values = array_values($list);
11 $maximum = count($values);
13 $maximumTemporaire = 0;
14 for($i = 0; $i < $maximum; $i++){
16 (isset($values[$i + 1]) && $order == "ASC" && $values[$i][$key] > $values[$i + 1][$key])
17 || (isset($values[$i + 1]) && $order == "DESC" && $values[$i][$key] < $values[$i + 1][$key])
20 $values[$i] = $values[$i + 1];
21 $values[$i + 1] = $tmp;
22 $maximumTemporaire = $i + 1;
25 $maximum = $maximumTemporaire;
28 foreach($values as $value) if($value["id"]) $res[$value["id"]] = $value;
32 public function upload($image, $upload_dir){
34 $upload_dir .= $upload_dir && (substr($upload_dir, -1) != "/") ? "/" : "";
36 if(isset($_FILES[$image])){
37 if($_FILES[$image]["error"] === UPLOAD_ERR_OK){
38 if(move_uploaded_file($_FILES[$image]["tmp_name"], $upload_dir.$_FILES[$image]["name"])){
39 $file = $_FILES[$image]["name"];
43 elseif($_FILES[$image]["error"] !== UPLOAD_ERR_NO_FILE) $file = false;