function photoshop_create_table($shop_array_photos, $type, $template) { //we create two basic templates html and text global $SHOP_CONFIG, $CONFIG, $lang_photoshop, $cd_price; $out = array(); $out['html'] = '<tr><td><table cellpadding="0" cellspacing="1" width="100%">'; $out['text'] = sprintf("%s\n\n", ''); if ($type == 'photo') { $out['html'] .= <<<EOT \t\t<tr> \t\t\t<td class="tableh1" width="25%">{$lang_photoshop['item_id_checkout']}</td> \t\t\t<td class="tableh1" width="25%">{$lang_photoshop['type_chckout']}</td> \t\t\t<td class="tableh1" width="25%">{$lang_photoshop['amount_checkout']}</td> \t\t\t<td class="tableh1" width="25%">{$lang_photoshop['total_checkout']}</td> \t\t</tr> EOT; $out['text'] .= sprintf("%10.10s\t", $lang_photoshop['item_id_checkout']) . sprintf("%15.15s\t", $lang_photoshop['type_chckout']) . sprintf("%10.10s\t", $lang_photoshop['amount_checkout']) . sprintf("%15.15s\n", $lang_photoshop['total_checkout']); } elseif ($type == 'cd' && photoshop_in_array_multi("CD", $shop_array_photos)) { $out['html'] .= <<<EOT \t\t<tr> \t\t\t<td class="tableh1" width="25%">{$lang_photoshop['item_id_checkout']}</td> \t\t\t<td class="tableh1" width="25%">{$lang_photoshop['type_chckout']}</td> \t\t\t<td class="tableh1" width="25%"> </td> \t\t\t<td class="tableh1" width="25%"> </td> \t\t</tr> EOT; $out['text'] .= sprintf("%10.10s\t", $lang_photoshop['item_id_checkout']) . sprintf("%15.15s\n", $lang_photoshop['type_chckout']); } foreach ($shop_array_photos as $key => $item_id) { $select_columns = 'filepath, filename, url_prefix, filesize, pwidth, pheight, ctime, title, aid'; $result = cpg_db_query("SELECT {$select_columns} from {$CONFIG['TABLE_PICTURES']} WHERE pid='{$item_id['pid']}' LIMIT 1"); $row = mysql_fetch_array($result); $price = $SHOP_CONFIG[$item_id['id']]['price']; //price override $results = cpg_db_query("SELECT * FROM {$CONFIG['TABLE_SHOP_PRICES']} WHERE aid={$row['aid']}"); while ($temp_data = mysql_fetch_array($results)) { if ($temp_data['gid'] == $SHOP_CONFIG[$item_id['id']]['id']) { $price = $temp_data['price']; } } mysql_free_result($results); //here we check if the price is set to -1 (that's a free item, and we set price for display reasons back to 0.00) //do the same in cart and calc total an in function item_price, pricelist, photoshop_add_data if ($price < 0) { $price = "0.00"; } //html resize thumb if ($CONFIG['enable_mini_thumbs'] == '1') { // if you use the modpack and have enabled mini thumbs -> these get used instead of html resized thumbs $thumb_url = get_pic_url($row, 'mini'); $destWidth = $CONFIG['mini_thumb_width']; $destHeight = $CONFIG['mini_thumb_height']; } else { $thumb_url = get_pic_url($row, 'thumb'); $new_size = 60; $ratio = max($row['pwidth'], $row['pheight']) / $new_size; $ratio = max($ratio, 1.0); $destWidth = (int) ($row['pwidth'] / $ratio); $destHeight = (int) ($row['pheight'] / $ratio); } if ($item_id['id'] == 'CD') { $out['html'] .= <<<EOT \t\t\t\t<tr> \t\t\t\t\t<td> \t\t\t\t\t<a href="displayimage.php?pos=-{$item_id['pid']}"><img class="image" src="{$thumb_url}" width="{$destWidth}" height="{$destHeight}" alt="" /></a> \t\t\t\t\t</td> \t\t\t\t\t<td>{$item_id['id']} text</td> \t\t\t\t\t<td> </td> \t\t\t\t\t<td> </td> \t\t\t\t</tr> EOT; $out['text'] .= sprintf("%10.10s\t", $item_id['pid']) . sprintf("%15.15s\n", $item_id['id']); } else { $price = number_format($price * $item_id['amount'], 2); $out['html'] .= <<<EOT \t\t\t\t<tr> \t\t\t\t\t<td> \t\t\t\t\t<a href="displayimage.php?pos=-{$item_id['pid']}"><img class="image" src="{$thumb_url}" width="{$destWidth}" height="{$destHeight}" alt="" /></a> \t\t\t\t\t</td> \t\t\t\t\t<td>{$SHOP_CONFIG[$item_id['id']]['name']}</td> \t\t\t\t\t<td>{$item_id['amount']}</td> \t\t\t\t\t<td>{$price} {$CONFIG['photo_shop_currency']}</td> \t\t\t\t</tr> EOT; $out['text'] .= sprintf("%10.10s\t", $item_id['pid']) . sprintf("%15.15s\t", $SHOP_CONFIG[$item_id['id']]['name']) . sprintf("%10.10s\t", $item_id['amount']) . sprintf("%15.15s\n", $CONFIG['photo_shop_currency'] . ' ' . $price); } } $out['html'] .= "</td></tr></table>"; return $out[$template]; }
function photoshop_in_array_multi($needle, $haystack) { if (!is_array($haystack)) { return $needle == $haystack; } foreach ($haystack as $value) { if (photoshop_in_array_multi($needle, $value)) { return true; } } return false; }