主要修改:
修改类文件,webpage.class.inc.php 加入变量,函数,功能改写
修改language 配置文件,不再需要手动修改itop webservice的url,前提是itop自己的配置文件,root_url后面带有/符号
修改application/webpage.class.inc.php
在56行下面
添加
protected $s_userid; protected $s_userlanguage;
修改application/webpage.class.inc.php
在112行添加2个函数
public function set_userid($s_userid) { $this->s_userid = $s_userid; } public function set_userlanguage($s_userlanguage) { $this->s_userlanguage = $s_userlanguage; }
修改application/webpage.class.inc.php
搜索 (class_exists(‘MetaModel‘) && MetaModel::GetConfig()),改成下面
if (class_exists(‘MetaModel‘) && MetaModel::GetConfig()) { echo "<link rel=\"shortcut icon\" href=\"".utils::GetAbsoluteUrlAppRoot()."images/favicon.ico?itopversion=".ITOP_VERSION."\" />\n"; } /* 需要修改的区域 ,在portal页面的顶部,添加跳转 */ $myUserID = $this->s_userid; $mylanguage=‘‘; $lanuage_logo=‘‘; $title=‘‘; if ($this->s_userlanguage=="EN US"){$mylanguage = "ZH CN";$lanuage_logo ="../images/chinese.jpg";$title="切换到中文";} if ($this->s_userlanguage=="ZH CN"){$mylanguage = "EN US";$lanuage_logo ="../images/english.jpg";$title="switch to English";} echo "</head>\n"; echo "<body>\n"; $logo1 = ‘<div id="logo"></div>‘; $logo2 = " <div id=\"logo\"> "; $logo2 .= " <form action=language/main.php method=\"post\"> "; $logo2 .= "<input type=\"hidden\" value=\"{$myUserID}\" name=\"user_id\" />"; $logo2 .= " <input type=\"hidden\" value=\"{$mylanguage}\" name=\"lang\" />"; $logo2 .= " <input type=\"image\" src={$lanuage_logo} width=\"45\" title=\"{$title}\" onclick=\"this.submit()\" style=\"position:absolute;right:30px;top:00px\" />"; $logo2 .= "</form>"; $logo2 .= "<a href=‘../‘><img width=\"22\" heigth=\"22\" title=\"Go to console\" src=\"../images/switch.png\" style=\"position:absolute;right:0px;top:00px\"></a> "; $logo2 .= "</div> "; $myhtml = self::FilterXSS($this->s_content); echo str_replace($logo1,$logo2,$myhtml); /* 需要修改的区域 */ //改成上面 if (class_exists(‘DBSearch‘))
============================
在portal/index.php"
只需要修改
case ‘show_ongoing‘: default: $oP->set_title(Dict::S(‘Portal:ShowOngoing‘)); DisplayMainMenu($oP); ShowOngoingTickets($oP); } } } $oP->set_userid(UserRights::GetUserId()); $oP->set_userlanguage(Dict::GetUserLanguage()); $oP->output(); =================================
在portal/index.php 加入
// // Main program // /////////////////////////////////////////////////////////////////////////////// try { require_once(‘popup.php‘); =========================================
popup.php 文件位置与内容
所使用的jquery下载
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>高</b> - 业务服务、系统、网络、应用,影响客户可见<br> - 重要的内部应用且影响到公司层面<br><br> <b>中</b> - 业务服务、系统、网络、应用,影响客户不可见<br> - 重要的内部应用且影响到部门层面<br><br> <b>低</b>- 非关键服务、系统、网络、应用,影响范围小且严重程度低<br> - 影响一个或少数内部员工<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>紧急:已经产生影响</b> <br> <b>高 : 几小时内即将产生影响 </b><br> <b>中 : 可能一周内产生影响</b> <br> <b>低 : 在一周内不会产生影响</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> - 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 <?php require "../../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 <?php function request_post($url, $param) { if (empty($url) || empty($param)) return false; $postUrl = $url; $curlPost = $param; $ch = curl_init(); //初始化curl curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($ch, CURLOPT_URL,$postUrl); //抓取指定网页 curl_setopt($ch, CURLOPT_HEADER, 0); //设置header curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //要求结果为字符串且输出到屏幕上 curl_setopt($ch, CURLOPT_POST, 1); //post提交方式 curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost); $data = curl_exec($ch); //运行curl curl_close($ch); return json_decode($data,true); //把返回的数据转换成json格式 } //检查与itop通信是否正常 function check_itop_network (){ global $aConfig; $url = $aConfig[‘itop_webservice‘]; $get1 = request_post($url,"test"); $get=$get1[‘message‘]; if(!strstr($get,"Missing parameter" )){ echo "与 itop 连接失败!\n"; exit; } } //itop 的 webservice 接口,可以对itop中符合Data Model进行增删改查 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\": $key, \"output_fields\": \"*\", \"fields\": { $fields } , \"comment\": \"\" }"; return request_post($url, $post_data); } #******************************************************************************** # Main #******************************************************************************** require "conf.php"; //检查与itop联络状态 check_itop_network(); //接收用户的ldap_user id $ldap_id = $_POST[‘user_id‘]; //接收用户想要改成什么语言 EN US ,ZH CN $ldap_lang = $_POST[‘lang‘]; $fields="\"language\": \"{$ldap_lang}\""; Action_update(‘UserLDAP‘,$ldap_id,$fields) ; header("Location: ../index.php"); ?>
[email protected]:/var/www/html/itop.new/portal/language#
==============================================
排版修改
[email protected]:/var/www/html$ sudo vim portal/portal.css
78 a.button , a.button:visited { 79 /* line-height: 1.2em; */ 80 color: #FFFFFF; 81 font-size: 1.1em; 82 font-weight: bold; 83 text-decoration: none; 84 display: inline; 85 clear:both; 86 }
可能遇到的问题,
按钮图标不显示:请核对路径,看看图片文件是否存在
时间: 2024-10-12 13:23:45