Skip to content

Commit c9a7a4f

Browse files
authored
Add new anonymous page hooks
- ADD_CSS_ANONYMOUS_PAGE - ADD_JAVASCRIPT_ANONYMOUS_PAGE - ADD_JAVASCRIPT_MODULE_ANONYMOUS_PAGE - ADD_HEADER_TAG_ANONYMOUS
1 parent 115c355 commit c9a7a4f

File tree

4 files changed

+114
-0
lines changed

4 files changed

+114
-0
lines changed

example_anonymous.css

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*!
2+
* -------------------------------------------------------------------------
3+
* Example plugin for GLPI
4+
* -------------------------------------------------------------------------
5+
*
6+
* LICENSE
7+
*
8+
* This file is part of Example.
9+
*
10+
* Example is free software; you can redistribute it and/or modify
11+
* it under the terms of the GNU General Public License as published by
12+
* the Free Software Foundation; either version 2 of the License, or
13+
* (at your option) any later version.
14+
*
15+
* Example is distributed in the hope that it will be useful,
16+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
* GNU General Public License for more details.
19+
*
20+
* You should have received a copy of the GNU General Public License
21+
* along with Example. If not, see <http://www.gnu.org/licenses/>.
22+
* -------------------------------------------------------------------------
23+
* @copyright Copyright (C) 2006-2022 by Example plugin team.
24+
* @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html
25+
* @link https://github.com/pluginsGLPI/example
26+
* -------------------------------------------------------------------------
27+
*/
28+
29+
/* empty file */

example_anonymous.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* -------------------------------------------------------------------------
3+
* Example plugin for GLPI
4+
* -------------------------------------------------------------------------
5+
*
6+
* LICENSE
7+
*
8+
* This file is part of Example.
9+
*
10+
* Example is free software; you can redistribute it and/or modify
11+
* it under the terms of the GNU General Public License as published by
12+
* the Free Software Foundation; either version 2 of the License, or
13+
* (at your option) any later version.
14+
*
15+
* Example is distributed in the hope that it will be useful,
16+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
* GNU General Public License for more details.
19+
*
20+
* You should have received a copy of the GNU General Public License
21+
* along with Example. If not, see <http://www.gnu.org/licenses/>.
22+
* -------------------------------------------------------------------------
23+
* @copyright Copyright (C) 2006-2022 by Example plugin team.
24+
* @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html
25+
* @link https://github.com/pluginsGLPI/example
26+
* -------------------------------------------------------------------------
27+
*/
28+
29+
/* empty file */

mymodule_anonymous.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
/**
3+
* -------------------------------------------------------------------------
4+
* Example plugin for GLPI
5+
* -------------------------------------------------------------------------
6+
*
7+
* LICENSE
8+
*
9+
* This file is part of Example.
10+
*
11+
* Example is free software; you can redistribute it and/or modify
12+
* it under the terms of the GNU General Public License as published by
13+
* the Free Software Foundation; either version 2 of the License, or
14+
* (at your option) any later version.
15+
*
16+
* Example is distributed in the hope that it will be useful,
17+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+
* GNU General Public License for more details.
20+
*
21+
* You should have received a copy of the GNU General Public License
22+
* along with Example. If not, see <http://www.gnu.org/licenses/>.
23+
* -------------------------------------------------------------------------
24+
* @copyright Copyright (C) 2006-2022 by Example plugin team.
25+
* @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html
26+
* @link https://github.com/pluginsGLPI/example
27+
* -------------------------------------------------------------------------
28+
*/
29+
30+
/* empty JS module file */
31+
export {};

setup.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,31 @@ function plugin_init_example() {
200200
],
201201
];
202202

203+
// Add specific files to add to the header into anonymous page : javascript or css
204+
$PLUGIN_HOOKS[Hooks::ADD_CSS_ANONYMOUS_PAGE]['example'] = 'example_anonymous.css';
205+
$PLUGIN_HOOKS[Hooks::ADD_JAVASCRIPT_MODULE_ANONYMOUS_PAGE]['example'] = 'mymodule_anonymous.js';
206+
$PLUGIN_HOOKS[Hooks::ADD_JAVASCRIPT_ANONYMOUS_PAGE]['example'] = 'example_anonymous.js';
207+
208+
// Add specific tags to the header into anonymous page
209+
$PLUGIN_HOOKS[Hooks::ADD_HEADER_TAG_ANONYMOUS_PAGE]['example'] = [
210+
[
211+
'tag' => 'meta',
212+
'properties' => [
213+
'name' => 'robots',
214+
'content' => 'noindex, nofollow',
215+
]
216+
],
217+
[
218+
'tag' => 'link',
219+
'properties' => [
220+
'rel' => 'alternate',
221+
'type' => 'application/rss+xml',
222+
'title' => 'The company RSS feed',
223+
'href' => 'https://example.org/feed.xml',
224+
]
225+
],
226+
];
227+
203228
// request more attributes from ldap
204229
//$PLUGIN_HOOKS['retrieve_more_field_from_ldap']['example']="plugin_retrieve_more_field_from_ldap_example";
205230

0 commit comments

Comments
 (0)