Dropdown::showItemTypes PHP Метод

showItemTypes() статический публичный Метод

Make a select box for device type
static public showItemTypes ( $name, $types = [], $options = [] ) : nothing
$name name of the select box
$types array of types to display
$options Parameters which could be used in options array : - value : integer / preselected value (default '') - used : array / Already used items ID: not to display in dropdown (default empty) - emptylabel : Empty choice's label (default self::EMPTY_VALUE) - display : boolean if false get string - width : specific width needed (default not set) - emptylabel : empty label if empty displayed (default self::EMPTY_VALUE) - display_emptychoice : display empty choice (default false)
Результат nothing (print out an HTML select box)
    static function showItemTypes($name, $types = array(), $options = array())
    {
        global $CFG_GLPI;
        $params['value'] = '';
        $params['used'] = array();
        $params['emptylabel'] = self::EMPTY_VALUE;
        $params['display'] = true;
        $params['width'] = '80%';
        $params['display_emptychoice'] = true;
        $params['rand'] = mt_rand();
        if (is_array($options) && count($options)) {
            foreach ($options as $key => $val) {
                $params[$key] = $val;
            }
        }
        $values = array();
        if (count($types)) {
            foreach ($types as $type) {
                if ($item = getItemForItemtype($type)) {
                    $values[$type] = $item->getTypeName(1);
                }
            }
        }
        asort($values);
        return self::showFromArray($name, $values, $params);
    }

Usage Example

Пример #1
1
 static function showAllItems($myname, $value_type = 0, $value = 0, $entity_restrict = -1, $types, $locations_id = -1, $action = 'showItem')
 {
     global $DB, $CFG_GLPI;
     $rand = mt_rand();
     $plugin = new Plugin();
     echo "<table border='0'><tr><td>\n";
     if ($myname == 'type') {
         $newtypes = array_flip($types);
         unset($newtypes['Location']);
         unset($newtypes['Netpoint']);
         if ($plugin->isActivated("resources")) {
             unset($newtypes['PluginResourcesResource']);
         }
         $types = array_flip($newtypes);
     }
     $rand = Dropdown::showItemTypes($myname, $types, array('emptylabel' => Dropdown::EMPTY_VALUE, 'width' => 150));
     $params = array('type' => '__VALUE__', 'value' => $value, 'myname' => $myname, 'action' => $action, 'entity_restrict' => $entity_restrict, 'locations_id' => $locations_id);
     Ajax::updateItemOnSelectEvent("dropdown_{$myname}{$rand}", "show_{$myname}{$rand}", $CFG_GLPI["root_doc"] . "/plugins/positions/ajax/dropdownAllItems.php", $params);
     echo "</td><td>\n";
     echo "<span id='show_{$myname}{$rand}'>&nbsp;</span>\n";
     echo "</td></tr></table>\n";
     if ($value > 0) {
         echo "<script type='text/javascript' >\n";
         echo "document.getElementById('item_type{$rand}').value='" . $value_type . "';";
         echo "</script>\n";
         $params["typetable"] = $value_type;
         Ajax::updateItem("show_{$myname}{$rand}", $CFG_GLPI["root_doc"] . "/plugins/positions/ajax/dropdownAllItems.php", $params);
     }
     return $rand;
 }
All Usage Examples Of Dropdown::showItemTypes