diff --git a/csv_check.php b/csv_check.php
index 4be0060..8680dfe 100644
--- a/csv_check.php
+++ b/csv_check.php
@@ -200,7 +200,7 @@ $crosscheck1 = ['object_other_title','detailed_description','detailed_descriptio
$crosscheck2 = ['object_other_title_kind_of','detailed_description_md','detailed_description_extern','inscription_md','inscription_extern','dimensions_separate_length_unit', 'dimensions_separate_width_unit', 'dimensions_separate_height_unit', 'dimensions_separate_diameter_unit', 'dimensions_separate_wall_thickness_unit', 'dimensions_separate_weight_unit','closer_location_as','bought_for_currency','worth_unit','worth_insurance_unit'];
$depcon_error = 0;
-foreach ($crosscheck1 as $tCrossCheck) {
+foreach ($crosscheck1 as $l => $tCrossCheck) {
if (in_array($tCrossCheck, $erstezeile)) {
@@ -215,11 +215,11 @@ foreach ($crosscheck1 as $tCrossCheck) {
}
-for ($l = 0; $l < count($eventpart); $l++) {
- if (in_array($eventpart[$l], $erstezeile)) {
+foreach ($eventpart as $l => $tEventPart) {
+ if (in_array($tEventPart, $erstezeile)) {
for ($j = 1; $j < ($y + 1); $j++) {
- if ($inhalt[$j][array_search($eventpartsure[$l], $erstezeile)] !== '' and $inhalt[$j][array_search($eventpart[$l], $erstezeile)] == '') {
- echo '
Tag ' . $eventpartsure[$l] . ' given but no entry for ' . $eventpart[$l] . ' (row ' . $j . ')';
+ if ($inhalt[$j][array_search($eventpartsure[$l], $erstezeile)] !== '' and $inhalt[$j][array_search($tEventPart, $erstezeile)] == '') {
+ echo '
Tag ' . $eventpartsure[$l] . ' given but no entry for ' . $tEventPart . ' (row ' . $j . ')';
$depcon_error++;
}
}
@@ -227,8 +227,7 @@ for ($l = 0; $l < count($eventpart); $l++) {
}
if (in_array('dimensions_separate_show_md', $erstezeile)) {
- for ($j = 1; $j < ($y + 1); $j++)
- {
+ for ($j = 1; $j < ($y + 1); $j++) {
if ($inhalt[$j][array_search('dimensions_separate_show_md', $erstezeile)] !== '' and ($inhalt[$j][array_search('dimensions_separate_length_value', $erstezeile)] == '') and $inhalt[$j][array_search('dimensions_separate_width_value', $erstezeile)] == '' and $inhalt[$j][array_search('dimensions_separate_heigt_value', $erstezeile)] == '' and $inhalt[$j][array_search('dimensions_separate_weight_value', $erstezeile)] == '' and $inhalt[$j][array_search('dimensions_separate_diameter_value', $erstezeile)] == '' and $inhalt[$j][array_search('dimensions_separate_wall_thickness_value', $erstezeile)] == '') {
echo '
Tag dimensions_separate_show_md given but no separate values available (row ' . $j . ')';
$depcon_error = $depcon_error + 1;
@@ -305,13 +304,12 @@ for ($i = 2; $i <= $y; $i++) {
if (isset($errormessage) and $errormessage != '') {
echo 'Columns with controlled values contain invalid values !';
- for ($i = 0; $i < count ($errormessage); $i++) {
- echo '
' . $errormessage[$i];
- $error = $error + 1;
+ foreach ($errormessage as $tMsg) {
+ echo '
' . $tMsg;
+ $error++;
}
}
-else
-{
+else {
echo 'Values in controlled fields are all valid !';
}
@@ -332,36 +330,35 @@ if ($hasanyimage > 0) {
for ($i = 1; $i <= $y; $i++)
{
if ($i > 1) {
- $maimg[$i] = 0;
//check if in a row any image_name is given
- $hatimg[$i] = 0;
- for ($im = 0; $im < count($imagemain); $im++)
- {
- if ($inhalt[$i][$imagemain[$im]['name']] != '') $hatimg[$i]++;
+ $maimg = $hatimg = 0;
+ foreach ($imagemain as $im => $tMainImage) {
+ if ($inhalt[$i][$tMainImage] != '') $hatimg++;
}
- if ($hatimg[$i] > 0) {
+ if ($hatimg > 0) {
// first check: how many main-images?
- for ($im = 0; $im < count($imagemain); $im++)
- {
- if ($inhalt[$i][$imagemain[$im]['main']] == 'y') {$maimg[$i]++;$merk = $im;
+ foreach ($imagemain as $im => $tMainImage) {
+ if ($inhalt[$i][$imagemain[$im]['main']] == 'y') {
+ $maimg++;
+ $merk = $im;
}
}
// if there is exacly one main-image, is it visible?
- if ($maimg[$i] == 1) {
+ if ($maimg == 1) {
if ($inhalt[$i][$imagemain[$merk]['visible']] == 'n') {
$errormessage[] = 'Main image in row ' . $i . ' is not visible';
}
}
}
+ if ($maimg == 0 and $hatimg > 0) $errormessage[] = 'There is no visible main image given in row ' . $i . '';
+ if ($maimg > 1 and $hatimg > 0) $errormessage[] = 'There are ' . $maimg . ' main images given in row ' . $i . '';
}
- if ($i > 1 and $maimg[$i] == 0 and $hatimg[$i] > 0) $errormessage[] = 'There is no visible main image given in row ' . $i . '';
- if ($i > 1 and $maimg[$i] > 1 and $hatimg[$i] > 0) $errormessage[] = 'There are ' . $maimg[$i] . ' main images given in row ' . $i . '';
}
- if (isset($errormessage) and $errormessage != '') {
+ if (!empty($errormessage)) {
echo 'There is not one main image for each object !';
- for ($i = 0; $i < count($errormessage); $i++) {
- echo '
' . $errormessage[$i];
+ foreach ($errormessage as $tMsg) {
+ echo '
' . $tMsg;
$error++;
}
}