コード例 #1
0
ファイル: html.class.php プロジェクト: OlivierLM/glpi
 /**
  * Print a nice HTML head for help page
  *
  * @param $title  title of the page
  * @param $url    not used anymore (default '')
  **/
 static function helpHeader($title, $url = '')
 {
     global $CFG_GLPI, $HEADER_LOADED, $PLUGIN_HOOKS;
     // Print a nice HTML-head for help page
     if ($HEADER_LOADED) {
         return;
     }
     $HEADER_LOADED = true;
     self::includeHeader($title);
     // Body
     $body_class = "layout_" . $_SESSION['glpilayout'];
     if (strpos($_SERVER['REQUEST_URI'], "form.php") !== false && isset($_GET['id']) && $_GET['id'] > 0) {
         if (!CommonGLPI::isLayoutExcludedPage()) {
             $body_class .= " form";
         } else {
             $body_class = "";
         }
     }
     echo "<body class='{$body_class}'>";
     // Main Headline
     echo "<div id='header'>";
     echo "<div id='header_top'>";
     echo "<div id='c_logo'>";
     echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/helpdesk.public.php' accesskey='1' title=\"" . __s('Home') . "\"><span class='invisible'>Logo</span></a>";
     echo "</div>";
     // Les préférences + lien déconnexion
     echo "<div id='c_preference' >";
     echo "<ul>";
     echo "<li id='deconnexion'>";
     echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/logout.php";
     /// logout witout noAuto login for extauth
     if (isset($_SESSION['glpiextauth']) && $_SESSION['glpiextauth']) {
         echo "?noAUTO=1";
     }
     echo "' title=\"" . __s('Logout') . "\">";
     // check user id : header used for display messages when session logout
     echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/logout.png' title=\"" . __s('Logout') . "\"  alt=\"" . __s('Logout') . "\" class='button-icon'>";
     echo "</a>";
     echo "</li>\n";
     echo "<li id='preferences_link'><a href='" . $CFG_GLPI["root_doc"] . "/front/preference.php' title=\"" . __s('My settings') . "\">";
     echo "<span id='preferences_icon' title=\"" . __s('My settings') . "\"  alt=\"" . __s('My settings') . "\" class='button-icon' /></span>";
     // check user id : header used for display messages when session logout
     if (Session::getLoginUserID()) {
         echo "<span id='myname'>";
         echo formatUserName(0, $_SESSION["glpiname"], $_SESSION["glpirealname"], $_SESSION["glpifirstname"], 0, 20);
         echo "</span>";
     }
     echo "</a></li>";
     echo "<li>";
     Ajax::createIframeModalWindow('loadbookmark', $CFG_GLPI["root_doc"] . "/front/bookmark.php?action=load", array('title' => __('Load a bookmark'), 'reloadonclose' => true));
     echo "<a href='#' onClick=\"" . Html::jsGetElementbyID('loadbookmark') . ".dialog('open');\">";
     echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/bookmark.png' title=\"" . __s('Load a bookmark') . "\"  alt=\"" . __s('Load a bookmark') . "\" class='button-icon'>";
     echo "</a></li>";
     echo "<li id='help_link'>" . "<a href='" . (empty($CFG_GLPI["helpdesk_doc_url"]) ? "http://glpi-project.org/help-helpdesk" : $CFG_GLPI["helpdesk_doc_url"]) . "' target='_blank' title=\"" . __s('Help') . "\">" . "<img src='" . $CFG_GLPI["root_doc"] . "/pics/help.png' title=\"" . __s('Help') . "\"  alt=\"" . __s('Help') . "\" class='button-icon'>";
     "</a></li>";
     echo "</ul>";
     echo "</div>";
     //-- Le moteur de recherche --
     echo "<div id='c_recherche'></div>";
     echo "</div>";
     //-- Le menu principal --
     echo "<div id='c_menu'>";
     echo "<ul id='menu'>";
     // Build the navigation-elements
     // Home
     echo "<li id='menu1'>";
     echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/helpdesk.public.php' title=\"" . __s('Home') . "\" class='itemP'>" . __('Home') . "</a>";
     echo "</li>";
     //  Create ticket
     if (Session::haveRight("ticket", CREATE)) {
         echo "<li id='menu2'>";
         echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/helpdesk.public.php?create_ticket=1' " . "title=\"" . __s('Create a ticket') . "\" class='itemP'>" . __('Create a ticket') . "</a>";
         echo "</li>";
     }
     //  Suivi ticket
     if (Session::haveRight("ticket", Ticket::READMY) || Session::haveRight("followup", TicketFollowup::SEEPUBLIC)) {
         echo "<li id='menu3'>";
         echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/ticket.php' title=\"" . __s('Ticket followup') . "\" class='itemP'>" . _n('Ticket', 'Tickets', Session::getPluralNumber()) . "</a>";
         echo "</li>";
     }
     // Reservation
     if (Session::haveRight("reservation", ReservationItem::RESERVEANITEM)) {
         echo "<li id='menu4'>";
         echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/reservationitem.php' title=\"" . _sn('Reservation', 'Reservations', Session::getPluralNumber()) . "\" class='itemP'>" . _n('Reservation', 'Reservations', Session::getPluralNumber()) . "</a>";
         echo "</li>";
     }
     // FAQ
     if (Session::haveRight('knowbase', KnowbaseItem::READFAQ)) {
         echo "<li id='menu5' >";
         echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/helpdesk.faq.php' title=\"" . __s('FAQ') . "\" class='itemP'>" . __('FAQ') . "</a>";
         echo "</li>";
     }
     // PLUGINS
     $plugins = array();
     if (isset($PLUGIN_HOOKS["helpdesk_menu_entry"]) && count($PLUGIN_HOOKS["helpdesk_menu_entry"])) {
         foreach ($PLUGIN_HOOKS["helpdesk_menu_entry"] as $plugin => $active) {
             if ($active) {
                 $plugins[$plugin] = Plugin::getInfo($plugin);
             }
         }
     }
     if (isset($plugins) && count($plugins) > 0) {
         $list = array();
         foreach ($plugins as $key => $val) {
             $list[$key] = $val["name"];
         }
         asort($list);
         echo "<li id='menu5' onmouseover=\"javascript:menuAff('menu5','menu');\">";
         echo "<a href='#' title=\"" . _sn('Plugin', 'Plugins', Session::getPluralNumber()) . "\" class='itemP'>" . __('Plugins') . "</a>";
         // default none
         echo "<ul class='ssmenu'>";
         // list menu item
         foreach ($list as $key => $val) {
             $link = "";
             if (is_string($PLUGIN_HOOKS["helpdesk_menu_entry"][$key])) {
                 $link = $PLUGIN_HOOKS["helpdesk_menu_entry"][$key];
             }
             echo "<li><a href='" . $CFG_GLPI["root_doc"] . "/plugins/" . $key . $link . "'>" . $plugins[$key]["name"] . "</a></li>\n";
         }
         echo "</ul></li>";
     }
     echo "</ul>";
     echo "</div>";
     // End navigation bar
     // End headline
     //  Le fil d ariane
     echo "<div id='c_ssmenu2'>";
     echo "<ul>";
     echo "<li class='breadcrumb_item'>" . "<a href='" . $CFG_GLPI["root_doc"] . "/front/helpdesk.public.php' title=\"" . __s('Home') . "\">" . __('Home') . "</a></li>";
     if (TicketValidation::getValidateRights()) {
         $opt = array();
         $opt['reset'] = 'reset';
         $opt['criteria'][0]['field'] = 55;
         // validation status
         $opt['criteria'][0]['searchtype'] = 'equals';
         $opt['criteria'][0]['value'] = TicketValidation::WAITING;
         $opt['criteria'][0]['link'] = 'AND';
         $opt['criteria'][1]['field'] = 59;
         // validation aprobator
         $opt['criteria'][1]['searchtype'] = 'equals';
         $opt['criteria'][1]['value'] = Session::getLoginUserID();
         $opt['criteria'][1]['link'] = 'AND';
         $url_validate = $CFG_GLPI["root_doc"] . "/front/ticket.php?" . Toolbox::append_params($opt, '&amp;');
         $pic_validate = "<a href='{$url_validate}'>" . "<img title=\"" . __s('Ticket waiting for your approval') . "\" alt=\"" . __s('Ticket waiting for your approval') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/menu_showall.png' class='pointer'></a>";
         echo "<li class='icons_block'>{$pic_validate}</li>\n";
     }
     if (Session::haveRight('ticket', CREATE) && strpos($_SERVER['PHP_SELF'], "ticket")) {
         echo "<li class='icons_block'><a href='" . $CFG_GLPI["root_doc"] . "/front/helpdesk.public.php?create_ticket=1'>";
         echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/menu_add.png' title=\"" . __s('Add') . "\" alt=\"" . __s('Add') . "\" class='pointer'></a></li>";
     }
     // check user id : header used for display messages when session logout
     if (Session::getLoginUserID()) {
         self::showProfileSelecter($CFG_GLPI["root_doc"] . "/front/helpdesk.public.php");
     }
     echo "</ul></div>";
     echo "</div>";
     // fin header
     echo "<div id='page' >";
     // call static function callcron() every 5min
     CronTask::callCron();
     self::displayMessageAfterRedirect();
 }
コード例 #2
0
ファイル: ajax.class.php プロジェクト: btry/glpi
 /**
  *  Create Ajax Tabs apply to 'tabspanel' div. Content is displayed in 'tabcontent'
  *
  * @param $tabdiv_id                ID of the div containing the tabs (default 'tabspanel')
  * @param $tabdivcontent_id         ID of the div containing the content loaded by tabs
  *                                  (default 'tabcontent')
  * @param $tabs               array of tabs to create :
  *                                  tabs is array('key' => array('title'=> 'x',
  *                                                                url    => 'url_toload',
  *                                                                params => 'url_params')...
  * @param $type                     itemtype for active tab
  * @param $ID                       ID of element for active tab (default 0)
  * @param $orientation              orientation of tabs (default vertical may also be horizontal)
  *
  * @return nothing
  **/
 static function createTabs($tabdiv_id = 'tabspanel', $tabdivcontent_id = 'tabcontent', $tabs = array(), $type, $ID = 0, $orientation = 'vertical')
 {
     global $CFG_GLPI;
     /// TODO need to clean params !!
     $active_tabs = Session::getActiveTab($type);
     $rand = mt_rand();
     if (count($tabs) > 0) {
         echo "<div id='tabs{$rand}' class='center {$orientation}'>";
         if (CommonGLPI::isLayoutWithMain() && !CommonGLPI::isLayoutExcludedPage()) {
             $orientation = 'horizontal';
         }
         echo "<ul>";
         $current = 0;
         $selected_tab = 0;
         foreach ($tabs as $key => $val) {
             if ($key == $active_tabs) {
                 $selected_tab = $current;
             }
             echo "<li><a title=\"" . str_replace(array("<sup class='tab_nb'>", '</sup>'), '', $val['title']) . "\" ";
             echo " href='" . $val['url'] . (isset($val['params']) ? '?' . $val['params'] : '') . "'>";
             // extract sup information
             // $title = '';
             // $limit = 16;
             // No title strip for horizontal menu
             $title = $val['title'];
             echo $title . "</a></li>";
             $current++;
         }
         echo "</ul>";
         echo "</div>";
         echo "<div id='loadingtabs{$rand}' class='invisible'>" . "<div class='loadingindicator'>" . __s('Loading...') . "</div></div>";
         $js = "\n         forceReload{$rand} = false;\n         \$('#tabs{$rand}').tabs({\n            active: {$selected_tab},\n            // Loading indicator\n            beforeLoad: function (event, ui) {\n               if (\$(ui.panel).html()\n                   && !forceReload{$rand}) {\n                  event.preventDefault();\n               } else {\n                  ui.panel.html(\$('#loadingtabs{$rand}').html());\n                  forceReload{$rand} = false;\n                }\n            },\n            ajaxOptions: {type: 'POST'},\n            activate : function( event, ui ) {\n               // Get future value\n               var newIndex = ui.newTab.parent().children().index(ui.newTab);\n               \$.get('" . $CFG_GLPI['root_doc'] . "/ajax/updatecurrenttab.php',\n                  { itemtype: '{$type}', id: '{$ID}', tab: newIndex });\n            }\n         });";
         if ($orientation == 'vertical') {
             $js .= "\$('#tabs{$rand}').tabs().addClass( 'ui-tabs-vertical ui-helper-clearfix' );";
         }
         if (CommonGLPI::isLayoutWithMain() && !CommonGLPI::isLayoutExcludedPage()) {
             $js .= "\$('#tabs{$rand}').scrollabletabs();";
         } else {
             $js .= "\$('#tabs{$rand}').removeClass( 'ui-corner-top' ).addClass( 'ui-corner-left' );";
         }
         $js .= "// force reload\n            function reloadTab(add) {\n               forceReload{$rand} = true;\n               var current_index = \$('#tabs{$rand}').tabs('option','active');\n               // Save tab\n               currenthref = \$('#tabs{$rand} ul>li a').eq(current_index).attr('href');\n               \$('#tabs{$rand} ul>li a').eq(current_index).attr('href',currenthref+'&'+add);\n               \$('#tabs{$rand}').tabs( 'load' , current_index);\n               // Restore tab\n               \$('#tabs{$rand} ul>li a').eq(current_index).attr('href',currenthref);\n            };";
         echo Html::scriptBlock($js);
     }
 }