本文整理汇总了PHP中Dropdown::showFromArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Dropdown::showFromArray方法的具体用法?PHP Dropdown::showFromArray怎么用?PHP Dropdown::showFromArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dropdown
的用法示例。
在下文中一共展示了Dropdown::showFromArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: displayTabContentForItem
static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0)
{
echo "<form name='notificationtargets_form' id='notificationtargets_form'\n method='post' action=' ";
echo Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
echo "<table class ='tab_cadre_fixe'>";
echo '<tr><th colspan="2">' . __('Access type', 'formcreator') . '</th></tr>';
echo '<td>' . __('Access', 'formcreator') . '</td>';
echo '<td>';
Dropdown::showFromArray('access_rights', array(PluginFormcreatorForm::ACCESS_PUBLIC => __('Public access', 'formcreator'), PluginFormcreatorForm::ACCESS_PRIVATE => __('Private access', 'formcreator'), PluginFormcreatorForm::ACCESS_RESTRICTED => __('Restricted access', 'formcreator')), array('value' => isset($item->fields["access_rights"]) ? $item->fields["access_rights"] : 1));
echo '</td>';
if ($item->fields["access_rights"] == PluginFormcreatorForm::ACCESS_RESTRICTED) {
echo '<tr><th colspan="2">' . self::getTypeName(2) . '</th></tr>';
$table = getTableForItemType(__CLASS__);
$table_profile = getTableForItemType('Profile');
$query = "SELECT p.`id`, p.`name`, IF(f.`plugin_formcreator_profiles_id` IS NOT NULL, 1, 0) AS `profile`\n FROM {$table_profile} p\n LEFT JOIN {$table} f\n ON p.`id` = f.`plugin_formcreator_profiles_id`\n AND f.`plugin_formcreator_forms_id` = " . (int) $item->fields['id'];
$result = $GLOBALS['DB']->query($query);
while (list($id, $name, $profile) = $GLOBALS['DB']->fetch_array($result)) {
$checked = $profile ? ' checked' : '';
echo '<tr><td colspan="2"><label>';
echo '<input type="checkbox" name="profiles_id[]" value="' . $id . '" ' . $checked . '> ';
echo $name;
echo '</label></td></tr>';
}
}
echo '<tr>';
echo '<td class="center" colspan="2">';
echo '<input type="hidden" name="profiles_id[]" value="0" />';
echo '<input type="hidden" name="form_id" value="' . (int) $item->fields['id'] . '" />';
echo '<input type="submit" name="update" value="' . __('Save') . '" class="submit" />';
echo "</td>";
echo "</tr>";
echo "</table>";
Html::closeForm();
}
示例2: showForGroup
static function showForGroup(Group $group)
{
global $DB;
$ID = $group->getField('id');
if (!$group->can($ID, READ)) {
return false;
}
$canedit = $group->can($ID, UPDATE);
if ($canedit) {
// Get data
$item = new self();
if (!$item->getFromDB($ID)) {
$item->getEmpty();
}
$rand = mt_rand();
echo "<form name='group_level_form{$rand}' id='group_level_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
echo "<input type='hidden' name='" . self::$items_id . "' value='{$ID}' />";
echo "<div class='spaced'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_1'><th>" . __('Level attribution', 'itilcategorygroups') . "</th></tr>";
echo "<tr class='tab_bg_2'><td class='center'>";
Dropdown::showFromArray('lvl', array(NULL => "---", 1 => __('Level 1', 'itilcategorygroups'), 2 => __('Level 2', 'itilcategorygroups'), 3 => __('Level 3', 'itilcategorygroups'), 4 => __('Level 4', 'itilcategorygroups')), array('value' => $item->fields['lvl']));
echo "</td></tr>";
echo "</td><td class='center'>";
if ($item->fields["id"]) {
echo "<input type='hidden' name='id' value='" . $item->fields["id"] . "'>";
echo "<input type='submit' name='update' value=\"" . __('Save') . "\"\n class='submit'>";
} else {
echo "<input type='submit' name='add' value=\"" . __('Save') . "\" class='submit'>";
}
echo "</td></tr>";
echo "</table></div>";
Html::closeForm();
}
}
示例3: showForm
function showForm($ID, $options = array())
{
$this->initForm($ID, $options);
$this->showFormHeader($options);
echo "<tr class='tab_bg_1'>";
echo "<td>";
echo __('Name');
echo "</td>";
echo "<td>";
Html::autocompletionTextField($this, 'name');
echo "</td>";
echo "<td>" . __('Type') . "</td>";
echo "<td>";
Dropdown::showFromArray('type', PluginFusioninventoryCollect::getTypes(), array('value' => $this->fields['type']));
echo "</td>";
echo "</tr>\n";
echo "<tr class='tab_bg_1'>";
echo "<td>";
echo __('Comments');
echo "</td>";
echo "<td class='middle'>";
echo "<textarea cols='45' rows='3' name='comment' >" . $this->fields["comment"] . "</textarea>";
echo "</td>";
echo "<td>" . __('Active') . "</td>";
echo "<td>";
Dropdown::showYesNo('is_active', $this->fields['is_active']);
echo "</td>";
echo "</tr>\n";
$this->showFormButtons($options);
return TRUE;
}
示例4: displayField
public function displayField($canEdit = true)
{
if ($canEdit) {
$rand = mt_rand();
$tab_values = array();
$required = $this->fields['required'] ? ' required' : '';
$values = $this->getAvailableValues();
echo '<div class="form_field">';
if (!empty($this->fields['values'])) {
foreach ($values as $value) {
if (trim($value) != '') {
$tab_values[$value] = $value;
}
}
if ($this->fields['show_empty']) {
$tab_values = array('' => '-----') + $tab_values;
}
Dropdown::showFromArray('formcreator_field_' . $this->fields['id'], $tab_values, array('value' => static::IS_MULTIPLE ? '' : $this->getValue(), 'values' => static::IS_MULTIPLE ? $this->getValue() : array(), 'rand' => $rand, 'multiple' => static::IS_MULTIPLE));
}
echo '</div>' . PHP_EOL;
echo '<script type="text/javascript">
jQuery(document).ready(function($) {
jQuery("#dropdown_formcreator_field_' . $this->fields['id'] . $rand . '").on("change", function(e) {
var selectedValues = jQuery("#dropdown_formcreator_field_' . $this->fields['id'] . $rand . '").val();
formcreatorChangeValueOf (' . $this->fields['id'] . ', selectedValues);
});
});
</script>';
} else {
echo '<div class="form_field">';
echo nl2br($this->getAnswer());
echo '</div>' . PHP_EOL;
}
}
示例5: dropdownEvents
static function dropdownEvents($itemtype, $value = '')
{
$events = array();
$target = NotificationTarget::getInstanceByType($itemtype);
if ($target) {
$events = $target->getAllEvents();
}
$events[''] = DROPDOWN_EMPTY_VALUE;
Dropdown::showFromArray('event', $events, array('value' => $value));
}
示例6: manageContacts
function manageContacts($items_id)
{
global $LANG;
$pmContact = new PluginMonitoringContact();
$user = new User();
$a_list = $this->find("`plugin_monitoring_hosts_id`='" . $items_id . "'");
echo "<form name='contacts_form' id='contacts_form'\n method='post' action=' ";
echo getItemTypeFormURL(__CLASS__) . "'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_1'>";
echo "<th colspan='3'>";
echo $LANG['plugin_monitoring']['contact'][20];
echo "</th>";
echo "</tr>";
echo "<tr class='tab_bg_1'>";
echo "<td class='right'>";
$a_contacts = $pmContact->find();
$a_elements = array();
foreach ($a_contacts as $data) {
$user->getFromDB($data['users_id']);
$a_elements[$data['id']] = $user->getName();
}
asort($a_elements);
Dropdown::showFromArray('plugin_monitoring_contacts_id', $a_elements);
echo "</td>";
echo "<td class='center'>";
echo "<input type='submit' class='submit' name='parent_add' value='" . $LANG['buttons'][8] . " >>'>";
echo "<br><br>";
if ($a_list) {
echo "<input type='submit' class='submit' name='parent_delete' value='<< " . $LANG['buttons'][6] . "'>";
}
echo "</td>";
echo "<td>";
if ($a_list) {
echo "<select name='parent_to_delete[]' multiple size='5'>";
foreach ($a_list as $data) {
$pmContact->getFromDB($data['plugin_monitoring_contacts_id']);
$user->getFromDB($pmContact->fields['users_id']);
echo "<option value='" . $data['plugin_monitoring_contacts_id'] . "'>" . $user->getName() . "</option>";
}
echo "</select>";
} else {
echo " ";
}
echo "</td>";
echo "</tr>";
echo "</table>";
echo "<input type='hidden' name='id' value='" . $items_id . "' />";
echo "</form>";
}
示例7: displayCriteria
function displayCriteria()
{
$this->getReport()->startColumn();
echo $this->getCriteriaLabel() . ' :';
$this->getReport()->endColumn();
$this->getReport()->startColumn();
if (empty($this->signe)) {
Dropdown::showFromArray($this->getName() . "_sign", array('<=' => '<=', '>=' => '>='), array('value' => Toolbox::unclean_cross_side_scripting_deep($this->getParameter($this->getName() . "_sign"))));
echo " ";
}
Dropdown::showInteger($this->getName(), $this->getParameterValue(), $this->min, $this->max, 1);
echo ' ' . $this->unit;
$this->getReport()->endColumn();
}
示例8: dropdownBehaviour
/**
* Dropdown of states for behaviour config
*
* @param $name select name
* @param $lib string to add for -1 value (default '')
* @param $value default value (default 0)
**/
static function dropdownBehaviour($name, $lib = "", $value = 0)
{
global $DB;
$elements = array("0" => __('Keep status'));
if ($lib) {
$elements["-1"] = $lib;
}
$queryStateList = "SELECT `id`, `name`\n FROM `glpi_states`\n ORDER BY `name`";
$result = $DB->query($queryStateList);
if ($DB->numrows($result) > 0) {
while ($data = $DB->fetch_assoc($result)) {
$elements[$data["id"]] = sprintf(__('Set status: %s'), $data["name"]);
}
}
Dropdown::showFromArray($name, $elements, array('value' => $value));
}
示例9: dropdownBehaviour
/**
* Dropdown of states for behaviour config
*
* @param $name select name
* @param $lib string to add for -1 value
* @param $value default value
**/
static function dropdownBehaviour($name, $lib = "", $value = 0)
{
global $DB, $LANG;
$elements = array("0" => $LANG['setup'][195]);
if ($lib) {
$elements["-1"] = $lib;
}
$queryStateList = "SELECT `id`, `name`\n FROM `glpi_states`\n ORDER BY `name`";
$result = $DB->query($queryStateList);
if ($DB->numrows($result) > 0) {
while ($data = $DB->fetch_assoc($result)) {
$elements[$data["id"]] = $LANG['setup'][198] . " : " . $data["name"];
}
}
Dropdown::showFromArray($name, $elements, array('value' => $value));
}
示例10: showMassiveActionsSubForm
/**
* @since version 0.85
*
* @see CommonDBTM::showMassiveActionsSubForm()
**/
static function showMassiveActionsSubForm(MassiveAction $ma)
{
global $CFG_GLPI;
switch ($ma->getAction()) {
case 'move_bookmark':
$values = array('after' => __('After'), 'before' => __('Before'));
Dropdown::showFromArray('move_type', $values, array('width' => '20%'));
$param = array('name' => "bookmarks_id_ref", 'width' => '50%');
$param['condition'] = "(`is_private`='1' AND `users_id`='" . Session::getLoginUserID() . "') ";
$param['entity'] = -1;
Bookmark::dropdown($param);
echo "<br><br>\n";
echo Html::submit(_x('button', 'Move'), array('name' => 'massiveaction')) . "</span>";
return true;
}
return parent::showMassiveActionsSubForm($ma);
}
示例11: dropdownEvents
/**
* @param $itemtype
* @param $options array to pass to showFromArray or $value
**/
static function dropdownEvents($itemtype, $options = array())
{
$p['name'] = 'event';
$p['display'] = true;
$p['value'] = '';
$p['display_emptychoice'] = true;
if (is_array($options) && count($options)) {
foreach ($options as $key => $val) {
$p[$key] = $val;
}
}
$events = array();
$target = NotificationTarget::getInstanceByType($itemtype);
if ($target) {
$events = $target->getAllEvents();
}
return Dropdown::showFromArray($p['name'], $events, $p);
}
示例12: displayField
public function displayField($canEdit = true)
{
if ($canEdit) {
$rand = mt_rand();
$required = $this->fields['required'] ? ' required' : '';
echo '<div class="form_field">';
if (!empty($this->fields['values'])) {
$values = array();
if ($this->fields['show_empty']) {
$values[0] = Dropdown::EMPTY_VALUE;
}
$obj = new $this->fields['values']();
$obj->getEmpty();
$where = '';
$whereTab = array();
if (isset($obj->fields['is_deleted'])) {
$whereTab[] = '`is_deleted` = 0';
}
if (isset($obj->fields['is_active'])) {
$whereTab[] = '`is_active` = 1';
}
$where = implode(' AND ', $whereTab);
$result = $obj->find($where);
foreach ($result as $id => $datas) {
if ($this->fields['values'] == 'User') {
$values[$id] = getUserName($id);
} else {
$values[$id] = $datas['name'];
}
}
Dropdown::showFromArray('formcreator_field_' . $this->fields['id'], $values, array('value' => $this->getValue(), 'comments' => false, 'rand' => $rand));
}
echo '</div>' . PHP_EOL;
echo '<script type="text/javascript">
jQuery(document).ready(function($) {
jQuery("#dropdown_formcreator_field_' . $this->fields['id'] . $rand . '").on("select2-selecting", function(e) {
formcreatorChangeValueOf (' . $this->fields['id'] . ', e.val);
});
});
</script>';
} else {
echo $this->getAnswer();
}
}
示例13: showForm
function showForm($user_id, $options = array())
{
global $LANG;
$target = $this->getFormURL();
if (isset($options['target'])) {
$target = $options['target'];
}
$tzID = $this->getIDFromUserID($user_id);
if ($user_id) {
if (!$tzID) {
$tz = ini_get('date.timezone');
if (empty($tz)) {
$tz = @date_default_timezone_get();
}
$this->add(array('users_id' => $user_id, 'timezone' => $tz));
$tzID = $this->getID();
} else {
$this->getFromDB($tzID);
}
} else {
return;
}
echo "<form action='" . $target . "' method='post'>";
echo "<input type=hidden name=users_id value='{$user_id}'/>";
echo "<input type=hidden name=id value='{$tzID}'/>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr><th colspan='2'>" . $LANG['timezones']['item']['header'] . "</th></tr>";
echo "<tr class='tab_bg_2'>";
echo "<td>" . $LANG['timezones']['item']['dropdown'] . " :</td><td>";
$timezones = self::getTimezones();
Dropdown::showFromArray('timezone', $timezones, array('value' => $this->fields["timezone"]));
echo "</td></tr>";
echo "<tr class='tab_bg_2'>";
echo "<td colspan='4' class='center'>";
echo "<input type='submit' name='update' class='submit' value=\"" . $LANG['timezones']['item']['submit'] . "\">";
echo "</td></tr>";
echo "</table>";
Html::closeForm();
}
示例14: displaySpecificTypeField
function displaySpecificTypeField($ID, $field = array())
{
switch ($field['type']) {
case 'instantiation_type':
Dropdown::showFromArray($field['name'], NetworkPort::getNetworkPortInstantiationsWithNames(), array('value' => $this->fields[$field['name']]));
break;
case 'type':
Dropdown::showFromArray('type', NetworkPortEthernet::getPortTypeName(), array('value' => $this->fields[$field['name']]));
break;
case 'speed':
$standard_speeds = NetworkPortEthernet::getPortSpeed();
if (!isset($standard_speeds[$this->fields['speed']]) && !empty($this->fields['speed'])) {
$speed = NetworkPortEthernet::transformPortSpeed($this->fields['speed'], true);
} else {
$speed = true;
}
Dropdown::showFromArray('speed', $standard_speeds, array('value' => $this->fields['speed'], 'other' => $speed));
break;
case 'version':
Dropdown::showFromArray('version', WifiNetwork::getWifiCardVersion(), array('value' => $this->fields['version']));
break;
}
}
示例15: title
/**
* @since version 0.84
**/
static function title()
{
global $PLUGIN_HOOKS, $CFG_GLPI;
$opt_list["Ticket"] = __('Tickets');
$stat_list["Ticket"]["Ticket_Global"]["name"] = __('Global');
$stat_list["Ticket"]["Ticket_Global"]["file"] = "stat.global.php?itemtype=Ticket";
$stat_list["Ticket"]["Ticket_Ticket"]["name"] = __('By ticket');
$stat_list["Ticket"]["Ticket_Ticket"]["file"] = "stat.tracking.php?itemtype=Ticket";
$stat_list["Ticket"]["Ticket_Location"]["name"] = __('By hardware characteristics');
$stat_list["Ticket"]["Ticket_Location"]["file"] = "stat.location.php?itemtype=Ticket";
$stat_list["Ticket"]["Ticket_Item"]["name"] = __('By hardware');
$stat_list["Ticket"]["Ticket_Item"]["file"] = "stat.item.php";
if (Problem::canView()) {
$opt_list["Problem"] = _n('Problem', 'Problems', Session::getPluralNumber());
$stat_list["Problem"]["Problem_Global"]["name"] = __('Global');
$stat_list["Problem"]["Problem_Global"]["file"] = "stat.global.php?itemtype=Problem";
$stat_list["Problem"]["Problem_Problem"]["name"] = __('By problem');
$stat_list["Problem"]["Problem_Problem"]["file"] = "stat.tracking.php?itemtype=Problem";
}
if (Change::canView()) {
$opt_list["Change"] = _n('Change', 'Changes', Session::getPluralNumber());
$stat_list["Change"]["Change_Global"]["name"] = __('Global');
$stat_list["Change"]["Change_Global"]["file"] = "stat.global.php?itemtype=Change";
$stat_list["Change"]["Change_Change"]["name"] = __('By change');
$stat_list["Change"]["Change_Change"]["file"] = "stat.tracking.php?itemtype=Change";
}
//Affichage du tableau de presentation des stats
echo "<table class='tab_cadre_fixe'>";
echo "<tr><th colspan='2'>" . __('Select statistics to be displayed') . "</th></tr>";
echo "<tr class='tab_bg_1'><td class='center'>";
$values = array($CFG_GLPI["root_doc"] . '/front/stat.php' => Dropdown::EMPTY_VALUE);
$i = 0;
$selected = -1;
$count = count($stat_list);
foreach ($opt_list as $opt => $group) {
while ($data = each($stat_list[$opt])) {
$name = $data[1]["name"];
$file = $data[1]["file"];
$comment = "";
if (isset($data[1]["comment"])) {
$comment = $data[1]["comment"];
}
$key = $CFG_GLPI["root_doc"] . "/front/" . $file;
$values[$group][$key] = $name;
if (stripos($_SERVER['REQUEST_URI'], $key) !== false) {
$selected = $key;
}
}
}
// Manage plugins
$names = array();
$optgroup = array();
if (isset($PLUGIN_HOOKS["stats"]) && is_array($PLUGIN_HOOKS["stats"])) {
foreach ($PLUGIN_HOOKS["stats"] as $plug => $pages) {
if (is_array($pages) && count($pages)) {
foreach ($pages as $page => $name) {
$names[$plug . '/' . $page] = array("name" => $name, "plug" => $plug);
$optgroup[$plug] = Plugin::getInfo($plug, 'name');
}
}
}
asort($names);
}
foreach ($optgroup as $opt => $title) {
$group = $title;
foreach ($names as $key => $val) {
if ($opt == $val["plug"]) {
$file = $CFG_GLPI["root_doc"] . "/plugins/" . $key;
$values[$group][$file] = $val["name"];
if (stripos($_SERVER['REQUEST_URI'], $file) !== false) {
$selected = $file;
}
}
}
}
Dropdown::showFromArray('statmenu', $values, array('on_change' => "window.location.href=this.options[this.selectedIndex].value", 'value' => $selected));
echo "</td>";
echo "</tr>";
echo "</table>";
}