本文整理汇总了PHP中Toolbox::prepareArrayForInput方法的典型用法代码示例。如果您正苦于以下问题:PHP Toolbox::prepareArrayForInput方法的具体用法?PHP Toolbox::prepareArrayForInput怎么用?PHP Toolbox::prepareArrayForInput使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Toolbox
的用法示例。
在下文中一共展示了Toolbox::prepareArrayForInput方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: printPager
/**
* Print pager for search option (first/previous/next/last)
*
* @param $start from witch item we start
* @param $numrows total items
* @param $target page would be open when click on the option (last,previous etc)
* @param $parameters parameters would be passed on the URL.
* @param $item_type_output item type display - if >0 display export PDF et Sylk form
* (default 0)
* @param $item_type_output_param item type parameter for export (default 0)
* @param $additional_info Additional information to display (default '')
*
* @return nothing (print a pager)
*
**/
static function printPager($start, $numrows, $target, $parameters, $item_type_output = 0, $item_type_output_param = 0, $additional_info = '')
{
global $CFG_GLPI;
$list_limit = $_SESSION['glpilist_limit'];
// Forward is the next step forward
$forward = $start + $list_limit;
// This is the end, my friend
$end = $numrows - $list_limit;
// Human readable count starts here
$current_start = $start + 1;
// And the human is viewing from start to end
$current_end = $current_start + $list_limit - 1;
if ($current_end > $numrows) {
$current_end = $numrows;
}
// Empty case
if ($current_end == 0) {
$current_start = 0;
}
// Backward browsing
if ($current_start - $list_limit <= 0) {
$back = 0;
} else {
$back = $start - $list_limit;
}
// Print it
echo "<div><table class='tab_cadre_pager'>";
echo "<tr>";
if (strpos($target, '?') == false) {
$fulltarget = $target . "?" . $parameters;
} else {
$fulltarget = $target . "&" . $parameters;
}
// Back and fast backward button
if (!$start == 0) {
echo "<th class='left'>";
echo "<a href='{$fulltarget}&start=0'>";
echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/first.png' alt=\"" . __s('Start') . "\" title=\"" . __s('Start') . "\" class='pointer'>";
echo "</a></th>";
echo "<th class='left'>";
echo "<a href='{$fulltarget}&start={$back}'>";
echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/left.png' alt=\"" . __s('Previous') . "\" title=\"" . __s('Previous') . "\" class='pointer'>";
echo "</a></th>";
}
// Print the "where am I?"
echo "<td width='31%' class='tab_bg_2'>";
self::printPagerForm("{$fulltarget}&start={$start}");
echo "</td>";
if (!empty($additional_info)) {
echo "<td class='tab_bg_2'>";
echo $additional_info;
echo "</td>";
}
if (!empty($item_type_output) && isset($_SESSION["glpiactiveprofile"]) && $_SESSION["glpiactiveprofile"]["interface"] == "central") {
echo "<td class='tab_bg_2 responsive_hidden' width='30%'>";
echo "<form method='GET' action='" . $CFG_GLPI["root_doc"] . "/front/report.dynamic.php'\n target='_blank'>";
echo Html::hidden('item_type', array('value' => $item_type_output));
if ($item_type_output_param != 0) {
echo Html::hidden('item_type_param', array('value' => Toolbox::prepareArrayForInput($item_type_output_param)));
}
$split = explode("&", $parameters);
for ($i = 0; $i < count($split); $i++) {
$pos = Toolbox::strpos($split[$i], '=');
$length = Toolbox::strlen($split[$i]);
echo Html::hidden(Toolbox::substr($split[$i], 0, $pos), array('value' => urldecode(Toolbox::substr($split[$i], $pos + 1))));
}
Dropdown::showOutputFormat();
Html::closeForm();
echo "</td>";
}
echo "<td width='20%' class='tab_bg_2 b'>";
//TRANS: %1$d, %2$d, %3$d are page numbers
printf(__('From %1$d to %2$d on %3$d'), $current_start, $current_end, $numrows);
echo "</td>\n";
// Forward and fast forward button
if ($forward < $numrows) {
echo "<th class='right'>";
echo "<a href='{$fulltarget}&start={$forward}'>";
echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/right.png' alt=\"" . __s('Next') . "\" title=\"" . __s('Next') . "\" class='pointer'>";
echo "</a></th>\n";
echo "<th class='right'>";
echo "<a href='{$fulltarget}&start={$end}'>";
echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/last.png' alt=\"" . __s('End') . "\" title=\"" . __s('End') . "\" class='pointer'>";
echo "</a></th>\n";
}
//.........这里部分代码省略.........
示例2: showForm
//.........这里部分代码省略.........
}
echo "</tr>";
// View files added
echo "<tr class='tab_bg_1'>";
// Permit to add doc when creating a ticket
echo "<th style='width:{$colsize1}%'>";
echo $tt->getBeginHiddenFieldText('_documents_id');
$doctitle = sprintf(__('File (%s)'), Document::getMaxUploadSize());
printf(__('%1$s%2$s'), $doctitle, $tt->getMandatoryMark('_documents_id'));
// Do not show if hidden.
if (!$tt->isHiddenField('_documents_id')) {
DocumentType::showAvailableTypesLink();
}
echo $tt->getEndHiddenFieldText('_documents_id');
echo "</th>";
echo "<td colspan='3'>";
// Do not set values
echo $tt->getEndHiddenFieldValue('_documents_id');
if ($tt->isPredefinedField('_documents_id')) {
if (isset($values['_documents_id']) && is_array($values['_documents_id']) && count($values['_documents_id'])) {
echo "<span class='b'>" . __('Default documents:') . '</span>';
echo "<br>";
$doc = new Document();
foreach ($values['_documents_id'] as $key => $val) {
if ($doc->getFromDB($val)) {
echo "<input type='hidden' name='_documents_id[{$key}]' value='{$val}'>";
echo "- " . $doc->getNameID() . "<br>";
}
}
}
}
echo "<div id='fileupload_info'></div>";
echo "</td>";
echo "</tr>";
if ((!$ID || $canupdate || $canupdate_descr || Session::haveRightsOr(self::$rightname, array(self::ASSIGN, self::STEAL, DELETE, PURGE))) && !$options['template_preview']) {
echo "<tr class='tab_bg_1'>";
if ($ID) {
if (Session::haveRightsOr(self::$rightname, array(UPDATE, DELETE, PURGE)) || $this->canDeleteItem() || $this->canUpdateItem()) {
echo "<td class='tab_bg_2 center' colspan='4'>";
if ($this->fields["is_deleted"] == 1) {
if (self::canPurge()) {
echo "<input type='submit' class='submit' name='restore' value='" . _sx('button', 'Restore') . "'> ";
}
} else {
if (self::canUpdate()) {
echo "<input type='submit' class='submit' name='update' value='" . _sx('button', 'Save') . "'> ";
}
}
if ($this->fields["is_deleted"] == 1) {
if (self::canPurge()) {
echo "<input type='submit' class='submit' name='purge' value='" . _sx('button', 'Delete permanently') . "' " . Html::addConfirmationOnAction(__('Confirm the final deletion?')) . ">";
}
} else {
if ($this->canDeleteItem()) {
echo "<input type='submit' class='submit' name='delete' value='" . _sx('button', 'Put in dustbin') . "'>";
}
}
echo "<input type='hidden' name='_read_date_mod' value='" . $this->getField('date_mod') . "'>";
echo "</td>";
}
} else {
echo "<td class='tab_bg_2 center' colspan='4'>";
echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
if ($tt->isField('id') && $tt->fields['id'] > 0) {
echo "<input type='hidden' name='_tickettemplates_id' value='" . $tt->fields['id'] . "'>";
echo "<input type='hidden' name='_predefined_fields'\n value=\"" . Toolbox::prepareArrayForInput($predefined_fields) . "\">";
}
}
}
// File upload system
$colspan = 3;
if (!$CFG_GLPI['use_rich_text']) {
$colspan = 4;
}
echo "<tr class='tab_bg_1'>";
echo "<td colspan='{$colspan}'>";
echo $tt->getBeginHiddenFieldValue('_documents_id');
echo Html::file(array('multiple' => true, 'showfilecontainer' => 'fileupload_info', 'values' => array('filename' => $values['_filename'], 'tag' => $values['_tag_filename'])));
echo "</td>";
if ($CFG_GLPI['use_rich_text']) {
echo "</tr>";
echo "<tr class='tab_bg_1'>";
echo "<td colspan='{$colspan}'>";
if (!isset($rand)) {
$rand = mt_rand();
}
if ($canupdate_descr) {
echo Html::initImagePasteSystem($content_id, $rand);
}
echo "</td>";
}
echo "</tr>";
echo "</table>";
echo "<input type='hidden' name='id' value='{$ID}'>";
echo "</div>";
if (!$options['template_preview']) {
Html::closeForm();
}
return true;
}
示例3: getHelpdesk
//.........这里部分代码省略.........
$condition .= " AND `is_incident`='1'";
}
$opt = array('value' => $values['itilcategories_id'], 'condition' => $condition, 'on_change' => 'submit()');
if ($values['itilcategories_id'] && $tt->isMandatoryField("itilcategories_id")) {
$opt['display_emptychoice'] = false;
}
ITILCategory::dropdown($opt);
echo "</td></tr>";
if ($CFG_GLPI['urgency_mask'] != 1 << 3) {
if (!$tt->isHiddenField('urgency')) {
echo "<tr class='tab_bg_1'>";
echo "<td>" . sprintf(__('%1$s%2$s'), __('Urgency'), $tt->getMandatoryMark('urgency')) . "</td>";
echo "<td>";
Ticket::dropdownUrgency(array('value' => $values["urgency"]));
echo "</td></tr>";
}
}
if (empty($delegating) && NotificationTargetTicket::isAuthorMailingActivatedForHelpdesk()) {
echo "<tr class='tab_bg_1'>";
echo "<td>" . __('Inform me about the actions taken') . "</td>";
echo "<td>";
if ($values["_users_id_requester"] == 0) {
$values['_users_id_requester'] = Session::getLoginUserID();
}
$_POST['value'] = $values['_users_id_requester'];
$_POST['field'] = '_users_id_requester_notif';
$_POST['use_notification'] = $values['_users_id_requester_notif']['use_notification'];
include GLPI_ROOT . "/ajax/uemailUpdate.php";
echo "</td></tr>";
}
if ($_SESSION["glpiactiveprofile"]["helpdesk_hardware"] != 0) {
if (!$tt->isHiddenField('itemtype')) {
echo "<tr class='tab_bg_1'>";
echo "<td>" . sprintf(__('%1$s%2$s'), __('Hardware type'), $tt->getMandatoryMark('itemtype')) . "</td>";
echo "<td>";
Ticket::dropdownMyDevices($values['_users_id_requester'], $_SESSION["glpiactive_entity"], $values['itemtype'], $values['items_id']);
Ticket::dropdownAllDevices("itemtype", $values['itemtype'], $values['items_id'], 0, $values['_users_id_requester'], $_SESSION["glpiactive_entity"]);
echo "<span id='item_ticket_selection_information'></span>";
echo "</td></tr>";
}
}
if (!$tt->isHiddenField('locations_id')) {
echo "<tr class='tab_bg_1'><td>";
printf(__('%1$s%2$s'), __('Location'), $tt->getMandatoryMark('locations_id'));
echo "</td><td>";
Location::dropdown(array('value' => $values["locations_id"]));
echo "</td></tr>";
}
if (!$tt->isHiddenField('name') || $tt->isPredefinedField('name')) {
echo "<tr class='tab_bg_1'>";
echo "<td>" . sprintf(__('%1$s%2$s'), __('Title'), $tt->getMandatoryMark('name')) . "</td>";
echo "<td><input type='text' maxlength='250' size='80' name='name'\n value=\"" . $values['name'] . "\"></td></tr>";
}
if (!$tt->isHiddenField('content') || $tt->isPredefinedField('content')) {
echo "<tr class='tab_bg_1'>";
echo "<td>" . sprintf(__('%1$s%2$s'), __('Description'), $tt->getMandatoryMark('content')) . "</td>";
// * Changed by plugin surveyticket
// * Added by plugin surveyticket
$psTicketTemplate = new PluginSurveyticketTicketTemplate();
$psSurvey = new PluginSurveyticketSurvey();
$plugin_surveyticket_surveys_id = 0;
$a_tickettemplates = current($psTicketTemplate->find("`tickettemplates_id`='" . $tt->fields['id'] . "'\n AND `type`='" . $values['type'] . "'\n AND `is_helpdesk`='1'"));
if (isset($a_tickettemplates['plugin_surveyticket_surveys_id'])) {
echo "<td>";
$psSurvey = new PluginSurveyticketSurvey();
$psSurvey->getFromDB($a_tickettemplates['plugin_surveyticket_surveys_id']);
if ($psSurvey->fields['is_active'] == 1) {
$plugin_surveyticket_surveys_id = $a_tickettemplates['plugin_surveyticket_surveys_id'];
$psSurvey = new PluginSurveyticketSurvey();
$psSurvey->startSurvey($plugin_surveyticket_surveys_id);
}
} else {
echo "<td><textarea name='content' cols='80' rows='14'>" . $values['content'] . "</textarea>";
}
// * End of change
echo "</td></tr>";
}
echo "<tr class='tab_bg_1'>";
echo "<td>" . sprintf(__('%1$s (%2$s)'), __('File'), Document::getMaxUploadSize());
echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/aide.png' class='pointer' alt='" . __s('Help') . "' onclick=\"window.open('" . $CFG_GLPI["root_doc"] . "/front/documenttype.list.php','Help','scrollbars=1,resizable=1,width=1000,height=800')\">";
echo " ";
Ticket::showDocumentAddButton(60);
echo "</td>";
echo "<td><div id='uploadfiles'><input type='file' name='filename[]' value='' size='60'></div>";
echo "</td></tr>";
if (!$ticket_template) {
echo "<tr class='tab_bg_1'>";
echo "<td colspan='2' class='center'>";
if ($tt->isField('id') && $tt->fields['id'] > 0) {
echo "<input type='hidden' name='_tickettemplates_id' value='" . $tt->fields['id'] . "'>";
echo "<input type='hidden' name='_predefined_fields'\n value=\"" . Toolbox::prepareArrayForInput($predefined_fields) . "\">";
}
echo "<input type='submit' name='add' value=\"" . __s('Submit message') . "\" class='submit'>";
echo "</td></tr>";
}
echo "</table></div>";
if (!$ticket_template) {
Html::closeForm();
}
}
示例4: showForm
//.........这里部分代码省略.........
if (!empty($this->fields["content"])) {
echo nl2br($this->fields["content"]);
} else {
_e('Empty description');
}
echo "</div>\n";
echo "<div id='viewdesc{$rand}'></div>\n";
if (!$ID) {
echo "<script type='text/javascript' >\n\n showDesc{$rand}();\n </script>";
}
echo $tt->getEndHiddenFieldValue('content', $this);
} else {
echo nl2br($this->fields["content"]);
}
echo "</td>";
echo "</tr>";
echo "<tr class='tab_bg_1'>";
// Permit to add doc when creating a ticket
if (!$ID) {
echo "<th width='{$colsize1}%'>" . sprintf(__('File (%s)'), Document::getMaxUploadSize());
echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/aide.png' class='pointer' alt=\"" . __s('Help') . "\" onclick=\"window.open('" . $CFG_GLPI["root_doc"] . "/front/documenttype.list.php','Help','scrollbars=1,resizable=1,width=1000," . "height=800')\">";
echo " ";
self::showDocumentAddButton();
echo "</th>";
echo "<td width='{$colsize2}%'>";
echo "<div id='uploadfiles'><input type='file' name='filename[]' size='20'></div></td>";
} else {
echo "<th colspan='2'>";
$docnb = Document_Item::countForItem($this);
echo "<a href=\"" . $this->getLinkURL() . "&forcetab=Document_Item\$1\">";
//TRANS: %d is the document number
echo sprintf(_n('%d associated document', '%d associated documents', $docnb), $docnb);
echo "</a></th>";
}
if ($view_linked_tickets) {
echo "<th width='{$colsize3}%'>" . _n('Linked ticket', 'Linked tickets', 2);
$rand_linked_ticket = mt_rand();
if ($canupdate) {
echo " ";
echo "<img onClick=\"Ext.get('linkedticket{$rand_linked_ticket}').setDisplayed('block')\"\n title=\"" . __s('Add') . "\" alt=\"" . __s('Add') . "\"\n class='pointer' src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png'>";
}
echo '</th>';
echo "<td width='{$colsize4}%'>";
if ($canupdate) {
echo "<div style='display:none' id='linkedticket{$rand_linked_ticket}'>";
Ticket_Ticket::dropdownLinks('_link[link]', isset($values["_link"]) ? $values["_link"]['link'] : '');
printf(__('%1$s: %2$s'), __('Ticket'), __('ID'));
echo "<input type='hidden' name='_link[tickets_id_1]' value='{$ID}'>\n";
echo "<input type='text' name='_link[tickets_id_2]'\n value='" . (isset($values["_link"]) ? $values["_link"]['tickets_id_2'] : '') . "'\n size='10'>\n";
echo " ";
echo "</div>";
if (isset($values["_link"]) && !empty($values["_link"]['tickets_id_2'])) {
echo "<script language='javascript'>Ext.get('linkedticket{$rand_linked_ticket}').\n setDisplayed('block');</script>";
}
}
Ticket_Ticket::displayLinkedTicketsTo($ID);
echo "</td>";
} else {
echo "<td></td>";
}
echo "</tr>";
if ((!$ID || $canupdate || $canupdate_descr || Session::haveRight("assign_ticket", "1") || Session::haveRight("steal_ticket", "1")) && !$options['template_preview']) {
echo "<tr class='tab_bg_1'>";
if ($ID) {
if (Session::haveRight('delete_ticket', 1)) {
echo "<td class='tab_bg_2 center' colspan='2'>";
if ($this->fields["is_deleted"] == 1) {
echo "<input type='submit' class='submit' name='restore' value='" . _sx('button', 'Restore') . "'></td>";
} else {
echo "<input type='submit' class='submit' name='update' value='" . _sx('button', 'Save') . "'></td>";
}
echo "<td class='tab_bg_2 center' colspan='2'>";
if ($this->fields["is_deleted"] == 1) {
echo "<input type='submit' class='submit' name='purge' value='" . _sx('button', 'Delete permanently') . "' " . Html::addConfirmationOnAction(__('Confirm the final deletion?')) . ">";
} else {
echo "<input type='submit' class='submit' name='delete' value='" . _sx('button', 'Put in dustbin') . "'></td>";
}
} else {
echo "<td class='tab_bg_2 center' colspan='4'>";
echo "<input type='submit' class='submit' name='update' value='" . _sx('button', 'Save') . "'>";
}
echo "<input type='hidden' name='_read_date_mod' value='" . $this->getField('date_mod') . "'>";
} else {
echo "<td class='tab_bg_2 center' colspan='4'>";
echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
if ($tt->isField('id') && $tt->fields['id'] > 0) {
echo "<input type='hidden' name='_tickettemplates_id' value='" . $tt->fields['id'] . "'>";
echo "<input type='hidden' name='_predefined_fields'\n value=\"" . Toolbox::prepareArrayForInput($predefined_fields) . "\">";
}
}
}
echo "</table>";
echo "<input type='hidden' name='id' value='{$ID}'>";
echo "</div>";
if (!$options['template_preview']) {
Html::closeForm();
$this->addDivForTabs();
}
return true;
}
示例5: printPager
/**
* Print pager for search option (first/previous/next/last)
*
* @param $start from witch item we start
* @param $numrows total items
* @param $target page would be open when click on the option (last,previous etc)
* @param $parameters parameters would be passed on the URL.
* @param $item_type_output item type display - if >0 display export PDF et Sylk form
* (default 0)
* @param $item_type_output_param item type parameter for export (default 0)
* @param $additional_info Additional information to display (default '')
*
* @return nothing (print a pager)
*
* */
function printPager($start, $numrows, $target, $parameters, $item_type_output = 0, $item_type_output_param = 0, $additional_info = '')
{
global $CFG_GLPI;
$list_limit = $_SESSION['glpilist_limit'];
// Forward is the next step forward
$forward = $start + $list_limit;
// This is the end, my friend
$end = $numrows - $list_limit;
// Human readable count starts here
$current_start = $start + 1;
// And the human is viewing from start to end
$current_end = $current_start + $list_limit - 1;
if ($current_end > $numrows) {
$current_end = $numrows;
}
// Empty case
if ($current_end == 0) {
$current_start = 0;
}
// Backward browsing
if ($current_start - $list_limit <= 0) {
$back = 0;
} else {
$back = $start - $list_limit;
}
// Print it
echo "<div><table class='tab_cadre_pager'>";
echo "<tr>";
// Back and fast backward button
if (!$start == 0) {
echo "<th class='left'>";
echo "<a href='{$target}?{$parameters}&start=0'>";
echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/first.png' alt=\"" . __s('Start') . "\" title=\"" . __s('Start') . "\">";
echo "</a></th>";
echo "<th class='left'>";
echo "<a href='{$target}?{$parameters}&start={$back}'>";
echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/left.png' alt=\"" . __s('Previous') . "\" title=\"" . __s('Previous') . "\">";
echo "</a></th>";
}
// Print the "where am I?"
echo "<td width='50%' class='tab_bg_2'>";
Html::printPagerForm("{$target}?{$parameters}&start={$start}");
echo "</td>";
if (!empty($additional_info)) {
echo "<td class='tab_bg_2'>";
echo $additional_info;
echo "</td>";
}
if (!empty($item_type_output) && isset($_SESSION["glpiactiveprofile"]) && $_SESSION["glpiactiveprofile"]["interface"] == "central") {
echo "<td class='tab_bg_2' width='30%'>";
echo "<form method='GET' action='" . $target . "' target='_blank'>";
echo Html::hidden('item_type', array('value' => $item_type_output));
if ($item_type_output_param != 0) {
echo Html::hidden('item_type_param', array('value' => Toolbox::prepareArrayForInput($item_type_output_param)));
}
$split = explode("&", $parameters);
for ($i = 0; $i < count($split); $i++) {
$pos = Toolbox::strpos($split[$i], '=');
$length = Toolbox::strlen($split[$i]);
echo Html::hidden(Toolbox::substr($split[$i], 0, $pos), array('value' => urldecode(Toolbox::substr($split[$i], $pos + 1))));
}
Dropdown::showOutputFormat();
$this->showCSVOptions();
echo "<script type='text/javascript'>";
echo "\$('select[name=display_type]').change(function() {\r\n switch(\$(this).val()){\r\n case '3' :case '-3' :\r\n \$('#display_csv_preferences').css('display', 'block');\r\n break;\r\n default : \r\n \$('#display_csv_preferences').css('display', 'none');\r\n break;\r\n }\r\n });";
echo "</script>";
Html::closeForm();
echo "</td>";
}
echo "<td width='50%' class='tab_bg_2 b'>";
//TRANS: %1$d, %2$d, %3$d are page numbers
printf(__('From %1$d to %2$d on %3$d'), $current_start, $current_end, $numrows);
echo "</td>\n";
// Forward and fast forward button
if ($forward < $numrows) {
echo "<th class='right'>";
echo "<a href='{$target}?{$parameters}&start={$forward}'>";
echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/right.png' alt=\"" . __s('Next') . "\" title=\"" . __s('Next') . "\">";
echo "</a></th>\n";
echo "<th class='right'>";
echo "<a href='{$target}?{$parameters}&start={$end}'>";
echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/last.png' alt=\"" . __s('End') . "\" title=\"" . __s('End') . "\">";
echo "</a></th>\n";
}
// End pager
//.........这里部分代码省略.........
示例6: updateItemJsCode
/**
* Javascript code for update an item (Javascript code only)
*
* @param $toupdate id of the item to update
* @param $url Url to get datas to update the item
* @param $parameters array of parameters to send to ajax URL
* @param $toobserve id of another item used to get value in case of __VALUE__ used
* or
* array of id to get value in case of __VALUE#__ used (default '')
* @param $display boolean display or get string (default true)
**/
static function updateItemJsCode($toupdate, $url, $parameters = array(), $toobserve = "", $display = true)
{
// Get it from a Ext.Element object
$out = "Ext.get('{$toupdate}').load({\n url: '{$url}',\n scripts: true";
if (count($parameters)) {
$out .= ",\n params:'";
$first = true;
foreach ($parameters as $key => $val) {
if ($first) {
$first = false;
} else {
$out .= "&";
}
$out .= $key . "=";
if (is_array($val)) {
$out .= Toolbox::prepareArrayForInput($val);
} else {
if (preg_match('/^__VALUE(\\d+)__$/', $val, $regs)) {
$out .= "'+Ext.get('" . $toobserve[$regs[1]] . "').getValue()+'";
} else {
if ($val === "__VALUE__") {
$out .= "'+Ext.get('{$toobserve}').getValue()+'";
} else {
if (preg_match("/['\"]/", $val)) {
$out .= rawurlencode($val);
} else {
$out .= $val;
}
}
}
}
}
$out .= "'\n";
}
$out .= "});";
if ($display) {
echo $out;
} else {
return $out;
}
}