Valides HTML auch bei Datenpflege im xt:Commerce Admin-Bereich
In xt:Commerce wurde wenig Wert auf valides HTML gelegt, wie die Online-Prüfung der meisten xt:Commerce-Shops belegt.
Gleichwohl ist es möglich, mit xt:Commerce valides HTML zu erzeugen, wie unsere eigene Seite purador zeigt. Dahinter steckt allerdings ein beträchtlicher Aufwand.
Ärgerlich ist es, dass bei der Datenpflege im Admin-Bereich valides HTML “zerschossen” wird, wenn man z. B. im Content-Manager Text pflegt, der die HTML-Umschreibung für das Kaufmannsund & enthält. Diese Umschreibung ist für valides HTML unabdingbar, wird aber beim erneuten Bearbeiten des Textes durch ein reines & erstetzt. Und damit ist das valide HTML futsch.
Der Effekt tritt nach meinem Kenntnisstand nur bei mehrzeiligen Eingabefeldern auf, den sog. textareas. Und das auch, wenn man ausschließlich im Quelltexteditor arbeitet.
Abhilfe schafft ein kleiner Eingriff in die Datei html_output.php im Verzeichnis /admin/includes/functions:
Originale xtc-Datei html_output.php
// Output a form textarea field
function xtc_draw_textarea_field($name, $wrap, $width, $height, $text = '', $params = '', $reinsert_value = true) {
$field = '<textarea id="'.$name.'" name="' . $name . '" wrap="' . $wrap . '" cols="' . $width . '" rows="' . $height . '"';
if ($params) $field .= ' ' . $params;
$field .= '>';
if ( ($GLOBALS[$name]) && ($reinsert_value) ) {
$field .= $GLOBALS[$name];
} elseif ($text != '') {
$field .= $text;
}
$field .= '</textarea>';
return $field;
}
Angepasste xtc-Datei html_output.php
// Output a form textarea field
function xtc_draw_textarea_field($name, $wrap, $width, $height, $text = '', $params = '', $reinsert_value = true) {
$field = '<textarea id="'.$name.'" name="' . $name . '" wrap="' . $wrap . '" cols="' . $width . '" rows="' . $height . '"';
if ($params) $field .= ' ' . $params;
$field .= '>';
if ( ($GLOBALS[$name]) && ($reinsert_value) ) {
$field .= str_replace('&', '&', $GLOBALS[$name]); // xxx
} elseif ($text != '') {
$field .= str_replace('&', '&', $text); // xxx
}
$field .= '</textarea>';
return $field;
}
Es wurden nur die zwei Zeilen mit xxx verändert.
Nachtrag am 12.3.2008: Der obige Patch führt im Admin-Bereich unter Konfiguration -> Mein Shop -> Geschäftsadresse und Telefonnummer zu HTML-Mischmasch. Auch dazu habe ich einen Workaround geschrieben:
Original /admin/configuration.php:
if ($configuration['set_function']) {
eval('$value_field = ' . $configuration['set_function'] . '"' . htmlspecialchars($configuration['configuration_value']) . '");');
} else {
$value_field = xtc_draw_input_field($configuration['configuration_key'], $configuration['configuration_value'],'size=40');
}
Workaround (Patch):
if ($configuration['set_function']) {
// Patch start
if ($configuration['configuration_key'] != 'STORE_NAME_ADDRESS')
eval('$value_field = ' . $configuration['set_function'] . '"' . htmlspecialchars($configuration['configuration_value']) . '");');
else
eval('$value_field = ' . $configuration['set_function'] . '"' . $configuration['configuration_value'] . '");');
// Patch end
} else {
$value_field = xtc_draw_input_field($configuration['configuration_key'], $configuration['configuration_value'],'size=40');
}




Zu diesem Thema gibt es einen Thread im Forum von Traum-Projekt.