Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
getServices.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5  */
6 
7 class Service
8 {
9 
10  private static $path = "./service.d/";
11 
12  public static function serviceInfos($path)
13  {
14  $info = null;
15  if (is_file($path . "/info.php")) {
16  include ($path . "/info.php");
17  $info["error"] = "";
18  $info["title"] = (isset($title) ? $title : $path);
19  $info["description"] = (isset($description) ? $description : $path);
20  if (!isset($start)) {
21  $info["error"] = "Can't load service {$path}, start is not defined.";
22  } else {
23  if (is_file($path . "/" . $start)) {
24  $info["start"] = $path . "/" . $start;
25  } else {
26  $info["error"] = "Can't load service {$path}, start file {$start} not found.";
27  }
28  }
29  } else {
30  $info["error"] = "Can't load service {$path}, info.php not found.";
31  }
32  return $info;
33  }
34 
35  public static function getAll()
36  {
37  $services = array();
38  if (is_dir(Service::$path)) {
39  if ($dh = opendir(Service::$path)) {
40  while (($file = readdir($dh)) !== false) {
41  if ($file != "." && $file != ".." && filetype(Service::$path . $file) == "dir") {
42  $ret = Service::serviceInfos(Service::$path . $file);
43  if (is_array($ret)) $services[] = $ret;
44  }
45  }
46  closedir($dh);
47  }
48  usort($services, 'Service::servicesort');
49  } else {
50  header("HTTP/1.0 404 Service directory not found");
51  }
52  return $services;
53  }
54 
55  public static function servicesort($a, $b)
56  {
57  return strcmp($a["title"], $b["title"]);
58  }
59 }
60 
61 print_r(json_encode(Service::getAll()));
62 ?>
static getAll()
Definition: getServices.php:35
print< H1 > Check Database< i > $dbaccess</i ></H1 > $a
Definition: checklist.php:45
static servicesort($a, $b)
Definition: getServices.php:55
static serviceInfos($path)
Definition: getServices.php:12
$ret
$file
$info
Definition: geticon.php:30
← centre documentaire © anakeen