Exemple #1
0
 public function getInfoByCode($user = '', $pass = '', $code = '')
 {
     //用户检查
     $action = new CodeInfo();
     if ($code) {
         $result = $action->getInfoByCodeFormMySystem($code);
     }
     $xw = new XMLWriter();
     $xw->openMemory();
     $xw->startDocument('1.0', 'gb2312');
     //版本與編碼
     $xw->startElement('packet');
     if ($result) {
         $xw->writeElement('result', 'true');
     } else {
         $xw->writeElement('result', 'false');
     }
     //查询条码失败
     $fields = array("code", "factoryNo", "goodsName", "spec", "current1", "voltage1", "direct", "constant", "grade", "madeIn", "madeDate");
     if ($result) {
         $xw->startElement('codeInfo');
         foreach ($result as $key => $value) {
             if (!is_bool(array_search($key, $fields))) {
                 $xw->writeElement($key, $value);
             }
         }
         $xw->endElement('codeInfo');
     }
     $xw->endElement('packet');
     return $xw->outputMemory(true);
 }
Exemple #2
0
 private function writeCommon(\XMLWriter $writer, Common $common)
 {
     if ($common->getAuthor()) {
         $writer->startElement('itunes:author');
         $writer->writeCdata($common->getAuthor());
         $writer->endElement();
     }
     if ($common->getSummary()) {
         $writer->startElement('itunes:summary');
         $writer->writeCdata($common->getSummary());
         $writer->endElement();
     }
     if ($common->getBlock()) {
         $writer->writeElement('itunes:block', 'Yes');
     }
     if ($common->getImage()) {
         $writer->startElement('itunes:image');
         $writer->writeAttribute('href', $common->getImage());
         $writer->endElement();
     }
     $writer->writeElement('itunes:explicit', true === $common->getExplicit() ? 'Yes' : 'No');
     if ($common->getSubtitle()) {
         $writer->startElement('itunes:subtitle');
         $writer->writeCdata($common->getSubtitle());
         $writer->endElement();
     }
 }
 public function addPerfil($nome, $dataNascimento, $idade, $codUsuario)
 {
     # Instancia do objeto XMLWriter
     $xml = new XMLWriter();
     # Cria memoria para armazenar a saida
     $xml->openMemory();
     # Inicia o cabeçalho do documento XML
     $xml->startDocument('1.0', 'iso-8859-1');
     # Adiciona/Inicia um Elemento / Nó Pai <item>
     $xml->startElement("perfil");
     #  Adiciona um Nó Filho <quantidade> e valor 8
     $xml->writeElement("nome", $nome);
     $xml->writeElement("datanascimento", $dataNascimento);
     $xml->writeElement("idade", $idade);
     $xml->writeElement("codusuario", $codUsuario);
     #  Finaliza o Nó Pai / Elemento <Item>
     $xml->endElement();
     #  Configura a saida do conteúdo para o formato XML
     header('Content-type: text/xml');
     # Imprime os dados armazenados
     print $xml->outputMemory(true);
     # Salvando o arquivo em disco
     # retorna erro se o header foi definido
     # retorna erro se outputMemory já foi chamado
     $file = fopen("cod" . $codUsuario . ".xml", "w+");
     fwrite($file, $xml->outputMemory(true));
     fclose($file);
 }
 /**
  * @param string $fileToSave
  * @param number $offsetStart
  * @param number $limit
  * @param null | string $suffix
  *
  * @return string
  */
 protected function saveToFile($fileToSave, $offsetStart, $limit, $suffix = null)
 {
     $writer = new \XMLWriter();
     $path = pathinfo($fileToSave);
     $filePath = $path['dirname'] . '/' . $path['filename'];
     if (!is_null($suffix)) {
         $filePath .= self::SEPERATOR . $suffix;
     }
     if (empty($path['extension'])) {
         $filePath .= self::XML_EXT;
     } else {
         $filePath .= '.' . $path['extension'];
     }
     $writer->openURI($filePath);
     $writer->startDocument('1.0', 'UTF-8');
     $writer->setIndent(true);
     $writer->startElement('sitemapindex');
     $writer->writeAttribute('xmlns', self::SCHEMA);
     for ($i = $offsetStart; $i < count($this->items) && $i < $limit; $i++) {
         $item = $this->items[$i];
         $writer->startElement('sitemap');
         $writer->writeElement('loc', $item['url']);
         $writer->writeElement('lastmod', $item['modified']->format(ModifiableInterface::MODIFIED_DATE_FORMAT));
         $writer->endElement();
     }
     $writer->endElement();
     $writer->endDocument();
     return $filePath;
 }
 public function writeXML(\XMLWriter $xmlWriter)
 {
     if ($this->maximumMessageSize != NULL) {
         $xmlWriter->writeElement(Constants::MAXIMUM_MESSAGE_SIZE, $this->maximumMessageSize);
     }
     if ($this->messageRetentionPeriod != NULL) {
         $xmlWriter->writeElement(Constants::MESSAGE_RETENTION_PERIOD, $this->messageRetentionPeriod);
     }
 }
 /**
  * Write XML output
  * 
  * @param \XMLWriter $xml
  * @param string $nodeName 
  */
 public function writeXml(\XMLWriter $xml, $nodeName)
 {
     $xml->startElement($nodeName);
     if ($conditionType = $this->get('ConditionType')) {
         $xml->writeElement('ConditionType', $conditionType);
     }
     if ($conditionNote = $this->get('ConditionNote')) {
         $xml->writeElement('ConditionNote', $conditionNote);
     }
     $xml->endElement();
 }
 /**
  * Write XML output
  * 
  * @param \XMLWriter $xml
  * @param string $nodeName 
  */
 public function writeXml(\XMLWriter $xml, $nodeName)
 {
     $xml->startElement($nodeName);
     if ($type = $this->get('type')) {
         $xml->writeElement('Type', $type);
     }
     if ($value = $this->get('value')) {
         $xml->writeElement('Value', $value);
     }
     $xml->endElement();
 }
 /**
  * 
  */
 private function writeImagePathElement()
 {
     if (isset($this->ticket['issueType']) && $this->ticket['issueType'] == 'Epic' || $this->ticket['issueType'] == 'Bug') {
         $this->buffer->writeElement('imagePath', config('printer.imagePath')[$this->ticket['issueType']]);
     } else {
         // check for mother ship conditions
         if (isset($this->ticket['hasSubTasks']) && isset($this->ticket['issueType']) && $this->ticket['hasSubTasks'] == 1 && $this->ticket['issueType'] == 'Story') {
             $this->buffer->writeElement('imagePath', config('printer.imagePath')['MotherShip']);
         }
     }
 }
Exemple #9
0
 /**
  * Write XML output
  * 
  * @param \XMLWriter $xml
  * @param string $nodeName 
  */
 public function writeXml(\XMLWriter $xml, $nodeName)
 {
     $xml->startElement($nodeName);
     if ($sku = $this->get('sku')) {
         $xml->writeElement('SKU', $sku);
     }
     if ($type = $this->get('type')) {
         $xml->writeElement('Type', $type);
     }
     $xml->endElement();
 }
 /**
  * @param string    $url
  * @param float     $priority
  * @param string    $changefreq
  * @param \DateTime $lastmod
  */
 public function addEntry($url, $priority = 1.0, $changefreq = 'yearly', \DateTime $lastmod = null)
 {
     $this->map->startElement('url');
     $this->map->writeElement('loc', $url);
     $this->map->writeElement('priority', $priority);
     $this->map->writeElement('changefreq', $changefreq);
     if (false === is_null($lastmod)) {
         $this->map->writeElement('lastmod', $lastmod->format('Y-m-d'));
     }
     $this->map->endElement();
 }
 public function writeXML(\XMLWriter $xmlWriter)
 {
     if ($this->endpoint != NULL) {
         $xmlWriter->writeElement(Constants::ENDPOINT, $this->endpoint);
     }
     if ($this->strategy != NULL) {
         $xmlWriter->writeElement(Constants::STRATEGY, $this->strategy);
     }
     if ($this->contentFormat != NULL) {
         $xmlWriter->writeElement(Constants::CONTENT_FORMAT, $this->contentFormat);
     }
 }
 protected function doProcess($inputPath, $outputPath)
 {
     $sitemap = Yaml::parse(file_get_contents($inputPath));
     if (!isset($sitemap['locations'])) {
         throw new PieCrustException("No locations were defined in the sitemap.");
     }
     $xml = new \XMLWriter();
     $xml->openMemory();
     $xml->setIndent(true);
     $xml->startDocument('1.0', 'utf-8');
     $xml->startElement('urlset');
     $xml->writeAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
     foreach ($sitemap['locations'] as $loc) {
         $xml->startElement('url');
         // loc
         $locUrl = $this->pieCrust->getConfig()->getValueUnchecked('site/root') . ltrim($loc['url'], '/');
         $xml->writeElement('loc', $locUrl);
         // lastmod
         $locLastMod = null;
         if (isset($loc['lastmod'])) {
             $locLastMod = $loc['lastmod'];
         } else {
             if (isset($loc['lastmod_path'])) {
                 $fullPath = $this->pieCrust->getRootDir() . ltrim($loc['lastmod_path'], '/\\');
                 $locLastMod = date('c', filemtime($fullPath));
             } else {
                 $urlInfo = UriParser::parseUri($this->pieCrust, $loc['url']);
                 if ($urlInfo) {
                     if (is_file($urlInfo['path'])) {
                         $locLastMod = date('c', filemtime($urlInfo['path']));
                     }
                 }
             }
         }
         if (!$locLastMod) {
             throw new PieCrustException("No idea what '" . $loc['url'] . "' is. Please specify a 'lastmod' time, or 'lastmod_path' path.");
         }
         $xml->writeElement('lastmod', $locLastMod);
         // changefreq
         if (isset($loc['changefreq'])) {
             $xml->writeAttribute('changefreq', $loc['changefreq']);
         }
         // priority
         if (isset($loc['priority'])) {
             $xml->writeAttribute('priority', $loc['priority']);
         }
         $xml->endElement();
     }
     $xml->endElement();
     $xml->endDocument();
     $markup = $xml->outputMemory(true);
     file_put_contents($outputPath, $markup);
 }
Exemple #13
0
 public function genAPICredentials($paylaod)
 {
     $writer = new XMLWriter();
     $writer->openMemory();
     #$writer->setIndent(TRUE);
     $writer->startElement("APICredentials");
     $writer->writeElement("Username", $this->username);
     $writer->writeElement("TargetGateway", $this->target_gateway);
     $writer->writeElement("PayloadSignature", $this->payloadSignature($paylaod));
     $writer->endElement();
     return $writer->outputMemory();
 }
 public function writeMessagePropertiesForSendXML(\XMLWriter $xmlWriter)
 {
     if ($this->messageBody != NULL) {
         $xmlWriter->writeElement(Constants::MESSAGE_BODY, base64_encode($this->messageBody));
     }
     if ($this->delaySeconds != NULL) {
         $xmlWriter->writeElement(Constants::DELAY_SECONDS, $this->delaySeconds);
     }
     if ($this->priority != NULL) {
         $xmlWriter->writeElement(Constants::PRIORITY, $this->priority);
     }
 }
Exemple #15
0
 /**
  * Construct the record in XMLWriter
  *
  * @return null
  */
 public function build()
 {
     $this->xmlWriter->startElement($this->tagName);
     // Simple required elements
     foreach ($this->simpleValues as $tag => $method) {
         $this->xmlWriter->writeElement($tag, $this->record->{$method}());
     }
     foreach ($this->optionalSimpleValues as $tag => $method) {
         $value = $this->record->{$method}();
         if (!empty($value)) {
             $this->xmlWriter->writeElement($tag, $value);
         }
     }
     foreach ($this->complexValues as $generatorClass => $method) {
         $value = $this->record->{$method}();
         if ($value) {
             /** @var Record $generator */
             $generator = new $generatorClass();
             $generator->setXmlWriter($this->xmlWriter);
             $generator->setRecord($value);
             $generator->build();
         }
     }
     foreach ($this->complexValueSets as $tag => $complex) {
         $this->xmlWriter->startElement($tag);
         $method = $complex['values'];
         // getter method, should return an array
         $generatorClass = $complex['generator'];
         // Should be a subclass of BeerXML\Generator\Record
         $values = $this->record->{$method}();
         $generator = new $generatorClass();
         $generator->setXmlWriter($this->xmlWriter);
         foreach ($values as $record) {
             $generator->setRecord($record);
             $generator->build();
         }
         $this->xmlWriter->endElement();
     }
     // If the given record implements the interface for the display fields, write those too
     if ($this->record instanceof $this->displayInterface) {
         foreach ($this->displayValues as $tag => $method) {
             $value = $this->record->{$method}();
             if (!empty($value)) {
                 $this->xmlWriter->writeElement($tag, $value);
             }
         }
     }
     // Call the parser to allow it to add any other weird fields
     $this->additionalFields();
     $this->xmlWriter->endElement();
 }
Exemple #16
0
 /**
  * Write XML output
  * 
  * @param \XMLWriter $xml
  * @param string $nodeName 
  */
 public function writeXml(\XMLWriter $xml, $nodeName)
 {
     $xml->startElement($nodeName);
     if ($startDate = $this->get('startDate')) {
         $xml->writeElement('StartDate', $startDate->format('c'));
     }
     if ($endDate = $this->get('endDate')) {
         $xml->writeElement('EndDate', $endDate->format('c'));
     }
     if ($salePrice = $this->get('salePrice')) {
         $salePrice->writeXml($xml, 'SalePrice');
     }
     $xml->endElement();
 }
 /**
  * Writes view informations into a XML file, replacing or creating it if necessary.
  */
 public function saveToFile()
 {
     $XMLViewDoc = new XMLWriter();
     $XMLViewDoc->openURI('file://' . VIEW_DATA_DIR . '/' . $this->id . '.xml');
     $XMLViewDoc->setIndent(true);
     $XMLViewDoc->setIndentString('    ');
     $XMLViewDoc->startDocument();
     $XMLViewDoc->startElement("view");
     $XMLViewDoc->writeElement("slice-transformation-filename", $this->getXsltSliceToSVG());
     $XMLViewDoc->writeElement("obsel-transformation-filename", $this->getXsltObselToSVG());
     $XMLViewDoc->writeElement("default-scale", $this->getDefaultScale());
     $XMLViewDoc->writeElement("css-filename", $this->getCssFileName());
     $XMLViewDoc->endElement();
 }
 /** returns xml for hosted webservice "confirm" request */
 protected function createRequestXml()
 {
     $XMLWriter = new \XMLWriter();
     $XMLWriter->openMemory();
     $XMLWriter->setIndent(true);
     $XMLWriter->startDocument("1.0", "UTF-8");
     $XMLWriter->writeComment(\Svea\Helper::getLibraryAndPlatformPropertiesAsJson($this->config));
     $XMLWriter->startElement($this->method);
     $XMLWriter->writeElement("transactionid", $this->transactionId);
     $XMLWriter->writeElement("capturedate", $this->captureDate);
     $XMLWriter->endElement();
     $XMLWriter->endDocument();
     return $XMLWriter->flush();
 }
Exemple #19
0
/**
 * Create RSS Feed
 * @param entries
 * @param config
 */
function create_rss($entries, $config)
{
    // Inspired from http://www.phpntips.com/xmlwriter-2009-06/
    $xml = new XMLWriter();
    // Output directly to the user
    $xml->openURI('php://output');
    $xml->startDocument('1.0');
    $xml->setIndent(2);
    //rss
    $xml->startElement('rss');
    $xml->writeAttribute('version', '2.0');
    $xml->writeAttribute('xmlns:atom', 'http://www.w3.org/2005/Atom');
    //channel
    $xml->startElement('channel');
    // title, desc, link, date
    $xml->writeElement('title', $config['title']);
    // $xml->writeElement('description', $config['description']);
    // $xml->writeElement('link', 'http://www.example.com/rss.hml');
    $xml->writeElement('pubDate', date('r'));
    if (!empty($entries)) {
        foreach ($entries as $entry) {
            // item
            $xml->startElement('item');
            $xml->writeElement('title', $entry->title);
            if (isset($entry->permalink)) {
                $xml->writeElement('link', $entry->permalink);
            }
            $xml->startElement('description');
            $xml->writeCData($entry->content);
            $xml->endElement();
            $xml->writeElement('pubDate', date('r', strtotime($entry->date)));
            // category
            // $xml->startElement('category');
            // $xml->writeAttribute('domain', 'http://www.example.com/cat1.htm');
            // $xml->text('News');
            // $xml->endElement();
            // end item
            $xml->endElement();
        }
    }
    // end channel
    $xml->endElement();
    // end rss
    $xml->endElement();
    // end doc
    $xml->endDocument();
    // flush
    $xml->flush();
}
 public function Voice($MediaId)
 {
     $w = new \XMLWriter();
     $w->openMemory();
     $w->writeElement('MediaId', $MediaId);
     $this->add('Voice', $w->outputMemory(), true);
 }
 protected function _convertBook()
 {
     if (!($this->_reader->name == 'book' && $this->_reader->nodeType == XMLReader::ELEMENT)) {
         throw new ErrorException("Unexpected XML reader position, expecting a book element");
     }
     $title = $this->_reader->getAttribute('title');
     $this->_writer->startElement('folder');
     $this->_writer->writeElement('title', $title);
     while ($this->_reader->read()) {
         if ($this->_reader->nodeType == XMLReader::END_ELEMENT && $this->_reader->name == 'book') {
             break;
             // Done reading book element
         }
         if ($this->_reader->nodeType == XMLReader::ELEMENT) {
             switch ($this->_reader->name) {
                 case 'page':
                     $this->_convertPage();
                     break;
                 case 'book':
                     $this->_convertBook();
                     break;
             }
         }
     }
     $this->_writer->endElement();
     // End <folder> element
 }
Exemple #22
0
 /**
  * Method for parsing of elements
  *
  * @param string $node - node name
  * @param string $item - node content
  * @param bool $wrap - should be wrapped in array for singularization
  *
  * @return void
  *
  * @since 1.0
  */
 protected function handleElement($node, $item, $wrap = true)
 {
     if ($this->dispatcher->listensTo($node)) {
         $this->dispatcher->trigger($node, array($this->writer, $node, $item));
     } else {
         if ($node === self::COMMENT) {
             if (!is_array($item)) {
                 $item = array($item);
             }
             foreach ($item as $comment) {
                 $this->writer->writeComment($comment);
             }
         } elseif ($node === self::CDATA) {
             $this->writer->writeCdata($item);
         } else {
             if ($wrap === true) {
                 if ($this->assertElementName($node)) {
                     if ($this->config->nil_on_null === true && is_null($item)) {
                         $this->writer->startElement($node);
                         $this->writer->writeAttribute('xsi:nil', 'true');
                         $this->writer->writeRaw($item);
                         $this->writer->endElement();
                     } else {
                         $this->writer->writeElement($node, $item);
                     }
                 }
             } else {
                 $this->writer->writeRaw($item);
             }
         }
     }
 }
 /**
  * Generates the export
  *
  * @param integer $categoryId Category Id
  * @param boolean $downwards  If true, downwards, otherwise upward ordering
  * @param string  $language   Language
  *
  * @return string
  */
 public function generate($categoryId = 0, $downwards = true, $language = '')
 {
     global $PMF_LANG;
     // Initialize categories
     $this->category->transform($categoryId);
     $faqdata = $this->faq->get(FAQ_QUERY_TYPE_EXPORT_XHTML, $categoryId, $downwards, $language);
     $version = $this->_config->get('main.currentVersion');
     $comment = sprintf('XHTML output by phpMyFAQ %s | Date: %s', $version, PMF_Date::createIsoDate(date("YmdHis")));
     $this->xml->startDocument('1.0', 'utf-8');
     $this->xml->writeDtd('html', '-//W3C//DTD XHTML 1.0 Transitional//EN', 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd');
     $this->xml->startElement('html');
     $this->xml->writeAttribute('xmlns', 'http://www.w3.org/1999/xhtml');
     $this->xml->writeAttribute('xml:lang', $language);
     $this->xml->writeComment($comment);
     $this->xml->startElement('head');
     $this->xml->writeElement('title', $this->_config->get('main.titleFAQ'));
     $this->xml->startElement('meta');
     $this->xml->writeAttribute('http-equiv', 'Content-Type');
     $this->xml->writeAttribute('content', 'application/xhtml+xml; charset=utf-8');
     $this->xml->endElement();
     $this->xml->endElement();
     // </head>
     $this->xml->startElement('body');
     $this->xml->writeAttribute('dir', $PMF_LANG['dir']);
     if (count($faqdata)) {
         $lastCategory = 0;
         foreach ($faqdata as $data) {
             if ($data['category_id'] != $lastCategory) {
                 $this->xml->writeElement('h1', $this->category->getPath($data['category_id'], ' >> '));
             }
             $this->xml->writeElement('h2', strip_tags($data['topic']));
             $this->xml->startElement('p');
             $this->xml->writeCdata(html_entity_decode($data['content'], ENT_QUOTES, 'UTF-8'));
             $this->xml->endElement();
             $this->xml->writeElement('p', $PMF_LANG['msgAuthor'] . ': ' . $data['author_email']);
             $this->xml->writeElement('p', $PMF_LANG['msgLastUpdateArticle'] . PMF_Date::createIsoDate($data['lastmodified']));
             $lastCategory = $data['category_id'];
         }
     }
     $this->xml->endElement();
     // </body>
     $this->xml->endElement();
     // </html>
     header('Content-type: text/html');
     return $this->xml->outputMemory();
 }
 protected function writeXML()
 {
     $xml = new \XMLWriter();
     $xml->openMemory();
     $xml->setIndent(4);
     $xml->startDocument('1.0', 'utf-8');
     $xml->startElement('d:sync-collection');
     $xml->writeAttribute('xmlns:d', 'DAV:');
     $xml->writeElement('d:sync-token', $this->sync_token);
     $xml->writeElement('d:sync-level', $this->sync_level);
     $xml->startElement('d:prop');
     $xml->writeElement('d:getetag');
     $xml->endElement();
     $xml->endElement();
     $xml->endDocument();
     return $xml->outputMemory();
 }
 /**
  * @param bool $root
  * @return string
  */
 public function pack($root = false)
 {
     $writer = new XMLWriter();
     $writer->openMemory();
     if ($root) {
         $writer->startDocument();
     }
     $writer->startElement('header_info');
     if (isset($this->fromDomain)) {
         $writer->writeElement('from_domain', $this->fromDomain);
     }
     if (isset($this->fromIdentity)) {
         $writer->writeElement('from_identity', $this->fromIdentity);
     }
     $writer->endElement();
     return $writer->outputMemory();
 }
Exemple #26
0
 public function save($locale, $path)
 {
     $xml = new XMLWriter();
     $xml->openMemory();
     $xml->setIndent(true);
     $xml->startDocument('1.0', 'UTF-8');
     $xml->startElement('xliff');
     $xml->writeAttribute('version', '1.0');
     $xml->startElement('file');
     $xml->writeAttribute('original', 'global');
     $xml->writeAttribute('source-language', 'en');
     $xml->writeAttribute('target-language', $locale);
     $xml->writeAttribute('datatype', 'plaintext');
     $xml->startElement('body');
     
     $count = 1;
     foreach ($this->translations[$locale] as $key => $translation) {
         if (is_array($translation)) {
             $count2 = 0;
             $xml->startElement('group');
             $xml->writeAttribute('restype', 'x-gettext-plurals');
             foreach ($translation as $k => $v) {
                 $xml->startElement('trans-unit');
                 $xml->writeAttribute('id', "{$count}[{$count2}]");
                 if (is_string($k)) $xml->writeAttribute('resname', $k);
                 $xml->writeElement('source', $key);
                 $xml->writeElement('target', $v);
                 $xml->endElement();
                 $count2++;
             }
             $xml->endElement();
         } else {
             $xml->startElement('trans-unit');
             $xml->writeAttribute('id', $count);
             $xml->writeElement('source', $key);
             $xml->writeElement('target', $translation);
             $xml->endElement();
         }
         $count++;
     }
     
     $xml->endElement();
     $xml->endElement();
     $xml->endElement();
     file_put_contents($this->get_translation_file_path($path, $locale), $xml->flush());
 }
 /**
  * @param bool $root
  * @return string
  */
 public function pack($root = false)
 {
     $writer = new XMLWriter();
     $writer->openMemory();
     if ($root) {
         $writer->startDocument();
     }
     $writer->startElement('scalar_string_attribute');
     if (isset($this->type)) {
         $writer->writeElement('type', $this->type);
     }
     if (isset($this->value)) {
         $writer->writeElement('value', $this->value);
     }
     $writer->endElement();
     return $writer->outputMemory();
 }
	/**
	 * Exports the messages to XLIFF trans-units.
	 * TODO: Add more information like provided in the web interface.
	 * @param $w XMLWriter
	 * @param $handle
	 * @param $collection MessageCollection
	 */
	protected function messages( XMLWriter $w, $handle, MessageCollection $collection ) {
		$w->startElement( 'body' );

		foreach ( $collection as $key => $m ) {
			$w->startElement( 'trans-unit' );
			$w->writeAttribute( 'id', $key );
			$w->writeElement( 'source', $m->definition() );
			$translation = $m->translatiom();

			if ( $translation !== null ) {
				$w->writeElement( 'target',  $translation );
			}
			$w->endElement();
			fwrite( $handle, $w->outputMemory( true ) );
		}
		$w->endElement(); // </body>
	}
Exemple #29
0
 public function write(\XMLWriter $writer, \DateTimeZone $timezone, $stringTag)
 {
     if ($stringTag) {
         $writer->writeElement('string', $this->value);
     } else {
         $writer->text($this->value);
     }
 }
Exemple #30
0
 /**
  * @param bool $root
  * @return string
  */
 public function pack($root = false)
 {
     $writer = new XMLWriter();
     $writer->openMemory();
     if ($root) {
         $writer->startDocument();
     }
     $writer->startElement('po_info');
     if (isset($this->agentId)) {
         $writer->writeElement('agent_id', $this->agentId);
     }
     if (isset($this->currency)) {
         $writer->writeElement('currency', $this->currency);
     }
     $writer->endElement();
     return $writer->outputMemory();
 }