private static function readSources($xml) { $sources = array(); foreach ($xml->source_citation as $o) { $id = (string) $o['id']; $key = 'SOURCE|' . $id; // sometimes people put the references in the wrong fields, so gather them all together list($dummy, $images, $notes) = MergeForm::readSourcesImagesNotes(null, (string) $o['images'], (string) $o['notes']); $sources[] = array('id' => $id, 'title' => (string) $o['title'], 'record_name' => (string) $o['record_name'], 'page' => (string) $o['page'], 'quality' => (string) $o['quality'], 'date' => (string) $o['date'], 'notes' => $notes, 'images' => $images, 'text' => (string) $o['text'] . (string) $o, 'key' => $key); } return $sources; }