00001 <?php
00002 require_once
TM_PATH . 'constants.php';
00003 require_once
TM_PATH . 'juelich/JuelichGlobals.php';
00004 require_once
TM_PATH . 'juelich/lib/
JuelichString.php';
00005
00016 class JuelichFunction {
00017
00018 var
$str;
00019 var
$data;
00020 var
$shortList =
true;
00021 var
$pId = 0;
00023 function
JuelichFunction() {
00024 $this->str =
new JuelichString;
00025 $this->data =&
getDataInstance();
00026
if ($this->data->getAppData('mode') ==
M_DETAIL ||
00027 $this->data->getAppData('mode') ==
M_DETAIL2 ||
00028 $this->data->getAppData('mode') ==
M_INCLUSION) {
00029 $this->shortList =
false;
00030 }
00031 }
00032
00041 function
getModuleDataValues(&$row, $pId) {
00042 $this->pId =
$pId;
00043 $mData = $this->data->getAppData('module')->webData;
00044 $l10n = $this->data->getAppData('l10n');
00045 $content =
"";
00046 foreach ($mData as $d) {
00047
if (!$d[0] && $this->shortList) {
00048
continue;
00049 }
00050 $v = array();
00051 $tmp = explode(
',', str_replace(
' ', '', $d[1]));
00052 foreach ($tmp as $field) {
00053
if ($this->data->getAppData('dependDetail')) {
00054 $pFields = $this->data->getAppData('module')->depend['primaryFields'];
00055 $prim = explode(
',', str_replace(
' ', '', $pFields));
00056
if (in_array($field, $prim)) {
00057 $field = 'prim_' . $field;
00058 }
00059 }
00060 array_push($v, $row[$field]);
00061 }
00062 $para =
"";
00063
if (count($d) > 7) {
00064 $para = $d[7];
00065 }
00066 $value = $this->
getValue($d[6], $v, $para);
00067
if (!empty($value)) {
00068 $content .= $d[2 + $l10n - 1]
00069 . ': '
00070 . $value;
00071
$s = strlen($value);
00072
if (is_numeric($value[$s - 1])) {
00073 $content .= $d[5];
00074 }
00075 $content .=
"<br>\n";
00076 }
00077 }
00078
return $content;
00079 }
00080
00088 function
getProductDataValues(&$row) {
00089 $d = array();
00090 $d['name'] = $this->
getValue(
F_PN, $row['p_name']);
00091 $img = $this->
getValue(
F_IMG_SHORT, array($row['p_bild'],
00092 'ps',
00093 $row['produkt_id'],
00094 $d['name']));
00095 $d['imageLink'] =
"<a href=\"./"
00096 . $this->
getValue(
F_LD, array($row['produkt_id'], $d['name']))
00097 .
"\">$img</a>";
00098 $d['text'] = $this->
getValue(
F_TS, $row['p_besch2']);
00099 $d['detailLink'] = $this->
getValue(
F_LD2, array($row['produkt_id'],
00100 $d['name'])
00101 );
00102 $d['price'] = $this->
getValue(
F_FP, $row['p_preis']);
00103
return $d;
00104 }
00105
00113 function
getProductDataDetailValues(&$row) {
00114 $d = array();
00115 $d['name'] = $this->
getValue(
F_PN, $row['p_name']);
00116 $d['image'] = $this->
getValue(
F_IMG, array($row['p_bild'],
00117
'p',
00118 $row['produkt_id'],
00119 $d['name']));
00120 $d['text'] = $this->
getValue(
F_NL2BR, array($row['p_besch1'],
00121 $row['p_besch2']));
00122 $d['price'] = $this->
getValue(
F_FP, $row['p_preis']);
00123
return $d;
00124 }
00125
00133 function
getAccessDataValues(&$row) {
00134 $sData = $this->
scanInternalField($row['z_intern']);
00135 $d = array();
00136 $d['name'] = $row['z_name'];
00137
if (!empty($sData['link'])) {
00138 $l10n =
getDataInstance()->getAppData('l10n');
00139 $d['detailLink'] = $sData['link'][$l10n - 1];
00140 }
00141
else {
00142 $d['detailLink'] = $this->
getValue(
F_LD,
00143 array(
'z' . $row['zubehoer_id'],
00144 $d['name'])
00145 );
00146 }
00147 $d['price'] = $this->
getValue(
F_FP, $row['z_preis']);
00148
if (!empty($sData['pAppend'])) {
00149 $l10n =
getDataInstance()->getAppData('l10n');
00150 $d['price'] .= $sData['pAppend'][$l10n - 1];
00151 }
00152
return $d;
00153 }
00154
00162 function
getAccessDataDetailValues(&$row) {
00163 $d = array();
00164 $d['name'] = $this->
getValue(
F_PN, $row['z_name']);
00165 $d['image'] = $this->
getValue(
F_IMG, array($row['z_bild'],
00166
'z',
00167 $row['zubehoer_id'],
00168 $d['name']));
00169 $d['text'] = $row['z_besch1'] . $row['z_besch2'];
00170 $d['price'] = $this->
getValue(
F_FP, $row['z_preis']);
00171
return $d;
00172 }
00173
00184 function
getValue($func, $raw, $para =
"") {
00185
if (!is_array($raw)) {
00186 $raw = array($raw);
00187 }
00188 $rawCount = count($raw);
00189 $l10n = $this->data->getAppData('l10n');
00190
00191
switch ($func) {
00192
00193
case F_TF:
00194
return $this->str->trimFloat($raw[0]);
00195
00196
case F_FP:
00197
return $this->str->formatPrice($raw[0], $l10n);
00198
00199
case F_PN:
00200
return $this->data->getAppData('modelName') .
' ' . $raw[0];
00201
00202
case F_LD:
00203
return $this->
getHref($raw);
00204
00205
case F_LD2:
00206 $href = $this->
getHref($raw);
00207
return $this->data->getAppData('module')->baseName[$l10n]
00208 .
"/" . $href;
00209
00210
case F_TV:
00211 $v1 = $this->str->trimFloat($raw[0]);
00212 $r1 = floatval($raw[1]);
00213
if (!empty($r1)) {
00214
return $v1 . $para . $this->str->trimFloat($r1);
00215 }
00216
return $v1;
00217
00218
case F_TS:
00219
return $this->str->text_k($raw[0]);
00220
00221
case F_IMG_SHORT:
00222
if ($raw[0] ==
SQL_YES) {
00223
$path = '/img/'
00224 . $raw[1]
00225 .
'/'
00226 . $raw[2]
00227 .
'/'
00228 . $this->data->getAppData('module')->baseName[$l10n]
00229 .
'_'
00230 . $this->str->ugly2Pretty($raw[3])
00231 . '.jpg';
00232 $alt = $raw[3];
00233
return "<img border=\"0\" src=\"$path\" title=\"$alt\" alt=\"$alt\">";
00234 }
00235
else {
00236 $img = array(1 => '/pictures/kein_bild_kl-de.jpg',
00237 'Kein Bild verfügbar',
00238 '/pictures/kein_bild_kl-fr.jpg',
00239 'Pas d\'image disponible',
00240 '/pictures/kein_bild_kl-en.jpg',
00241 'No image available'
00242 );
00243 $alt = $img[$l10n * 2];
00244
$path = $img[$l10n * 2 - 1];
00245
return "<img border=\"0\" src=\"$path\" alt=\"$alt\" title=\"$alt\">";
00246 }
00247
break;
00248
00249
case F_IMG:
00250
if ($raw[0] ==
SQL_YES) {
00251
$path = '/img/'
00252 . $raw[1]
00253 .
'/'
00254 . $raw[2]
00255 .
'/'
00256 . $this->data->getAppData('module')->baseName[$l10n]
00257 .
'_'
00258 . $this->str->ugly2Pretty($raw[3])
00259 . '.jpg';
00260 $alt = $raw[3];
00261
return "<img border=\"0\" src=\"$path\" title=\"$alt\" alt=\"$alt\">";
00262 }
00263
else {
00264 $img = array(1 => '/pictures/kein_bild-de.jpg',
00265 'Kein Bild verfügbar',
00266 '/pictures/kein_bild-fr.jpg',
00267 'Pas d\'image disponible',
00268 '/pictures/kein_bild-en.jpg',
00269 'No image available'
00270 );
00271 $alt = $img[$l10n * 2];
00272
$path = $img[$l10n * 2 - 1];
00273
return "<img border=\"0\" src=\"$path\" alt=\"$alt\" title=\"$alt\">";
00274 }
00275
break;
00276
00277
case F_RAW:
00278
return $raw[0];
00279
00280
case F_DB_ENUM:
00281
if($raw[0] ==
SQL_ACRYL) {
00282
return 'Acryl (bruchsicher)';
00283 }
00284 elseif ($raw[0] ==
SQL_KRISTALL) {
00285
return 'Kristallglas (mundgeblasen)';
00286 }
00287 elseif ($raw[0] ==
SQL_GLAS) {
00288 $glas = array(1 => 'Glas',
00289 'Verre',
00290 'Glass');
00291
return $glas[$l10n];
00292 }
00293 elseif ($raw[0] ==
SQL_KUNSTOFF) {
00294 $kunst = array(1 => 'Kunstoff',
00295 'Plastic',
00296 'Plastic');
00297
return $kunst[$l10n];
00298 }
00299 elseif ($raw[0] ==
SQL_LEICHTMETALL) {
00300
return 'Leichtmetall';
00301 }
00302 elseif ($raw[0] ==
SQL_KARBON) {
00303
return 'Karbon';
00304 }
00305 elseif ($raw[0] ==
SQL_HOLZ) {
00306
return 'Holz';
00307 }
00308 elseif ($raw[0] ==
SQL_STAHL) {
00309
return 'Stahl';
00310 }
00311 elseif ($raw[0] ==
SQL_YES) {
00312 $yes = array(1 => 'Ja',
00313 'Oui',
00314 'Yes');
00315
return $yes[$l10n];
00316 }
00317 elseif ($raw[0] ==
SQL_NO) {
00318 $no = array(1 => 'Nein',
00319 'Non',
00320 'No');
00321
return $no[$l10n];
00322 }
00323
break;
00324
00325
case F_MT_LINENC:
00326 $linenc = array(1 => 'Mit Linear-Encoder: ',
00327 '',
00328 '');
00329
00330 $ecodrive = array(1 => 'einseitiges Anfahren|beidseitiges Anfahren',
00331 '',
00332 '');
00333
static $ecoFlag = 0;
00334
if ($this->pId == '580' && $ecoFlag == 0) {
00335 $eco = explode(
'|', $ecodrive[$l10n]);
00336 $ecoFlag = 1;
00337
return "$eco[0]: "
00338 . $this->str->trimFloat($raw[0])
00339 .
"µm <br>\n"
00340 . ' '
00341 .
"$eco[1]: "
00342 . $this->str->trimFloat($raw[1]);
00343 }
00344
if ($ecoFlag == 1) {
00345
return "<" . $this->str->trimFloat($raw[0]);
00346 }
00347
00348 $val = $para
00349 . $this->str->trimFloat($raw[0]);
00350
00351 $r1 = floatval($raw[1]);
00352
if (!empty($r)){
00353 $val .=
"µm<br>\n"
00354 . ' '
00355 . $linenc[$l10n]
00356 . $para
00357 . $this->str->trimFloat($r1);
00358 }
00359
return $val;
00360
00361
case F_MT_VMAX:
00362 $spindelText = array(1 => 'Mit %dmm Spindel: ',
00363 '',
00364 '');
00365 $spindelSize = array(1, 2, 4);
00366 $val =
"";
00367
for ($i = 0; $i < 3; ++$i) {
00368 $r = floatval($raw[$i]);
00369
if (!empty($r)) {
00370 $val .=
"<br>\n"
00371 . ' '
00372 . sprintf($spindelText[$l10n],
00373 $spindelSize[$i]
00374 )
00375 . $para
00376 . $this->str->trimFloat($r)
00377 .
"mm/s";
00378 }
00379 }
00380
$l = strlen($val);
00381
return substr($val, 0, $l - 4);
00382
00383
case F_U2P:
00384
return $this->str->ugly2Pretty($raw[0]);
00385
00386
case F_SO_VERGR:
00387 $vergr1 = round($raw[0] / $raw[1]);
00388 $r2 = floatval($raw[2]);
00389
if (!empty($r2)) {
00390 $vergr2 = round($raw[0] / $r2);
00391
return $vergr1 . $para . $vergr2;
00392 }
00393
return $vergr1;
00394
00395
case F_SO_AUST:
00396 $vergr1 = round($raw[0] / $raw[1]);
00397 $r2 = floatval($raw[2]);
00398
if (!empty($r2)) {
00399 $vergr2 = round($raw[0] / $r2);
00400
return round($raw[3] / $vergr1, 1)
00401 . $para
00402 . round($raw[3] / $vergr2, 1);
00403 }
00404
return round($raw[3] / $vergr1, 1);
00405
00406
case F_SO_SEHF:
00407 $vergr1 = round($raw[0] / $raw[1]);
00408 $r2 = floatval($raw[2]);
00409
if (!empty($r2)) {
00410 $vergr2 = round($raw[0] / $r2);
00411
return round($raw[3] * 17.5 / $vergr1)
00412 . $para
00413 . round($raw[4] * 17.5 / $vergr2);
00414 }
00415
return round($raw[3] *17.5 / $vergr1);
00416
00417
case F_MODEL_NAME:
00418 $pos = strpos ($raw[0],
'_', 0);
00419
if ($pos ===
false) {
00420
return $raw[0];
00421 }
00422
return substr($raw[0], 0, $pos);
00423
00424
case F_F_EINSATZ:
00425 $egs = array(
00426 'aj' => array(1 => 'Astronomie<br>Jagd',
00427 '',
00428 'Astronomy<br>Hunting'
00429 ),
00430
'w' => array(1 => 'Wandern',
00431 '',
00432 'Hiking'
00433 ),
00434
'o' => array(1 => 'Ornithologie',
00435 '',
00436 'Birding'
00437 )
00438 );
00439 $l10n =
getDataInstance()->getAppData('l10n');
00440 $eg = '';
00441
if ($raw[0] >= 4) {
00442 $eg = $egs['aj'][$l10n];
00443 }
00444
if ($raw[0] >= 4 && $raw[2] >= 7) {
00445
if ($eg != '') {
00446 $eg .= '<br>';
00447 }
00448 $eg .= $egs[
'o'][$l10n];
00449 }
00450
if ($raw[1] <= 750) {
00451
if ($eg != '') {
00452 $eg .= '<br>';
00453 }
00454 $eg .= $egs[
'w'][$l10n];
00455 }
00456
return $eg;
00457
00458
case F_SP_IMG_LINK:
00459
if ($raw[0] ==
SQL_YES) {
00460
return "<a href=\"javascript:openFenster('"
00461 .
"/img/p/"
00462 . $raw[1]
00463 .
"/"
00464 . $this->str->ugly2Pretty($raw[2])
00465 .
".jpg', 600, 450)\">"
00466 . $raw[2]
00467 .
"</a>";
00468 }
00469
return $raw[2];
00470
00471
case F_NL2BR:
00472 $tmp = $raw[0];
00473
if ($rawCount == 2) {
00474 $tmp .= $raw[1];
00475 }
00476
return nl2br($tmp);
00477
00478
case F_L_MESSL:
00479 $messl = array(1 => 'Öffnungswinkel',
00480 'Angle d\'ouverture',
00481 'Aperture angle',
00482 'Winkel',
00483 'Angle',
00484 'Angle');
00485 $val =
"";
00486
switch ($raw[0]) {
00487
case 999999:
00488 $val = $messl[$l10n];
00489
break;
00490
case 999998:
00491 $val = $messl[$l10n + 3];
00492
break;
00493
case 0:
00494
break;
00495
default:
00496 $val = $this->str->trimFloat($raw[0]);
00497
break;
00498 }
00499 $r1 = floatval($raw[1]);
00500
if (!empty($r)) {
00501 $val .= $para . $this->str->trimFloat($r1);
00502 }
00503
return $val;
00504
00505
case F_L_SICHTF:
00506 $sichtf =
" ";
00507 $r0 = floatval($raw[0]);
00508
if (!empty($r0)) {
00509 $sichtf = $this->str->trimFloat($r0);
00510 }
00511
switch ($raw[1]) {
00512
case 999999:
00513 $sichtf .=
"°";
00514
break;
00515
case 0:
00516
break;
00517
default:
00518 $sichtf .= $para . $this->str->trimFloat($raw[1]);
00519
break;
00520 }
00521
return $sichtf;
00522
default:
00523
break;
00524 }
00525
return;
00526 }
00527
00535 function
getHref($para) {
00536 $link =
"";
00537 $gId = $this->data->getAppData('module')->gruppe_id;
00538
if ($this->data->getAppData('l10n') ==
L_ENG &&
00539 ($gId ==
G_MIKROSKOP ||
00540 $gId ==
G_STEREOMIKROSKOP
00541 ) ) {
00542 $link = $para[0] .
"_en/";
00543 }
00544
else {
00545 $link = $para[0] .
"/";
00546 }
00547 $h = $this->data->getAppData('group1');
00548
if( $h !=
"" ) {
00549 $link .= $this->str->ugly2Pretty($h) .
"_";
00550 }
00551 $link .= $this->str->ugly2Pretty($para[1]) .
".html";
00552
return $link;
00553 }
00554
00570 function
scanInternalField($intern) {
00571 $internal = array();
00572 $pos = strpos($intern,
'[');
00573
if ($pos ===
false) {
00574
return;
00575 }
00576
do {
00577 $cEndPos = strpos($intern,
':', $pos + 1);
00578 $command = substr($intern, $pos + 1, $cEndPos - $pos - 1);
00579 $vEndPos = strpos($intern,
']', $cEndPos + 1);
00580 $values = substr($intern, $cEndPos + 1, $vEndPos - $cEndPos - 1);
00581 $values = chop($values);
00582 $values = ltrim($values);
00583 $internal[$command] = explode(
"\n", $values);
00584 $pos = strpos($intern,
'[', $vEndPos + 1);
00585 }
while ($pos > 0);
00586
return $internal;
00587 }
00588
00589 }
00590
00591 ?>