Revision 077e4de7
Prise en compte conventions de codage
Change-Id: I74d6ea904e099519e7d2b08f0586696470514280
Reviewed-on: https://vigilo-dev.si.c-s.fr/review/2367
Tested-by: Build system <qa@vigilo-dev.si.c-s.fr>
Reviewed-by: Francois POIROTTE <francois.poirotte@c-s.fr>
src/inc/vigilotemplate.class.php | ||
---|---|---|
1 | 1 |
<?php |
2 | 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() { |
|
3 |
class PluginVigiloVigiloTemplate extends CommonDBTM |
|
4 |
{ |
|
5 |
public static function getAllTemplates() |
|
6 |
{ |
|
9 | 7 |
$hosttdir = "/etc/vigilo/vigiconf/conf.d/hosttemplates"; |
10 | 8 |
$hosttemplates_files = scandir($hosttdir); |
11 | 9 |
$templates = array(); |
12 | 10 |
$pattern = "<template name=\"(\w*)\">"; |
13 | 11 |
|
14 |
foreach($hosttemplates_files as $file) { |
|
12 |
foreach ($hosttemplates_files as $file) {
|
|
15 | 13 |
$filepath = $hosttdir . DIRECTORY_SEPARATOR . $file; |
16 | 14 |
$test_filepath = preg_match("/(.*).xml$/", $filepath); |
17 | 15 |
|
18 |
if (is_file($filepath) AND !empty($test_filepath)) {
|
|
16 |
if (is_file($filepath) && !empty($test_filepath)) {
|
|
19 | 17 |
preg_match_all($pattern, file_get_contents($filepath), $matches); |
20 | 18 |
|
21 | 19 |
foreach ($matches[1] as $match) { |
... | ... | |
29 | 27 |
return $templates; |
30 | 28 |
} |
31 | 29 |
|
32 |
static function getAjaxArrayTemplates() {
|
|
33 |
|
|
30 |
public static function getAjaxArrayTemplates()
|
|
31 |
{ |
|
34 | 32 |
$templates = PluginVigiloVigiloTemplate::getAllTemplates(); |
35 | 33 |
$id = 0; |
36 | 34 |
$ret = array(); |
37 | 35 |
|
38 |
foreach($templates as $t) { |
|
36 |
foreach ($templates as $t) {
|
|
39 | 37 |
$ret[] = array("id" => $id, "text" => $t); |
40 | 38 |
$id++; |
41 | 39 |
} |
... | ... | |
43 | 41 |
return $ret; |
44 | 42 |
} |
45 | 43 |
|
46 |
static function getVigiloTemplateNameByID($id) {
|
|
47 |
|
|
44 |
public static function getVigiloTemplateNameByID($id)
|
|
45 |
{ |
|
48 | 46 |
if (is_numeric($id)) { |
49 |
if ($id === '0') return "NULL"; |
|
47 |
if ($id === '0') { |
|
48 |
return "NULL"; |
|
49 |
} |
|
50 | 50 |
$templates = PluginVigiloVigiloTemplate::getAllTemplates(); |
51 | 51 |
return $templates[$id]; |
52 | 52 |
} |
Also available in: Unified diff