Itop portal Page Language Toggle icon button, interface Jump button, perfect solution
Main changes:
Modify class file, webpage.class.inc.php add variable, function, function overwrite
Modify the language configuration file, no longer need to manually modify the URL of the Itop webservice, as long as itop own configuration file, root_url behind with/symbol
Modify application/webpage.class.inc.php
Below the 56 line
Add to
protected $s _userid; protected $s _userlanguage;
Modify application/webpage.class.inc.php
Add 2 functions in 112 rows
Public function Set_userid ($s _userid) {$this->s_userid = $s _userid; The public function set_userlanguage ($s _userlanguage) {$this->s_userlanguage = $s _userlanguage; }
Modify application/webpage.class.inc.php
Search (class_exists (' Metamodel ') && metamodel::getconfig ()), change to below
if (class_exists (' Metamodel ') && Metamodel::getconfig ()) { echo "<link rel=\" shortcut icon\ " href=\" ". Utils::getabsoluteurlapproot ()." Images/favicon.ico?itopversion= ". Itop_version. " \ " />\n"; } /* area to be modified at the top of the portal page, add a jump */ $myUserID = $this->s_userid; $mylanguage = '; $lanuage _logo= '; $title = '; if  ($this->s_userlanguage== "En us") {$mylanguage = "ZH&NBSP;CN"; $lanuage _logo = ". /images/chinese.jpg "; $title =" Switch to Chinese ";} if ($this->s_userlanguage== "ZH&NBSP;CN") {$mylanguage = "En us", $lanuage _logo = ". /images/english.jpg "; $title =" Switch to english ";} echo "
============================
in portal/index.php
only needs to be modified
case ' show_ongoing ': default: $oP->set_title (dict::s (' Portal: Showongoing ')); Displaymainmenu ($oP); &nbSp; showongoingtickets ($oP); } } } $oP- >set_userid (Userrights::getuserid ()); $oP->set_ Userlanguage (Dict::getuserlanguage ()); $oP->output (); ======= ==========================
Join in portal/index.php
Main program/////////////////////////////////////////////////////////////////////////////////try{require_ Once (' popup.php '); =========================================
popup.php file location and content
The jquery download used
wget http://libs.baidu.com/jquery/2.0.0/jquery.min.js
[email protected]:/var/www/html$ cat portal/popup.php<script src= "Jquery.min.js" > </script><?php$str_op_china = <<< eot<div id= "OP1" role= "tooltip " class=" > "Ui-tooltip ui-widget ui-corner-all ui-widget-content form_field_error" <div class= "Ui-tooltip-content" ><b> high </b>- Business services, systems, networks, applications, Impact Customer visibility <br> - critical internal applications and impact on company level <br><br> <b> </b>- Business Services, systems, networks, applications that affect customer visibility <br> - important in-house applications and impact on departmental <br><br><b> low </b>- non-critical services, systems, networks, applications, small impact areas and low levels of severity <br>& nbsp; - affects one or a few internal employees <br></div></div><div Id= "OP2" role= "tooltip" class= "ui-tooltip ui-widget ui-corner-all ui-widget-content form_field_erroR "> <div class=" Ui-tooltip-content "><b> Emergency: already has an impact </b> <br><b> high : will affect </b><br><b in a few hours > : may have an impact within a week </b> <br><b> low : within a week will not have an impact </b></div></div>EOT; $str _op_english = <<< eot<div id= "OP1" role= "tooltip" class= "Ui-tooltip ui-widget ui-corner-all ui-widget-content form_field_error "> <div class= "Ui-tooltip-content" ><b>high</b><br> - business service, system , network or application of which the impacts are visible to business clients <br> - internal critical service, system, network or applicaTion with impact at corporate level<br><b>meduim </b><br >- Business service, system, network or application of which the impacts are invisible to business clients<br>- internal Service, system, network or application with impact at functional level<br><b>low</b><br>- none critical service, system, network or application of which impacts are limited<br>- a single or a few internal users are impacted<br></div>< /div><div id= "OP2" role= "tooltip" class= "Ui-tooltip ui-widget ui-corner-all ui-widget-content form_field_error "> <div class=" Ui-tooltip-content "><b>Urgent</b> - substantial impact in place <br><b>high</b> & nbsp; - imminent impact within hours <br><b>medium< /b> - possible impact within days<br><b>low</b > - possible impact a week later</div></div>eot;if (Dict::GetUserLanguage () = = "En us") {echo ($str _op_english);} else{echo ($str _op_china);}? > <script type= "Text/javascript" >$ (document). Ready (function () { $ (' #op1, #op2 '). Hide (); var attr = $ (' Select#attr_ Impact '). Offset (). left + $ (' Select#attr_impact '). Width (); $ (' select#attr_impact '). MouseOver (function () { $ (' #op1 '). Show (); $ ("Div#op1"). Offset ({ top: $ (' Select#attr_ Impact '). Offset (). top, left: attr }); }); $ (' select#attr_urgency '). MouseOver (function () { $ (' # Op2 '). Show (); $ ("Div#op2"). Offset ({ top: $ (' select#attr_urgency '). Offset () .top, left: attr }); }); $ (' select,option '). Mouseout (function () { $ (' #op1, #op2 '). Hide (); }); });</script>
========================================================
[Email protected]:/var/www/html/itop.new/portal/language# cat conf.php <?phprequire ". /.. /conf/production/config-itop.php "; $itop _webservice = $MySettings [' App_root_url ']. ' Webservices/rest.php '; $aConfig = array ( ' Itop_user ' => ' Admin ', ' Itop_pass ' => ' asset$it ' , ' Itop_webservice ' => "$itop _webservice", );? >
[email protected]:/var/www/html/itop.new/portal/language# [email protected]:/var/www/html/ Itop.new/portal/language# [email protected]:/var/www/html/itop.new/portal/language# [email protected]:/var/www/html/itop.new/portal/language# cat main.php <?phpfunction Request_post ($url, $param) { if (Empty ($url) | | empty ($param)) return false; $postUrl = $url; $curlPost = $param; $ch = curl_init (); //Initialize curl curl_setopt ($ch, curlopt_ssl_verifypeer, false); curl_setopt ($ch, curlopt_ssl_verifyhost, false); curl_setopt ($ch, curlopt_url,$ PostURL); //Crawl specified page curl_setopt ($ch, curlopt_header, 0); //set Header curl_setopt ($ch, curlopt_returntransfer, &NBSP;1) //requires the result to be a string and output to the on-screen curl_setopt ($ch, curlopt_post, 1 ); //post Submission Method curl_setopt ($ch, curlopt_postfields, $curlPost); $data = curl_exec ($ch); //running Curl curl_close ($ch); Return json_decode ($data, True); //convert the returned data into JSON format}//check if communication with Itop is normal function check_itop_network () { global $aConfig; $url = $aConfig [' Itop_webservice ']; $get 1 = request_post ($url, "test"); $get = $get 1[' message ']; if (!strstr ($get, "Missing parameter" ) { echo "and itop Connection Failed! \ n "; exit; }}//itop 's webservice interface, Data model can be itop in accordance with the Function action_update ($class, $key, $fields) { global $ aconfig; $url = $aConfig [' Itop_webservice ']; $post _data[' version '] = ' 1.0 '; $post _data[' auth_user ']= $aConfig [' Itop_user ']; $post _data[' auth_pwd ' ] = $aConfig [' Itop_pass ']; $post _data[' json_data ']= ' { \ "operation\": \ "core/update\", \ "class\": \ "{$class}\", \ "key\": &NBSP; $key, \ "output_fields\": \ "*\", \ "fields\": { $fields } , \ "comment\": \ "\" Return request_post ($url, $post _data);} #********************************************************************************# main#********************************************************************************require "conf.php";//check with Itop contact status check_itop_network ();//Receive User's Ldap_user id$ldap_id = $_ post[' user_id '];//receive what language the user wants to change en us ,zh cn$ldap_lang = $_post[' Lang $fields = "\" language\ ": \" {$ldap _lang}\ ""; Action_update (' Userldap ', $ldap _id, $fields) ;header ("LOCATION:&NBSP;.. /index.php ");? >
[Email protected]:/var/www/html/itop.new/portal/language#
==============================================
Typesetting modification
[Email protected]:/var/www/html$ sudo vim portal/portal.css
A.button, a.button:visited {*/line-height:1.2em; * * Color: #FFFFFF; Bayi Font-size:1.1em; Font-weight:bold; Text-decoration:none; Display:inline; Clear:both; 86}
Problems that may be encountered,
button icon does not display: Please check the path to see if the picture file exists
This article from "Soul Bucket Luo" blog, reproduced please contact the author!
Itop portal Page Language Toggle icon button, interface Jump button, perfect solution