Made minor clean-up
This commit is contained in:
parent
1eb21bfc54
commit
326265a646
|
@ -81,20 +81,12 @@ if ($error != 0) echo '<br><b style="color:#990000;">Not allowed tags found !</b
|
||||||
echo '<br><br>2: Not allowed multiple use of tags (column names)?';
|
echo '<br><br>2: Not allowed multiple use of tags (column names)?';
|
||||||
$compare = array_unique($zeile);
|
$compare = array_unique($zeile);
|
||||||
|
|
||||||
function identical_values($arrayA, $arrayB) {
|
|
||||||
sort($arrayA);
|
|
||||||
sort($arrayB);
|
|
||||||
return $arrayA == $arrayB;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = identical_values($zeile, $compare);
|
$result = identical_values($zeile, $compare);
|
||||||
if ($result == false) {
|
if ($result == false) {
|
||||||
echo '<br><b style="color:#990000;">There are dublicate column names !</b>';
|
echo '<br><b style="color:#990000;">There are dublicate column names !</b>';
|
||||||
$error = $error + 1;
|
$error = $error + 1;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
echo '<br><i style="font-style:normal;color:#009900;">No dublicate column names !</i>';
|
echo '<br><i style="font-style:normal;color:#009900;">No dublicate column names !</i>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,12 +94,10 @@ else
|
||||||
//// Get values into memory for following checks
|
//// Get values into memory for following checks
|
||||||
$fp = fopen ( $csv_datei, 'r' );
|
$fp = fopen ( $csv_datei, 'r' );
|
||||||
$y = 0;
|
$y = 0;
|
||||||
while ( $zeile = fgetcsv ( $fp, 100000, ';' ) )
|
while ($zeile = fgetcsv($fp, 100000, ';')) {
|
||||||
{
|
|
||||||
$y++;
|
$y++;
|
||||||
//echo '<br>';print_r($zeile);
|
for ($x = 0; $x < count ( $zeile ); $x++) {
|
||||||
for ($x = 0; $x < count ( $zeile ); $x++)
|
|
||||||
{
|
|
||||||
$inhalt[$y][$x] = str_replace("'", "\'", $zeile[$x]);
|
$inhalt[$y][$x] = str_replace("'", "\'", $zeile[$x]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,25 +108,21 @@ echo '<br><br>3: Mandatory tags available and always filled in?';
|
||||||
unset($inv_array);
|
unset($inv_array);
|
||||||
$inv_error = 0;
|
$inv_error = 0;
|
||||||
|
|
||||||
function get_duplicates($array)
|
function get_duplicates($array) {
|
||||||
{
|
|
||||||
return array_unique( array_diff_assoc( $array, array_unique( $array ) ) );
|
return array_unique( array_diff_assoc( $array, array_unique( $array ) ) );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$mandatory = array('inventory_number','object_type','object_title','object_description');
|
$mandatory = array('inventory_number','object_type','object_title','object_description');
|
||||||
for ($i = 0; $i < count ($mandatory); $i++)
|
for ($i = 0; $i < count($mandatory); $i++) {
|
||||||
{
|
|
||||||
if (!in_array($mandatory[$i], $erstezeile)) {
|
if (!in_array($mandatory[$i], $erstezeile)) {
|
||||||
echo '<br><i style="font-style:normal;color:#990000;">Mandatory: Column <b>' . $mandatory[$i] . '</b> missing</i>';
|
echo '<br><i style="font-style:normal;color:#990000;">Mandatory: Column <b>' . $mandatory[$i] . '</b> missing</i>';
|
||||||
$error = $error + 1;
|
$error = $error + 1;
|
||||||
$inv_error = $inv_error + 1;
|
$inv_error = $inv_error + 1;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
$spaltenr = array_search($mandatory[$i], $erstezeile);
|
$spaltenr = array_search($mandatory[$i], $erstezeile);
|
||||||
for ($j = 0; $j < $y; $j++)
|
for ($j = 0; $j < $y; $j++) {
|
||||||
{
|
|
||||||
if ($inhalt[$j + 1][$spaltenr] == '') {
|
if ($inhalt[$j + 1][$spaltenr] == '') {
|
||||||
echo '<br><i style="font-style:normal;color:#990000;">Missing value for <b>' . $mandatory[$i] . '</b> in row ' . ($j + 1) . '</i>';
|
echo '<br><i style="font-style:normal;color:#990000;">Missing value for <b>' . $mandatory[$i] . '</b> in row ' . ($j + 1) . '</i>';
|
||||||
$error = $error + 1;
|
$error = $error + 1;
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
<?PHP
|
<?PHP
|
||||||
/**
|
/**
|
||||||
* Generic collection of functions used in CSVXML.
|
* Generic collection of functions used in CSVXML.
|
||||||
|
*
|
||||||
|
* @file
|
||||||
|
*
|
||||||
|
* @author
|
||||||
*/
|
*/
|
||||||
declare(strict_types = 1);
|
declare(strict_types = 1);
|
||||||
|
|
||||||
|
@ -164,9 +168,9 @@ function generateHelpTooltip(string $identifier, string $title, string $explica,
|
||||||
*
|
*
|
||||||
* @param DOMDocument $xmlDoc XML object.
|
* @param DOMDocument $xmlDoc XML object.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return string
|
||||||
*/
|
*/
|
||||||
function printDOMDocToXML(DOMDocument $xmlDoc) {
|
function printDOMDocToXML(DOMDocument $xmlDoc):string {
|
||||||
|
|
||||||
return '<?xml version="1.0" encoding="UTF-8"?>' . $xmlDoc->saveXML($xmlDoc->documentElement);
|
return '<?xml version="1.0" encoding="UTF-8"?>' . $xmlDoc->saveXML($xmlDoc->documentElement);
|
||||||
|
|
||||||
|
@ -187,9 +191,8 @@ function createTextDomElement(DOMDocument $xmlDoc, string $tag, string $content)
|
||||||
$element = $xmlDoc->createElement($tag);
|
$element = $xmlDoc->createElement($tag);
|
||||||
}
|
}
|
||||||
catch (DOMException $e) {
|
catch (DOMException $e) {
|
||||||
print_r($e);
|
echo "Error at " . __FILE__ . ", line #" . __LINE__;
|
||||||
print_r($tag);
|
exit;
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$element->appendChild($xmlDoc->createTextNode($content));
|
$element->appendChild($xmlDoc->createTextNode($content));
|
||||||
|
@ -213,7 +216,14 @@ function getBlankRecordChannel():array {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function rrmdir($dir) {
|
/**
|
||||||
|
* Function for removing a directory with all its contents.
|
||||||
|
*
|
||||||
|
* @param string $dir File path of the directory to remove.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function rrmdir(string $dir) {
|
||||||
if (is_dir($dir)) {
|
if (is_dir($dir)) {
|
||||||
$objects = scandir($dir);
|
$objects = scandir($dir);
|
||||||
foreach ($objects as $object) {
|
foreach ($objects as $object) {
|
||||||
|
@ -226,3 +236,18 @@ function rrmdir($dir) {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function for checking if two arrays have identical values / contents.
|
||||||
|
*
|
||||||
|
* @param array $arrayA First array to compare.
|
||||||
|
* @param array $arrayB Second array to compare.
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
function identical_values(array $arrayA, array $arrayB):bool {
|
||||||
|
sort($arrayA);
|
||||||
|
sort($arrayB);
|
||||||
|
return $arrayA == $arrayB;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user