本文整理汇总了PHP中Bookmark::getParameters方法的典型用法代码示例。如果您正苦于以下问题:PHP Bookmark::getParameters方法的具体用法?PHP Bookmark::getParameters怎么用?PHP Bookmark::getParameters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bookmark
的用法示例。
在下文中一共展示了Bookmark::getParameters方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: manageParams
/**
* Completion of the URL $_GET values with the $_SESSION values or define default values
*
* @param $itemtype item type to manage
* @param $params array params to parse
* @param $usesession Use datas save in session (true by default)
* @param $forcebookmark force trying to load parameters from default bookmark:
* used for global search (false by default)
*
* @return parsed params array
**/
static function manageParams($itemtype, $params = array(), $usesession = true, $forcebookmark = false)
{
global $CFG_GLPI, $DB;
$redirect = false;
$default_values = array();
$default_values["start"] = 0;
$default_values["order"] = "ASC";
$default_values["sort"] = 1;
$default_values["is_deleted"] = 0;
if ($CFG_GLPI['allow_search_view'] == 2) {
$default_criteria = 'view';
} else {
$options = self::getCleanedOptions($itemtype);
foreach ($options as $key => $val) {
if (is_array($val)) {
$default_criteria = $key;
break;
}
}
}
$default_values["criteria"] = array(0 => array('field' => $default_criteria, 'link' => 'contains', 'value' => ''));
$default_values["metacriteria"] = array();
// Reorg search array
// start
// order
// sort
// is_deleted
// itemtype
// criteria : array (0 => array (link =>
// field =>
// searchtype =>
// value => (contains)
// metacriteria : array (0 => array (itemtype =>
// link =>
// field =>
// searchtype =>
// value => (contains)
if ($itemtype != 'AllAssets' && class_exists($itemtype) && method_exists($itemtype, 'getDefaultSearchRequest')) {
$default_values = array_merge($default_values, call_user_func(array($itemtype, 'getDefaultSearchRequest')));
}
// First view of the page or force bookmark : try to load a bookmark
if ($forcebookmark || $usesession && !isset($params["reset"]) && !isset($_SESSION['glpisearch'][$itemtype])) {
$query = "SELECT `bookmarks_id`\n FROM `glpi_bookmarks_users`\n WHERE `users_id`='" . Session::getLoginUserID() . "'\n AND `itemtype` = '{$itemtype}'";
if ($result = $DB->query($query)) {
if ($DB->numrows($result) > 0) {
$IDtoload = $DB->result($result, 0, 0);
// Set session variable
$_SESSION['glpisearch'][$itemtype] = array();
// Load bookmark on main window
$bookmark = new Bookmark();
// Only get datas for bookmarks
if ($forcebookmark) {
$params = $bookmark->getParameters($IDtoload);
} else {
$bookmark->load($IDtoload, false);
}
}
}
}
// Force reorder criterias
if (isset($params["criteria"]) && is_array($params["criteria"]) && count($params["criteria"])) {
$tmp = $params["criteria"];
$params["criteria"] = array();
foreach ($tmp as $val) {
$params["criteria"][] = $val;
}
}
if (isset($params["metacriteria"]) && is_array($params["metacriteria"]) && count($params["metacriteria"])) {
$tmp = $params["metacriteria"];
$params["metacriteria"] = array();
foreach ($tmp as $val) {
$params["metacriteria"][] = $val;
}
}
if ($usesession && isset($params["reset"])) {
if (isset($_SESSION['glpisearch'][$itemtype])) {
unset($_SESSION['glpisearch'][$itemtype]);
}
}
if (isset($params) && is_array($params) && $usesession) {
foreach ($params as $key => $val) {
$_SESSION['glpisearch'][$itemtype][$key] = $val;
}
}
foreach ($default_values as $key => $val) {
if (!isset($params[$key])) {
if ($usesession && isset($_SESSION['glpisearch'][$itemtype][$key])) {
$params[$key] = $_SESSION['glpisearch'][$itemtype][$key];
} else {
//.........这里部分代码省略.........
示例2: manageGetValues
/**
* Completion of the URL $_GET values with the $_SESSION values or define default values
*
* @param $itemtype item type to manage
* @param $usesession Use datas save in session (true by default)
* @param $forcebookmark force trying to load parameters from default bookmark:
* used for global search (false by default)
*
* @return nothing
**/
static function manageGetValues($itemtype, $usesession = true, $forcebookmark = false)
{
global $_GET, $DB;
$redirect = false;
if (isset($_GET["add_search_count"]) && $_GET["add_search_count"]) {
$_SESSION["glpisearchcount"][$itemtype]++;
Html::redirect(str_replace("add_search_count=1&", "", $_SERVER['REQUEST_URI']));
}
if (isset($_GET["delete_search_count"]) && $_GET["delete_search_count"]) {
if ($_SESSION["glpisearchcount"][$itemtype] > 1) {
$_SESSION["glpisearchcount"][$itemtype]--;
}
Html::redirect(str_replace("delete_search_count=1&", "", $_SERVER['REQUEST_URI']));
}
if (isset($_GET["add_search_count2"]) && $_GET["add_search_count2"]) {
$_SESSION["glpisearchcount2"][$itemtype]++;
Html::redirect(str_replace("add_search_count2=1&", "", $_SERVER['REQUEST_URI']));
}
if (isset($_GET["delete_search_count2"]) && $_GET["delete_search_count2"]) {
if ($_SESSION["glpisearchcount2"][$itemtype] >= 1) {
$_SESSION["glpisearchcount2"][$itemtype]--;
}
Html::redirect(str_replace("delete_search_count2=1&", "", $_SERVER['REQUEST_URI']));
}
$default_values = array();
$default_values["start"] = 0;
$default_values["order"] = "ASC";
$default_values["is_deleted"] = 0;
$default_values["distinct"] = "N";
$default_values["link"] = array();
$default_values["field"] = array();
$default_values["contains"] = array(0 => "");
$default_values["searchtype"] = array(0 => "contains");
$default_values["link2"] = array();
$default_values["field2"] = array(0 => "view");
$default_values["contains2"] = array(0 => "");
$default_values["itemtype2"] = "";
$default_values["searchtype2"] = "";
$default_values["sort"] = 1;
if ($itemtype != 'AllAssets' && class_exists($itemtype) && method_exists($itemtype, 'getDefaultSearchRequest')) {
$default_values = array_merge($default_values, call_user_func(array($itemtype, 'getDefaultSearchRequest')));
}
// First view of the page or force bookmark : try to load a bookmark
if ($forcebookmark || $usesession && !isset($_GET["reset"]) && !isset($_SESSION['glpisearch'][$itemtype])) {
$query = "SELECT `bookmarks_id`\n FROM `glpi_bookmarks_users`\n WHERE `users_id`='" . Session::getLoginUserID() . "'\n AND `itemtype` = '{$itemtype}'";
if ($result = $DB->query($query)) {
if ($DB->numrows($result) > 0) {
$IDtoload = $DB->result($result, 0, 0);
// Set session variable
$_SESSION['glpisearch'][$itemtype] = array();
// Load bookmark on main window
$bookmark = new Bookmark();
// Only get datas for bookmarks
if ($forcebookmark) {
$_GET = $bookmark->getParameters($IDtoload);
} else {
$bookmark->load($IDtoload, false);
}
}
}
}
if ($usesession && isset($_GET["reset"])) {
if (isset($_SESSION['glpisearch'][$itemtype])) {
unset($_SESSION['glpisearch'][$itemtype]);
}
if (isset($_SESSION['glpisearchcount'][$itemtype])) {
unset($_SESSION['glpisearchcount'][$itemtype]);
}
if (isset($_SESSION['glpisearchcount2'][$itemtype])) {
unset($_SESSION['glpisearchcount2'][$itemtype]);
}
// Bookmark use
if (isset($_GET["glpisearchcount"])) {
$_SESSION["glpisearchcount"][$itemtype] = $_GET["glpisearchcount"];
} else {
if (isset($_GET["field"])) {
$_SESSION["glpisearchcount"][$itemtype] = count($_GET["field"]);
}
}
// Bookmark use
if (isset($_GET["glpisearchcount2"])) {
$_SESSION["glpisearchcount2"][$itemtype] = $_GET["glpisearchcount2"];
} else {
if (isset($_GET["field2"])) {
$_SESSION["glpisearchcount2"][$itemtype] = count($_GET["field2"]);
}
}
}
if (is_array($_GET) && $usesession) {
foreach ($_GET as $key => $val) {
//.........这里部分代码省略.........