Skip to content

Commit

Permalink
refactor(question): get field icon from dedicated method
Browse files Browse the repository at this point in the history
Signed-off-by: btry <tbugier@teclib.com>
  • Loading branch information
btry committed Dec 4, 2019
1 parent ef68bb6 commit 1f63bcb
Show file tree
Hide file tree
Showing 24 changed files with 140 additions and 1 deletion.
5 changes: 5 additions & 0 deletions inc/fieldinterface.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,9 @@ public function LessThan($value);
* @return boolean true if the field can work with anonymous forms
*/
public function isAnonymousFormCompatible();

/**
* Gets HTML code for the icon of a field
*/
public function getHtmlIcon();
}
6 changes: 6 additions & 0 deletions inc/fields/actorfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,4 +323,10 @@ public function lessThan($value) {
public function isAnonymousFormCompatible() {
return false;
}

public function getHtmlIcon() {
global $CFG_GLPI;

return '<img src="' . $CFG_GLPI['root_doc'] . '/plugins/formcreator/pics/ui-actor-field.png" title="" />';
}
}
6 changes: 6 additions & 0 deletions inc/fields/checkboxesfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,4 +307,10 @@ public function lessThan($value) {
public function isAnonymousFormCompatible() {
return true;
}

public function getHtmlIcon() {
global $CFG_GLPI;

return '<img src="' . $CFG_GLPI['root_doc'] . '/plugins/formcreator/pics/ui-checkboxes-field.png" title="" />';
}
}
6 changes: 6 additions & 0 deletions inc/fields/datefield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,10 @@ public function parseAnswerValues($input, $nonDestructive = false) {
public function isAnonymousFormCompatible() {
return true;
}

public function getHtmlIcon() {
global $CFG_GLPI;

return '<img src="' . $CFG_GLPI['root_doc'] . '/plugins/formcreator/pics/ui-date-field.png" title="" />';
}
}
6 changes: 6 additions & 0 deletions inc/fields/datetimefield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,10 @@ public function parseAnswerValues($input, $nonDestructive = false) {
public function isAnonymousFormCompatible() {
return true;
}

public function getHtmlIcon() {
global $CFG_GLPI;

return '<img src="' . $CFG_GLPI['root_doc'] . '/plugins/formcreator/pics/ui-datetime-field.png" title="" />';
}
}
6 changes: 6 additions & 0 deletions inc/fields/descriptionfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,10 @@ public function parseAnswerValues($input, $nonDestructive = false) {
public function isAnonymousFormCompatible() {
return true;
}

public function getHtmlIcon() {
global $CFG_GLPI;

return '<img src="' . $CFG_GLPI['root_doc'] . '/plugins/formcreator/pics/ui-description-field.png" title="" />';
}
}
6 changes: 6 additions & 0 deletions inc/fields/dropdownfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -643,4 +643,10 @@ public function parseObjectProperties(
$TRANSLATE->setLocale($oldLocale);
return $content;
}

public function getHtmlIcon() {
global $CFG_GLPI;

return '<img src="' . $CFG_GLPI['root_doc'] . '/plugins/formcreator/pics/ui-dropdown-field.png" title="" />';
}
}
6 changes: 6 additions & 0 deletions inc/fields/emailfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,10 @@ public function lessThan($value) {
public function isAnonymousFormCompatible() {
return true;
}

public function getHtmlIcon() {
global $CFG_GLPI;

return '<img src="' . $CFG_GLPI['root_doc'] . '/plugins/formcreator/pics/ui-email-field.png" title="" />';
}
}
6 changes: 6 additions & 0 deletions inc/fields/filefield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,10 @@ public function lessThan($value) {
public function isAnonymousFormCompatible() {
return true;
}

public function getHtmlIcon() {
global $CFG_GLPI;

return '<img src="' . $CFG_GLPI['root_doc'] . '/plugins/formcreator/pics/ui-file-field.png" title="" />';
}
}
6 changes: 6 additions & 0 deletions inc/fields/floatfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,4 +267,10 @@ public function lessThan($value) {
public function isAnonymousFormCompatible() {
return true;
}

public function getHtmlIcon() {
global $CFG_GLPI;

return '<img src="' . $CFG_GLPI['root_doc'] . '/plugins/formcreator/pics/ui-float-field.png" title="" />';
}
}
6 changes: 6 additions & 0 deletions inc/fields/glpiselectfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,10 @@ public function lessThan($value) {
public function isAnonymousFormCompatible() {
return false;
}

public function getHtmlIcon() {
global $CFG_GLPI;

return '<img src="' . $CFG_GLPI['root_doc'] . '/plugins/formcreator/pics/ui-glpiselect-field.png" title="" />';
}
}
6 changes: 6 additions & 0 deletions inc/fields/hiddenfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,10 @@ public function lessThan($value) {
public function isAnonymousFormCompatible() {
return true;
}

public function getHtmlIcon() {
global $CFG_GLPI;

return '<img src="' . $CFG_GLPI['root_doc'] . '/plugins/formcreator/pics/ui-hidden-field.png" title="" />';
}
}
6 changes: 6 additions & 0 deletions inc/fields/hostnamefield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,10 @@ public function lessThan($value) {
public function isAnonymousFormCompatible() {
return true;
}

public function getHtmlIcon() {
global $CFG_GLPI;

return '<img src="' . $CFG_GLPI['root_doc'] . '/plugins/formcreator/pics/ui-actor-field.png" title="" />';
}
}
6 changes: 6 additions & 0 deletions inc/fields/integerfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,4 +267,10 @@ public function lessThan($value) {
public function isAnonymousFormCompatible() {
return true;
}

public function getHtmlIcon() {
global $CFG_GLPI;

return '<img src="' . $CFG_GLPI['root_doc'] . '/plugins/formcreator/pics/ui-integer-field.png" title="" />';
}
}
6 changes: 6 additions & 0 deletions inc/fields/ipfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,10 @@ public function lessThan($value) {
public function isAnonymousFormCompatible() {
return true;
}

public function getHtmlIcon() {
global $CFG_GLPI;

return '<img src="' . $CFG_GLPI['root_doc'] . '/plugins/formcreator/pics/ui-hostname-field.png" title="" />';
}
}
6 changes: 6 additions & 0 deletions inc/fields/ldapselectfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,4 +270,10 @@ public function lessThan($value) {
public function isAnonymousFormCompatible() {
return false;
}

public function getHtmlIcon() {
global $CFG_GLPI;

return '<img src="' . $CFG_GLPI['root_doc'] . '/plugins/formcreator/pics/ui-ldapselect-field.png" title="" />';
}
}
6 changes: 6 additions & 0 deletions inc/fields/multiselectfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,4 +311,10 @@ public function lessThan($value) {
public function isAnonymousFormCompatible() {
return true;
}

public function getHtmlIcon() {
global $CFG_GLPI;

return '<img src="' . $CFG_GLPI['root_doc'] . '/plugins/formcreator/pics/ui-multiselect-field.png" title="" />';
}
}
6 changes: 6 additions & 0 deletions inc/fields/radiosfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,4 +242,10 @@ public function lessThan($value) {
public function isAnonymousFormCompatible() {
return true;
}

public function getHtmlIcon() {
global $CFG_GLPI;

return '<img src="' . $CFG_GLPI['root_doc'] . '/plugins/formcreator/pics/ui-radios-field.png" title="" />';
}
}
6 changes: 6 additions & 0 deletions inc/fields/selectfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,10 @@ public function lessThan($value) {
public function isAnonymousFormCompatible() {
return true;
}

public function getHtmlIcon() {
global $CFG_GLPI;

return '<img src="' . $CFG_GLPI['root_doc'] . '/plugins/formcreator/pics/ui-select-field.png" title="" />';
}
}
6 changes: 6 additions & 0 deletions inc/fields/tagfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,10 @@ public function lessThan($value) {
public function isAnonymousFormCompatible() {
return false;
}

public function getHtmlIcon() {
global $CFG_GLPI;

return '<img src="' . $CFG_GLPI['root_doc'] . '/plugins/formcreator/pics/ui-tag-field.png" title="" />';
}
}
6 changes: 6 additions & 0 deletions inc/fields/textareafield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,10 @@ public function lessThan($value) {
public function isAnonymousFormCompatible() {
return true;
}

public function getHtmlIcon() {
global $CFG_GLPI;

return '<img src="' . $CFG_GLPI['root_doc'] . '/plugins/formcreator/pics/ui-textarea-field.png" title="" />';
}
}
6 changes: 6 additions & 0 deletions inc/fields/textfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,4 +254,10 @@ public function lessThan($value) {
public function isAnonymousFormCompatible() {
return true;
}

public function getHtmlIcon() {
global $CFG_GLPI;

return '<img src="' . $CFG_GLPI['root_doc'] . '/plugins/formcreator/pics/ui-text-field.png" title="" />';
}
}
6 changes: 6 additions & 0 deletions inc/fields/urgencyfield.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,10 @@ public function lessThan($value) {
public function isAnonymousFormCompatible() {
return true;
}

public function getHtmlIcon() {
global $CFG_GLPI;

return '<img src="' . $CFG_GLPI['root_doc'] . '/plugins/formcreator/pics/ui-urgency-field.png" title="" />';
}
}
4 changes: 3 additions & 1 deletion inc/question.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,13 @@ public static function showForForm(CommonDBTM $item, $withtemplate = '') {
$question_number = count($found_questions);
$i = 0;
foreach ($found_questions as $question) {
$fieldType = 'PluginFormcreator' . ucfirst($question['fieldtype']) . 'Field';
$field = new $fieldType($question);
$i++;
echo '<tr class="line' . ($i % 2) . '" id="question_row_' . $question['id'] . '">';
echo '<td onclick="plugin_formcreator_editQuestion(' . $item->getId() . ', \'' . $token . '\', ' . $question['id'] . ', ' . $section['id'] . ')">';
echo "<a href='#'>";
echo '<img src="' . $CFG_GLPI['root_doc'] . '/plugins/formcreator/pics/ui-' . $question['fieldtype'] . '-field.png" title="" /> ';
echo $field->getHtmlIcon();
echo $question['name'];
echo "<a>";
echo '</td>';
Expand Down

0 comments on commit 1f63bcb

Please sign in to comment.