retrieve SAP notes
This commit is contained in:
@@ -694,6 +694,13 @@ class Databap extends PhpObject
|
||||
@$oDom->loadHTML(file_get_contents($sUrl));
|
||||
return $oDom->getElementsByTagName('body')->item(0);
|
||||
}
|
||||
|
||||
public function getNote($iNote)
|
||||
{
|
||||
$this->oClassManagement->incClass('note');
|
||||
$oNote = new Note($iNote);
|
||||
return $oNote->getNote();
|
||||
}
|
||||
|
||||
public function addUser($sFirstName, $sLastName, $sCompany, $sEmail='', $iClearance=self::CLEARANCE_MEMBER)
|
||||
{
|
||||
|
||||
114
inc/note.php
Normal file
114
inc/note.php
Normal file
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
class Note extends PhpObject
|
||||
{
|
||||
private $sNote;
|
||||
private $sUrl;
|
||||
private $sCookie;
|
||||
|
||||
function __construct($sNote)
|
||||
{
|
||||
parent::__construct(__CLASS__, Settings::DEBUG);
|
||||
$this->sNote = $sNote;
|
||||
$this->sUrl = '';
|
||||
$this->sCookie = '';
|
||||
}
|
||||
|
||||
public function getNote()
|
||||
{
|
||||
$sContent = '';
|
||||
if($this->sNote!='')
|
||||
{
|
||||
$this->sUrl = 'http://service.sap.com/sap/support/notes/'.$this->sNote;
|
||||
$this->getPageRecursive();
|
||||
$sSapPath = substr($this->sUrl, 0, strpos($this->sUrl, '/bc/bsp/sno/ui_entry/entry.htm'));
|
||||
$sFirstDir = substr($sSapPath, strpos($sSapPath, 'sap('));
|
||||
$this->sUrl = $sSapPath.'/bc/bsp/sno/ui/main.do'.strstr($this->sUrl, '?param=');
|
||||
|
||||
$sDomain = self::getDomain($this->sUrl);
|
||||
$sDomain = $sDomain.(substr($sDomain, -1)=='/'?'':'/');
|
||||
|
||||
$sContent = $this->getPage();
|
||||
$sContent = preg_replace('`(src|href|action|popup_emptydoc|emptyhoverurl|mimepath|stylepath)(\=|\:)\"(.*)\"`mUi', '$1$2"'.$sDomain.'$3"', $sContent);
|
||||
$sContent = preg_replace('`(src|href|action|popup_emptydoc|emptyhoverurl|mimepath|stylepath)(\=|\:)\\\'(.*)\\\'`mUi', '$1$2"'.$sDomain.'$3"', $sContent);
|
||||
$sContent = preg_replace('`url\((.*)\)`mUi', 'url('.$sDomain.'$1)"', $sContent);
|
||||
$sContent = str_replace('.sap-ag.de//', '.sap-ag.de/', $sContent);
|
||||
$sContent = str_replace('.sap-ag.de/1x1', '.sap-ag.de/'.$sFirstDir.'/bc/bsp/sno/ui/1x1', $sContent);
|
||||
$sContent = str_replace("url = '/sap/support/notes/'", "url = '".$sDomain."sap/support/notes/'", $sContent);
|
||||
|
||||
//$sContent = str_replace('domainrelaxing:sapUrDomainRelaxing.NONE', 'domainrelaxing:sapUrDomainRelaxing.MAXIMAL', $sContent);
|
||||
|
||||
//Add customized javascript function
|
||||
$sPre = '<script>window.onresize = setHeight;';
|
||||
$sPost = '</script>';
|
||||
$sInsert = ' parent.onEndOfProcess();';
|
||||
$sContent = str_replace($sPre.$sPost, $sPre.$sInsert.$sPost, $sContent);
|
||||
|
||||
//Deleting auto resize
|
||||
//$sContent = str_replace('lv_diff = 210','lv_diff = 0', $sContent);
|
||||
$sContent = str_replace(array('setHeight();', 'window.onresize = setHeight; '), '', $sContent);
|
||||
|
||||
}
|
||||
else $this->addError('Empty note number');
|
||||
|
||||
return $sContent;
|
||||
}
|
||||
|
||||
private function getPage($bHeader=false)
|
||||
{
|
||||
$oCurl = curl_init();
|
||||
curl_setopt($oCurl, CURLOPT_URL, $this->sUrl);
|
||||
curl_setopt($oCurl, CURLOPT_HEADER, $bHeader);
|
||||
curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($oCurl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
|
||||
//if($bHeader) curl_setopt($oCurl, CURLOPT_FOLLOWLOCATION, true);
|
||||
if($this->sCookie!='') curl_setopt($oCurl, CURLOPT_COOKIE, $this->sCookie);
|
||||
curl_setopt($oCurl, CURLOPT_USERPWD, $this->getCredentials());
|
||||
$sContent = curl_exec($oCurl);
|
||||
curl_close($oCurl);
|
||||
return $sContent;
|
||||
}
|
||||
|
||||
private function getPageRecursive()
|
||||
{
|
||||
$sheader = $this->getPage(true);
|
||||
$asLines = explode("\n", $sheader);
|
||||
foreach($asLines as $sLine) $asInfo[strtolower(strstr($sLine, ':', true))] = trim(substr(strstr($sLine, ':'), 1));
|
||||
|
||||
if(array_key_exists('set-cookie', $asInfo)) $this->parseSetCookie($asInfo['set-cookie']);
|
||||
|
||||
$bToBeContinued = array_key_exists('location', $asInfo);
|
||||
if($bToBeContinued)
|
||||
{
|
||||
$this->sUrl = ((substr($asInfo['location'], 0, 4)!='http')?self::getDomain($this->sUrl):'').$asInfo['location'];
|
||||
return $this->getPageRecursive();
|
||||
}
|
||||
else return substr($sheader, strpos($sheader, '<html>'));
|
||||
}
|
||||
|
||||
private function parseSetCookie($sCookie)
|
||||
{
|
||||
//Store current cookie
|
||||
$this->sCookie .= $sCookie;
|
||||
|
||||
//Parse FIXME
|
||||
$asCookieInfo = explode('; ', $sCookie);
|
||||
foreach($asCookieInfo as $sCookieInfo) $asCookie[strstr($sCookieInfo, '=', true)] = substr(strstr($sCookieInfo, '='), 1);
|
||||
setcookie('sap-appcontext', $asCookie['sap-appcontext'], time()+3600, $asCookie['path']);
|
||||
}
|
||||
|
||||
private function getCredentials()
|
||||
{
|
||||
$asLogins = array_keys(Settings::$OSS_ACCOUNTS);
|
||||
$iIndex = rand(0, count($asLogins)-1);
|
||||
return $asLogins[$iIndex].':'.Settings::$OSS_ACCOUNTS[$asLogins[$iIndex]];
|
||||
}
|
||||
|
||||
private static function getDomain($sUrl)
|
||||
{
|
||||
$asUrl = parse_url($sUrl);
|
||||
return $asUrl['scheme'].'://'.$asUrl['host'];
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -176,6 +176,9 @@ if($bUserOk && $sAction!=Databap::EXT_ACCESS)
|
||||
case 'list':
|
||||
$sResult = $oDatabap->getItemList();
|
||||
break;
|
||||
case 'note':
|
||||
$sResult = $oDatabap->getNote($oItemId);
|
||||
break;
|
||||
case 'css':
|
||||
$sResult = $oDatabap->getStyleSheet();
|
||||
break;
|
||||
|
||||
4
jquery/databap.js
vendored
4
jquery/databap.js
vendored
@@ -344,8 +344,8 @@ function Databap()
|
||||
|
||||
this.transition = function(fOnFinish)
|
||||
{
|
||||
if(self.vars2('fade')) fOnFinish();
|
||||
else $.when(self.$main.add(self.$title).stop().fadeTo(self.consts.transTime, 0)).done(fOnFinish);
|
||||
if(self.vars2('fade')) $.when(self.$main.add(self.$title).stop().fadeTo(self.consts.transTime, 0)).done(fOnFinish);
|
||||
else fOnFinish();
|
||||
self.vars2('fade', false);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,9 +1,43 @@
|
||||
<div id="article">
|
||||
<p class="loading_box step_box round"><i class="fa fa-60 fa-inline fa-spin fa-c-loading"></i>La note est en cours de chargement...</p>
|
||||
<div id="note">
|
||||
<!-- <p class="loading_box step_box round"><i class="fa fa-60 fa-inline fa-spin fa-c-loading"></i>La note est en cours de chargement...</p> -->
|
||||
<form id="note_form">
|
||||
<input type="text" id="note_id" class="round" />
|
||||
</form>
|
||||
<iframe id="note_frame" class="round" src=""></iframe>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
databap.pageInit = function()
|
||||
{
|
||||
self.goToExternalLink('http://service.sap.com/sap/support/notes/'+self.vars.id);
|
||||
databap.tmp('note', 'integer');
|
||||
|
||||
//Add note selection form
|
||||
$('#note_id').addDefaultValue('N° note');
|
||||
$('#note_form')
|
||||
.addButton('ok', 'Ok', $('#note_form').submit, 'submit', 'heavy')
|
||||
.submit(function(){databap.goToInternalLink('note', $('#note_id').val())});
|
||||
|
||||
$('#note_frame').css('height', 'calc(100% - '+($('#note_form').outerHeight()+14)+'px)');
|
||||
|
||||
//Start fetching note
|
||||
var iNote = databap.vars.id;
|
||||
if(isNumeric(iNote) && iNote > 0 && iNote!=databap.tmp('note'))
|
||||
{
|
||||
$('#note_id').val(iNote).focus();
|
||||
self.addBufferIcon();
|
||||
$('#note_frame').attr('src', 'index.php?a=note&id='+iNote);
|
||||
databap.tmp('note', iNote);
|
||||
}
|
||||
}
|
||||
|
||||
function onEndOfProcess()
|
||||
{
|
||||
databap.resetIcon();
|
||||
var $Frame = $('#note_frame').contents().find('body').css({'margin':0, 'width':'calc(100% - 6px)'});
|
||||
var $Form = $Frame.find('#htmlb_form_1').css('margin-bottom', 0);
|
||||
var $Rows = $Form.children('table').eq(2).find('tbody').children();
|
||||
|
||||
$Rows.filter(':lt(2), :eq(3)').add('#htmlb_form_2').hide();
|
||||
|
||||
$Frame.find('#Display_Group').height('+=200px');
|
||||
}
|
||||
</script>
|
||||
@@ -2692,8 +2692,29 @@ a.uploader_item_cancel {
|
||||
color: #04357B;
|
||||
margin-top: 25px; }
|
||||
|
||||
/* Debug*/
|
||||
/* Note */
|
||||
/* line 1326, databap.scss */
|
||||
#note {
|
||||
height: 100%; }
|
||||
|
||||
/* line 1330, databap.scss */
|
||||
#note_frame {
|
||||
width: calc(100% - 4px);
|
||||
height: calc(100% - 4px);
|
||||
border: 2px solid #04357B;
|
||||
margin: 0;
|
||||
overflow: hidden; }
|
||||
|
||||
/* line 1338, databap.scss */
|
||||
#note_form {
|
||||
margin-bottom: 10px; }
|
||||
|
||||
/* line 1342, databap.scss */
|
||||
#note_form a.button {
|
||||
padding: 5px 7px; }
|
||||
|
||||
/* Debug*/
|
||||
/* line 1348, databap.scss */
|
||||
.line_h {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
@@ -2702,7 +2723,7 @@ a.uploader_item_cancel {
|
||||
border-bottom: 1px solid red;
|
||||
z-index: 1000; }
|
||||
|
||||
/* line 1334, databap.scss */
|
||||
/* line 1356, databap.scss */
|
||||
.line_v {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
@@ -2711,4 +2732,4 @@ a.uploader_item_cancel {
|
||||
border-left: 1px solid red;
|
||||
z-index: 1000; }
|
||||
|
||||
/*# sourceMappingURL=databap.css.map */
|
||||
/*# sourceMappingURL=style/databap.css.map */
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1321,6 +1321,28 @@
|
||||
margin-top:25px;
|
||||
}
|
||||
|
||||
/* Note */
|
||||
|
||||
#note {
|
||||
height:100%;
|
||||
}
|
||||
|
||||
#note_frame {
|
||||
width:calc(100% - 4px);
|
||||
height:calc(100% - 4px);
|
||||
border: 2px solid $col_blue;
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#note_form {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
#note_form a.button {
|
||||
padding:5px 7px;
|
||||
}
|
||||
|
||||
/* Debug*/
|
||||
|
||||
.line_h {
|
||||
|
||||
7
todo
7
todo
@@ -9,8 +9,9 @@ Internal:
|
||||
- Créer un fichier de testing
|
||||
|
||||
Bug fix:
|
||||
- [1.0.1] Check le document type plutot que l'extension pour les /img
|
||||
- [1.0.1] Resize .gif
|
||||
- [1.0.1] Fix unread messages
|
||||
- [1.0.2] Check le document type plutot que l'extension pour les /img
|
||||
- [1.0.2] Resize .gif
|
||||
- Fix les "xxx se déconnecte" intempestives
|
||||
- code reader : mettre la scrollbar à l'intérieur du code
|
||||
- Trouver une meilleure place pour le menu
|
||||
@@ -38,7 +39,7 @@ EHP 1
|
||||
-----
|
||||
|
||||
- Interface menu modifié
|
||||
- Ajout des notes aux liens dynamiques. Par exemple : note 1622681 => lien vers http://service.sap.com/sap/support/notes/1622681
|
||||
- Ajout des notes sans authentification : #note-<num>
|
||||
|
||||
Testing
|
||||
-------
|
||||
|
||||
Reference in New Issue
Block a user