glpi / inc / vigilotemplate.class.php @ 0d761a49
History | View | Annotate | Download (1.19 KB)
1 |
<?php
|
---|---|
2 |
|
3 |
if (!defined('GLPI_ROOT')) { |
4 |
die("Sorry. You can't access directly to this file"); |
5 |
} |
6 |
|
7 |
class PluginVigiloVigiloTemplate extends CommonDBTM { |
8 |
static function getAllTemplates() { |
9 |
$hosttdir = "/etc/vigilo/vigiconf/conf.d/hosttemplates"; |
10 |
$hosttemplates_files = scandir($hosttdir); |
11 |
$templates = array(); |
12 |
$pattern = "<template name=\"(\w*)\">"; |
13 |
|
14 |
foreach($hosttemplates_files as $file) { |
15 |
$filepath = $hosttdir . DIRECTORY_SEPARATOR . $file; |
16 |
$test_filepath = preg_match("/(.*).xml$/", $filepath); |
17 |
if (is_file($filepath) AND !empty($test_filepath)) { |
18 |
preg_match_all($pattern, file_get_contents($filepath), $matches); |
19 |
foreach ($matches[1] as $match) { |
20 |
$templates[] = $match; |
21 |
} |
22 |
} |
23 |
} |
24 |
|
25 |
sort($templates, SORT_STRING); |
26 |
array_unshift($templates, '-----'); |
27 |
return $templates; |
28 |
} |
29 |
|
30 |
static function getVigiloTemplateNameByID($id) { |
31 |
|
32 |
if (is_numeric($id)) { |
33 |
if ($id === '0') return "NULL"; |
34 |
$templates = PluginVigiloVigiloTemplate::getAllTemplates(); |
35 |
return $templates[$id]; |
36 |
} |
37 |
} |
38 |
} |