public function getMappingErrors($t_mapping) { $va_errors = array(); $va_top = $t_mapping->getTopLevelItems(); foreach ($va_top as $va_item) { $t_item = new ca_data_exporter_items($va_item['item_id']); $vs_element = $va_item['element']; if (!is_numeric($vs_element)) { $va_errors[] = _t("Element %1 is not numeric", $vs_element); } if (intval($vs_element) <= 0) { $va_errors[] = _t("Element %1 is not a positive number", $vs_element); } if (sizeof($t_item->getHierarchyChildren()) > 0) { $va_errors[] = _t("CSV exports can't be hierarchical", $vs_element); } } return $va_errors; }
private function getMappingErrorsForItem($pa_item) { $va_errors = array(); $t_item = new ca_data_exporter_items($pa_item['item_id']); // check if element is attribute and if so, if it's valid and if it has a non-attribute parent it belongs to $vs_element = $t_item->get('element'); $vs_first = substr($vs_element, 0, 1); if ($vs_first == "@") { $vs_attribute_name = substr($vs_element, 1); if (!preg_match("/^[_:A-Za-z][-._:A-Za-z0-9]*\$/", $vs_attribute_name)) { $va_errors[] = _t("Invalid XML attribute name '%1'", $vs_attribute_name); } $t_parent = new ca_data_exporter_items($t_item->get('parent_id')); $vs_parent_first = substr($t_parent->get('element'), 0, 1); if ($vs_parent_first == "@" || !$t_parent->get('element')) { $va_errors[] = _t("XML attribute '%1' doesn't have a valid parent element", $vs_attribute_name); } } else { // plain old XML element -> check for naming convention if (!preg_match("/^[_:A-Za-z][-._:A-Za-z0-9]*\$/", $vs_element)) { $va_errors[] = _t("Invalid XML element name '%1'", $vs_element); } } foreach ($t_item->getHierarchyChildren() as $va_child) { $va_errors = array_merge($va_errors, $this->getMappingErrorsForItem($va_child)); } return $va_errors; }
public static function loadExporterItemByID($pn_item_id) { if (isset(ca_data_exporters::$s_exporter_item_cache[$pn_item_id])) { return ca_data_exporters::$s_exporter_item_cache[$pn_item_id]; } else { $t_item = new ca_data_exporter_items(); if ($t_item->load($pn_item_id)) { return ca_data_exporters::$s_exporter_item_cache[$pn_item_id] = $t_item; } } return false; }
public function getMappingErrors($t_mapping) { if (!caExifToolInstalled()) { $va_errors[] = _t('ExifTool must be installed and available!'); } $va_errors = array(); $va_top = $t_mapping->getTopLevelItems(); $va_namespace_keys = array(); foreach (array_keys($this->opa_namespaces) as $vs_key) { $va_namespace_keys[] = str_replace('xmlns:', '', $vs_key); } foreach ($va_top as $va_item) { $vs_element_ns = preg_replace("/\\:.+\$/", '', $va_item['element']); if (!in_array($vs_element_ns, $va_namespace_keys)) { $va_errors[] = _t('%1 is not a valid element for ExifTool exports. It must be in of one of the ExifTool namespaces.', $va_item['element']); } $t_item = new ca_data_exporter_items($va_item['item_id']); $va_children = $t_item->getHierarchyChildren(); if (is_array($va_children) && sizeof($va_children) > 0) { $va_errors[] = _t("ExifTool mappings can't be hierarchical. It looks like element %1 has children.", $va_item['element']); } } return $va_errors; }