$meta['_' . $meta_key] = array('parent' => 'feat_boxes', 'meta_key' => '_' . $meta_key, 'title' => $feat_boxes[$meta_key]['title'], 'name' => $feat_boxes[$meta_key]['name']); } elseif (!empty($meta_boxes[$meta_key]['name'])) { $meta['_' . $meta_key] = array('parent' => 'meta_boxes', 'meta_key' => '_' . $meta_key, 'title' => $meta_boxes[$meta_key]['title'], 'name' => $meta_boxes[$meta_key]['name']); } elseif (!empty($comment_boxes[$meta_key]['name'])) { $meta['_' . $meta_key] = array('parent' => 'comment_boxes', 'meta_key' => '_' . $meta_key, 'title' => $comment_boxes[$meta_key]['title'], 'name' => $comment_boxes[$meta_key]['name']); } } $taxonomies = get_object_taxonomies('gtcd', 'objects'); //Build array of user import fields $importFields = array(); $importFile = $_POST['file-name']; if ($_POST['file-type'] == 'xml') { $fileData = file_get_contents(GTCDI_DIR . '/' . $importFile); $dom = new DomDocument(); $dom->loadXML($fileData); $xmlArray = gtcd_xml_to_array($dom); $importFields = gtcd_get_xpath($xmlArray, $_POST['file-path']); $importFields = gtcd_get_keys($importFields); } elseif ($_POST['file-type'] == 'csv') { $row = 1; if (($handle = fopen(GTCDI_DIR . '/' . $importFile, 'r')) !== FALSE) { while (($data = fgetcsv($handle, 1000, '|')) !== FALSE) { //get first line column names and break $importFields = $data; break; } fclose($handle); } } //create import fields drop down $options = '';
function gtcd_xml_to_array($root) { $result = array(); if ($root->hasAttributes()) { $attrs = $root->attributes; foreach ($attrs as $attr) { $result['@attributes'][$attr->name] = $attr->value; } } if ($root->hasChildNodes()) { $children = $root->childNodes; if ($children->length == 1) { $child = $children->item(0); if ($child->nodeType == XML_TEXT_NODE) { $result['_value'] = $child->nodeValue; return count($result) == 1 ? $result['_value'] : $result; } } $groups = array(); foreach ($children as $child) { if (!isset($result[$child->nodeName])) { if ($child->nodeName != "#text") { $result[$child->nodeName] = gtcd_xml_to_array($child); } } else { if (!isset($groups[$child->nodeName])) { if ($child->nodeName != "#text") { $result[$child->nodeName] = array($result[$child->nodeName]); } if ($child->nodeName != "#text") { $groups[$child->nodeName] = 1; } } if ($child->nodeName != "#text") { $result[$child->nodeName][] = gtcd_xml_to_array($child); } } } } return $result; }