Make a select box for icons
static public dropdownIcons ( $myname, $value, $store_path, $display = true ) : nothing | ||
$myname | the name of the HTML select | |
$value | the preselected value we want | |
$store_path | path where icons are stored | |
$display | boolean display of get string ? (true by default) | |
return | nothing | (print out an HTML select box) |
function showForm($ID, $options = array()) { global $CFG_GLPI; if (!$this->isNewID($ID)) { $this->check($ID, READ); } else { // Create item $this->check(-1, CREATE); } $this->showFormHeader($options); $fields = $this->getAdditionalFields(); $nb = count($fields); echo "<tr class='tab_bg_1'><td>" . __('Name') . "</td>"; echo "<td>"; if ($this instanceof CommonDevice) { // Awfull hack for CommonDevice where name is designation Html::autocompletionTextField($this, "designation"); } else { Html::autocompletionTextField($this, "name"); } echo "</td>"; echo "<td rowspan='" . ($nb + 1) . "'>" . __('Comments') . "</td>"; echo "<td rowspan='" . ($nb + 1) . "'>\n <textarea cols='45' rows='" . ($nb + 2) . "' name='comment' >" . $this->fields["comment"]; echo "</textarea></td></tr>\n"; foreach ($fields as $field) { if ($field['name'] == 'entities_id' && $ID == 0 && !$this->isNewID($ID)) { // No display for root entity echo "<tr class='tab_bg_1'><td colspan='2'> </td></tr>"; break; } if (!isset($field['type'])) { $field['type'] = ''; } if ($field['name'] == 'header') { echo "<tr class='tab_bg_1'><th colspan='2'>" . $field['label'] . "</th></tr>"; continue; } echo "<tr class='tab_bg_1'><td>" . $field['label']; if (isset($field['comment']) && !empty($field['comment'])) { echo " "; Html::showToolTip($field['comment']); } echo "</td><td>"; switch ($field['type']) { case 'UserDropdown': $param = array('name' => $field['name'], 'value' => $this->fields[$field['name']], 'right' => 'interface', 'entity' => $this->fields["entities_id"]); if (isset($field['right'])) { $params['right'] = $field['right']; } User::dropdown($param); break; case 'dropdownValue': $params = array('value' => $this->fields[$field['name']], 'name' => $field['name'], 'entity' => $this->getEntityID()); if (isset($field['condition'])) { $params['condition'] = $field['condition']; } Dropdown::show(getItemTypeForTable(getTableNameForForeignKeyField($field['name'])), $params); break; case 'text': Html::autocompletionTextField($this, $field['name']); break; case 'textarea': $cols = 40; $rows = 3; if (isset($field['rows'])) { $rows = $field['rows']; } if (isset($field['cols'])) { $cols = $field['cols']; } echo "<textarea name='" . $field['name'] . "' cols='{$cols}' rows='{$rows}'>" . $this->fields[$field['name']] . "</textarea >"; break; case 'integer': Dropdown::showNumber($field['name'], array('value' => $this->fields[$field['name']])); break; case 'timestamp': $param = array('value' => $this->fields[$field['name']]); if (isset($field['min'])) { $param['min'] = $field['min']; } if (isset($field['max'])) { $param['max'] = $field['max']; } if (isset($field['step'])) { $param['step'] = $field['step']; } Dropdown::showTimeStamp($field['name'], $param); break; case 'parent': if ($field['name'] == 'entities_id') { $restrict = -1; } else { $restrict = $this->getEntityID(); } Dropdown::show(getItemTypeForTable($this->getTable()), array('value' => $this->fields[$field['name']], 'name' => $field['name'], 'entity' => $restrict, 'used' => $ID > 0 ? getSonsOf($this->getTable(), $ID) : array())); break; case 'icon': Dropdown::dropdownIcons($field['name'], $this->fields[$field['name']], GLPI_ROOT . "/pics/icones"); if (!empty($this->fields[$field['name']])) { echo " <img style='vertical-align:middle;' alt='' src='" . $CFG_GLPI["typedoc_icon_dir"] . "/" . $this->fields[$field['name']] . "'>"; } break; case 'bool': Dropdown::showYesNo($field['name'], $this->fields[$field['name']]); break; case 'color': Html::showColorField($field['name'], array('value' => $this->fields[$field['name']])); break; case 'date': Html::showDateField($field['name'], array('value' => $this->fields[$field['name']])); break; case 'datetime': Html::showDateTimeField($field['name'], array('value' => $this->fields[$field['name']])); break; case 'password': echo "<input type='password' name='password' value='' size='20' autocomplete='off'>"; break; default: $this->displaySpecificTypeField($ID, $field); break; } if (isset($field['unit'])) { echo " " . $field['unit']; } echo "</td></tr>\n"; } if (isset($this->fields['is_protected']) && $this->fields['is_protected']) { $options['candel'] = false; } if (isset($_REQUEST['_in_modal'])) { echo "<input type='hidden' name='_in_modal' value='1'>"; } $this->showFormButtons($options); return true; }
/** * @since version 0.84 * * @param $field * @param $name (default '') * @param $values (default '') * @param $options array **/ static function getSpecificValueToSelect($field, $name = '', $values = '', array $options = array()) { if (!is_array($values)) { $values = array($field => $values); } $options['display'] = false; switch ($field) { case 'icon': return Dropdown::dropdownIcons($name, $values[$field], GLPI_ROOT . "/pics/icones", false); } return parent::getSpecificValueToSelect($field, $name, $values, $options); }
function showForm($ID, $options = array()) { global $CFG_GLPI, $LANG; if (!$this->isNewID($ID)) { $this->check($ID, 'r'); } else { // Create item $this->check(-1, 'w'); } $this->showTabs($options); $this->showFormHeader($options); $fields = $this->getAdditionalFields(); $nb = count($fields); echo "<tr class='tab_bg_1'><td>" . $LANG['common'][16] . " :</td>"; echo "<td>"; echo "<input type='hidden' name='itemtype' value='" . $this->getType() . "'>"; if ($this instanceof CommonDevice) { // Awfull hack for CommonDevice where name is designation autocompletionTextField($this, "designation"); } else { autocompletionTextField($this, "name"); } echo "</td>"; echo "<td rowspan='" . ($nb + 1) . "'>"; echo $LANG['common'][25] . " :</td>"; echo "<td rowspan='" . ($nb + 1) . "'>\n <textarea cols='45' rows='" . ($nb + 2) . "' name='comment' >" . $this->fields["comment"]; echo "</textarea></td></tr>\n"; foreach ($fields as $field) { echo "<tr class='tab_bg_1'><td>" . $field['label'] . " :</td><td>"; switch ($field['type']) { case 'UserDropdown': User::dropdown(array('name' => $field['name'], 'value' => $this->fields[$field['name']], 'right' => 'interface', 'entity' => $this->fields["entities_id"])); break; case 'dropdownValue': Dropdown::show(getItemTypeForTable(getTableNameForForeignKeyField($field['name'])), array('value' => $this->fields[$field['name']], 'name' => $field['name'], 'entity' => $this->getEntityID())); break; case 'text': autocompletionTextField($this, $field['name']); break; case 'textarea': echo "<textarea name='" . $field['name'] . "' cols='40' rows='3'>" . $this->fields[$field['name']] . "</textarea >"; break; case 'parent': if ($field['name'] == 'entities_id') { $restrict = -1; } else { $restrict = $this->getEntityID(); } Dropdown::show(getItemTypeForTable($this->getTable()), array('value' => $this->fields[$field['name']], 'name' => $field['name'], 'entity' => $restrict, 'used' => $ID > 0 ? getSonsOf($this->getTable(), $ID) : array())); break; case 'icon': Dropdown::dropdownIcons($field['name'], $this->fields[$field['name']], GLPI_ROOT . "/pics/icones"); if (!empty($this->fields[$field['name']])) { echo " <img style='vertical-align:middle;' alt='' src='" . $CFG_GLPI["typedoc_icon_dir"] . "/" . $this->fields[$field['name']] . "'>"; } break; case 'bool': Dropdown::showYesNo($field['name'], $this->fields[$field['name']]); break; case 'date': showDateFormItem($field['name'], $this->fields[$field['name']]); break; case 'datetime': showDateTimeFormItem($field['name'], $this->fields[$field['name']]); break; case 'password': echo "<input type='password' name='password' value='' size='20' autocomplete='off'>"; break; default: $this->displaySpecificTypeField($ID, $field); break; } if (isset($field['unit'])) { echo " " . $field['unit']; } echo "</td></tr>\n"; } if (isset($this->fields['is_protected']) && $this->fields['is_protected']) { $options['candel'] = false; } $this->showFormButtons($options); $this->addDivForTabs(); return true; }