本文整理汇总了PHP中Ajax::createIframeModalWindow方法的典型用法代码示例。如果您正苦于以下问题:PHP Ajax::createIframeModalWindow方法的具体用法?PHP Ajax::createIframeModalWindow怎么用?PHP Ajax::createIframeModalWindow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ajax
的用法示例。
在下文中一共展示了Ajax::createIframeModalWindow方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: displayDatas
/**
* Display datas extracted from DB
*
* @param $data array of search datas prepared to get datas
*
* @return nothing
**/
static function displayDatas(array &$data)
{
global $CFG_GLPI;
$item = null;
if (class_exists($data['itemtype'])) {
$item = new $data['itemtype']();
}
$rand = mt_rand();
if (!isset($data['data']) || !isset($data['data']['totalcount'])) {
return false;
}
// Contruct Pager parameters
$globallinkto = Toolbox::append_params(array('criteria' => Toolbox::stripslashes_deep($data['search']['criteria']), 'metacriteria' => Toolbox::stripslashes_deep($data['search']['metacriteria'])), '&');
$parameters = "sort=" . $data['search']['sort'] . "&order=" . $data['search']['order'] . '&' . $globallinkto;
if (isset($_GET['_in_modal'])) {
$parameters .= "&_in_modal=1";
}
// Global search header
if ($data['display_type'] == self::GLOBAL_SEARCH) {
if ($data['item']) {
echo "<div class='center'><h2>" . $data['item']->getTypeName();
// More items
if ($data['data']['totalcount'] > $data['search']['start'] + self::GLOBAL_DISPLAY_COUNT) {
echo " <a href='" . $data['search']['target'] . "?{$parameters}'>" . __('All') . "</a>";
}
echo "</h2></div>\n";
} else {
return false;
}
}
// If the begin of the view is before the number of items
if ($data['data']['count'] > 0) {
// Display pager only for HTML
if ($data['display_type'] == self::HTML_OUTPUT) {
// For plugin add new parameter if available
if ($plug = isPluginItemType($data['itemtype'])) {
$function = 'plugin_' . $plug['plugin'] . '_addParamFordynamicReport';
if (function_exists($function)) {
$out = $function($data['itemtype']);
if (is_array($out) && count($out)) {
$parameters .= Toolbox::append_params($out, '&');
}
}
}
$search_config_top = "";
$search_config_bottom = "";
if (!isset($_GET['_in_modal']) && Session::haveRightsOr('search_config', array(DisplayPreference::PERSONAL, DisplayPreference::GENERAL))) {
$search_config_top = $search_config_bottom = "<div class='pager_controls'><img alt=\"" . __s('Select default items to show') . "\" title=\"" . __s('Select default items to show') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/options_search.png' ";
$search_config_top .= " class='pointer' onClick=\"";
$search_config_top .= Html::jsGetElementbyID('search_config_top') . ".dialog('open');\">";
$search_config_bottom .= " class='pointer' onClick=\"";
$search_config_bottom .= Html::jsGetElementbyID('search_config_bottom') . ".dialog('open');\">";
$search_config_top .= Ajax::createIframeModalWindow('search_config_top', $CFG_GLPI["root_doc"] . "/front/displaypreference.form.php?itemtype=" . $data['itemtype'], array('title' => __('Select default items to show'), 'reloadonclose' => true, 'display' => false));
$search_config_bottom .= Ajax::createIframeModalWindow('search_config_bottom', $CFG_GLPI["root_doc"] . "/front/displaypreference.form.php?itemtype=" . $data['itemtype'], array('title' => __('Select default items to show'), 'reloadonclose' => true, 'display' => false));
}
if ($item !== null && $item->maybeDeleted()) {
$delete_ctrl = self::isDeletedSwitch($data['search']['is_deleted']);
$search_config_top .= $delete_ctrl;
}
Html::printPager($data['search']['start'], $data['data']['totalcount'], $data['search']['target'], $parameters, $data['itemtype'], 0, $search_config_top);
$search_config_top .= "</div>";
$search_config_bottom .= "</div>";
}
// Define begin and end var for loop
// Search case
$begin_display = $data['data']['begin'];
$end_display = $data['data']['end'];
// Form to massive actions
$isadmin = $data['item'] && $data['item']->canUpdate();
if (!$isadmin && InfoCom::canApplyOn($data['itemtype'])) {
$isadmin = Infocom::canUpdate() || Infocom::canCreate();
}
if ($data['itemtype'] != 'AllAssets') {
$showmassiveactions = count(MassiveAction::getAllMassiveActions($data['item'], $data['search']['is_deleted']));
} else {
$showmassiveactions = true;
}
$massformid = 'massform' . $data['itemtype'];
if ($showmassiveactions && $data['display_type'] == self::HTML_OUTPUT) {
Html::openMassiveActionsForm($massformid);
$massiveactionparams = $data['search']['massiveactionparams'];
$massiveactionparams['num_displayed'] = $end_display - $begin_display;
$massiveactionparams['fixed'] = false;
$massiveactionparams['is_deleted'] = $data['search']['is_deleted'];
$massiveactionparams['container'] = $massformid;
Html::showMassiveActions($massiveactionparams);
}
// Compute number of columns to display
// Add toview elements
$nbcols = count($data['data']['cols']);
if ($data['display_type'] == self::HTML_OUTPUT && $showmassiveactions) {
// HTML display - massive modif
$nbcols++;
//.........这里部分代码省略.........
示例2: showForm
function showForm($ID, $options)
{
global $DB, $CFG_GLPI;
if (!Config::canUpdate()) {
return false;
}
$notificationtemplates_id = -1;
if (isset($options['notificationtemplates_id'])) {
$notificationtemplates_id = $options['notificationtemplates_id'];
}
if ($this->getFromDB($ID)) {
$notificationtemplates_id = $this->getField('notificationtemplates_id');
}
$this->initForm($ID, $options);
$template = new NotificationTemplate();
$template->getFromDB($notificationtemplates_id);
Html::initEditorSystem('content_html');
$this->showFormHeader($options);
echo "<tr class='tab_bg_1'>";
echo "<td>" . NotificationTemplate::getTypeName() . "</td>";
echo "<td colspan='2'><a href='" . Toolbox::getItemTypeFormURL('NotificationTemplate') . "?id=" . $notificationtemplates_id . "'>" . $template->getField('name') . "</a>";
echo "</td><td>";
$rand = mt_rand();
Ajax::createIframeModalWindow("tags" . $rand, $CFG_GLPI['root_doc'] . "/front/notification.tags.php?sub_type=" . $template->getField('itemtype'));
echo "<a class='vsubmit' href='#' onClick=\"" . Html::jsGetElementbyID("tags" . $rand) . ".dialog('open');\">" . __('Show list of available tags') . "</a>";
echo "</td></tr>";
echo "<tr class='tab_bg_1'>";
echo "<td>" . __('Language') . "</td><td colspan='3'>";
//Get all used languages
$used = self::getAllUsedLanguages($notificationtemplates_id);
if ($ID > 0) {
if (isset($used[$this->getField('language')])) {
unset($used[$this->getField('language')]);
}
}
Dropdown::showLanguages("language", array('display_emptychoice' => true, 'value' => $this->fields['language'], 'used' => $used));
echo "</td></tr>";
echo "<tr class='tab_bg_1'><td>" . __('Subject') . "</td>";
echo "<td colspan='3'>";
Html::autocompletionTextField($this, 'subject', array('size' => 100));
echo "</td></tr>";
echo "<tr class='tab_bg_1'><td>";
_e('Email text body');
echo "<br>" . __('(leave the field empty for a generation from HTML)');
echo "</td><td colspan='3'>";
echo "<textarea cols='100' rows='15' name='content_text' >" . $this->fields["content_text"];
echo "</textarea></td></tr>";
echo "<tr class='tab_bg_1'>";
echo "<td>";
_e('Email HTML body');
echo "</td><td colspan='3'>";
echo "<textarea cols='100' rows='15' name='content_html'>" . $this->fields["content_html"];
echo "</textarea>";
echo "<input type='hidden' name='notificationtemplates_id' value='" . $template->getField('id') . "'>";
echo "</td></tr>";
$this->showFormButtons($options);
return true;
}
示例3: showList
//.........这里部分代码省略.........
// Pager
$parameters = "start=" . $params["start"] . "&knowbaseitemcategories_id=" . $params['knowbaseitemcategories_id'] . "&contains=" . $params["contains"] . "&is_faq=" . $params['faq'];
if (isset($options['item_itemtype']) && isset($options['item_items_id'])) {
$parameters .= "&item_items_id=" . $options['item_items_id'] . "&item_itemtype=" . $options['item_itemtype'];
}
if ($output_type == Search::HTML_OUTPUT) {
Html::printPager($params['start'], $numrows, Toolbox::getItemTypeSearchURL('KnowbaseItem'), $parameters, 'KnowbaseItem');
}
$nbcols = 1;
// Display List Header
echo Search::showHeader($output_type, $numrows_limit + 1, $nbcols);
echo Search::showNewLine($output_type);
$header_num = 1;
echo Search::showHeaderItem($output_type, __('Subject'), $header_num);
if ($output_type != Search::HTML_OUTPUT) {
echo Search::showHeaderItem($output_type, __('Content'), $header_num);
}
if ($showwriter) {
echo Search::showHeaderItem($output_type, __('Writer'), $header_num);
}
echo Search::showHeaderItem($output_type, __('Category'), $header_num);
if (isset($options['item_itemtype']) && isset($options['item_items_id']) && $output_type == Search::HTML_OUTPUT) {
echo Search::showHeaderItem($output_type, ' ', $header_num);
}
// Num of the row (1=header_line)
$row_num = 1;
for ($i = 0; $i < $numrows_limit; $i++) {
$data = $DB->fetch_assoc($result_limit);
Session::addToNavigateListItems('KnowbaseItem', $data["id"]);
// Column num
$item_num = 1;
$row_num++;
echo Search::showNewLine($output_type, $i % 2);
$item = new self();
$item->getFromDB($data["id"]);
$name = $data["name"];
$answer = $data["answer"];
// Manage translations
if (isset($data['transname']) && !empty($data['transname'])) {
$name = $data["transname"];
}
if (isset($data['transanswer']) && !empty($data['transanswer'])) {
$answer = $data["transanswer"];
}
if ($output_type == Search::HTML_OUTPUT) {
$toadd = '';
if (isset($options['item_itemtype']) && isset($options['item_items_id'])) {
$href = " href='#' onClick=\"" . Html::jsGetElementbyID('kbshow' . $data["id"]) . ".dialog('open');\"";
$toadd = Ajax::createIframeModalWindow('kbshow' . $data["id"], $CFG_GLPI["root_doc"] . "/front/knowbaseitem.form.php?id=" . $data["id"], array('display' => false));
} else {
$href = " href=\"" . $CFG_GLPI['root_doc'] . "/front/knowbaseitem.form.php?id=" . $data["id"] . "\" ";
}
echo Search::showItem($output_type, "<div class='kb'>{$toadd}<a " . ($data['is_faq'] ? " class='pubfaq' title='" . __("This item is part of the FAQ") . "' " : " class='knowbase' ") . " {$href}>" . Html::resume_text($name, 80) . "</a></div>\n <div class='kb_resume'>" . Html::resume_text(Html::clean(Toolbox::unclean_cross_side_scripting_deep($answer)), 600) . "</div>", $item_num, $row_num);
} else {
echo Search::showItem($output_type, $name, $item_num, $row_num);
echo Search::showItem($output_type, Html::clean(Toolbox::unclean_cross_side_scripting_deep(html_entity_decode($answer, ENT_QUOTES, "UTF-8"))), $item_num, $row_num);
}
$showuserlink = 0;
if (Session::haveRight('user', READ)) {
$showuserlink = 1;
}
if ($showwriter) {
echo Search::showItem($output_type, getUserName($data["users_id"], $showuserlink), $item_num, $row_num);
}
$categ = $data["category"];
if ($output_type == Search::HTML_OUTPUT) {
$cathref = $ki->getSearchURL() . "?knowbaseitemcategories_id=" . $data["knowbaseitemcategories_id"] . '&forcetab=Knowbase$2';
$categ = "<a href='{$cathref}'>" . $categ . '</a>';
}
echo Search::showItem($output_type, $categ, $item_num, $row_num);
if (isset($options['item_itemtype']) && isset($options['item_items_id']) && $output_type == Search::HTML_OUTPUT) {
$forcetab = $options['item_itemtype'];
if (!$_SESSION['glpiticket_timeline'] || $_SESSION['glpiticket_timeline_keep_replaced_tabs']) {
$forcetab .= '$2';
//Solution tab
} else {
$forcetab .= '$1';
//Timeline tab
}
$content = "<a href='" . Toolbox::getItemTypeFormURL($options['item_itemtype']) . "?load_kb_sol=" . $data['id'] . "&id=" . $options['item_items_id'] . "&forcetab=" . $forcetab . "'>" . __('Use as a solution') . "</a>";
echo Search::showItem($output_type, $content, $item_num, $row_num);
}
// End Line
echo Search::showEndLine($output_type);
}
// Display footer
if ($output_type == Search::PDF_OUTPUT_LANDSCAPE || $output_type == Search::PDF_OUTPUT_PORTRAIT) {
echo Search::showFooter($output_type, Dropdown::getDropdownName("glpi_knowbaseitemcategories", $params['knowbaseitemcategories_id']));
} else {
echo Search::showFooter($output_type);
}
echo "<br>";
if ($output_type == Search::HTML_OUTPUT) {
Html::printPager($params['start'], $numrows, Toolbox::getItemTypeSearchURL('KnowbaseItem'), $parameters, 'KnowbaseItem');
}
} else {
echo "<div class='center b'>" . __('No item found') . "</div>";
}
}
}
示例4: showForm
//.........这里部分代码省略.........
echo "</td></tr>\n";
}
if ($this->maybePrivate()) {
echo "<tr class='tab_bg_1'>";
echo "<td>" . __('Private') . "</td>";
echo "<td>";
Dropdown::showYesNo('is_private', $this->fields["is_private"]);
echo "</td>";
echo "</tr>";
}
echo "<tr class='tab_bg_1'>";
echo "<td>" . __('Duration') . "</td><td>";
$toadd = array();
for ($i = 9; $i <= 100; $i++) {
$toadd[] = $i * HOUR_TIMESTAMP;
}
Dropdown::showTimeStamp("actiontime", array('min' => 0, 'max' => 8 * HOUR_TIMESTAMP, 'value' => $this->fields["actiontime"], 'rand' => $rand_time, 'addfirstminutes' => true, 'inhours' => true, 'toadd' => $toadd));
echo "</td></tr>\n";
if ($ID <= 0) {
Document_Item::showSimpleAddForItem($item);
}
echo "<tr class='tab_bg_1'>";
echo "<td>" . __('By') . "</td>";
echo "<td colspan='2'>";
echo Html::image($CFG_GLPI['root_doc'] . "/pics/user.png") . " ";
echo _n('User', 'Users', 1);
$rand_user = mt_rand();
$params = array('name' => "users_id_tech", 'value' => $ID > -1 ? $this->fields["users_id_tech"] : Session::getLoginUserID(), 'right' => "own_ticket", 'rand' => $rand_user, 'entity' => $item->fields["entities_id"], 'width' => '');
$params['toupdate'] = array('value_fieldname' => 'users_id', 'to_update' => "user_available{$rand_user}", 'url' => $CFG_GLPI["root_doc"] . "/ajax/planningcheck.php");
User::dropdown($params);
echo " <a href='#' onClick=\"" . Html::jsGetElementbyID('planningcheck' . $rand) . ".dialog('open');\">";
echo " <img src='" . $CFG_GLPI["root_doc"] . "/pics/reservation-3.png'\n title=\"" . __s('Availability') . "\" alt=\"" . __s('Availability') . "\"\n class='calendrier'>";
echo "</a>";
Ajax::createIframeModalWindow('planningcheck' . $rand, $CFG_GLPI["root_doc"] . "/front/planning.php?checkavailability=checkavailability" . "&itemtype=" . $item->getType() . "&{$fkfield}=" . $item->getID(), array('title' => __('Availability')));
echo "<br />";
echo Html::image($CFG_GLPI['root_doc'] . "/pics/group.png") . " ";
echo _n('Group', 'Groups', 1) . " ";
$rand_group = mt_rand();
$params = array('name' => "groups_id_tech", 'value' => $ID > -1 ? $this->fields["groups_id_tech"] : Dropdown::EMPTY_VALUE, 'condition' => "is_task", 'rand' => $rand_group, 'entity' => $item->fields["entities_id"]);
$params['toupdate'] = array('value_fieldname' => 'users_id', 'to_update' => "group_available{$rand_group}", 'url' => $CFG_GLPI["root_doc"] . "/ajax/planningcheck.php");
Group::dropdown($params);
echo "</td>\n";
echo "<td>";
if ($canplan) {
echo __('Planning');
}
if (!empty($this->fields["begin"])) {
if (Session::haveRight('planning', Planning::READMY)) {
echo "<script type='text/javascript' >\n";
echo "function showPlan" . $ID . $rand_text . "() {\n";
echo Html::jsHide("plan{$rand_text}");
$params = array('action' => 'add_event_classic_form', 'form' => 'followups', 'users_id' => $this->fields["users_id_tech"], 'groups_id' => $this->fields["groups_id_tech"], 'id' => $this->fields["id"], 'begin' => $this->fields["begin"], 'end' => $this->fields["end"], 'rand_user' => $rand_user, 'rand_group' => $rand_group, 'entity' => $item->fields["entities_id"], 'itemtype' => $this->getType(), 'items_id' => $this->getID());
Ajax::updateItemJsCode("viewplan{$rand_text}", $CFG_GLPI["root_doc"] . "/ajax/planning.php", $params);
echo "}";
echo "</script>\n";
echo "<div id='plan{$rand_text}' onClick='showPlan" . $ID . $rand_text . "()'>\n";
echo "<span class='showplan'>";
}
if (isset($this->fields["state"])) {
echo Planning::getState($this->fields["state"]) . "<br>";
}
printf(__('From %1$s to %2$s'), Html::convDateTime($this->fields["begin"]), Html::convDateTime($this->fields["end"]));
if (isset($this->fields["users_id_tech"]) && $this->fields["users_id_tech"] > 0) {
echo "<br>" . getUserName($this->fields["users_id_tech"]);
}
if (isset($this->fields["groups_id_tech"]) && $this->fields["groups_id_tech"] > 0) {
示例5: showForm
/** form for rule criteria
*
* @since version 0.85
*
* @param $ID integer Id of the criteria
* @param $options array of possible options:
* - rule Object : the rule
**/
function showForm($ID, $options = array())
{
global $CFG_GLPI;
// Yllen: you always have parent for criteria
$rule = $options['parent'];
if ($ID > 0) {
$this->check($ID, READ);
} else {
// Create item
$options[static::$items_id] = $rule->getField('id');
//force itemtype of parent
static::$itemtype = get_class($rule);
$this->check(-1, CREATE, $options);
}
$this->showFormHeader($options);
echo "<tr class='tab_bg_1'>";
echo "<td class='center'>" . _n('Criterion', 'Criteria', 1) . "</td><td colspan='3'>";
echo "<input type='hidden' name='" . $rule->getRuleIdField() . "' value='" . $this->fields[$rule->getRuleIdField()] . "'>";
$rand = $rule->dropdownCriteria(array('value' => $this->fields['criteria']));
$params = array('criteria' => '__VALUE__', 'rand' => $rand, 'sub_type' => $rule->getType());
Ajax::updateItemOnSelectEvent("dropdown_criteria{$rand}", "criteria_span", $CFG_GLPI["root_doc"] . "/ajax/rulecriteria.php", $params);
if (isset($this->fields['criteria']) && !empty($this->fields['criteria'])) {
$params['criteria'] = $this->fields['criteria'];
$params['condition'] = $this->fields['condition'];
$params['pattern'] = $this->fields['pattern'];
echo "<script type='text/javascript' >\n";
Ajax::updateItemJsCode("criteria_span", $CFG_GLPI["root_doc"] . "/ajax/rulecriteria.php", $params);
echo '</script>';
}
if ($rule->specific_parameters) {
$itemtype = get_class($rule) . 'Parameter';
echo "<img alt='' title=\"" . __s('Add a criterion') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png' style='cursor:pointer; margin-left:2px;'\n onClick=\"" . Html::jsGetElementbyID('addcriterion' . $rand) . ".dialog('open');\">";
Ajax::createIframeModalWindow('addcriterion' . $rand, Toolbox::getItemTypeFormURL($itemtype), array('reloadonclose' => true));
}
echo "</td></tr>";
echo "<tr><td colspan='4'><span id='criteria_span'>\n";
echo "</span></td></tr>\n";
$this->showFormButtons($options);
}
示例6: showAvailableTypesLink
/**
* @since version 0.85
**/
static function showAvailableTypesLink()
{
global $CFG_GLPI;
echo " <a href='#' onClick=\"" . Html::jsGetElementbyID('documenttypelist') . ".dialog('open');\">";
echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/info-small.png' title=\"" . __s('Help') . "\"\n alt=\"" . __s('Help') . "\" class='calendrier pointer'>";
echo "</a>";
Ajax::createIframeModalWindow('documenttypelist', $CFG_GLPI["root_doc"] . "/front/documenttype.list.php", array('title' => static::getTypeName(Session::getPluralNumber())));
}
示例7: header
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
GLPI is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
* @since version 0.83
*/
// Direct access to file
if (strpos($_SERVER['PHP_SELF'], "planningcheck.php")) {
$AJAX_INCLUDE = 1;
include '../inc/includes.php';
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
}
Session::checkLoginUser();
if (isset($_POST['users_id']) && $_POST['users_id'] > 0) {
$rand = mt_rand();
echo " <a href='#' onClick=\"" . Html::jsGetElementbyID('planningcheck' . $rand) . ".dialog('open');\">";
echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/reservation-3.png'\n title=\"" . __s('Availability') . "\" alt=\"" . __s('Availability') . "\"\n class='calendrier'>";
echo "</a>";
Ajax::createIframeModalWindow('planningcheck' . $rand, $CFG_GLPI["root_doc"] . "/front/planning.php?checkavailability=checkavailability" . "&itemtype=User&users_id=" . $_POST['users_id'], array('title' => __('Availability')));
}
示例8: 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)
* - ldap_import
* - on_change : string / value to transmit to "onChange"
* - display : boolean / display or get string (default true)
* - width : specific width needed (default 80%)
* - 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 (default /ajax/getDropdownUsers.php)
*
* @return rand value if displayed / string if not
**/
static function dropdown($options = array())
{
global $DB, $CFG_GLPI;
// Default values
$p['name'] = 'users_id';
$p['value'] = '';
$p['right'] = 'id';
$p['all'] = 0;
$p['on_change'] = '';
$p['comments'] = 1;
$p['width'] = '80%';
$p['entity'] = -1;
$p['entity_sons'] = false;
$p['used'] = array();
$p['ldap_import'] = false;
$p['toupdate'] = '';
$p['rand'] = mt_rand();
$p['display'] = true;
$p['_user_index'] = 0;
$p['specific_tags'] = array();
$p['url'] = $CFG_GLPI['root_doc'] . "/ajax/getDropdownUsers.php";
if (is_array($options) && count($options)) {
foreach ($options as $key => $val) {
$p[$key] = $val;
}
}
// check default value (in case of multiple observers)
if (is_array($p['value'])) {
$p['value'] = $p['value'][$p['_user_index']];
}
// Check default value for dropdown : need to be a numeric
if (strlen($p['value']) == 0 || !is_numeric($p['value'])) {
$p['value'] = 0;
}
$output = '';
if (!($p['entity'] < 0) && $p['entity_sons']) {
if (is_array($p['entity'])) {
$output .= "entity_sons options is not available with array of entity";
} else {
$p['entity'] = getSonsOf('glpi_entities', $p['entity']);
}
}
// Make a select box with all glpi users
$user = getUserName($p['value'], 2);
$view_users = self::canView();
if (!empty($p['value']) && $p['value'] > 0) {
$default = $user["name"];
} else {
if ($p['all']) {
$default = __('All');
} else {
$default = Dropdown::EMPTY_VALUE;
}
}
$field_id = Html::cleanId("dropdown_" . $p['name'] . $p['rand']);
$param = array('value' => $p['value'], 'valuename' => $default, 'width' => $p['width'], 'all' => $p['all'], 'right' => $p['right'], 'on_change' => $p['on_change'], 'used' => $p['used'], 'entity_restrict' => $p['entity'], 'specific_tags' => $p['specific_tags']);
$output = Html::jsAjaxDropdown($p['name'], $field_id, $p['url'], $param);
// Display comment
if ($p['comments']) {
$comment_id = Html::cleanId("comment_" . $p['name'] . $p['rand']);
$link_id = Html::cleanId("comment_link_" . $p["name"] . $p['rand']);
if (!$view_users) {
$user["link"] = '';
} else {
if (empty($user["link"])) {
$user["link"] = $CFG_GLPI['root_doc'] . "/front/user.php";
}
}
$output .= " " . Html::showToolTip($user["comment"], array('contentid' => $comment_id, 'display' => false, 'link' => $user["link"], 'linkid' => $link_id));
$paramscomment = array('value' => '__VALUE__', 'table' => "glpi_users");
if ($view_users) {
$paramscomment['withlink'] = $link_id;
}
$output .= Ajax::updateItemOnSelectEvent($field_id, $comment_id, $CFG_GLPI["root_doc"] . "/ajax/comments.php", $paramscomment, false);
}
$output .= Ajax::commonDropdownUpdateItem($p, false);
if (Session::haveRight('user', self::IMPORTEXTAUTHUSERS) && $p['ldap_import'] && Entity::isEntityDirectoryConfigured($_SESSION['glpiactive_entity'])) {
$output .= "<img alt='' title=\"" . __s('Import a user') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png' style='cursor:pointer; margin-left:2px;'\n onClick=\"" . Html::jsGetElementbyID('userimport' . $p['rand']) . ".dialog('open');\">";
$output .= Ajax::createIframeModalWindow('userimport' . $p['rand'], $CFG_GLPI["root_doc"] . "/front/ldap.import.php?entity=" . $_SESSION['glpiactive_entity'], array('title' => __('Import a user'), 'display' => false));
}
if ($p['display']) {
echo $output;
return $p['rand'];
}
return $output;
}
示例9: show
//.........这里部分代码省略.........
$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;
}
示例10: showSaveButton
/**
* Display bookmark buttons
*
* @param $type bookmark type to use
* @param $itemtype device type of item where is the bookmark (default 0)
**/
static function showSaveButton($type, $itemtype = 0)
{
global $CFG_GLPI;
echo " <a href='#' onClick=\"" . Html::jsGetElementbyID('bookmarksave') . ".dialog('open');\">";
echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/bookmark_record.png'\n title=\"" . __s('Save as bookmark') . "\" alt=\"" . __s('Save as bookmark') . "\"\n class='calendrier pointer'>";
echo "</a>";
Ajax::createIframeModalWindow('bookmarksave', $CFG_GLPI["root_doc"] . "/front/bookmark.php?type={$type}" . "&action=edit&itemtype={$itemtype}&" . "url=" . rawurlencode($_SERVER["REQUEST_URI"]), array('title' => __('Save as bookmark'), 'reloadonclose' => true));
}
示例11: showListRules
//.........这里部分代码省略.........
$rule->dropdownConditions(array('value' => $p['condition'], 'on_change' => 'reloadTab("start=0&inherited=' . $p['inherited'] . '&childrens=' . $p['childrens'] . '&condition="+this.value)'));
echo "</td></tr></table>";
}
$nb = $this->getCollectionSize($p['inherited'], $p['condition']);
$p['start'] = isset($options["start"]) ? $options["start"] : 0;
if ($p['start'] >= $nb) {
$p['start'] = 0;
}
$p['limit'] = $_SESSION['glpilist_limit'];
$this->getCollectionPart($p);
Html::printAjaxPager('', $p['start'], $nb);
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
echo "\n<div class='spaced'>";
if ($canedit && $nb) {
$massiveactionparams = array('num_displayed' => min($p['limit'], $nb), 'container' => 'mass' . __CLASS__ . $rand, 'extraparams' => array('entity' => $this->entity, 'condition' => $p['condition'], 'rule_class_name' => $this->getRuleClassName()));
Html::showMassiveActions($massiveactionparams);
}
echo "<table class='tab_cadre_fixehov table-striped table-hover'>";
$colspan = 6;
if ($display_entities) {
$colspan++;
}
if ($use_conditions) {
$colspan++;
}
echo "<tr><th colspan='{$colspan}'>" . $this->getTitle() . "</th></tr>\n";
echo "<tr>";
echo "<th>";
if ($canedit) {
Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand);
}
echo "</th>";
echo "<th>" . __('Name') . "</th>";
echo "<th>" . __('Description') . "</th>";
if ($use_conditions) {
echo "<th>" . __('Use rule for') . "</th>";
}
echo "<th>" . __('Active') . "</th>";
if ($display_entities) {
echo "<th>" . __('Entity') . "</th>\n";
}
if (!$display_entities) {
echo "<th colspan='2'> </th>";
}
echo "</tr>\n";
if (count($this->RuleList->list)) {
$ruletype = $this->RuleList->list[0]->getType();
Session::initNavigateListItems($ruletype);
}
for ($i = $p['start'], $j = 0; isset($this->RuleList->list[$j]); $i++, $j++) {
$this->RuleList->list[$j]->showMinimalForm($target, $i == 0, $i == $nb - 1, $display_entities, $p['condition']);
Session::addToNavigateListItems($ruletype, $this->RuleList->list[$j]->fields['id']);
}
if ($nb) {
echo "<tr>";
echo "<th>";
if ($canedit) {
Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand);
}
echo "</th>";
echo "<th>" . __('Name') . "</th>";
echo "<th>" . __('Description') . "</th>";
if ($use_conditions) {
echo "<th>" . __('Use rule for') . "</th>";
}
echo "<th>" . __('Active') . "</th>";
if ($display_entities) {
echo "<th>" . __('Entity') . "</th>\n";
}
if (!$display_entities) {
echo "<th colspan='2'> </th>";
}
echo "</tr>\n";
}
echo "</table>\n";
if ($canedit && $nb) {
$massiveactionparams['ontop'] = false;
Html::showMassiveActions($massiveactionparams);
}
echo "</div>";
Html::closeForm();
Html::printAjaxPager('', $p['start'], $nb);
echo "<div class='spaced center'>";
if ($plugin = isPluginItemType($this->getType())) {
$url = $CFG_GLPI["root_doc"] . "/plugins/" . strtolower($plugin['plugin']);
} else {
$url = $CFG_GLPI["root_doc"];
}
echo "<a class='vsubmit' href='#' onClick=\"" . Html::jsGetElementbyID('allruletest' . $rand) . ".dialog('open');\">" . __('Test rules engine') . "</a>";
Ajax::createIframeModalWindow('allruletest' . $rand, $url . "/front/rulesengine.test.php?" . "sub_type=" . $this->getRuleClassName() . "&condition=" . $p['condition'], array('title' => __('Test rules engine')));
echo "</div>";
if ($this->can_replay_rules) {
echo "<div class='spaced center'>";
echo "<a class='vsubmit' href='" . $rule->getSearchURL() . "?replay_rule=replay_rule'>" . __s('Replay the dictionary rules') . "</a>";
echo "</div>";
}
echo "<div class='spaced'>";
$this->showAdditionalInformationsInForm($target);
echo "</div>";
}
示例12: displayItemLogID
/**
* @param $type
* @param $items_id
**/
static function displayItemLogID($type, $items_id)
{
global $CFG_GLPI;
if ($items_id == "-1" || $items_id == "0") {
echo " ";
//$item;
} else {
switch ($type) {
case "rules":
echo "<a href=\"" . $CFG_GLPI["root_doc"] . "/front/rule.generic.form.php?id=" . $items_id . "\">" . $items_id . "</a>";
break;
case "infocom":
$rand = mt_rand();
echo " <a href='#' onClick=\"" . Html::jsGetElementbyID('infocom' . $rand) . ".\n dialog('open');\">{$items_id}</a>";
Ajax::createIframeModalWindow('infocom' . $rand, $CFG_GLPI["root_doc"] . "/front/infocom.form.php" . "?id=" . $items_id, array('height' => 600));
case "devices":
echo $items_id;
break;
case "reservationitem":
echo "<a href=\"" . $CFG_GLPI["root_doc"] . "/front/reservation.php?reservationitems_id=" . $items_id . "\">" . $items_id . "</a>";
break;
default:
$type = getSingular($type);
$url = '';
if ($item = getItemForItemtype($type)) {
$url = $item->getFormURL();
}
if (!empty($url)) {
echo "<a href=\"" . $url . "?id=" . $items_id . "\">" . $items_id . "</a>";
} else {
echo $items_id;
}
break;
}
}
}
示例13: getWidgetContentForItem
function getWidgetContentForItem($widgetId)
{
global $CFG_GLPI, $DB;
if (empty($this->form)) {
$this->init();
}
switch ($widgetId) {
case $this->getType() . "1":
$plugin = new Plugin();
if ($plugin->isActivated("tasklists")) {
$widget = new PluginMydashboardDatatable();
$headers = array(__('Name'), __('Priority'), _n('Context', 'Contexts', 1, 'tasklists'), __('User'), __('Percent done'), __('Due date'), __('Action'));
$query = "SELECT `glpi_plugin_tasklists_tasks`.*,`glpi_plugin_tasklists_tasktypes`.`completename` as 'type' \n FROM `glpi_plugin_tasklists_tasks`\n LEFT JOIN `glpi_plugin_tasklists_tasktypes` ON (`glpi_plugin_tasklists_tasks`.`plugin_tasklists_tasktypes_id` = `glpi_plugin_tasklists_tasktypes`.`id`) \n WHERE NOT `glpi_plugin_tasklists_tasks`.`is_deleted`\n AND `glpi_plugin_tasklists_tasks`.`state` < 2 ";
$query .= getEntitiesRestrictRequest('AND', 'glpi_plugin_tasklists_tasks');
$query .= "ORDER BY `glpi_plugin_tasklists_tasks`.`priority`DESC ";
$tasks = array();
if ($result = $DB->query($query)) {
if ($DB->numrows($result)) {
while ($data = $DB->fetch_array($result)) {
//$groups = Group_User::getGroupUsers($data['groups_id']);
$groupusers = Group_User::getGroupUsers($data['groups_id']);
$groups = array();
foreach ($groupusers as $groupuser) {
$groups[] = $groupuser["id"];
}
if ($data['visibility'] == 1 && $data['users_id'] == Session::getLoginUserID() || $data['visibility'] == 2 && ($data['users_id'] == Session::getLoginUserID() || in_array(Session::getLoginUserID(), $groups)) || $data['visibility'] == 3) {
$ID = $data['id'];
$rand = mt_rand();
$url = Toolbox::getItemTypeFormURL("PluginTasklistsTask") . "?id=" . $data['id'];
$tasks[$data['id']][0] = "<a id='task" . $data["id"] . $rand . "' target='_blank' href='{$url}'>" . $data['name'] . "</a>";
$tasks[$data['id']][0] .= Html::showToolTip($data['comment'], array('applyto' => 'task' . $data["id"] . $rand, 'display' => false));
$bgcolor = $_SESSION["glpipriority_" . $data['priority']];
$tasks[$data['id']][1] = "<div class='center' style='background-color:{$bgcolor};'>" . CommonITILObject::getPriorityName($data['priority']) . "</div>";
$tasks[$data['id']][2] = $data['type'];
$tasks[$data['id']][3] = getUserName($data['users_id']);
$tasks[$data['id']][4] = Dropdown::getValueWithUnit($data['percent_done'], "%");
$due_date = $data['due_date'];
$display = Html::convDate($data['due_date']);
if ($due_date <= date('Y-m-d') && !empty($due_date)) {
$display = "<div class='deleted'>" . Html::convDate($data['due_date']) . "</div>";
}
$tasks[$data['id']][5] = $display;
$tasks[$data['id']][6] = "<div align='center'>";
if (Session::haveRight("plugin_tasklists", UPDATE)) {
$tasks[$data['id']][6] .= "<a class='pointer' onclick=\" submitGetLink('" . $CFG_GLPI['root_doc'] . "/plugins/tasklists/front/task.form.php', {'done': 'done', 'id': '" . $data['id'] . "', '_glpi_csrf_token': '" . Session::getNewCSRFToken() . "', '_glpi_simple_form': '1'});\"><img src='" . $CFG_GLPI['root_doc'] . "/plugins/tasklists/pics/ok.png' title='" . __('Mark as done', 'tasklists') . "'></a>";
}
if (Session::haveRight("plugin_tasklists", UPDATENOTE)) {
$link = " <a href=\"javascript:" . Html::jsGetElementbyID('comment' . $rand) . ".dialog('open');\">";
$link .= "<img class='pointer' src='" . $CFG_GLPI['root_doc'] . "/plugins/tasklists/pics/plus.png' title='" . __('Add comment', 'tasklists') . "'>";
$link .= "</a>";
$link .= Ajax::createIframeModalWindow('comment' . $rand, $CFG_GLPI["root_doc"] . "/plugins/tasklists/front/comment.form.php?id=" . $ID, array('title' => __('Add comment', 'tasklists'), 'reloadonclose' => false, 'width' => 1100, 'display' => false, 'height' => 300));
$tasks[$data['id']][6] .= $link;
}
$tasks[$data['id']][6] .= "</div>";
}
}
}
}
$widget->setTabDatas($tasks);
$widget->setTabNames($headers);
$widget->setOption("bSort", false);
$widget->toggleWidgetRefresh();
$link = "<div align='right'><a class='vsubmit' href=\"javascript:" . Html::jsGetElementbyID('task') . ".dialog('open');\">";
$link .= __('Add task', 'tasklists');
$link .= "</a></div>";
$link .= Ajax::createIframeModalWindow('task', $CFG_GLPI["root_doc"] . "/plugins/tasklists/front/task.form.php", array('title' => __('Add task', 'tasklists'), 'reloadonclose' => false, 'width' => 1180, 'display' => false, 'height' => 600));
$widget->appendWidgetHtmlContent($link);
$widget->setWidgetTitle(__("Tasks list", 'tasklists'));
return $widget;
} else {
$widget = new PluginMydashboardDatatable();
$widget->setWidgetTitle(__("Tasks list", 'tasklists'));
return $widget;
}
break;
}
}
示例14: array
if ($_SESSION["glpiactiveprofile"]["interface"] == "helpdesk") {
Html::helpHeader(Ticket::getTypeName(Session::getPluralNumber()), '', $_SESSION["glpiname"]);
} else {
Html::header(Ticket::getTypeName(Session::getPluralNumber()), '', "helpdesk", "ticket");
}
$available_options = array('load_kb_sol', '_openfollowup');
$options = array();
foreach ($available_options as $key) {
if (isset($_GET[$key])) {
$options[$key] = $_GET[$key];
}
}
$options['id'] = $_GET["id"];
$track->display($options);
if (isset($_GET['_sol_to_kb'])) {
Ajax::createIframeModalWindow('savetokb', $CFG_GLPI["root_doc"] . "/front/knowbaseitem.form.php?_in_modal=1&item_itemtype=Ticket&item_items_id=" . $_GET["id"], array('title' => __('Save solution to the knowledge base'), 'reloadonclose' => false));
echo Html::scriptBlock(Html::jsGetElementbyID('savetokb') . ".dialog('open');");
}
} else {
Html::header(__('New ticket'), '', "helpdesk", "ticket");
unset($_REQUEST['id']);
// Add a ticket from item : format data
if (isset($_REQUEST['_add_fromitem'])) {
$_REQUEST['items_id'] = array($_REQUEST['itemtype'] => array($_REQUEST['items_id']));
}
$track->display($_REQUEST);
}
if ($_SESSION["glpiactiveprofile"]["interface"] == "helpdesk") {
Html::helpFooter();
} else {
Html::footer();
示例15: showDisplayLink
/**
* Show infocom link to display modal
*
* @param $itemtype integer item type
* @param $device_id integer item ID
*
* @return float
**/
static function showDisplayLink($itemtype, $device_id)
{
global $DB, $CFG_GLPI;
if (!Session::haveRight(self::$rightname, READ) || !($item = getItemForItemtype($itemtype))) {
return false;
}
$query = "SELECT COUNT(*)\n FROM `glpi_infocoms`\n WHERE `items_id` = '{$device_id}'\n AND `itemtype` = '{$itemtype}'";
$add = "add";
$text = __('Add');
$result = $DB->query($query);
if ($DB->result($result, 0, 0) > 0) {
$add = "";
$text = _x('button', 'Show');
} else {
if (!Infocom::canUpdate()) {
return false;
}
}
if ($item->canView()) {
echo "<span onClick=\"" . Html::jsGetElementbyID('infocom' . $itemtype . $device_id) . ".\n dialog('open');\" style='cursor:pointer'>\n <img src=\"" . $CFG_GLPI["root_doc"] . "/pics/dollar{$add}.png\" alt=\"{$text}\" title=\"{$text}\">\n </span>";
Ajax::createIframeModalWindow('infocom' . $itemtype . $device_id, $CFG_GLPI["root_doc"] . "/front/infocom.form.php" . "?itemtype={$itemtype}&items_id={$device_id}", array('height' => 600));
}
}