Projet

Général

Profil

Paste
Télécharger (1,07 ko) Statistiques
| Branche: | Révision:

root / class / utils.class.php @ c0db737e

1
<?php
2

    
3
abstract class utils {
4
  static public function init() {
5
    function __autoload($class) {
6
      $class_loc = 'class/'.$class.'.class.php';
7
      if (is_readable($class_loc)) {
8
        require_once($class_loc);
9
      }
10
    }
11

    
12
    function errorToException($code, $msg, $file, $line) {
13
      throw new Exception($msg);
14
    }
15
    set_error_handler('errorToException');
16
  }
17

    
18
  static public function list_available_panos($base_dir) {
19
          $dir = opendir($base_dir);
20
          $ret = array();
21
          $finfo = finfo_open(FILEINFO_MIME_TYPE); // Retourne le type mime du fichier
22

    
23
          while(false !== ($filename = readdir($dir))) {
24
                  if (!preg_match('/^\.\.?$/', $filename)) {
25
                          $ftype = finfo_file($finfo, $base_dir.'/'.$filename);
26
                          if (isset($ftype)) {
27
                                  $pano = array(
28
                                    'comment' =>  $filename,
29
                                    'title' => sprintf('fichier de type %s', $ftype)
30
                                  );
31
                          } else {
32
                                  $pano = array(
33
                                    'comment' =>  sprintf('<samp>%s</samp>', $filename),
34
                                    'title' => ''
35
                                  );
36
                          }
37
                          $pano['filename'] = $filename;
38
                          $ret[] = $pano;
39
                  }
40
          }
41
          return $ret;
42
  }
43
}
44

    
45
?>