public function export(SimpleXMLElement $artifact_xml, SimpleXMLElement $changeset_xml, Tracker_Artifact $artifact, Tracker_Artifact_ChangesetValue $changeset_value)
 {
     $field_change = $this->createFieldChangeNodeInChangesetNode($changeset_value, $changeset_xml);
     $cdata_factory = new XML_SimpleXMLCDATAFactory();
     $cdata_factory->insert($field_change, 'value', $changeset_value->getText());
     $field_change->value['format'] = $changeset_value->getFormat();
 }
 private function appendFileToArtifactNode(Tracker_FileInfo $file_info, $index, SimpleXMLElement $artifact_xml)
 {
     $cdata_factory = new XML_SimpleXMLCDATAFactory();
     $node = $artifact_xml->addChild('file');
     $node->addAttribute('id', $this->getFileInfoIdForXML($file_info));
     $cdata_factory->insert($node, 'filename', $file_info->getFilename());
     $node->addChild('path', $this->path_exporter->getPath($file_info));
     $node->addChild('filesize', $file_info->getFilesize());
     $node->addChild('filetype', $file_info->getFiletype());
     $cdata_factory->insert($node, 'description', $file_info->getDescription());
 }
 /** @return string */
 public function toXML()
 {
     $xml_element = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?>
                                          <users />');
     foreach ($this->users as $user) {
         if ($user->isNone()) {
             continue;
         }
         $user_node = $xml_element->addChild('user');
         $user_node->addChild('id', (int) $user->getId());
         $user_node->addChild('username', $user->getUserName());
         $this->cdata_factory->insert($user_node, 'realname', $user->getRealName());
         $this->cdata_factory->insert($user_node, 'email', $user->getEmail());
         $this->cdata_factory->insert($user_node, 'ldapid', $user->getLdapId());
     }
     $rng_path = realpath(ForgeConfig::get('tuleap_dir') . '/src/common/xml/resources/users.rng');
     $this->xml_validator->validate($xml_element, $rng_path);
     return $this->convertToXml($xml_element);
 }
 public function exportToXML(SimpleXMLElement $comments_node)
 {
     $comment_node = $comments_node->addChild('comment');
     $user_xml_exporter = new UserXMLExporter(UserManager::instance());
     $user_xml_exporter->exportUserByUserId($this->submitted_by, $comment_node, 'submitted_by');
     $submitted_on_node = $comment_node->addChild('submitted_on', date('c', $this->submitted_on));
     $submitted_on_node->addAttribute('format', 'ISO8601');
     $cdata_factory = new XML_SimpleXMLCDATAFactory();
     $cdata_factory->insert($comment_node, 'body', $this->body);
     $comment_node->body['format'] = $this->bodyFormat;
 }
 /**
  * Transforms FormElement into a SimpleXMLElement
  *
  * @param SimpleXMLElement $root        the node to which the FormElement is attached (passed by reference)
  * @param array            &$xmlMapping correspondance between real ids and xml IDs
  *
  * @return void
  */
 public function exportToXml(SimpleXMLElement $root, &$xmlMapping)
 {
     $cdata_section_factory = new XML_SimpleXMLCDATAFactory();
     $root->addAttribute('type', Tracker_FormElementFactory::instance()->getType($this));
     // this id is internal to XML
     $ID = $this->getXMLId();
     $xmlMapping[$ID] = $this->id;
     $root->addAttribute('ID', $ID);
     $root->addAttribute('rank', $this->rank);
     // if old ids are important, modify code here
     if (false) {
         $root->addAttribute('id', $this->id);
         $root->addAttribute('tracker_id', $this->tracker_id);
         $root->addAttribute('parent_id', $this->parent_id);
     }
     // ony add if values are different from default
     if (!$this->use_it) {
         $root->addAttribute('use_it', $this->use_it);
     }
     // TODO: decide which scope is default P or S
     if ($this->scope && $this->scope != 'P') {
         $root->addAttribute('scope', $this->scope);
     }
     if ($this->required) {
         $root->addAttribute('required', $this->required);
     }
     if ($this->notifications) {
         $root->addAttribute('notifications', $this->notifications);
     }
     $root->addChild('name', $this->name);
     $cdata_section_factory->insert($root, 'label', $this->label);
     // only add if not empty
     if ($this->description) {
         $cdata_section_factory->insert($root, 'description', $this->description);
     }
     if ($this->getProperties()) {
         $this->exportPropertiesToXML($root);
     }
 }
 /**
  * Transforms Bind into a SimpleXMLElement
  */
 public function exportToXml(SimpleXMLElement $root, &$xmlMapping, $project_export_context, UserXMLExporter $user_xml_exporter)
 {
     $cdata_section_factory = new XML_SimpleXMLCDATAFactory();
     $root->addAttribute('is_rank_alpha', $this->is_rank_alpha);
     if ($this->getAllValues()) {
         $child = $root->addChild('items');
         foreach ($this->getAllValues() as $val) {
             $grandchild = $child->addChild('item');
             $ID = $val->getXMLId();
             $grandchild->addAttribute('ID', $ID);
             $xmlMapping['values'][$ID] = $val->getId();
             $grandchild->addAttribute('label', $val->getLabel());
             $grandchild->addAttribute('is_hidden', $val->isHidden());
             if ($val->getDescription() != '') {
                 $cdata_section_factory->insert($grandchild, 'description', $val->getDescription());
             }
         }
         if ($this->decorators) {
             $child = $root->addChild('decorators');
             foreach ($this->decorators as $deco) {
                 $deco->exportToXML($child, array_search($deco->value_id, $xmlMapping['values']));
             }
         }
         if ($this->default_values) {
             $default_child = $root->addChild('default_values');
             foreach ($this->default_values as $id => $nop) {
                 if ($ref = array_search($id, $xmlMapping['values'])) {
                     $default_child->addChild('value')->addAttribute('REF', $ref);
                 }
             }
         }
     }
 }
示例#7
0
 /**
  * Exports the tracker to an XML file.
  *
  * @return SimpleXMLElement
  */
 private function exportTrackerToXML(SimpleXMLElement $xmlElem, UserXMLExporter $user_xml_exporter, array &$xmlMapping, $project_export_context)
 {
     $xmlElem->addAttribute('id', "T" . $this->getId());
     $cdata_section_factory = new XML_SimpleXMLCDATAFactory();
     $parent_id = $this->getParentId();
     if ($parent_id && !$project_export_context) {
         $parent_id = "T" . $parent_id;
     } else {
         $parent_id = "0";
     }
     $xmlElem->addAttribute('parent_id', (string) $parent_id);
     // only add attributes which are different from the default value
     if ($this->enable_emailgateway) {
         $xmlElem->addAttribute('enable_emailgateway', $this->enable_emailgateway);
     }
     if ($this->allow_copy) {
         $xmlElem->addAttribute('allow_copy', $this->allow_copy);
     }
     if ($this->instantiate_for_new_projects) {
         $xmlElem->addAttribute('instantiate_for_new_projects', $this->instantiate_for_new_projects);
     }
     if ($this->log_priority_changes) {
         $xmlElem->addAttribute('log_priority_changes', $this->log_priority_changes);
     }
     if ($this->stop_notification) {
         $xmlElem->addAttribute('stop_notification', $this->stop_notification);
     }
     // these will not be used at the import
     $cdata_section_factory->insert($xmlElem, 'name', $this->getName());
     $xmlElem->addChild('item_name', $this->getItemName());
     $cdata_section_factory->insert($xmlElem, 'description', $this->getDescription());
     $xmlElem->addChild('color', $this->getColor());
     // add only if not empty
     if ($this->submit_instructions) {
         $cdata_section_factory->insert($xmlElem, 'submit_instructions', $this->submit_instructions);
     }
     if ($this->browse_instructions) {
         $cdata_section_factory->insert($xmlElem, 'browse_instructions', $this->browse_instructions);
     }
     $child = $xmlElem->addChild('cannedResponses');
     if ($responses = $this->getCannedResponseFactory()->getCannedResponses($this)) {
         foreach ($responses as $response) {
             $grandchild = $child->addChild('cannedResponse');
             $response->exportToXML($grandchild);
         }
     }
     $child = $xmlElem->addChild('formElements');
     // association between ids in database and ids in xml
     foreach ($this->getFormElementFactory()->getUsedFormElementForTracker($this) as $formElement) {
         $grandchild = $child->addChild('formElement');
         $formElement->exportToXML($grandchild, $xmlMapping, $project_export_context, $user_xml_exporter);
     }
     // semantic
     $tsm = $this->getTrackerSemanticManager();
     $child = $xmlElem->addChild('semantics');
     $tsm->exportToXML($child, $xmlMapping);
     // rules
     $child = $xmlElem->addChild('rules');
     $this->getGlobalRulesManager()->exportToXML($child, $xmlMapping);
     // only the reports with project scope are exported
     $reports = $this->getReportFactory()->getReportsByTrackerId($this->id, null);
     if ($reports) {
         $child = $xmlElem->addChild('reports');
         foreach ($this->getReportFactory()->getReportsByTrackerId($this->id, null) as $report) {
             $report->exportToXML($child, $xmlMapping);
         }
     }
     // workflow
     $child = $xmlElem->addChild('workflow');
     $workflow = $this->getWorkflowFactory()->getWorkflowByTrackerId($this->id);
     if (!empty($workflow)) {
         $workflow->exportToXML($child, $xmlMapping);
     }
     // permissions
     $node_perms = $xmlElem->addChild('permissions');
     // tracker permissions
     if ($permissions = $this->getPermissionsByUgroupId()) {
         foreach ($permissions as $ugroup_id => $permission_types) {
             if (($ugroup = array_search($ugroup_id, $GLOBALS['UGROUPS'])) !== false && $ugroup_id < 100) {
                 foreach ($permission_types as $permission_type) {
                     $node_perm = $node_perms->addChild('permission');
                     $node_perm->addAttribute('scope', 'tracker');
                     $node_perm->addAttribute('ugroup', $ugroup);
                     $node_perm->addAttribute('type', $permission_type);
                     unset($node_perm);
                 }
             }
         }
     }
     // fields permission
     if ($formelements = $this->getFormElementFactory()->getUsedFormElementForTracker($this)) {
         foreach ($formelements as $formelement) {
             $formelement->exportPermissionsToXML($node_perms, $xmlMapping);
         }
     }
     return $xmlElem;
 }
 public function exportToXML(SimpleXMLElement $comments_node, UserXMLExporter $user_xml_exporter)
 {
     $comment_node = $comments_node->addChild('comment');
     $user_xml_exporter->exportUserByUserId($this->submitted_by, $comment_node, 'submitted_by');
     $submitted_on_node = $comment_node->addChild('submitted_on', date('c', $this->submitted_on));
     $submitted_on_node->addAttribute('format', 'ISO8601');
     $cdata_factory = new XML_SimpleXMLCDATAFactory();
     $comment_escaped = $this->getCommentBodyWithEscapedCrossReferences();
     $cdata_factory->insert($comment_node, 'body', $comment_escaped);
     $comment_node->body['format'] = $this->bodyFormat;
 }