<?php require "../settings.php"; require "../core-settings.php"; require "bank-pay-supp-write.php"; if (isset($_POST["key"])) { switch ($_POST["key"]) { case "search": $OUTPUT = show_entries($_POST); break; case "confirm": $OUTPUT = process_entries($_POST); break; default: $OUTPUT = get_filter(); } } elseif (isset($_GET["supid"])) { $OUTPUT = print_entry($_GET); } else { $OUTPUT = get_filter(); } require "../template.php"; function get_filter() { $display = "\n\t\t<h2>Select Date Range For Listing</h2>\n\t\t<table " . TMPL_tblDflts . ">\n\t\t<form action='" . SELF . "' method='POST'>\n\t\t\t<input type='hidden' name='key' value='search'>\n\t\t\t<tr>\n\t\t\t\t<th colspan='2'>Date Range</th>\n\t\t\t</tr>\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>\n\t\t\t\t\t" . mkDateSelect("from", date("Y"), date("m"), "01") . "\n\t\t\t\t\tTo\n\t\t\t\t\t" . mkDateSelect("to") . "\n\t\t\t\t</td>\n\t\t\t\t<td><input type='submit' value='View'></td>\n\t\t\t</tr>\n\t\t</form>\n\t\t</table>"; return $display; } function show_entries($_POST, $err = "") { extract($_POST); $fromdate = "{$from_year}-{$from_month}-{$from_day}";
function process_entries($entry) { $html = ''; $pron_gb; $pron_us; $sound_effects; $dvd_pic; $baseUrl = 'https://api.pearson.com/longman/dictionary/0.1'; //if the value is an array, it means it is a definition. if it isnt, need to break the loop if (isset($entry['@id'])) { //get multimedia if (isset($entry['multimedia']) && is_array($entry['multimedia'])) { foreach ($entry['multimedia'] as $media) { if ($media['@type'] == 'US_PRON') { $pron_us = '<audio preload="none" controls> <source src="' . $baseUrl . $media['@href'] . '" type="audtio/mpeg" /> <a href="' . $baseUrl . $media['@href'] . '?apikey=' . $apiKey . '">US Pron</a> </audio>'; } else { if ($media['@type'] == 'GB_PRON') { $pron_gb = '<audio preload="none" controls> <source src="' . $baseUrl . $media['@href'] . '" type="audtio/mpeg" /> <a href="' . $baseUrl . $media['@href'] . '?apikey=' . $apiKey . '">GB Pron</a> </audio>'; } else { if ($media['@type'] == 'SOUND_EFFECTS') { $sound_effects = '<audio preload="none" controls> <source src="' . $baseUrl . $media['@href'] . '" type="audtio/mpeg" /> <a href="' . $baseUrl . $media['@href'] . '?apikey=' . $apiKey . '">Sound effect</a> </audio>'; } else { if ($media['@type'] == 'DVD_PICTURES') { $dvd_pic = '<img src="' . $baseUrl . $media['@href'] . '?apikey=' . $apiKey . '" />'; } } } } } } if (isset($pron_gb)) { $html .= $pron_gb; } if (isset($pron_us)) { $html .= $pron_us; } if (isset($sound_effects)) { $html .= $sound_effects; } if (isset($dvd_pic)) { $html .= $dvd_pic; } //debugLog.append("Processing Entry: " + from.Head.HWD['#text'] + '<br/>'); $html .= '<li><a>'; $html .= $entry['Head']['HWD']['#text']; if (isset($entry['Head']['PronCodes']['PRON']['#text'])) { $html .= '<span class="pron">' . $entry['Head']['PronCodes']['PRON']['#text'] . '</span>'; } $html .= '<span>(' . $entry['Head']['POS']['#text'] . ')</span>'; $html .= '</a><div>'; //var attr = $(from).attr('multimedia'); //if () { // $html .= multimedia(from.multimedia); //} $html .= '<ol id="sense">'; $html .= get_sense($entry['Sense']); $html .= '</ol>'; $html .= '</div></li>'; } else { foreach ($entry as $entry) { $html .= process_entries($entry); } } return $html; }