00024 {
00025 $data =&
getDataInstance();
00026
$db =&
getDbReaderInstance();
00027 $func =
new JuelichFunction;
00028 $l10n = $data->getAppData('l10n');
00029 $mod = $data->getAppData('module');
00030
00031 $sortField = $mod->list['sortDefault'];
00032
if ($data->existsFormvar('sort')) {
00033 $sortField = $data->getFormVar('sort');
00034 }
00035
00036 $modName = $mod->baseName[1];
00037 $start =
$db->getTemplateContent($modName .
"-list-start", $l10n);
00038 $sort = $mod->list['sort'];
00039 $pattern = '/(
id=
"head-%s".*?>)(.*?)(<\/td>)/s';
00040 foreach (array_keys($sort) as $key) {
00041
if ($key != $sortField) {
00042 $pat = sprintf($pattern, $key);
00043
if (preg_match($pat, $start, $match) == 1) {
00044 $replace = $match[1]
00045 .
"\n"
00046 .
"<a href=\"?sort=$key\">"
00047 . ltrim(chop($match[2]))
00048 .
"</a>"
00049 .
"\n"
00050 . $match[3];
00051 $start = preg_replace($pat, $replace, $start);
00052 }
00053 }
00054 }
00055
00056 $sqlPrep =
"SELECT h_name, m_name, p_name, "
00057 .
"produkt.produkt_id, p_preis, %s "
00058 .
"FROM produkt "
00059 .
"LEFT JOIN produkt_l10n USING(produkt_id) "
00060 .
"LEFT JOIN %s USING(produkt_id) "
00061 .
"LEFT JOIN hersteller "
00062 .
"ON produkt.hersteller_id=hersteller.hersteller_id "
00063 .
"LEFT JOIN modell_l10n "
00064 .
"ON produkt.modell_id=modell_l10n.modell_id "
00065 .
"WHERE gruppe_id = %d "
00066 .
"AND produkt_l10n.l10n_id = %d "
00067 .
"AND modell_l10n.l10n_id = %d "
00068 .
"%s " # Weitere Einschränkungen
00069 .
"ORDER BY %s";
00070
$sql = sprintf($sqlPrep,
00071 $mod->list['dataFields'],
00072 $mod->table,
00073 $mod->gruppe_id,
00074 $l10n,
00075 $l10n,
00076 $mod->list['sqlAnd'],
00077 $sort[$sortField]
00078 );
00079
00080 $content = $start;
00081 $colorFlag =
false;
00082 $rowColor = $mod->list['rowColor'];
00083 $listData = $mod->listData;
00084 $tplRow =
$db->getTemplateContent($modName . '-list-row', 0);
00085
00086 $rows = array();
00087
$db->getAllRows($sql, $rows);
00088 foreach ($rows as $row) {
00089 $rowOutput = array();
00090
if ($rowColor) {
00091
if ($colorFlag) {
00092 array_push($rowOutput, ' bgcolor=
"#d0ffd0"');
00093 $colorFlag =
false;
00094 }
00095
else {
00096 array_push($rowOutput, '');
00097 $colorFlag =
true;
00098 }
00099 }
00100 foreach ($listData as $l) {
00101 $v = array();
00102 $tmp = explode(
',', str_replace(
' ', '', $l[0]));
00103 foreach ($tmp as $field) {
00104 array_push($v, $row[$field]);
00105 }
00106 $para =
"";
00107
if (count($l) > 3) {
00108 $para =
$l[3];
00109 }
00110 $value = $func->getValue($l[2], $v, $para);
00111
if (empty($value)) {
00112 $value = ' ';
00113 }
00114
else {
00115
$s = substr($value, strlen($value) - 1);
00116
if (is_numeric($s)) {
00117 $value .=
$l[1];
00118 }
00119 }
00120 array_push($rowOutput, $value);
00121 }
00122 $content .= vsprintf($tplRow, $rowOutput) . $mod->list['rowDivider'];
00123 }
00124 $content .=
$db->getTemplateContent($modName .
"-list-end", $l10n);
00125
return $content;
00126 }