public function appendNode(DOMElement $changeset_node, $tracker_id, $artifact_id, array $row)
 {
     if (isset($row['new_value'])) {
         $row['new_value'] = Encoding_SupportedXmlCharEncoding::getXMLCompatibleString($row['new_value']);
     }
     $this->appendStringNode($changeset_node, self::TV5_TYPE, $row);
 }
 /**
  *
  * @param SimpleXMLElement $parent_node
  * @param string $node_name
  * @param string $node_value
  */
 public function insert(SimpleXMLElement $parent_node, $node_name, $node_value)
 {
     $node = $parent_node->addChild($node_name);
     $dom_node = dom_import_simplexml($node);
     $document = $dom_node->ownerDocument;
     $value = Encoding_SupportedXmlCharEncoding::getXMLCompatibleString($node_value);
     $cdata = $document->createCDATASection($value);
     $dom_node->appendChild($cdata);
 }
 /**
  * This test can be only run in php53. That is beacuse ENT_IGNORE is not available in
  * earlier versions of php
  */
 public function itReplacesBadCharacters()
 {
     $bad_chars = array("" => ' ', "" => ' ', "" => ' ', "" => ' ', "" => ' ', "" => ' ', "" => ' ', "" => ' ', "\v" => ' ', "\f" => ' ', "" => ' ', "" => ' ', "" => ' ', "’" => '’');
     foreach ($bad_chars as $bad_char => $replace) {
         $string = htmlentities($bad_char, ENT_IGNORE, 'UTF-8');
         $bad_text = html_entity_decode($string, ENT_IGNORE, 'ISO-8859-1');
         $returned = Encoding_SupportedXmlCharEncoding::getXMLCompatibleString($bad_text);
         $this->assertEqual($returned, $replace);
     }
 }
 private function createCommentNode(array $row)
 {
     $comment_node = $this->node_helper->createElement('comment');
     $this->node_helper->appendSubmittedBy($comment_node, $row['submitted_by'], $row['is_anonymous']);
     $this->node_helper->appendSubmittedOn($comment_node, $row['date']);
     $comment = Encoding_SupportedXmlCharEncoding::getXMLCompatibleString($row['comment']);
     $body = $this->node_helper->getNodeWithValue('body', $comment);
     $body->setAttribute('format', $this->getFormat($row['format']));
     $comment_node->appendChild($body);
     return $comment_node;
 }
 public function appendNode(DOMElement $changeset_node, $tracker_id, $artifact_id, array $row)
 {
     $values = array_filter(explode(',', $row['new_value']));
     $field_node = $this->node_helper->createElement('field_change');
     $field_node->setAttribute('field_name', 'cc');
     $field_node->setAttribute('type', self::TV5_TYPE);
     $field_node->setAttribute('bind', 'users');
     foreach ($values as $value) {
         $value = Encoding_SupportedXmlCharEncoding::getXMLCompatibleString($value);
         $cc_value_node = $this->node_helper->getNodeWithValue('value', $value);
         $field_node->appendChild($cc_value_node);
     }
     $changeset_node->appendChild($field_node);
 }
 private function getValueLabel($tracker_id, $artifact_id, $field_name, $value)
 {
     if ($field_name == self::SPECIAL_SEVERITY && $value == 0) {
         return '';
     }
     if ($value == 100) {
         return '';
     }
     $values_list = $this->dao->searchFieldValuesList($tracker_id, $field_name);
     if (!$values_list) {
         return '';
     }
     foreach ($values_list as $row) {
         if ($row['value_id'] == $value) {
             return Encoding_SupportedXmlCharEncoding::getXMLCompatibleString($row['value']);
         }
     }
     throw new Exception_TV3XMLException("Unknown label for {$artifact_id} {$value}");
 }
 public function exportToSOAP(array &$soap)
 {
     if ($this->body) {
         $body = Encoding_SupportedXmlCharEncoding::getXMLCompatibleString($this->body);
         $soap['body'] = $body;
         return $soap;
     }
 }
 private function fetchListValueLabels(array $field_value_row, $tracker_id)
 {
     $field_name = $this->getFieldNameFromRow($field_value_row);
     if (empty($this->labels[$field_name])) {
         $values_label_rows = $this->dao->searchFieldValuesList($tracker_id, $field_name);
         foreach ($values_label_rows as $values_label_row) {
             $this->labels[$field_name][$values_label_row['value_id']] = Encoding_SupportedXmlCharEncoding::getXMLCompatibleString($values_label_row['value']);
         }
     }
 }
 /**
  * By default, changeset values are returned as string in 'value' field
  */
 protected function encapsulateRawSoapValue($value)
 {
     $value = Encoding_SupportedXmlCharEncoding::getXMLCompatibleString($value);
     return array('value' => $value);
 }
 public function itDoesntRemoveGoodCharsInAnotherEncoding()
 {
     $str = 'REPLACEabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789¶²&é"\'(-è_çà)=~#{[|`\\^@]}£$ù%*µ,;:!?./§\'<>œÇêÊàÀÉ`È¡';
     $str = mb_convert_encoding($str, 'ISO-8859-1');
     $this->assertEqual($str, Encoding_SupportedXmlCharEncoding::getXMLCompatibleString($str));
 }