/**
  * Close current writer and flush if needed.
  *
  * @return void
  */
 public function close()
 {
     if ($this->xmlWriter) {
         $this->xmlWriter->flush();
     }
     $this->xmlWriter = null;
 }
Ejemplo n.º 2
0
 public function end()
 {
     if (!$this->documentEnded) {
         $this->xmlWriter->endDocument();
         $this->xmlWriter->flush();
         $this->documentEnded = true;
     }
 }
Ejemplo n.º 3
0
 public function finalize()
 {
     $this->xml->endElement();
     //root element
     $this->xml->endDocument();
     $this->xml->flush();
     return $this->filename;
 }
Ejemplo n.º 4
0
 public function to_html($parent)
 {
     $w = new XMLWriter();
     $w->openMemory();
     $w->startElement('div');
     $w->writeAttribute('class', 'season');
     $w->startElement('div');
     $w->writeAttribute('class', 'season_name');
     $w->text("Saison " . $this->get_num());
     $w->endElement();
     $w->startElement('div');
     $w->writeAttribute('class', 'episode_container');
     $str = "";
     usort($this->episodes, 'wssub_cmp_num');
     foreach ($this->episodes as $ep) {
         if (!$ep->get_num()) {
             $this->log("Bad ep with no number: " . $ep->to_string(), 'warn');
             continue;
         }
         $str .= $ep->to_html($parent);
     }
     $w->writeRaw($str);
     $w->endElement();
     $w->endElement();
     return $w->flush();
 }
Ejemplo n.º 5
0
 /**
  * Returns the generated XML document or writes it to given filename. All open
  * elements will be automatically closed before flushing.
  * 
  * @param	string		$filename
  * @return	mixed
  */
 public function endDocument($filename = '')
 {
     // mark document as done
     $this->activeDocument = false;
     // close all open tags
     while ($this->openElements) {
         $this->endElement();
     }
     if (empty($filename)) {
         // return XML as string
         return $this->xml->flush(true);
     } else {
         // write to file
         file_put_contents($filename, $this->xml->flush(true));
     }
 }
Ejemplo n.º 6
0
 /**
  * Generate a partial report for a single processed file.
  *
  * Function should return TRUE if it printed or stored data about the file
  * and FALSE if it ignored the file. Returning TRUE indicates that the file and
  * its data should be counted in the grand totals.
  *
  * @param array   $report      Prepared report data.
  * @param boolean $showSources Show sources?
  * @param int     $width       Maximum allowed line width.
  *
  * @return boolean
  */
 public function generateFileReport($report, $showSources = false, $width = 80)
 {
     $out = new XMLWriter();
     $out->openMemory();
     $out->setIndent(true);
     if ($report['errors'] === 0 && $report['warnings'] === 0) {
         // Nothing to print.
         return false;
     }
     $out->startElement('file');
     $out->writeAttribute('name', $report['filename']);
     foreach ($report['messages'] as $line => $lineErrors) {
         foreach ($lineErrors as $column => $colErrors) {
             foreach ($colErrors as $error) {
                 $error['type'] = strtolower($error['type']);
                 if (PHP_CODESNIFFER_ENCODING !== 'utf-8') {
                     $error['message'] = iconv(PHP_CODESNIFFER_ENCODING, 'utf-8', $error['message']);
                 }
                 $out->startElement('error');
                 $out->writeAttribute('line', $line);
                 $out->writeAttribute('column', $column);
                 $out->writeAttribute('severity', $error['type']);
                 $out->writeAttribute('message', $error['message']);
                 $out->writeAttribute('source', $error['source']);
                 $out->endElement();
             }
         }
     }
     //end foreach
     $out->endElement();
     echo $out->flush();
     return true;
 }
Ejemplo n.º 7
0
 public function to_html($parent)
 {
     if (!$this->get_lang()) {
         $this->log("to_html() no lang", 'error');
         return null;
     }
     if (!$this->get_id()) {
         $this->log("to_html() no id", 'error');
         return null;
     }
     if (!$parent->get_request()->is_lang_ok($this->get_lang())) {
         return null;
     }
     $w = new XMLWriter();
     $w->openMemory();
     $w->startElement('div');
     $w->writeAttribute('class', 'subtitle');
     $w->startElement('a');
     $w->writeAttribute('class', 'subtitle_href');
     $w->writeAttribute('href', $parent->get_prefix_url() . '/download-' . $this->get_id() . '.html');
     $w->startElement('img');
     $w->writeAttribute('class', 'subtitle_lang');
     $w->writeAttribute('src', $parent->get_prefix_url() . '/images/flags/' . $this->get_lang() . '.gif');
     $w->endElement();
     $w->endElement();
     $w->endElement();
     return $w->flush();
 }
Ejemplo n.º 8
0
 public static function xml_list()
 {
     $xw = new XMLWriter();
     $xw->openMemory();
     $xw->startDocument('1.0', 'UTF-8');
     $xw->startElement('Albums');
     $xw->setIndent(true);
     foreach (ORM::factory('Album')->with('genre')->order_by('artist')->order_by('name')->find_all()->as_array() as $album) {
         $xw->startElement('Album');
         $xw->startElement('ID');
         $xw->text($album->id);
         $xw->endElement();
         $xw->startElement('Artist');
         $xw->text($album->artist);
         $xw->endElement();
         $xw->startElement('Name');
         $xw->text($album->name);
         $xw->endElement();
         $xw->startElement('Genre');
         $xw->text($album->genre->name);
         $xw->endElement();
         $xw->endElement();
         // Album
     }
     $xw->endElement();
     // Albums
     $data = $xw->outputMemory(true);
     $xw->flush();
     unset($xw);
     return $data;
 }
Ejemplo n.º 9
0
 /**
  * Get written data
  *
  * @return $data
  */
 public function getData() {
 	if ($this->_tempFileName == '') {
 		return $this->_xmlWriter->outputMemory(true);
 	} else {
 		$this->_xmlWriter->flush();
 		return file_get_contents($this->_tempFileName);
 	}
 }
Ejemplo n.º 10
0
Archivo: XML.php Proyecto: fewlines/xml
 /**
  * @param string $resource
  */
 private function writeTo($resource)
 {
     $this->writer->openURI($resource);
     $this->writer->startDocument($this->version, $this->encoding);
     $this->writer->setIndent(true);
     $this->writer->setIndentString("\t");
     $this->getRoot()->save($this->writer);
     $this->writer->endDocument();
     $this->writer->flush();
 }
 /**
  * Fetches the site with the given name and exports it as XML into the given file.
  *
  * @param array<Site> $sites
  * @param boolean $tidy Whether to export formatted XML
  * @param string $pathAndFilename Path to where the export output should be saved to
  * @param string $nodeTypeFilter Filter the node type of the nodes, allows complex expressions (e.g. "TYPO3.Neos:Page", "!TYPO3.Neos:Page,TYPO3.Neos:Text")
  * @return void
  */
 public function exportToFile(array $sites, $tidy = false, $pathAndFilename, $nodeTypeFilter = null)
 {
     $this->resourcesPath = Files::concatenatePaths(array(dirname($pathAndFilename), 'Resources'));
     Files::createDirectoryRecursively($this->resourcesPath);
     $this->xmlWriter = new \XMLWriter();
     $this->xmlWriter->openUri($pathAndFilename);
     $this->xmlWriter->setIndent($tidy);
     $this->exportSites($sites, $nodeTypeFilter);
     $this->xmlWriter->flush();
 }
 /**
  * generate export
  * 
  * @return mixed filename/generated object/...
  */
 public function generate()
 {
     $this->_writer = new XMLWriter();
     $this->_writer->openURI('php://output');
     $this->_writer->startDocument("1.0", "iso-8859-1");
     $this->_writer->startElement("phonebooks");
     $this->_writer->startElement("phonebook");
     $this->_exportRecords();
     $this->_writer->endDocument();
     $this->_writer->flush();
 }
Ejemplo n.º 13
0
 /** returns xml for hosted webservice "annul" 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->endElement();
     $XMLWriter->endDocument();
     return $XMLWriter->flush();
 }
Ejemplo n.º 14
0
 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("merchantid", $this->config->getMerchantId(\ConfigurationProvider::HOSTED_TYPE, $this->countryCode));
     $XMLWriter->endElement();
     $XMLWriter->endDocument();
     return $XMLWriter->flush();
 }
Ejemplo n.º 15
0
 public function to_html($parent)
 {
     $w = new XMLWriter();
     $w->openMemory();
     $w->startElement('div');
     $w->writeAttribute('class', 'log_message');
     $w->startElement('div');
     $w->writeAttribute('class', 'log_message_' . $this->type);
     $w->writeRaw('<div class="log_class">' . $this->class . '</div>::<div class="log_msg">' . $this->msg . '</div>');
     $w->endElement();
     $w->endElement();
     return $w->flush();
 }
Ejemplo n.º 16
0
function GetProjectDetail($projId)
{
    //Return metadata about the columns in each table for a given database (table_schema)
    $qry = "SELECT id, p_name, p_details FROM tb_projects where id = " . $projId;
    date_default_timezone_set('Australia/Sydney');
    error_log("In project_get_detail.php...\n" . $qry);
    $dbConn = opendatabase();
    $result = mysqli_query($dbConn, $qry);
    date_default_timezone_set('Australia/Sydney');
    error_log("Records in Projects: " . mysqli_num_rows($result));
    if (!$result || mysqli_num_rows($result) <= 0) {
        echo "Could not obtain metadata information.";
        return false;
    }
    /*****************************************************************/
    $xml = new XMLWriter();
    //$projXml  = new DOMDocument();
    //$xml->openURI("php://output");
    $xml->openMemory();
    $xml->startDocument();
    $xml->setIndent(true);
    $xml->startElement("projects");
    while ($row = mysqli_fetch_assoc($result)) {
        $xml->startElement("project");
        $xml->writeAttribute('id', $projId);
        $xml->writeRaw($row['p_name']);
        $xml->endElement();
        $xml->startElement("project_details");
        $xml->startCData("details");
        $xml->writeRaw($row['p_details']);
        $xml->endCData();
        $xml->endElement();
    }
    $xml->endElement();
    $xml->endDocument();
    $dbConn->close();
    header('Content-type: text/xml');
    $strXML = $xml->outputMemory(TRUE);
    $xml->flush();
    date_default_timezone_set('Australia/Sydney');
    error_log("String XML:\n " . $strXML);
    //$projXml->loadXML($strXML);
    echo $strXML;
    /*****************************************************************
    	$options = array();
    	while ($row = mysqli_fetch_assoc($result)){
    		$options['object_row'][] = $row;
    	}
    	echo json_encode($options);
    	*****************************************************************/
}
Ejemplo n.º 17
0
 protected function _convertRoot()
 {
     // Find first <book> element
     while (!($this->_reader->nodeType == XMLReader::ELEMENT && $this->_reader->name == 'book')) {
         $this->_reader->read();
     }
     if (!($this->_reader->nodeType == XMLReader::ELEMENT && $this->_reader->name == 'book')) {
         throw new ErrorException("Unable to find root book element");
     }
     // Find the title attribute
     $bookTitle = $this->_reader->getAttribute('title');
     if (!$bookTitle) {
         throw new ErrorException("Unable to find book title attribute");
     }
     // Start XML and write root element
     $this->_writer->startDocument('1.0', 'UTF-8');
     $this->_writer->startElement('book');
     $this->_writer->writeAttribute('xmlns', 'http://arr.gr/humanhelp/book');
     $this->_writer->writeAttribute('timestamp', time());
     // Write title
     $this->_writer->writeElement('title', $bookTitle);
     // Write default pageFilters
     $this->_writer->startElement('pageFilters');
     $this->_writer->startElement('filter');
     $this->_writer->writeAttribute('class', 'HHLib_XhtmlFilter_FixMediaUrls');
     $this->_writer->endElement();
     $this->_writer->startElement('filter');
     $this->_writer->writeAttribute('class', 'HHLib_XhtmlFilter_FixBSSCPopupUrls');
     $this->_writer->endElement();
     $this->_writer->endElement();
     // Start creating the the TOC
     $this->_writer->startElement('toc');
     while ($this->_reader->read()) {
         if ($this->_reader->nodeType == XMLReader::ELEMENT) {
             switch ($this->_reader->name) {
                 case 'page':
                     $this->_convertPage();
                     break;
                 case 'book':
                     $this->_convertBook();
                     break;
             }
         }
     }
     $this->_writer->endElement();
     // End of <toc> element
     $this->_writer->endElement();
     // End of root <book> element
     $this->_writer->endDocument();
     $this->_writer->flush();
 }
Ejemplo n.º 18
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();
}
Ejemplo n.º 19
0
 /**
  * Writes the schema difference definition in $dbSchema to the file $file.
  *
  * @param string          $file
  * @param ezcDbSchemaDiff $dbSchema
  * @todo throw exception when file can not be opened
  */
 public function saveDiffToFile($file, ezcDbSchemaDiff $dbSchema)
 {
     $this->writer = new XMLWriter();
     if (!@$this->writer->openUri($file)) {
         throw new ezcBaseFilePermissionException($file, ezcBaseFileException::WRITE);
     }
     $this->writer->startDocument('1.0', 'utf-8');
     $this->writer->setIndent(true);
     $this->writer->startElement('database');
     $this->writer->flush();
     // New tables
     $this->writer->startElement('new-tables');
     $this->writer->flush();
     foreach ($dbSchema->newTables as $tableName => $table) {
         $this->writeTable($tableName, $table);
         $this->writer->flush();
     }
     $this->writer->endElement();
     $this->writer->flush();
     // Removed tables
     $this->writer->startElement('removed-tables');
     $this->writer->flush();
     foreach ($dbSchema->removedTables as $tableName => $tableStatus) {
         $this->writer->startElement('table');
         $this->writer->startElement('name');
         $this->writer->text($tableName);
         $this->writer->endElement();
         $this->writer->startElement('removed');
         $this->writer->text($tableStatus ? 'true' : 'false');
         $this->writer->endElement();
         $this->writer->endElement();
         $this->writer->flush();
     }
     $this->writer->endElement();
     $this->writer->flush();
     // Changed tables
     $this->writer->startElement('changed-tables');
     $this->writer->flush();
     foreach ($dbSchema->changedTables as $tableName => $table) {
         $this->writeChangedTable($tableName, $table);
         $this->writer->flush();
     }
     $this->writer->endElement();
     $this->writer->flush();
     $this->writer->endElement();
     $this->writer->endDocument();
 }
Ejemplo n.º 20
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());
 }
Ejemplo n.º 21
0
 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("amount", $this->amount);
     $XMLWriter->writeElement("customerrefno", $this->customerRefNo);
     $XMLWriter->writeElement("subscriptionid", $this->subscriptionId);
     if (isset($this->currency)) {
         $XMLWriter->writeElement("currency", $this->currency);
     }
     $XMLWriter->endElement();
     $XMLWriter->endDocument();
     return $XMLWriter->flush();
 }
Ejemplo n.º 22
0
 /**
  * Prints all violations for processed files, in a proprietary XML format.
  *
  * Errors and warnings are displayed together, grouped by file.
  *
  * @param array   $report      Prepared report.
  * @param boolean $showSources Show sources?
  * @param int     $width       Maximum allowed lne width.
  * @param boolean $toScreen    Is the report being printed to screen?
  *
  * @return string
  */
 public function generate($report, $showSources = false, $width = 80, $toScreen = true)
 {
     $out = new XMLWriter();
     $out->openMemory();
     $out->setIndent(true);
     $out->startDocument('1.0', 'UTF-8');
     $out->startElement('phpcs');
     $out->writeAttribute('version', '1.3.3');
     $errorsShown = 0;
     foreach ($report['files'] as $filename => $file) {
         if (empty($file['messages']) === true) {
             continue;
         }
         $out->startElement('file');
         $out->writeAttribute('name', $filename);
         $out->writeAttribute('errors', $file['errors']);
         $out->writeAttribute('warnings', $file['warnings']);
         foreach ($file['messages'] as $line => $lineErrors) {
             foreach ($lineErrors as $column => $colErrors) {
                 foreach ($colErrors as $error) {
                     $error['type'] = strtolower($error['type']);
                     if (PHP_CODESNIFFER_ENCODING !== 'utf-8') {
                         $error['message'] = iconv(PHP_CODESNIFFER_ENCODING, 'utf-8', $error['message']);
                     }
                     $out->startElement($error['type']);
                     $out->writeAttribute('line', $line);
                     $out->writeAttribute('column', $column);
                     $out->writeAttribute('source', $error['source']);
                     $out->writeAttribute('severity', $error['severity']);
                     $out->text($error['message']);
                     $out->endElement();
                     $errorsShown++;
                 }
             }
         }
         //end foreach
         $out->endElement();
     }
     //end foreach
     $out->endElement();
     echo $out->flush();
     return $errorsShown;
 }
Ejemplo n.º 23
0
 public function write()
 {
     $writer = new XMLWriter();
     $writer->openMemory();
     $writer->startDocument('1.0', 'UTF-8');
     $writer->startElement("products");
     foreach ($this->products as $shopProduct) {
         $writer->startElement("product");
         $writer->writeAttribute("title", $shopProduct->getTitle());
         $writer->startElement("summary");
         $writer->text($shopProduct->getSummaryLine());
         $writer->endElement();
         // summary
         $writer->endElement();
         // product
     }
     $writer->endElement();
     // products
     $writer->endDocument();
     print $writer->flush();
 }
Ejemplo n.º 24
0
 /**
  * Generate a partial report for a single processed file.
  *
  * Function should return TRUE if it printed or stored data about the file
  * and FALSE if it ignored the file. Returning TRUE indicates that the file and
  * its data should be counted in the grand totals.
  *
  * @param array                 $report      Prepared report data.
  * @param \PHP_CodeSniffer\File $phpcsFile   The file being reported on.
  * @param bool                  $showSources Show sources?
  * @param int                   $width       Maximum allowed line width.
  *
  * @return bool
  */
 public function generateFileReport($report, File $phpcsFile, $showSources = false, $width = 80)
 {
     $out = new \XMLWriter();
     $out->openMemory();
     $out->setIndent(true);
     $out->startElement('testsuite');
     $out->writeAttribute('name', $report['filename']);
     if (count($report['messages']) === 0) {
         $out->writeAttribute('tests', 1);
         $out->writeAttribute('failures', 0);
         $out->startElement('testcase');
         $out->writeAttribute('name', $report['filename']);
         $out->endElement();
     } else {
         $failures = $report['errors'] + $report['warnings'];
         $out->writeAttribute('tests', $failures);
         $out->writeAttribute('failures', $failures);
         foreach ($report['messages'] as $line => $lineErrors) {
             foreach ($lineErrors as $column => $colErrors) {
                 foreach ($colErrors as $error) {
                     $out->startElement('testcase');
                     $out->writeAttribute('name', $error['source'] . ' at ' . $report['filename'] . " ({$line}:{$column})");
                     $error['type'] = strtolower($error['type']);
                     if ($phpcsFile->config->encoding !== 'utf-8') {
                         $error['message'] = iconv($phpcsFile->config->encoding, 'utf-8', $error['message']);
                     }
                     $out->startElement('failure');
                     $out->writeAttribute('type', $error['type']);
                     $out->writeAttribute('message', $error['message']);
                     $out->endElement();
                     $out->endElement();
                 }
             }
         }
     }
     //end if
     $out->endElement();
     echo $out->flush();
     return true;
 }
Ejemplo n.º 25
0
 protected function writeXML()
 {
     // Create XML File
     $objXml = new XMLWriter();
     $objXml->openMemory();
     $objXml->setIndent(true);
     $objXml->setIndentString("\t");
     // XML Start
     $objXml->startDocument('1.0', 'UTF-8');
     $objXml->startElement('dependencies_filelist');
     // Write meta (header)
     $objXml->startElement('metatags');
     $objXml->writeElement('version', $GLOBALS['SYC_VERSION']);
     $objXml->writeElement('create_unix', time());
     $objXml->writeElement('create_date', date('Y-m-d', time()));
     $objXml->writeElement('create_time', date('H:i', time()));
     $objXml->endElement();
     // End metatags
     foreach ($this->arrFiles as $strDependencies => $arrFiles) {
         $objXml->startElement('dependency');
         $objXml->writeAttribute('name', $strDependencies);
         foreach ($arrFiles as $arrFile) {
             $objXml->startElement('file');
             $objXml->writeAttribute('id', $arrFile['hash']);
             $objXml->writeElement('path', $arrFile['path']);
             $objXml->writeElement('size', $arrFile['size']);
             $objXml->writeElement('hash', $arrFile['hash']);
             $objXml->endElement();
             // End file
         }
         $objXml->endElement();
         // End dependency
     }
     $objXml->endElement();
     // End doc
     $objFile = new File($GLOBALS['TL_CONFIG']['uploadPath'] . '/syncCto_backups/dependencies.xml');
     $objFile->write($objXml->flush());
     $objFile->close();
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $xml = new XMLWriter();
     $xml->openMemory();
     $xml->startDocument('1.0', 'UTF-8');
     $xml->startElement('urlset');
     $xml->writeAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9');
     PathRecord::chunk(200, function ($records) use($xml) {
         foreach ($records as $record) {
             $path = $record->getPath();
             if ($path->exists()) {
                 $url = URL::to($path->getUrl());
                 $xml->startElement('url');
                 $xml->writeElement('loc', $url);
                 $xml->endElement();
             }
         }
     });
     $xml->endElement();
     $xml->endDocument();
     echo $xml->flush();
 }
Ejemplo n.º 27
0
function create_item($arr)
{
    //  属性数组
    $attribute_array = array('title' => array('size' => 1));
    $xml = new XMLWriter();
    $xml->openUri("php://output");
    //  输出方式,也可以设置为某个xml文件地址,直接输出成文件
    $xml->setIndentString('  ');
    $xml->setIndent(true);
    $xml->startDocument('1.0', 'utf-8');
    //  开始创建文件
    //  根结点
    $xml->startElement('article');
    foreach ($arr as $data) {
        $xml->startElement('item');
        if (is_array($data)) {
            foreach ($data as $key => $row) {
                $xml->startElement($key);
                if (isset($attribute_array[$key]) && is_array($attribute_array[$key])) {
                    foreach ($attribute_array[$key] as $akey => $aval) {
                        //  设置属性值
                        $xml->writeAttribute($akey, $aval);
                    }
                }
                $xml->text($row);
                //  设置内容
                $xml->endElement();
                // $key
            }
        }
        $xml->endElement();
        //  item
    }
    $xml->endElement();
    //  article
    $xml->endDocument();
    $xml->flush();
}
Ejemplo n.º 28
0
 public function saveXml()
 {
     $xml = $this->_xmlWriter->flush(false);
     return $xml;
 }
Ejemplo n.º 29
0
/**
 * (re)write the web.config file to prevent browser access to the log file
 */
function handleWebConfig()
{
    if (!isset($_SERVER['IIS_UrlRewriteModule'])) {
        return;
    }
    global $setup_site_log_dir;
    global $setup_site_log_file;
    global $sugar_config;
    // Bug 36968 - Fallback to using $sugar_config values when we are not calling this from the installer
    if (empty($setup_site_log_file)) {
        $setup_site_log_file = $sugar_config['log_file'];
        if (empty($sugar_config['log_file'])) {
            $setup_site_log_file = 'sugarcrm.log';
        }
    }
    if (empty($setup_site_log_dir)) {
        $setup_site_log_dir = $sugar_config['log_dir'];
        if (empty($sugar_config['log_dir'])) {
            $setup_site_log_dir = '.';
        }
    }
    $prefix = $setup_site_log_dir . empty($setup_site_log_dir) ? '' : '/';
    $config_array = array(array('1' => $prefix . str_replace('.', '\\.', $setup_site_log_file) . '\\.*', '2' => 'log_file_restricted.html'), array('1' => $prefix . 'install.log', '2' => 'log_file_restricted.html'), array('1' => $prefix . 'upgradeWizard.log', '2' => 'log_file_restricted.html'), array('1' => $prefix . 'emailman.log', '2' => 'log_file_restricted.html'), array('1' => 'not_imported_.*.txt', '2' => 'log_file_restricted.html'), array('1' => 'XTemplate/(.*)/(.*).php', '2' => 'index.php'), array('1' => 'data/(.*).php', '2' => 'index.php'), array('1' => 'examples/(.*).php', '2' => 'index.php'), array('1' => 'include/(.*).php', '2' => 'index.php'), array('1' => 'include/(.*)/(.*).php', '2' => 'index.php'), array('1' => 'log4php/(.*).php', '2' => 'index.php'), array('1' => 'log4php/(.*)/(.*)', '2' => 'index.php'), array('1' => 'metadata/(.*)/(.*).php', '2' => 'index.php'), array('1' => 'modules/(.*)/(.*).php', '2' => 'index.php'), array('1' => 'soap/(.*).php', '2' => 'index.php'), array('1' => 'emailmandelivery.php', '2' => 'index.php'), array('1' => 'cron.php', '2' => 'index.php'), array('1' => $sugar_config['upload_dir'] . '.*', '2' => 'index.php'));
    $xmldoc = new XMLWriter();
    $xmldoc->openURI('web.config');
    $xmldoc->setIndent(true);
    $xmldoc->setIndentString(' ');
    $xmldoc->startDocument('1.0', 'UTF-8');
    $xmldoc->startElement('configuration');
    $xmldoc->startElement('system.webServer');
    $xmldoc->startElement('rewrite');
    $xmldoc->startElement('rules');
    for ($i = 0; $i < count($config_array); $i++) {
        $xmldoc->startElement('rule');
        $xmldoc->writeAttribute('name', "redirect{$i}");
        $xmldoc->writeAttribute('stopProcessing', 'true');
        $xmldoc->startElement('match');
        $xmldoc->writeAttribute('url', $config_array[$i]['1']);
        $xmldoc->endElement();
        $xmldoc->startElement('action');
        $xmldoc->writeAttribute('type', 'Redirect');
        $xmldoc->writeAttribute('url', $config_array[$i]['2']);
        $xmldoc->writeAttribute('redirectType', 'Found');
        $xmldoc->endElement();
        $xmldoc->endElement();
    }
    $xmldoc->endElement();
    $xmldoc->endElement();
    $xmldoc->startElement('caching');
    $xmldoc->startElement('profiles');
    $xmldoc->startElement('remove');
    $xmldoc->writeAttribute('extension', ".php");
    $xmldoc->endElement();
    $xmldoc->endElement();
    $xmldoc->endElement();
    $xmldoc->startElement('staticContent');
    $xmldoc->startElement("clientCache");
    $xmldoc->writeAttribute('cacheControlMode', 'UseMaxAge');
    $xmldoc->writeAttribute('cacheControlMaxAge', '30.00:00:00');
    $xmldoc->endElement();
    $xmldoc->endElement();
    $xmldoc->endElement();
    $xmldoc->endElement();
    $xmldoc->endDocument();
    $xmldoc->flush();
}
Ejemplo n.º 30
-11
 public static function Encode($requestObject)
 {
     $soap = "";
     try {
         $writer = new XMLWriter();
         $writer->openMemory();
         $writer->startDocument();
         $writer->setIndent(4);
         $writer->startElement("soap:Envelope");
         $writer->writeAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
         $writer->writeAttribute("xmlns:xsd", "http://www.w3.org/2001/XMLSchema");
         $writer->writeAttribute("xmlns:soap", "http://schemas.xmlsoap.org/soap/envelope/");
         $writer->startElement("soap:Body");
         $options = array(XML_SERIALIZER_OPTION_INDENT => '    ', XML_SERIALIZER_OPTION_LINEBREAKS => "\n", XML_SERIALIZER_OPTION_DEFAULT_TAG => '', XML_SERIALIZER_OPTION_TYPEHINTS => false, XML_SERIALIZER_OPTION_IGNORE_NULL => true, XML_SERIALIZER_OPTION_CLASSNAME_AS_TAGNAME => true);
         $serializer = new XML_Serializer($options);
         $result = $serializer->serialize($requestObject);
         if ($result === true) {
             $xml = $serializer->getSerializedData();
             $xml = str_replace('<>', '', $xml);
             $xml = str_replace('</>', '', $xml);
         }
         $writer->writeRaw($xml);
         $writer->endElement();
         $writer->endElement();
         $writer->endDocument();
         $soap = $writer->flush();
         $soap = str_replace("<?xml version=\"1.0\"?>", "", $soap);
     } catch (Exception $ex) {
         throw new Exception("Error occurred while Soap encoding");
     }
     return $soap;
 }