当前位置: 首页>>代码示例>>PHP>>正文


PHP Bookmark::load方法代码示例

本文整理汇总了PHP中Bookmark::load方法的典型用法代码示例。如果您正苦于以下问题:PHP Bookmark::load方法的具体用法?PHP Bookmark::load怎么用?PHP Bookmark::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Bookmark的用法示例。


在下文中一共展示了Bookmark::load方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 {
//.........这里部分代码省略.........
开发者ID:jose-martins,项目名称:glpi,代码行数:101,代码来源:search.class.php

示例2:

     $_GET["action"] = "";
 } else {
     if ($_GET["action"] == "edit" && isset($_GET['mark_default']) && isset($_GET["id"])) {
         $bookmark->check($_GET["id"], READ);
         if ($_GET["mark_default"] > 0) {
             $bookmark->mark_default($_GET["id"]);
         } else {
             if ($_GET["mark_default"] == 0) {
                 $bookmark->unmark_default($_GET["id"]);
             }
         }
         $_GET["action"] = "";
     } else {
         if ($_GET["action"] == "load" && isset($_GET["id"]) && $_GET["id"] > 0) {
             $bookmark->check($_GET["id"], READ);
             $bookmark->load($_GET["id"]);
             $_GET["action"] = "";
         } else {
             if (isset($_POST["action"]) && ($_POST["action"] == "up" || $_POST["action"] == "down")) {
                 Session::checkLoginUser();
                 $bookmark->changeBookmarkOrder($_POST['id'], $_POST["action"]);
                 $_GET["action"] = "";
             } else {
                 if (isset($_POST["purge"])) {
                     $bookmark->check($_POST["id"], PURGE);
                     $bookmark->delete($_POST, 1);
                     $_GET["action"] = "";
                 }
             }
         }
     }
开发者ID:btry,项目名称:glpi,代码行数:31,代码来源:bookmark.php

示例3: 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) {
//.........这里部分代码省略.........
开发者ID:JULIO8,项目名称:respaldo_glpi,代码行数:101,代码来源:searcha.class.php


注:本文中的Bookmark::load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。