Skip to content

Commit 9f415e0

Browse files
btrycedric-anne
authored andcommitted
global code update : namespace and src folder
1 parent 3351d0f commit 9f415e0

24 files changed

Lines changed: 184 additions & 110 deletions

config.php renamed to front/config.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@
3737
//header("Location:../../central.php");
3838

3939
// Entry menu case
40-
define('GLPI_ROOT', '../..');
41-
include (GLPI_ROOT . "/inc/includes.php");
40+
include ("../../../inc/includes.php");
4241

4342
Session::checkRight("config", UPDATE);
4443

front/devicecamera.form.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@
3333
// Purpose of file:
3434
// ----------------------------------------------------------------------
3535

36+
use GlpiPlugin\Example\DeviceCamera;
37+
3638
include ('../../../inc/includes.php');
3739

38-
$dropdown = new PluginExampleDeviceCamera();
40+
$dropdown = new DeviceCamera();
3941
include (GLPI_ROOT . "/front/dropdown.common.form.php");

front/devicecamera.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@
3535

3636
include ('../../../inc/includes.php');
3737

38-
$dropdown = new PluginExampleDeviceCamera();
38+
$dropdown = new DeviceCamera();
3939
include (GLPI_ROOT . "/front/dropdown.common.php");

front/dropdown.form.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@
3333
// Purpose of file:
3434
// ----------------------------------------------------------------------
3535

36+
use GlpiPlugin\Example\Dropdown;
3637

3738
include ('../../../inc/includes.php');
3839

3940
Plugin::load('example', true);
4041

41-
$dropdown = new PluginExampleDropdown();
42+
$dropdown = new Dropdown();
4243
include (GLPI_ROOT . "/front/dropdown.common.form.php");

front/dropdown.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@
3333
// Purpose of file:
3434
// ----------------------------------------------------------------------
3535

36+
use GlpiPlugin\Example\Dropdown;
3637

3738
include ('../../../inc/includes.php');
3839

3940
Plugin::load('example', true);
4041

41-
$dropdown = new PluginExampleDropdown();
42+
$dropdown = new Dropdown();
4243
include (GLPI_ROOT . "/front/dropdown.common.php");

front/example.form.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,17 @@
3333
// Purpose of file:
3434
// ----------------------------------------------------------------------
3535

36+
use GlpiPlugin\Example\Example;
37+
3638
include ('../../../inc/includes.php');
3739

3840
if ($_SESSION["glpiactiveprofile"]["interface"] == "central") {
39-
Html::header("TITRE", $_SERVER['PHP_SELF'], "plugins", "pluginexampleexample", "");
41+
Html::header("TITRE", $_SERVER['PHP_SELF'], "plugins", Example::class, "");
4042
} else {
4143
Html::helpHeader("TITRE", $_SERVER['PHP_SELF']);
4244
}
4345

44-
$example = new PluginExampleExample();
46+
$example = new Example();
4547
$example->display($_GET);
4648

4749
Html::footer();

front/example.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,19 @@
3333
// Purpose of file:
3434
// ----------------------------------------------------------------------
3535

36+
use GlpiPlugin\Example\Example;
37+
3638
include ('../../../inc/includes.php');
3739

3840
if ($_SESSION["glpiactiveprofile"]["interface"] == "central") {
39-
Html::header("TITRE", $_SERVER['PHP_SELF'], "plugins", "pluginexampleexample", "");
41+
Html::header("TITRE", $_SERVER['PHP_SELF'], "plugins", Example::class, "");
4042
} else {
4143
Html::helpHeader("TITRE", $_SERVER['PHP_SELF']);
4244
}
4345

4446

45-
//checkTypeRight('PluginExampleExample',"r");
47+
//checkTypeRight(Example::class,"r");
4648

47-
Search::show('PluginExampleExample');
49+
Search::show(Example::class);
4850

4951
Html::footer();

front/ruletest.form.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@
3333
// Purpose of file:
3434
// ----------------------------------------------------------------------
3535

36+
use GlpiPlugin\Example\RuleTestCollection;
3637

3738
include ('../../../inc/includes.php');
3839

39-
$rulecollection = new PluginExampleRuleTestCollection();
40+
$rulecollection = new RuleTestCollection();
4041

4142
include (GLPI_ROOT . "/front/rule.common.form.php");

front/ruletest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@
3333
// Purpose of file:
3434
// ----------------------------------------------------------------------
3535

36+
use GlpiPlugin\Example\RuleTestCollection;
3637

3738
include ('../../../inc/includes.php');
3839

39-
$rulecollection = new PluginExampleRuleTestCollection();
40+
$rulecollection = new RuleTestCollection();
4041

4142
include (GLPI_ROOT . "/front/rule.common.php");

hook.php

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
// Purpose of file:
3434
// ----------------------------------------------------------------------
3535

36+
use GlpiPlugin\Example\Dropdown;
37+
use GlpiPlugin\Example\Example;
38+
use Dropdown as GlpiDropdown;
39+
3640
// Hook called on profile change
3741
// Good place to evaluate the user right on this plugin
3842
// And to save it in the session
@@ -59,7 +63,7 @@ function plugin_example_getDatabaseRelations() {
5963
// Define Dropdown tables to be manage in GLPI :
6064
function plugin_example_getDropdown() {
6165
// Table => Name
62-
return ['PluginExampleDropdown' => __("Plugin Example Dropdown", 'example')];
66+
return [Dropdown::class => __("Plugin Example Dropdown", 'example')];
6367
}
6468

6569

@@ -94,15 +98,15 @@ function plugin_example_getAddSearchOptionsNew($itemtype) {
9498
return $options;
9599
}
96100

97-
// See also PluginExampleExample::getSpecificValueToDisplay()
101+
// See also GlpiPlugin\Example\Example::getSpecificValueToDisplay()
98102
function plugin_example_giveItem($type, $ID, $data, $num) {
99103
$searchopt = &Search::getOptions($type);
100104
$table = $searchopt[$ID]["table"];
101105
$field = $searchopt[$ID]["field"];
102106

103107
switch ($table.'.'.$field) {
104108
case "glpi_plugin_example_examples.name" :
105-
$out = "<a href='".Toolbox::getItemTypeFormURL('PluginExampleExample')."?id=".$data['id']."'>";
109+
$out = "<a href='".Toolbox::getItemTypeFormURL(Example::class)."?id=".$data['id']."'>";
106110
$out .= $data[$num][0]['name'];
107111
if ($_SESSION["glpiis_ids_visible"] || empty($data[$num][0]['name'])) {
108112
$out .= " (".$data["id"].")";
@@ -133,7 +137,7 @@ function plugin_example_addDefaultJoin($type, $ref_table, &$already_link_tables)
133137
// Example of default JOIN clause
134138
// No need of the function if you do not have specific cases
135139
switch ($type) {
136-
// case "PluginExampleExample" :
140+
// case Example::class :
137141
case "MyType" :
138142
return Search::addLeftJoin($type, $ref_table, $already_link_tables,
139143
"newtable", "linkfield");
@@ -146,7 +150,7 @@ function plugin_example_addDefaultSelect($type) {
146150
// Example of default SELECT item to be added
147151
// No need of the function if you do not have specific cases
148152
switch ($type) {
149-
// case "PluginExampleExample" :
153+
// case Example::class :
150154
case "MyType" :
151155
return "`mytable`.`myfield` = 'myvalue' AS MYNAME, ";
152156
}
@@ -158,7 +162,7 @@ function plugin_example_addDefaultWhere($type) {
158162
// Example of default WHERE item to be added
159163
// No need of the function if you do not have specific cases
160164
switch ($type) {
161-
// case "PluginExampleExample" :
165+
// case Example::class :
162166
case "MyType" :
163167
return " `mytable`.`myfield` = 'myvalue' ";
164168
}
@@ -179,7 +183,7 @@ function plugin_example_addLeftJoin($type, $ref_table, $new_table, $linkfield) {
179183

180184
function plugin_example_forceGroupBy($type) {
181185
switch ($type) {
182-
case 'PluginExampleExample' :
186+
case Example::class :
183187
// Force add GROUP BY IN REQUEST
184188
return true;
185189
}
@@ -272,7 +276,7 @@ function plugin_example_MassiveActions($type) {
272276
switch ($type) {
273277
// New action for core and other plugin types : name = plugin_PLUGINNAME_actionname
274278
case 'Computer' :
275-
return ['PluginExampleExample'.MassiveAction::CLASS_ACTION_SEPARATOR.'DoIt' =>
279+
return [Example::class . MassiveAction::CLASS_ACTION_SEPARATOR . 'DoIt' =>
276280
__("plugin_example_DoIt", 'example')];
277281

278282
// Actions for types provided by the plugin are included inside the classes
@@ -325,7 +329,7 @@ function plugin_example_searchOptionsValues($options = []) {
325329
switch ($table.".".$field) {
326330
case "glpi_plugin_example_examples.serial" :
327331
echo __("Not really specific - Use your own dropdown - Just for example", 'example');
328-
Dropdown::show(getItemTypeForTable($options['searchoption']['table']),
332+
GlpiDropdown::show(getItemTypeForTable($options['searchoption']['table']),
329333
['value' => $options['value'],
330334
'name' => $options['name'],
331335
'comments' => 0]);
@@ -427,7 +431,7 @@ function plugin_item_transfer_example($parm) {
427431

428432
// Do special actions for dynamic report
429433
function plugin_example_dynamicReport($parm) {
430-
if ($parm["item_type"] == 'PluginExampleExample') {
434+
if ($parm["item_type"] == Example::class) {
431435
// Do all what you want for export depending on $parm
432436
echo "Personalized export for type ".$parm["display_type"];
433437
echo 'with additional datas : <br>';
@@ -445,7 +449,7 @@ function plugin_example_dynamicReport($parm) {
445449

446450
// Add parameters to Html::printPager in search system
447451
function plugin_example_addParamFordynamicReport($itemtype) {
448-
if ($itemtype == 'PluginExampleExample') {
452+
if ($itemtype == Example::class) {
449453
// Return array data containing all params to add : may be single data or array data
450454
// Search config are available from session variable
451455
return ['add1' => $_SESSION['glpisearch'][$itemtype]['order'],
@@ -551,7 +555,7 @@ function plugin_example_install() {
551555

552556
// To be called for each task the plugin manage
553557
// task in class
554-
CronTask::Register('PluginExampleExample', 'Sample', DAY_TIMESTAMP, ['param' => 50]);
558+
CronTask::Register(Example::class, 'Sample', DAY_TIMESTAMP, ['param' => 50]);
555559
return true;
556560
}
557561

@@ -607,7 +611,7 @@ function plugin_example_uninstall() {
607611

608612

609613
function plugin_example_AssignToTicket($types) {
610-
$types['PluginExampleExample'] = "Example";
614+
$types[Example::class] = "Example";
611615
return $types;
612616
}
613617

0 commit comments

Comments
 (0)