Skip to content

Commit

Permalink
Merge pull request #84 from UB-Mannheim/scrutinizer-patch-1
Browse files Browse the repository at this point in the history
Scrutinizer Auto-Fixes
  • Loading branch information
zuphilip authored Oct 14, 2017
2 parents 1c15607 + 61e6a49 commit 0eba89f
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 36 deletions.
22 changes: 11 additions & 11 deletions isbn/b3kat.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

include 'lib.php';

$id = yaz_connect(B3KAT_URL, array("user" => B3KAT_USER, "password" => B3KAT_PASSWORD));//"mab2; charset=iso5426,utf8"
$id = yaz_connect(B3KAT_URL, array("user" => B3KAT_USER, "password" => B3KAT_PASSWORD)); //"mab2; charset=iso5426,utf8"
yaz_syntax($id, B3KAT_SYNTAX);
yaz_range($id, 1, 10);
yaz_element($id, B3KAT_ELEMENTSET);
Expand All @@ -41,10 +41,10 @@
if (isset($_GET['isbn'])) {
$n = trim($_GET['isbn']);
$nArray = explode(",", $n);
if (count($nArray)>1) {
if (count($nArray) > 1) {
//mehrere ISBNs, z.B. f @or @or @attr 1=7 "9783937219363" @attr 1=7 "9780521369107" @attr 1=7 "9780521518147"
//Anfuehrungsstriche muessen demaskiert werden, egal ob String mit ' gemacht wird
$suchString = str_repeat("@or ", count($nArray)-1) . '@attr 1=7 \"' . implode('\" @attr 1=7 \"', $nArray) . '\"';
$suchString = str_repeat("@or ", count($nArray) - 1) . '@attr 1=7 \"' . implode('\" @attr 1=7 \"', $nArray) . '\"';
yaz_search($id, "rpn", $suchString);
} else {
yaz_search($id, "rpn", '@attr 5=100 @attr 1=7 "' . $n . '"');
Expand All @@ -57,7 +57,7 @@
$error = yaz_error($id);
if (!empty($error)) {
echo "Error Number: " . yaz_errno($id);
echo "Error Description: " . $error ;
echo "Error Description: " . $error;
echo "Additional Error Information: " . yaz_addinfo($id);
}

Expand All @@ -67,23 +67,23 @@


for ($p = 1; $p <= yaz_hits($id); $p++) {
$record = yaz_record($id, $p, "render;charset=iso5426,utf8");//render;charset=iso5426,utf8
$recordArray = explode("\x1e", $record);
$record = yaz_record($id, $p, "render;charset=iso5426,utf8"); //render;charset=iso5426,utf8
$recordArray = explode("\x1e", $record);
$header = substr($recordArray[0], 0, 24);
$recordContent = '<datensatz id="" typ="'.substr($header, 23, 1).'" status="'.substr($header, 5, 1).'" mabVersion="'.substr($header, 6, 4).'">'."\n";
$recordContent = '<datensatz id="" typ="' . substr($header, 23, 1) . '" status="' . substr($header, 5, 1) . '" mabVersion="' . substr($header, 6, 4) . '">' . "\n";
$recordContent .= printLine(substr($recordArray[0], 24));

for ($j = 1; $j < count($recordArray); $j++) {
$recordContent .= printLine($recordArray[$j]);
}

$recordContent .= '</datensatz>'."\n";
$outputString .= $recordContent;
$recordContent .= '</datensatz>' . "\n";
$outputString .= $recordContent;
array_push($outputArray, $recordContent);

}

$outputString .= "</datei>";
$outputString .= "</datei>";
yaz_close($id);

$map = $standardMabMap;
Expand All @@ -93,7 +93,7 @@
header('Content-type: text/xml');
echo $outputString;

} else if ($_GET['format']=='json') {
} else if ($_GET['format'] == 'json') {

$outputXml = simplexml_load_string($outputString);
$outputMap = performMapping($map, $outputXml);
Expand Down
14 changes: 7 additions & 7 deletions isbn/hebis.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
include 'lib.php';

$id = yaz_connect(HEBIS_URL);
yaz_syntax($id, HEBIS_SYNTAX);//
yaz_syntax($id, HEBIS_SYNTAX); //
yaz_range($id, 1, 10);
yaz_element($id, HEBIS_ELEMENTSET); //

Expand All @@ -43,7 +43,7 @@
if (count($nArray) > 1) {
//mehrere ISBNs, z.B. f @or @or @attr 1=7 "9783937219363" @attr 1=7 "9780521369107" @attr 1=7 "9780521518147"
//Anfuehrungsstriche muessen demaskiert werden, egal ob String mit ' gemacht wird
$suchString = str_repeat("@or ", count($nArray)-1) . '@attr 1=7 \"' . implode('\" @attr 1=7 \"', $nArray) . '\"';
$suchString = str_repeat("@or ", count($nArray) - 1) . '@attr 1=7 \"' . implode('\" @attr 1=7 \"', $nArray) . '\"';
yaz_search($id, "rpn", $suchString);
} else {
yaz_search($id, "rpn", '@attr 5=100 @attr 1=7 "' . $n . '"');
Expand All @@ -55,7 +55,7 @@
$error = yaz_error($id);
if (!empty($error)) {
echo "Error Number: " . yaz_errno($id);
echo "Error Description: " . $error ;
echo "Error Description: " . $error;
echo "Additional Error Information: " . yaz_addinfo($id);
}

Expand All @@ -64,13 +64,13 @@
$outputArray = [];

for ($p = 1; $p <= yaz_hits($id); $p++) {
$record = yaz_record($id, $p, "xml");//Umwandlung in XML
$record = yaz_record($id, $p, "xml"); //Umwandlung in XML
//namespace löschen
$record = str_replace('xmlns="http://www.loc.gov/MARC21/slim"', '', $record);
$outputString .= $record;
$outputString .= $record;
array_push($outputArray, $record);
}
$outputString .= "</collection>";
$outputString .= "</collection>";
yaz_close($id);

$map = $standardMarcMap;
Expand All @@ -80,7 +80,7 @@
if (!isset($_GET['format'])) {
header('Content-type: text/xml');
echo $outputString;
} else if ($_GET['format']=='json') {
} else if ($_GET['format'] == 'json') {
$outputXml = simplexml_load_string($outputString);
$outputMap = performMapping($map, $outputXml);
$outputIndividualMap = [];
Expand Down
6 changes: 3 additions & 3 deletions isbn/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,14 +229,14 @@ function printLine($line)
$ind = substr($line, 3, 1);
$inhalt = substr($line, 4);
if (strstr($inhalt, "\x1f")) {
$lineArray = explode("\x1f", $inhalt);
$lineArray = explode("\x1f", $inhalt);
$output .= "<feld nr='$nr' ind='$ind'>\n";
for ($k = 1; $k < count($lineArray); $k++) {
$output .= '<uf code="'.substr($lineArray[$k], 0, 1).'">'.printMabContent(substr($lineArray[$k], 1)).'</uf>'."\n";
$output .= '<uf code="' . substr($lineArray[$k], 0, 1) . '">' . printMabContent(substr($lineArray[$k], 1)) . '</uf>' . "\n";
}
$output .= "</feld>";
} else {
$output .= '<feld nr="'.$nr.'" ind="'.$ind.'">'.printMabContent($inhalt).'</feld>'."\n";
$output .= '<feld nr="' . $nr . '" ind="' . $ind . '">' . printMabContent($inhalt) . '</feld>' . "\n";
}
}
return $output;
Expand Down
20 changes: 10 additions & 10 deletions isbn/man-sru.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,18 @@
@$doc->loadHTML($result);
$xpath = new DOMXPath($doc);

$records = $xpath->query("//records/record/recorddata/record");//beachte: kein CamelCase sondern alles klein schreiben
$records = $xpath->query("//records/record/recorddata/record"); //beachte: kein CamelCase sondern alles klein schreiben

$outputString = "<?xml version=\"1.0\"?>\n";
$outputString .= "<collection>\n";
$outputArray = [];

foreach ($records as $record) {

$outputString .= $doc->saveXML($record);
$outputString .= $doc->saveXML($record);
array_push($outputArray, $doc->saveXML($record));
}
$outputString .= "</collection>";
$outputString .= "</collection>";


$map = $standardMarcMap;
Expand All @@ -82,7 +82,7 @@
if (!isset($_GET['format'])) {
header('Content-type: text/xml');
echo $outputString;
} else if ($_GET['format']=='json') {
} else if ($_GET['format'] == 'json') {
$outputXml = simplexml_load_string($outputString);

$outputMap = performMapping($map, $outputXml);
Expand All @@ -97,7 +97,7 @@

header('Content-type: application/json');
echo json_encode($outputMap, JSON_PRETTY_PRINT);
} else if ($_GET['format']=='holdings') {
} else if ($_GET['format'] == 'holdings') {
echo "<html>\n<head>\n <title>Bestand UB Mannheim zu ISBN-Suche</title>\n <meta http-equiv='content-type' content='text/html; charset=UTF-8' />\n <style type='text/css'>body { font-family: Arial, Verdana, sans-serif; }</style>\n</head>\n<body>\n";
$outputXml = simplexml_load_string($outputString);
$avaNodes = $outputXml->xpath('//datafield[@tag="AVA"]');
Expand Down Expand Up @@ -149,7 +149,7 @@

echo '<div>Bestand der UB Mannheim: ';
foreach ($bestand as $loc => $n) {
echo $n . "x" . $loc . ", ";
echo $n . "x" . $loc . ", ";
}
if ($aveNodes) {
echo "E";
Expand Down Expand Up @@ -177,17 +177,17 @@
echo '<div>Bestand der UB Mannheim: eventuell da (' . $size . ")</div>\n";
echo '<table><tr><td><a href="' . $urlMAN . '" taget="_blank">See SRU Result</a></td></tr></table>';
} else {
$urlSWB='http://swb.bsz-bw.de/DB=2.1/SET=11/TTL=2/CMD?ACT=SRCHM&ACT0=SRCH&IKT0=2135&TRM0=%60180%60&ACT1=*&IKT1=1016&TRM1=' . str_replace(" ", "+", $suchStringSWB);
$urlSWB = 'http://swb.bsz-bw.de/DB=2.1/SET=11/TTL=2/CMD?ACT=SRCHM&ACT0=SRCH&IKT0=2135&TRM0=%60180%60&ACT1=*&IKT1=1016&TRM1=' . str_replace(" ", "+", $suchStringSWB);
$contentSWB = utf8_decode(file_get_contents($urlSWB));
//echo $contentSWB;
if (strpos($contentSWB, "Es wurde nichts gefunden")===false) {
if (strpos($contentSWB, "Es wurde nichts gefunden") === false) {
$nhits = substr_count($contentSWB, 'class="hit"');
if ($nhits !== 0) {//multiple results
$nhits = $nhits/2;
$nhits = $nhits / 2;
} else {//single result
$nhits = substr_count($contentSWB, 'class="Z3988"');
}
echo '<div>Bestand der UB Mannheim: SWB sagt ja (' . $nhits .' Treffer)</div>';
echo '<div>Bestand der UB Mannheim: SWB sagt ja (' . $nhits . ' Treffer)</div>';

} else {
echo 'Es wurde nichts gefunden';
Expand Down
10 changes: 5 additions & 5 deletions isbn/nebis.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
if (count($nArray) > 1) {
//mehrere ISBNs, z.B. f @or @or @attr 1=7 "9783937219363" @attr 1=7 "9780521369107" @attr 1=7 "9780521518147"
//Anfuehrungsstriche muessen demaskiert werden, egal ob String mit ' gemacht wird
$suchString = str_repeat("@or ", count($nArray)-1) . '@attr 1=7 \"' . implode('\" @attr 1=7 \"', $nArray) . '\"';
$suchString = str_repeat("@or ", count($nArray) - 1) . '@attr 1=7 \"' . implode('\" @attr 1=7 \"', $nArray) . '\"';
yaz_search($id, "rpn", $suchString);
} else {
yaz_search($id, "rpn", '@attr 5=100 @attr 1=7 "' . $n . '"');
Expand All @@ -56,7 +56,7 @@
$error = yaz_error($id);
if (!empty($error)) {
echo "Error Number: " . yaz_errno($id);
echo "Error Description: " . $error ;
echo "Error Description: " . $error;
echo "Additional Error Information: " . yaz_addinfo($id);
}

Expand All @@ -68,10 +68,10 @@
$record = yaz_record($id, $p, "xml");
//namespace löschen
$record = str_replace('xmlns="http://www.loc.gov/MARC21/slim"', '', $record);
$outputString .= $record;
$outputString .= $record;
array_push($outputArray, $record);
}
$outputString .= "</collection>";
$outputString .= "</collection>";

yaz_close($id);

Expand All @@ -83,7 +83,7 @@
header('Content-type: text/xml');
echo $outputString;

} else if ($_GET['format']=='json') {
} else if ($_GET['format'] == 'json') {

$outputXml = simplexml_load_string($outputString);
$outputMap = performMapping($map, $outputXml);
Expand Down

0 comments on commit 0eba89f

Please sign in to comment.