- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
function form_xml_items( $sXML, $reserve, $exchange ){
foreach ($exchange as $in => $outs) {
$currency_in = taxonomy_term_load($in);
switch ($in) {
case 6:
$currency_in->name = 'CASHUAH';
break;
case 18:
$currency_in->name = 'CASHUSD';
break;
// ...
$currency_in->name = 'TBRUB';
break;
case 161:
$currency_in->name = 'OPB';
break;
}
foreach ($outs as $out => $param) {
$currency_out = taxonomy_term_load($out);
switch ($out) {
case 11:
$currency_out->name ='CASHUAH';
break;
case 19:
$currency_out->name ='CASHUSD';
break;
// ...
case 155:
$currency_out->name = 'CARDRUB';
$currency_out->second_name = 'WIRERUB';
break;
case 162:
$currency_out->name = 'OPB';
break;
}
$sXML .= "<item>\n";
$sXML .= "<from>" . $currency_in->name . "</from>\n";
$sXML .= "<to>" . $currency_out->name . "</to>\n";
$sXML .= "<in>1</in>\n";
$sXML .= "<out>" . $param["rate"] . "</out>\n";
$sXML .= "<amount>" . $param["reserve"] . "</amount>\n";
$sXML .= "</item>\n";
//wire and card in
if (isset( $currency_in->second_name)){
$sXML .= "<item>\n";
$sXML .= "<from>" . $currency_in->second_name . "</from>\n";
$sXML .= "<to>" . $currency_out->name . "</to>\n";
$sXML .= "<in>1</in>\n";
$sXML .= "<out>" . $param["rate"] . "</out>\n";
$sXML .= "<amount>" . $param["reserve"] . "</amount>\n";
$sXML .= "</item>\n";
}
//wire and card out
if (isset($currency_out->second_name)){
$sXML .= "<item>\n";
$sXML .= "<from>" . $currency_in->name . "</from>\n";
$sXML .= "<to>" . $currency_out->second_name . "</to>\n";
$sXML .= "<in>1</in>\n";
$sXML .= "<out>" . $param["rate"] . "</out>\n";
$sXML .= "<amount>" . $param["reserve"] . "</amount>\n";
$sXML .= "</item>\n";
}
}
}
return $sXML;
}
Если не взирать на магические числа, кажеться этот код должен занимать строк 20, а не 130
Комментарии (0) RSS
Добавить комментарий