예제 #1
0
 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;
 }
예제 #2
0
 /**
  * Remove item from this exporter and delete
  * @param int $pn_item_id primary key of the item to remove
  * @return boolean success state
  */
 public function removeItem($pn_item_id)
 {
     if (!($vn_exporter_id = $this->getPrimaryKey())) {
         return null;
     }
     $t_item = new ca_data_exporter_items($pn_item_id);
     if ($t_item->getPrimaryKey() && $t_item->get('exporter_id') == $vn_exporter_id) {
         $t_item->setMode(ACCESS_WRITE);
         $t_item->delete(true);
         if ($t_item->numErrors()) {
             $this->errors = array_merge($this->errors, $t_item->errors);
             return false;
         }
         return true;
     }
     return false;
 }