} 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 = ''; foreach ($importFields as $field) {
function gtcd_get_xpath($arr, $xpath) { $xmlKeys = ''; foreach ($arr as $key => $value) { if (is_array($value)) { $xmlKeys = gtcd_get_xpath($value, $xpath); } if ($key === $xpath) { $xmlKeys = $value[0]; break; } } return $xmlKeys; }