Toggle navigation
Hot Examples
RU
EN
RU
DE
FR
ES
PT
IT
JP
ZH
KO
PHP
PHP
C#
Java
Go
C++
Python
JS
TS
Найти
Главная
Dropdown
show
Dropdown::show PHP Метод
Документация по классу Dropdown
Usage Examples Of Dropdown::show
Показать файл
Открыть проект
show()
статический
публичный
Метод
Print out an HTML "
" for a dropdown with preselected value static public show ( $itemtype, $options = [] ) : boolean $itemtype itemtype used for create dropdown $options array of possible options: - name : string / name of the select (default is depending itemtype) - value : integer / preselected value (default -1) - comments : boolean / is the comments displayed near the dropdown (default true) - toadd : array / array of specific values to add at the begining - entity : integer or array / restrict to a defined entity or array of entities (default -1 : no restriction) - entity_sons : boolean / if entity restrict specified auto select its sons only available if entity is a single value not an array (default false) - toupdate : array / Update a specific item on select change on dropdown (need value_fieldname, to_update, url (see Ajax::updateItemOnSelectEvent for information) and may have moreparams) - used : array / Already used items ID: not to display in dropdown (default empty) - on_change : string / value to transmit to "onChange" - rand : integer / already computed rand value - condition : string / aditional SQL condition to limit display - displaywith : array / array of field to display with request - emptylabel : Empty choice's label (default self::EMPTY_VALUE) - display_emptychoice : Display emptychoice ? (default true) - display : boolean / display or get string (default true) - width : specific width needed (default auto adaptive) - permit_select_parent : boolean / for tree dropdown permit to see parent items not available by default (default false) - specific_tags : array of HTML5 tags to add the the field - url : url of the ajax php code which should return the json data to show in the dropdown Результат boolean : false if error and random id if OK static function show($itemtype, $options = array()) { global $DB, $CFG_GLPI; if ($itemtype && !($item = getItemForItemtype($itemtype))) { return false; } $table = $item->getTable(); $params['name'] = $item->getForeignKeyField(); $params['value'] = $itemtype == 'Entity' ? $_SESSION['glpiactive_entity'] : ''; $params['comments'] = true; $params['entity'] = -1; $params['entity_sons'] = false; $params['toupdate'] = ''; $params['width'] = ''; $params['used'] = array(); $params['toadd'] = array(); $params['on_change'] = ''; $params['condition'] = ''; $params['rand'] = mt_rand(); $params['displaywith'] = array(); //Parameters about choice 0 //Empty choice's label $params['emptylabel'] = self::EMPTY_VALUE; //Display emptychoice ? $params['display_emptychoice'] = $itemtype != 'Entity'; $params['display'] = true; $params['permit_select_parent'] = false; $params['addicon'] = true; $params['specific_tags'] = array(); $params['url'] = $CFG_GLPI['root_doc'] . "/ajax/getDropdownValue.php"; if (is_array($options) && count($options)) { foreach ($options as $key => $val) { $params[$key] = $val; } } $output = ''; $name = $params['emptylabel']; $comment = ""; // Check default value for dropdown : need to be a numeric if (strlen($params['value']) == 0 || !is_numeric($params['value']) && $params['value'] != 'mygroups') { $params['value'] = 0; } if (isset($params['toadd'][$params['value']])) { $name = $params['toadd'][$params['value']]; } else { if ($params['value'] > 0 || $itemtype == "Entity" && $params['value'] >= 0) { $tmpname = self::getDropdownName($table, $params['value'], 1); if ($tmpname["name"] != " ") { $name = $tmpname["name"]; $comment = $tmpname["comment"]; } } } // Manage entity_sons if (!($params['entity'] < 0) && $params['entity_sons']) { if (is_array($params['entity'])) { // translation not needed - only for debug $output .= "entity_sons options is not available with entity option as array"; } else { $params['entity'] = getSonsOf('glpi_entities', $params['entity']); } } $field_id = Html::cleanId("dropdown_" . $params['name'] . $params['rand']); // Manage condition if (!empty($params['condition'])) { $params['condition'] = static::addNewCondition($params['condition']); } if (!$item instanceof CommonTreeDropdown) { $name = Toolbox::unclean_cross_side_scripting_deep($name); } $p = array('value' => $params['value'], 'valuename' => $name, 'width' => $params['width'], 'itemtype' => $itemtype, 'display_emptychoice' => $params['display_emptychoice'], 'displaywith' => $params['displaywith'], 'emptylabel' => $params['emptylabel'], 'condition' => $params['condition'], 'used' => $params['used'], 'toadd' => $params['toadd'], 'entity_restrict' => is_array($params['entity']) ? json_encode(array_values($params['entity'])) : $params['entity'], 'on_change' => $params['on_change'], 'permit_select_parent' => $params['permit_select_parent'], 'specific_tags' => $params['specific_tags']); $output = "<span class='no-wrap'>"; $output .= Html::jsAjaxDropdown($params['name'], $field_id, $params['url'], $p); // Display comment if ($params['comments']) { $comment_id = Html::cleanId("comment_" . $params['name'] . $params['rand']); $link_id = Html::cleanId("comment_link_" . $params['name'] . $params['rand']); $options_tooltip = array('contentid' => $comment_id, 'linkid' => $link_id, 'display' => false); if ($item->canView()) { if ($params['value'] && $item->getFromDB($params['value']) && $item->canViewItem()) { $options_tooltip['link'] = $item->getLinkURL(); } else { $options_tooltip['link'] = $item->getSearchURL(); } $options_tooltip['linktarget'] = '_blank'; } $output .= " " . Html::showToolTip($comment, $options_tooltip); if ($item instanceof CommonDropdown && $item->canCreate() && !isset($_REQUEST['_in_modal']) && $params['addicon']) { $output .= "<img alt='' title=\"" . __s('Add') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png' style='cursor:pointer; margin-left:2px;'\n onClick=\"" . Html::jsGetElementbyID('add_dropdown' . $params['rand']) . ".dialog('open');\">"; $output .= Ajax::createIframeModalWindow('add_dropdown' . $params['rand'], $item->getFormURL(), array('display' => false)); } // Display specific Links if ($itemtype == "Supplier") { if ($item->getFromDB($params['value'])) { $output .= $item->getLinks(); } } if ($itemtype == 'ITILCategory' && Session::haveRight('knowbase', READ)) { if ($params['value'] && $item->getFromDB($params['value'])) { $output .= ' ' . $item->getLinks(); } } $paramscomment = array('value' => '__VALUE__', 'table' => $table); if ($item->canView()) { $paramscomment['withlink'] = $link_id; } $output .= Ajax::updateItemOnSelectEvent($field_id, $comment_id, $CFG_GLPI["root_doc"] . "/ajax/comments.php", $paramscomment, false); } $output .= Ajax::commonDropdownUpdateItem($params, false); if ($params['display']) { echo $output; return $params['rand']; } $output .= "</span>"; return $output; } Usage Example Пример #1 0 Показать файл Файл: advanced_execution.class.php Проект: paisdelconocimiento/glpi-smartcities /** * Show form * * @global type $CFG_GLPI * @param type $ID * @param type $options */ function showForm($ID = 0, $options = array()) { global $CFG_GLPI; echo "<div class='center first-bloc'>"; echo "<form name='field_form' method='post' action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'>"; echo "<th>" . self::getTypeName() . "</th>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td class='tab_bg_2 center'>"; echo PluginShellcommandsCommandGroup::getTypeName(1) . " "; Dropdown::show('PluginShellcommandsCommandGroup', array('entity' => $_SESSION['glpiactive_entity'], 'width' => 200)); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td class='tab_bg_2 center'>"; $this->getEditValue(); echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td class='tab_bg_2 center'>"; echo "<input type='button' class='submit' onclick='shellcommand_advanced_execution(\"" . $CFG_GLPI['root_doc'] . "\",\"field_form\", \"advanced_execution_result\");' name='advanced_execution' value='" . __('Execute') . "'/>"; echo "</td>"; echo "</tr>"; echo "</table>"; Html::closeForm(); echo "</div>"; echo "<div class='spaced' id='advanced_execution_result'></div>"; } All Usage Examples Of Dropdown::show Dropdown addNewCondition dropdownIcons dropdownUsedItemTypes getDeviceItemTypes getDropdownArrayNames getDropdownName getGlobalSwitch getLanguageName getStandardDropdownItemTypes getValueWithUnit getYesNo import importExternal show showAdvanceDateRestrictionSwitch showAllItems showFromArray showGMT showGlobalSwitch showHours showInteger showItemType showItemTypeList showItemTypeMenu showItemTypes showLanguages showListLimit showNumber showOutputFormat showPrivatePublicSwitch showSelectItemFromItemtypes showTimeStamp showYesNo Популярные функции | Популярные классы | Документация | Политика конфиденциальности | Advertise with us PHP | C# (CSharp) | Java | Golang | C++ (Cpp) | Python | JavaScript | TypeScript EN | RU | DE | FR | ES | PT | IT | JP | ZH | KO