Vorlage:Legende: Unterschied zwischen den Versionen
Aus Afterbuy-Wiki
Admin (Diskussion | Beiträge) |
Admin (Diskussion | Beiträge) |
||
(17 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
Zeile 1: | Zeile 1: | ||
− | + | ||
<phptag> | <phptag> | ||
if(is_array($argv) && !empty($argv)){ | if(is_array($argv) && !empty($argv)){ | ||
array_shift( $argv ); | array_shift( $argv ); | ||
+ | $name="Name"; | ||
+ | if(isset($argv['name']) && trim($argv['name'])!=""){ | ||
+ | $name=trim($argv['name']); | ||
+ | } | ||
+ | $description="Beschreibung"; | ||
+ | if(isset($argv['description']) && trim($argv['description'])!=""){ | ||
+ | $description=trim($argv['description']); | ||
+ | } | ||
+ | |||
if(isset($argv[0]) && trim($argv[0])!=""){ | if(isset($argv[0]) && trim($argv[0])!=""){ | ||
+ | |||
+ | $errorMessages=array(); | ||
+ | $out=array( '<table class="table table-hover sortable"><tr><th>'.$name.'</th><th>'.$description.'</th></tr>'); | ||
$lines=explode('>>',$argv[0]); | $lines=explode('>>',$argv[0]); | ||
+ | $row=1; | ||
+ | $mandatory=false; | ||
+ | |||
foreach($lines as $line){ | foreach($lines as $line){ | ||
if(trim($line)!=""){ | if(trim($line)!=""){ | ||
$cells=explode('::',trim($line)); | $cells=explode('::',trim($line)); | ||
− | + | $fieldName=""; | |
+ | if(isset($cells[0]) && trim($cells[0])!=""){ | ||
+ | $fieldName=trim(str_replace('*','<html><span style="color:red;">*</span></html>',$cells[0])); | ||
+ | } else { | ||
+ | $errorMessages[]="Feld Name in Zeile ".$row." nicht gesetzt"; | ||
+ | } | ||
+ | if(strpos($fieldName,'*')!==false){ | ||
+ | $mandatory=true; | ||
+ | } | ||
+ | $fieldDescription=""; | ||
+ | if(isset($cells[1]) && trim($cells[1])!=""){ | ||
+ | $fieldDescription=chr(10).trim($cells[1]); | ||
+ | } else { | ||
+ | $errorMessages[]="Feld Beschreibung in Zeile ".$row." nicht gesetzt"; | ||
+ | } | ||
+ | $out[]='<tr><td class="font-weight-bold" style="width:33%;" align="left">'.$fieldName.'</td><td>'.$fieldDescription.'</td></tr>'; | ||
} | } | ||
+ | $row++; | ||
+ | } | ||
+ | |||
+ | if(isset($errorMessages) && is_array($errorMessages) && !empty($errorMessages)){ | ||
+ | echo '{{Warnung|Fehler in Legende: <br />'.implode('<br />',$errorMessages).'}}'; | ||
+ | } | ||
+ | |||
+ | if(isset($out) && is_array($out) && !empty($out)){ | ||
+ | echo implode('',$out).'</table>'; | ||
} | } | ||
+ | if($mandatory){ | ||
+ | echo '{{Info| Die mit <html><span style="color:red;">*</span></html> markierten Felder sind verpflichtende Angaben}}'; | ||
+ | } | ||
+ | |||
} | } | ||
} | } | ||
</phptag> | </phptag> | ||
− |
Aktuelle Version vom 27. Juli 2021, 14:03 Uhr