public function saveXml($extension_txt_id, $template_id_src) { $layouts = $this->getLayoutsByTemplate($template_id_src); $xml_data = array(); foreach ($layouts as $i => $layout) { $xml_data['layout'][$i] = array('name' => $layout['layout_name'], 'template_id' => $extension_txt_id, 'type' => $this->_getTextLayoutType($layout['layout_type']), 'pages' => array('page' => $this->_getLayoutPages4Xml($layout['layout_id'])), 'blocks' => $this->_getLayoutBlocks4Xml($layout['layout_id'])); } $xml = Array2XML::createXML('template_layouts', $xml_data); $xml = $xml->saveXML(); $path = DIR_EXT . $extension_txt_id . '/layout.xml'; if ($xml) { $result = file_put_contents($path, $xml); if ($result) { // and put xml-import call into install.php $import_call = "\n\$layout = new ALayoutManager();\n\$layout->loadXml(array('file' => DIR_EXT.'" . $extension_txt_id . "/layout.xml'));"; $code = file_get_contents(DIR_EXT . $extension_txt_id . '/install.php'); $code = str_replace($import_call, '', $code) . $import_call; file_put_contents(DIR_EXT . $extension_txt_id . '/install.php', $code); // and into uninstall.php $import_call = "\n\$layout = new ALayoutManager('" . $extension_txt_id . "');\n\$layout->deleteTemplateLayouts();"; $code = file_get_contents(DIR_EXT . $extension_txt_id . '/uninstall.php'); $code = str_replace($import_call, '', $code) . $import_call; file_put_contents(DIR_EXT . $extension_txt_id . '/uninstall.php', $code); return true; } else { $this->error = "Can't save extension " . $path . ". Unknown cause."; return false; } } else { return false; } }
function get_quota_data($data) { $response = array("ns1_get_quota_data_response" => array("bucket" => array(array("bucket_id" => "routing", "name" => "planing", "day" => array("date" => "2014-02-04", "quota" => "456", "close_time" => "2014-02-04 13:51:00", "max_available" => "24150", "other_activities" => "175", "used" => "225", "used_quota_percent" => "49.34210526", "count" => "5", "time_slot" => array(array("label" => "08-12", "quota_percent" => "55", "min_quota" => "67", "quota" => "251", "status" => "4", "max_available" => "8400", "other_activities" => "47", "used" => "90", "used_quota_percent" => "35.85657371", "count" => "2", "category" => array(array("label" => "04", "quota_percent" => "6.81818199", "quota" => "9", "stop_booking_at" => "12", "close_time" => "2014-02-04 23:30:00", "max_available" => "5040", "used" => "45", "used_quota_percent" => "500", "count" => "1"), array("label" => "6", "quota_percent" => "93.1818161", "quota" => "123", "stop_booking_at" => "2", "max_available" => "5280", "used" => "45", "used_quota_percent" => "36.58536585", "count" => "1", "work_zone" => array("label" => "98", "status" => "1", "closed_at" => "2014-02-03 08:14:37"))), "total" => array("quota" => "132", "max_available" => "10320", "used" => "90", "count" => "2")), array("label" => "12-17", "quota_percent" => "45", "min_quota" => "567", "quota" => "567", "close_time" => "2014-02-04 16:30:00", "max_available" => "10500", "other_activities" => "89", "used" => "135", "used_quota_percent" => "23.80952381", "count" => "3", "category" => array(array("label" => "04", "quota_percent" => "91.76470947", "quota" => "234", "stop_booking_at" => "7", "max_available" => "6300", "used" => "45", "used_quota_percent" => "19.23076923", "count" => "1"), array("label" => "6", "quota_percent" => "8.23529434", "quota" => "21", "stop_booking_at" => "4", "max_available" => "6600", "used" => "90", "used_quota_percent" => "428.57142857", "count" => "2")), "total" => array("quota" => "255", "max_available" => "12900", "used" => "135", "count" => "3"))), "total" => array("quota" => "818", "max_available" => "18900", "other_activities" => "136", "used" => "225", "count" => "5"))), array("bucket_id" => "planing", "name" => "planing 1", "day" => "")))); $xml = \Array2XML::createXML('soap', $response); $string = $xml->saveXML(); return $string; }
/** * Generate service output json format * @param ApiResult $result */ public static function generateOutput($result) { assert('$result instanceof ApiResult'); $data = $result->convertToArray(); $xml = Array2XML::createXML('zurmoMessage', $data); echo $xml->saveXML(); return; }
public function optOut($email) { //Build request data. $message = array('SITE_ID' => '2010003057', 'MLID' => 194503, 'DATA' => array(array('@attributes' => array('type' => 'extra', 'id' => 'password'), '@value' => $this->_password), array('@attributes' => array('type' => 'email'), '@value' => $email), array('@attributes' => array('type' => 'extra', 'id' => 'state'), '@value' => 'unsubscribed'))); //Convert to XML. $xml = Array2XML::createXML('DATASET', $message); $response = $this->_httpPost('record', 'update', $xml->saveXML()); return $response->TYPE == 'success' ? true : false; }
/** * Sample xml file */ public function actionSample() { header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=\"sample.xml\""); $productsList = array(); $productsList['product'] = array('name' => 'Мой товара', 'price' => 10, 'type' => 'Ваш тип товара', 'manufacturer' => 'Бренд', 'image' => 'http://example.com/myimage.jpg'); $xml = Array2XML::createXML('products', $productsList); echo $xml->saveXML(); Yii::app()->end(); }
private function prepareData() { require_once 'classXML2Array.php'; $xml = Array2XML::createXML('blocks', $this->blocksData); $file = $this->sitePath . 'tmp/' . date('Y-m-d', time()) . '.xml'; ob_start(); echo $xml->saveXML(); $data = ob_get_contents(); ob_end_clean(); $fp = @fopen($file, "w"); @fwrite($fp, $data); @fclose($fp); }
function setDocument($xml) { $this->document = $this->XmlToArray($xml); unset($this->document['ClinicalDocument']['@attributes']); Array2XML::init('1.0', 'UTF-8', true, ['xml-stylesheet' => 'type="text/xsl" href="' . URL . '/lib/CCRCDA/schema/cda2.xsl"']); $data = ['@attributes' => ['xmlns' => 'urn:hl7-org:v3', 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xsi:schemaLocation' => 'urn:hl7-org:v3 CDA.xsd']]; foreach ($this->document['ClinicalDocument'] as $i => $com) { $data[$i] = $com; } // Building the document $this->styledXml = Array2XML::createXML('ClinicalDocument', $data)->saveXML(); unset($data); $this->index = []; foreach ($this->document['ClinicalDocument']['component']['structuredBody']['component'] as $index => $component) { $code = isset($component['section']['code']['@attributes']['code']) ? $component['section']['code']['@attributes']['code'] : ''; //Advance Directives ??? switch ($code) { case '48765-2': $this->index['allergies'] = $index; break; case '10160-0': $this->index['medications'] = $index; break; case '11450-4': $this->index['problems'] = $index; break; case '47519-4': $this->index['procedures'] = $index; break; case '30954-2': $this->index['results'] = $index; break; case '46240-8': $this->index['encounters'] = $index; break; case '51847-2': $this->index['assessments'] = $index; break; case '46239-0': $this->index['chiefcomplaint'] = $index; break; default: $tplId = isset($component['section']['templateId']['@attributes']['root']) ? $component['section']['templateId']['@attributes']['root'] : ''; if ($tplId == '2.16.840.1.113883.10.20.22.2.21.1') { $this->index['advancedirectives'] = $index; } break; } } }
public function saveconfigAction() { require_once Mage::getBaseDir() . '/app/code/local/Etheme/Evoqueconfig/lib/Array2Xml.php'; $name = $this->getRequest()->getParam('name'); $store = $this->getRequest()->getParam('store'); $scope = $store ? 'stores' : 'default'; $sections = array('evoqueconfig', 'evoquecolors', 'evoquelayout', 'evoqueflex'); $data = array(); $data['name'] = $name; foreach ($sections as $section) { $data['sections'][$section] = Mage::getStoreConfig($section, $store); } $xml = Array2XML::createXML('config', $data); $file = Mage::getBaseDir() . '/ev_skins/' . $data['name'] . '.xml'; $content = $xml->saveXML(); @file_put_contents($file, $content); Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('evoqueconfig')->__('New preset configuration saved successfully. You can use it from "Load preset configuration" and find in folder ' . $file)); $this->getResponse()->setRedirect($this->getUrl("*/*/")); }
public function array2xml() { require_once BASEPATH . '../application/third_party/array2xml/Array2XML.php'; /* <?xml version="1.0" encoding="UTF-8"?> <head/> <books type="fiction"> <book author="George Orwell"> <title>1984</title> </book> <book author="Isaac Asimov"> <title><![CDATA[Foundation]]></title> <price>$15.61</price> </book> <book author="Robert A Heinlein"> <title><![CDATA[Stranger in a Strange Land]]></title> <price discount="10%">$18.00</price> </book> </books> */ $books = array('@attributes' => array('type' => 'fiction'), 'book' => array(array('@attributes' => array('author' => 'George Orwell'), 'title' => '1984'), array('@attributes' => array('author' => 'Isaac Asimov'), 'title' => array('@cdata' => 'Foundation'), 'price' => '$15.61'), array('@attributes' => array('author' => 'Robert A Heinlein'), 'title' => array('@cdata' => 'Stranger in a Strange Land'), 'price' => array('@attributes' => array('discount' => '10%'), '@value' => '$18.00')))); $xml = Array2XML::createXML('books', $books); echo $xml->saveXML(); }
public static function respond($rawResponse, $format, $debug) { global $logger, $warnings_payload; $httpStatusCode = $rawResponse['httpStatusCode']; $httpStatusCodeMessage = $rawResponse['httpStatusCodeMessage']; $otherHeaders = $rawResponse['otherHeaders']; $internalStatusCode = $rawResponse['code']; $internalStatusMessage = $rawResponse['message']; $warnings = $warnings_payload; $resourceData = $rawResponse['data']; $response = array(); if ($httpStatusCode == 500) { $response['internal_status'] = array('code' => $httpStatusCode, 'message' => $httpStatusCodeMessage); } else { $response['internal_status'] = array('code' => $internalStatusCode, 'message' => $internalStatusMessage); if (!empty($warnings)) { $response['warnings'] = implode(', ', $warnings); } //TO-DO: Remove "data" key in response; directly show resource list if (!empty($resourceData)) { $response['data'] = $resourceData; } if ($debug) { $response['logs'] = $logger->getEntries(); } } ob_clean(); ob_start(); $logger->debug("***** Result: " . json_encode($response)); /* Set HTTP Status header */ $statusHeader = 'HTTP/1.0 ' . $httpStatusCode . ' ' . $httpStatusCodeMessage; header($statusHeader); header('Access-Control-Allow-Origin: *'); header("Access-Control-Allow-Credentials: true"); header('Access-Control-Allow-Headers: X-Requested-With'); header('Access-Control-Allow-Headers: Content-Type'); header('Access-Control-Allow-Methods: POST, GET, OPTIONS, DELETE, PUT'); header('Access-Control-Max-Age: 86400'); if (array_key_exists('HTTP_ACCESS_CONTROL_REQUEST_HEADERS', $_SERVER)) { header('Access-Control-Allow-Headers: ' . $_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']); } else { header('Access-Control-Allow-Headers: *'); } /* Set Other headers, if any */ if (isset($rawResponse['otherHeaders'])) { foreach ($otherHeaders as $header) { header($header); } } if (isset($format) && $format == 'xml') { header('Content-type:text/xml; charset=utf-8'); $xml = Array2XML::createXML('response', $response); $result = trim($xml->saveXML()); } else { if (isset($format) && $format == 'json') { header('Content-type:application/json; charset=utf-8'); $result = trim(json_encode($response)); } else { $result = serialize($response); } } echo $result; $logger->debug("Buffering: " . var_export(ob_get_status(true), true)); if (ob_get_length() > 0) { ob_end_flush(); ob_flush(); flush(); } return $result; }
foreach ($campos as $x => $val) { $nodo[$val] = $_POST[$val][$i]; if (!$nodo[$val] || empty($nodo[$val])) { $errores[] = "No value for " . $val . " " . $i; } } $nodo["@attributes"] = array("id" => $_POST['id'][$i]); $TelevisionArrForm[] = $nodo; //krumo($nodo); } //krumo($TelevisionArrForm); $Television = array("Televisions" => array("Television" => $TelevisionArrForm, "@attributes" => array("noNamespaceSchemaLocation" => "Televisions.xsd"))); //krumo($Televisions); if (empty($errores)) { $Array2XML = Array2XML::init('1.0', 'iso-8859-1'); $outputDestXML = Array2XML::createXML('Televisions', $Television); $xmlString = $outputDestXML->saveXML(); $xmlString = utf8_encode($xmlString); $xmlDestinoFile = $_SESSION['workfolder_webdir'] . "Television.xml"; $fp = fopen($xmlDestinoFile, 'w'); fwrite($fp, $xmlString); fclose($fp); } else { $message = "<h3>Errores al parsear </h3>" . implode("<br>", $errores); } } /*$xml = simplexml_load_file($xmlDestino, 'SimpleXMLElement',LIBXML_NOCDATA); $json = json_encode($xml); $XMLarray = json_decode($json,TRUE); krumo($XMLarray);*/ $xml = @file_get_contents($xmlDestino);
/** * Create XML file */ public function proccessOutput() { $result = array(); header('Content-Type: text/html;charset=UTF-8'); header('Content-type: application/xml'); header('Content-Disposition: attachment; filename="export.xml"'); header('Content-Transfer-Encoding: binary'); foreach ($this->rows as $key => $row) { // $result['products']['product'][$key] = array('@attributes' => array('id' => 125)); foreach ($row as $index => $value) { if (!empty($value)) { // $result['products'][]=array($k=>$l); $result['product'][$key][$index] = iconv('cp1251', 'utf-8', $value); } } } $xml = Array2XML::createXML('products', $result); echo $xml->saveXML(); Yii::app()->end(); }
#!/usr/bin/php <?php include "array2xml.php"; include "xml2array.php"; $xml = file_get_contents("../test.xml"); $array = XML2Array::createArray($xml); #print_r($array); $php_array = $array; $xml = Array2XML::createXML('root_node_name', $php_array); echo $xml->saveXML();
/** * Output Query in either JSON/XML. The query data is outputted as JSON * by default * * @since 1.1 * @global $wp_query * * @param int $status_code */ public function output($status_code = 200) { global $wp_query; $format = $this->get_output_format(); status_header($status_code); do_action('give_api_output_before', $this->data, $this, $format); switch ($format) { case 'xml': require_once GIVE_PLUGIN_DIR . 'includes/libraries/array2xml.php'; $xml = Array2XML::createXML('give', $this->data); echo $xml->saveXML(); break; case 'json': header('Content-Type: application/json'); if (!empty($this->pretty_print)) { echo json_encode($this->data, $this->pretty_print); } else { echo json_encode($this->data); } break; default: // Allow other formats to be added via extensions do_action('give_api_output_' . $format, $this->data, $this); break; } do_action('give_api_output_after', $this->data, $this, $format); give_die(); }
public static function createXmlApiCall($url, $method, $headers, $data = array()) { $xmlData = Array2XML::createXML('zurmoMessage', $data); $data = array('data' => $xmlData->saveXML()); return ApiRestHelper::createApiCall($url, $method, $headers, $data); }
/** * @method: * Simple functionality that uses another library to convert array to xml */ private function _array_to_xml($array) { $array = json_decode(json_encode($array), true); $xml = Array2XML::createXML('project', $array); return $xml->saveXML(); }
/** * Override in your derivative class to do functionality before the fields are set on the object * @return boolean */ public function beforeSet() { $props = $this->getProperties(); $this->default = json_decode($props['default'], true); unset($props['default']); $this->unsetProperty('default'); /** * Cleaning first */ $configs = array(); foreach ($props['configs'] as $k => $v) { if ($k === 'modules') { /** * */ $checkChanges = array(); $i = 0; foreach ($v as $modName => $vals) { $checkChanges = array(); foreach ($vals['@attributes'] as $x => $y) { $y = trim($y); if ($x === 'name') { continue; } if (empty($y)) { continue; } $checkChanges[$x] = $y; } if (!empty($checkChanges)) { $innerChanges = array(); foreach ($vals['@attributes'] as $x => $y) { $y = trim($y); if ($x === 'name') { continue; } if (empty($y)) { continue; } $checkDefaultModConfs = $this->getModuleConfigs($vals['@attributes']['name']); if (empty($checkDefaultModConfs)) { continue; } if ($checkDefaultModConfs['@attributes'][$x] === $y) { continue; } $innerChanges[$x] = $y; } if (!empty($innerChanges)) { if (!isset($configs['modules'])) { $configs['modules'] = array(); } if (!isset($configs['modules']['module'])) { $configs['modules']['module'] = array(); } $vals['@attributes'] = $this->mergeValues($vals['@attributes'], $checkDefaultModConfs['@attributes']); $configs['modules']['module'][$i] = $vals; } } ++$i; } continue; } foreach ($v['@attributes'] as $x => $y) { $y = trim($y); if (empty($y)) { continue; } if (isset($this->default[$k]['@attributes'][$x]) && $this->default[$k]['@attributes'][$x] === $y) { continue; } $configs[$k]['@attributes'][$x] = $y; } } $this->unsetProperty('configs'); if (empty($configs)) { return $this->modx->lexicon('bbbx.config_err_no_changes'); } require_once $this->modx->bbbx->config['corePath'] . 'vendors/array2xml/Array2XML.php'; $array2xml = Array2XML::createXML('config', $configs); $xml = $array2xml->saveXML(); $xml = preg_replace('/>\\s+</', '><', $xml); $xml = str_replace('<?xml version="1.0" encoding="UTF-8"?>', '', $xml); $xml = trim($xml); $this->setProperty('xml', $xml); return !$this->hasErrors(); }
public function setConfigXMLFromArray(array $input = array(), $rootName = 'root') { if (!$this->modx->user->hasSessionContext('mgr')) { $err = 'Unable to join to server: unauthenticated user!'; $this->setError($err); $this->modx->log(modX::LOG_LEVEL_ERROR, $err, '', __METHOD__, __FILE__, __LINE__); return; } require_once dirname(dirname(__FILE__)) . 'vendors/array2xml/Array2XML.php'; $xml = Array2XML::createXML($rootName, $input); return $xml->saveXML(); }
public function updateRecord($table, $id, $query, $overwrite = false) { $file = $this->directories['data']['core']['dir'] . '/' . $table . '/' . $id . '.xml'; if ($this->tableExists($table) && file_exists($file)) { $this->debugLog('updating record:' . $table . '/' . $id); // pull the original data and manipulate the query data $oldXML = file_get_contents($file); $array = XML2Array::createArray($oldXML); $query['id'] = $id; $old = $array['channel']['item']; // to overwrite or not to overwrite if ($overwrite == false) { $newarray = $this->recordExists($table, $id); $newarray = array_merge($newarray, $query); $newarray = $this->manipulateData($table, $newarray); $array['channel']['item'] = $newarray; } else { $query = $this->manipulateData($table, $query); $array['channel']['item'] = $query; } // save to xml and stick the xml data into the session $xml = Array2XML::createXML('channel', $array['channel']); $xml->save($file); $_SESSION['matrix'][$table]['records'][$id] = $oldXML; // fix values $array['channel']['item'] = $this->unCdata($array['channel']['item']); foreach ($array['channel']['item'] as $field => $value) { if (is_array($value) && isset($value['value'])) { $array['channel']['item'][$field] = $value['value']; } } // return return array('status' => true, 'old' => $old, 'new' => $array['channel']['item']); } else { return array('status' => false, 'old' => $query, 'new' => false); } }
/** * @param null $data * @param string $docType * @return string */ private static function __CDA_v2($data = null, $docType = 'CCD') { // Set up the attributes of the XML $CDABuild = []; $CDABuild['@attributes'] = ['xmlns' => 'urn:hl7-org:v3', 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance']; switch ($docType) { // Referral Note case 'RN': break; // Transfer Summary // Transfer Summary case 'TS': // Merge the Document Level $CDABuild = array_merge($CDABuild, LevelDocument\RealmHeader_US::Insert($data)); $CDABuild = array_merge($CDABuild, LevelDocument\recordTarget::Insert($data)); break; // Continuite Of Care Document (CCD) v2 // Continuite Of Care Document (CCD) v2 default: case 'CCD': // Merge the Document Level $CDABuild = array_merge($CDABuild, LevelDocument\RealmHeader_US::Insert($data)); $CDABuild = array_merge($CDABuild, LevelDocument\recordTarget::Insert($data)); $CDABuild = array_merge($CDABuild, LevelDocument\author::Insert($data)); $CDABuild = array_merge($CDABuild, LevelDocument\dataEnterer::Insert($data)); $CDABuild = array_merge($CDABuild, LevelDocument\informant::Insert($data)); $CDABuild = array_merge($CDABuild, LevelDocument\legalAuthenticator::Insert($data)); $CDABuild = array_merge($CDABuild, LevelDocument\custodian::Insert($data)); $CDABuild = array_merge($CDABuild, LevelDocument\documentationOf::Insert($data)); foreach ($CDABuild['documentationOf']['performer'] as $Performer) { $CDABuild['documentationOf']['performer'][] = LevelDocument\performer::Insert($Performer); } // Merge the Section Level $CDABuild['component']['structuredBody'][] = LevelSection\advanceDirectives::Insert($data); $CDABuild['component']['structuredBody'][] = LevelSection\allergies::Insert($data); $CDABuild['component']['structuredBody'][] = LevelSection\encounters::Insert($data); $CDABuild['component']['structuredBody'][] = LevelSection\familyHistory::Insert($data); $CDABuild['component']['structuredBody'][] = LevelSection\functionalStatus::Insert($data); $CDABuild['component']['structuredBody'][] = LevelSection\immunizations::Insert($data); $CDABuild['component']['structuredBody'][] = LevelSection\medicalEquipment::Insert($data); $CDABuild['component']['structuredBody'][] = LevelSection\medications::Insert($data); $CDABuild['component']['structuredBody'][] = LevelSection\payers::Insert($data); $CDABuild['component']['structuredBody'][] = LevelSection\planOfTreatment::Insert($data); $CDABuild['component']['structuredBody'][] = LevelSection\problems::Insert($data); $CDABuild['component']['structuredBody'][] = LevelSection\procedures::Insert($data); $CDABuild['component']['structuredBody'][] = LevelSection\results::Insert($data); $CDABuild['component']['structuredBody'][] = LevelSection\socialHistory::Insert($data); $CDABuild['component']['structuredBody'][] = LevelSection\vitalSigns::Insert($data); break; } // echo '<pre>'; // print_r($CDABuild); // echo '</pre>'; // Buildup the XML $xml = Array2XML::createXML('ClinicalDocument', $CDABuild); return $xml->saveXML(); }
<?php /************************************************************************** * * Copyright 2012 American Public Media Group * * This file is part of AIR2. * * AIR2 is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * AIR2 is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with AIR2. If not, see <http://www.gnu.org/licenses/>. * *************************************************************************/ require_once 'Array2XML.php'; //var_export($xml); if (!isset($root_node)) { $root_node = 'air2'; } $converter = Array2XML::createXML($root_node, $xml); echo $converter->saveXML();
private static function _array2xml($array) { require_once dirname(__FILE__) . "/array2xml.lib.class.php"; $array['@attributes'] = array('xmlns' => 'http://mqs.aliyuncs.com/doc/v1/'); return Array2XML::createXML('Message', $array)->saveXML(); }
/** * @param array $data * @return bool|string */ public function generatePackage($data = array()) { $project_info = $this->getProjectConfig($this->session->data['dev_tools_prj_id']); $extension = $project_info['extension_txt_id']; if (!$extension) { return false; } if (!is_dir(DIR_EXT . $extension)) { return false; } $config_xml = simplexml_load_file(DIR_EXT . $extension . '/config.xml'); $data['version'] = (string) $config_xml->version; foreach ($config_xml->cartversions->item as $store_version) { $data['cartversions'][] = (string) $store_version; } if (is_writable(DIR_APP_SECTION . 'system/temp') && file_exists(DIR_APP_SECTION . 'system/temp')) { $package_dir = DIR_APP_SECTION . 'system/temp/'; } elseif (!is_dir(DIR_APP_SECTION . 'system/temp')) { $result = mkdir(DIR_APP_SECTION . 'system/temp', 0777); if (!$result) { $package_dir = sys_get_temp_dir(); } else { $package_dir = DIR_APP_SECTION . 'system/temp/'; } } else { $package_dir = sys_get_temp_dir(); } if (file_exists($package_dir . $extension)) { // if stuck files exists - breaks return false; } $package_directory = $package_dir . $extension . '_' . $data['version'] . '/'; mkdir($package_directory, 0777); mkdir($package_directory . '/code', 0777); mkdir($package_directory . '/code/extensions', 0777); mkdir($package_directory . '/code/extensions/' . $extension, 0777); $this->_copyDir(DIR_EXT . $extension, $package_directory . '/code/extensions/' . $extension); // build package.xml $xml_data = array('id' => $extension, 'type' => 'extension', 'version' => $data['version'], 'minversion' => $data['version']); if ($data['cartversions']) { foreach ($data['cartversions'] as &$ver) { $ver = explode('.', $ver); $ver = $ver[0] . "." . $ver[1]; } unset($ver); $xml_data['cartversions'] = array('item' => $data['cartversions']); } $xml_data['package_content'] = array('extensions' => array('extension' => $extension)); $xml = Array2XML::createXML('package', $xml_data); $xml = $xml->saveXML(); file_put_contents($package_directory . 'package.xml', $xml); if ($data['license']) { file_put_contents($package_directory . 'license.txt', $data['license']); } if ($data['copyright']) { file_put_contents($package_directory . 'copyright.txt', $data['copyright']); } $archive = new ABackup($extension . '_' . $data['version']); $archive->archive($package_dir . $extension . '_' . $data['version'] . '.tar.gz', $package_dir, $extension . '_' . $data['version']); if (file_exists($package_dir . $extension . '_' . $data['version'] . '.tar.gz')) { return $package_dir . $extension . '_' . $data['version'] . '.tar.gz'; } else { return false; } }
/** * Method buildCCD() */ public function createCCD() { try { if (!isset($this->pid)) { throw new Exception('PID variable not set'); } $this->xmlData = ['@attributes' => ['xmlns' => 'urn:hl7-org:v3', 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xsi:schemaLocation' => 'urn:hl7-org:v3 CDA.xsd']]; if (isset($this->eid)) { $this->encounter = $this->Encounter->getEncounter((int) $this->eid, false, false); $this->encounter = isset($this->encounter['encounter']) ? $this->encounter['encounter'] : $this->encounter; $this->encounterProvider = $this->User->getUserByUid($this->encounter['provider_uid']); $this->encounterFacility = $this->Facilities->getFacility($this->encounter['facility']); } $this->setRequirements(); $this->setHeader(); /** * Array of sections to include in CCD */ $sections = ['ReasonOfVisit', 'Instructions', 'ReasonForReferral', 'Procedures', 'Vitals', 'Immunizations', 'Medications', 'MedicationsAdministered', 'PlanOfCare', 'CareOfPlan', 'Problems', 'Allergies', 'SocialHistory', 'Results', 'FunctionalStatus']; /** * Run Section method for each section */ foreach ($sections as $Section) { call_user_func([$this, "set{$Section}Section"]); } /** * Build the CCR XML Object */ Array2XML::init('1.0', 'UTF-8', true, ['xml-stylesheet' => 'type="text/xsl" href="' . URL . '/lib/CCRCDA/schema/cda2.xsl"']); $this->xml = Array2XML::createXML('ClinicalDocument', $this->xmlData); } catch (Exception $e) { print $e->getMessage(); } }
function translateOneNode($currentNodeID, $to_languages, $content_type) { global $db, $XMLarray, $error_log; $separator = "7543545165934149"; // Fetch a node from Drupal if a copy does not already exist in sources dir. // $xml_MASTER is the original English-language version // $xml is the copy that will be translated $fn = getcwd() . "/sources/SOURCE_" . $currentNodeID . ".XML"; if (file_exists($fn)) { $xml_MASTER = file_get_contents($fn); if ($content_type == "page") { // Remove <teaser> from "page". The "teaser" is created by truncating the <body>, resulting in invalid XML $xml_MASTER = preg_replace("|<teaser>.*?</teaser>|us", "<teaser></teaser>", $xml_MASTER); } } else { $xml_MASTER = fetchOneNode($currentNodeID); if ($content_type == "page") { $xml_MASTER = preg_replace("|<teaser>.*?</teaser>|us", "<teaser></teaser>", $xml_MASTER); } $fh = fopen($fn, "w"); fwrite($fh, $xml_MASTER); fclose($fh); } foreach ($to_languages as $to_language) { $query = "select drupal_code from sovee.languages where sovee_code = '" . $to_language . "'"; $result = mysql_query($query, $db); while ($row = mysql_fetch_assoc($result)) { $drupalLanguageCode = $row['drupal_code']; } mysql_free_result($result); echo "\n=====================================================================================\n========== ==========\n. . . Translating node {$currentNodeID} ({$content_type}) into {$to_language} . . . \n"; $error_IncompleteNodeFlag = 0; $xml = $xml_MASTER; // Create a copy of the master, to be translated // Convert XML to array $XMLarray = XML2Array::createArray($xml); // Get info about the node // Requested info is placed in the $requestedTags array // and returned in the assoc. array info() $requestedTags = array("type", "tnid"); $info = getXMLinfo($xml, $requestedTags); $derivedContentType = $info['type']; // Build list of containers to parse for the given content_type. $query = "select DISTINCT sovee.node_fields.name from sovee.content_type \nLEFT JOIN sovee.field_map ON sovee.content_type.id = sovee.field_map.content_id\nLEFT JOIN sovee.node_fields ON sovee.node_fields.id = sovee.field_map.field_id\nWHERE sovee.content_type.name = '" . $derivedContentType . "'"; $result = mysql_query($query, $db); while ($row = mysql_fetch_assoc($result)) { $containerArrayTemplate[] = $row['name']; } mysql_free_result($result); // Walk throught the array, extract the specified containers, translate // and replace in the array // All array elements are assumed to be in the [node_export][node] array // $containerArrayTemplate = array("body", "title", "teaser", "field_product_subtitle|n*|value", "field_warranty|n*|value", "field_product_education|n*|value", // "field_prod_man_docs_link|n*|title", // "field_did_you_know|n*|value", "field_product_benefits|n*|value", "nodewords|copyright|value", "nodewords|dcterms.contributor|value", // "nodewords|dcterms.title|value", "nodewords|description|value", "nodewords|keywords|value" ); $containerArray = expandTemplate($containerArrayTemplate); $allContainers = "<div>{$separator}"; foreach ($containerArray as $oneContainer) { echo "\nProcessing container {$oneContainer}\n"; $parents = explode("|", $oneContainer); array_unshift($parents, "node_export", "node"); #echo "Parents: "; #print_r($parents); $XMLfragment = drupal_array_get_nested_value($XMLarray, $parents); if (is_array($XMLfragment)) { $XMLfragment = ""; } $translatedFragment = ""; $patterns = array("|^<div>|us", "|</div>\$|us"); // The "|u" flag enables multibyte support $replacements = array("", ""); if (strlen(trim($XMLfragment)) > 0 and !is_array($XMLfragment)) { $XMLfragment = "<div>" . $XMLfragment . "</div>"; // Encapsulate in dummy <div> to satisfy Sovee translator // echo "ORIGINAL Fragment = |$XMLfragment|\n"; } else { echo "Original Fragment |{$XMLfragment}| is empty -- skipping.\n"; } $allContainers .= $XMLfragment . $separator; // Add at the end of each container to faciliate preg_split } // ------- End of foreach($containerArray as $oneContainer) $allContainers .= "</div>"; // Translate the entire node if target language is not English echo "TO_LANGUAGE = {$to_language}\n"; $xxx = substr($to_language, 0, 2); echo "SUBSTR = |{$xxx}|\n"; $sovee_to_language = $to_language; if (substr($to_language, 0, 2) != "en") { if ($to_language == "es-419") { $sovee_to_language = "es-es"; } // Use standard Spanish for Latin America echo "Sending strings to Sovee . . . \n"; $translatedFragmentAry = translateFrag($allContainers, $currentNodeID, "FULL NODE", $to_language); // Perform the translation $translatedFragment = $translatedFragmentAry['content']; $translatedFragmentError = $translatedFragmentAry['error_count']; // Count of translation errors. 0 = success $error_IncompleteNodeFlag += $translatedFragmentError; } else { echo "English-to-English: No translation needed.\n"; $translatedFragment = $allContainers; $translatedFragmentError = 0; } // print_r($translatedFragmentAry); $separatorPattern = "/{$separator}/u"; $translatedNodeAry = preg_split($separatorPattern, $translatedFragment); // print_r($translatedNodeAry); $translatedContentPointer = 1; reset($containerArray); foreach ($containerArray as $oneContainer) { $parents = explode("|", $oneContainer); array_unshift($parents, "node_export", "node"); $stripped = trim(preg_replace($patterns, $replacements, $translatedNodeAry[$translatedContentPointer])); // Remove the leading and trailing <div>s from the node fragments // Special handling for page_title, which can be a string or an array if ($oneContainer == "page_title" and $stripped == "Array") { $pageTitleParents1 = array('node_export', 'node', 'page_title', 'value'); $pageTitleParents2 = array('node_export', 'node', 'page_title', 'attributes', 'type'); drupal_array_set_nested_value($XMLarray, $pageTitleParents1, "FALSE"); drupal_array_set_nested_value($XMLarray, $pageTitleParents2, "boolean"); } else { if (strlen($stripped) > 0) { drupal_array_set_nested_value($XMLarray, $parents, $stripped); } } $translatedContentPointer++; } // HTML-Encode any info in the <data> container // $dataParents = array('node_export', 'node', 'data'); // $dataFragment = htmlentities(drupal_array_get_nested_value($XMLarray, $dataParents)); // drupal_array_set_nested_value($XMLarray, $dataParents, $dataFragment); #echo "TRANSLATED XML ARRAY:"; #print_r($XMLarray); // Does an older version of this translated node exist? // If yes, return the node# and alias in an array // otherwise, $oldNodeID_ary['number'] == '' $oldNodeID_ary = findOldTranslation($currentNodeID, $to_language); $oldNodeID = $oldNodeID_ary['number']; $oldNodeIDalias = $oldNodeID_ary['url_alias']; if ($oldNodeID != "") { echo "\nFound old node number -- old={$oldNodeID}\n"; } if ($oldNodeIDalias != "") { echo "\nFound old node number alias -- old={$oldNodeIDalias}\n"; } // Update the nid and tnid fields // For new nodes, nid='' // and tnid = the current nid value $XMLarray['node_export']['node']['tnid'] = $currentNodeID; $XMLarray['node_export']['node']['nid'] = $oldNodeID; // $XMLarray['node_export']['node']['language'] = $oldNodeID['drupal_lang_code']; $XMLarray['node_export']['node']['language'] = $drupalLanguageCode; // // // $XMLarray['node_export']['node']['path'] = $oldNodeID['url_alias']; if (isset($XMLarray['node_export']['node']['xmlsitemap']['language'])) { // $XMLarray['node_export']['node']['xmlsitemap']['language'] = $oldNodeID['drupal_lang_code']; $XMLarray['node_export']['node']['xmlsitemap']['language'] = $drupalLanguageCode; } //echo "XMLARRAY = \n"; //print_r($XMLarray); $FOO = $XMLarray['node_export']['node']['nodewords']['location']['latitude']; $BAR = $XMLarray['node_export']['node']['nodewords']['location']['longitude']; echo "FOO = {$FOO}\nBAR = {$BAR}\n"; // If lat or long > 8 chars, set to zero, otherwise node will not import if (isset($XMLarray['node_export']['node']['nodewords']['location']['latitude'])) { if (strlen($XMLarray['node_export']['node']['nodewords']['location']['latitude']) > 8) { $XMLarray['node_export']['node']['nodewords']['location']['latitude'] = 0; } } if (isset($XMLarray['node_export']['node']['nodewords']['location']['longitude'])) { if (strlen($XMLarray['node_export']['node']['nodewords']['location']['longitude']) > 8) { $XMLarray['node_export']['node']['nodewords']['location']['longitude'] = 0; } } // Adjust the menu references $this_plid = $XMLarray['node_export']['node']['menu']['plid']; $this_menu_name = $XMLarray['node_export']['node']['menu']['menu_name']; if ($this_menu_name == "primary-links") { $mquery = "SELECT t_menuid from sovee.menus LEFT JOIN sovee.languages on sovee.menus.language_code = sovee.languages.id WHERE drupal_code = \"" . $drupalLanguageCode . "\" and Eng_menuid = \"" . $this_plid . "\""; echo "MQ = {$mquery}\n"; $rmquery = mysql_query($mquery, $db); $err_msg = trim(mysql_error($db)); if (strlen($err_msg) > 0) { echo "{$mquery}\n{$err_msg}\n\n\n"; } while ($m1 = mysql_fetch_assoc($rmquery)) { $newPlid = $m1['t_menuid']; $XMLarray['node_export']['node']['menu']['plid'] = $newPlid; } mysql_free_result($rmquery); } // Convert array back to XML $encoding = "UTF-8"; $xmlVersion = "1.0"; Array2XML::init($xmlVersion, $encoding); $xmlobj = Array2XML::createXML('DELETE_ME', $XMLarray); // Convert a PHP array to XML, using 'DELETE_ME' as the root_node_name $translated_xml = $xmlobj->saveXML(); // Returned object is of type DOMDocument $translated_xml = preg_replace("/<[\\/]?DELETE_ME>[\n]/u", "", $translated_xml); $fn = getcwd() . "/TRANSLATED_" . $drupalLanguageCode . "_" . $currentNodeID . ".XML"; echo "WRITING {$fn}\n"; $fh = fopen($fn, "w"); fwrite($fh, $translated_xml); fclose($fh); // If node translation was successful, // import the translated node back into Drupal if ($error_IncompleteNodeFlag == 0) { $cmd = "/usr/bin/drush --root=/var/www/pressflow node-export-import --file={$fn}"; echo "COMMAND = {$cmd}\n"; $success = `{$cmd}`; $error = "DRUSH IMPORT RESULTS: {$success}\n"; echo $error; fwrite($error_log, $error); $cmd = "/bin/rm {$fn}"; #$success = `$cmd`; $q1 = "INSERT INTO sovee.progress (node, status, type, language) VALUES(\"" . $currentNodeID . "\", \"1\", \"" . $derivedContentType . "\", \"" . $to_language . "\") ON DUPLICATE KEY UPDATE status=VALUES(status)"; echo "Q1={$q1}\n"; $r1 = mysql_query($q1, $db); } else { $error = "Node {$currentNodeID} ({$content_type}) not completely translated. Not importing into Drupal.\n"; echo $error; $q1 = "INSERT INTO sovee.progress (node, status, type, language) VALUES(\"" . $currentNodeID . "\", \"0\", \"" . $derivedContentType . "\", \"" . $to_language . "\") ON DUPLICATE KEY UPDATE status=VALUES(status)"; $r1 = mysql_query($q1, $db); $err_msg = trim(mysql_error($db)); if (strlen($err_msg) > 0) { echo "{$q1}\n{$err_msg}\n\n\n"; } fwrite($error_log, $error); } echo "========== ==========\n=====================================================================================\n"; } $translated_xml_array = array('status' => $error_IncompleteNodeFlag, 'translated_xml' => $translated_xml); return $translated_xml_array; }
//krumo($_POST); $destacadosArrForm = array(); $campos = array("Titulo", "Texto", "Imagen", "Enlace", "TextoEnlace"); for ($i = 1; $i < (int) ($_POST['numerocampos'] + 1); $i++) { $nodo = array(); foreach ($campos as $x => $val) { $nodo[$val] = $_POST[$val . "_" . $i]; } $nodo["@attributes"] = array("id" => $_POST["id_" . $i]); $destacadosArrForm[] = $nodo; //krumo($nodo); } $Destacados = array("Destacados" => array("Destacado" => $destacadosArrForm, "@attributes" => array("noNamespaceSchemaLocation" => "Destacados.xsd"))); //krumo($Destacados); $Array2XML = Array2XML::init('1.0', 'iso-8859-1'); $outputDestXML = Array2XML::createXML('Destacados', $Destacados); $xmlString = $outputDestXML->saveXML(); $xmlString = utf8_encode($xmlString); $xmlDestino2 = $_SESSION['workfolder_webdir'] . "Destacados.xml"; $fp = fopen($xmlDestino2, 'w'); fwrite($fp, $xmlString); fclose($fp); } /*$xml = simplexml_load_file($xmlDestino, 'SimpleXMLElement',LIBXML_NOCDATA); $json = json_encode($xml); $XMLarray = json_decode($json,TRUE); krumo($XMLarray);*/ $xml = file_get_contents($xmlDestino); // por lo visto es mejor iconv si el texto puede contener caracteres como € que no estan en utf_decode //$xml=iconv("UTF-8", "ISO-8859-1//TRANSLIT", $xml); // utf8_decode para los caracteres especiales, ñ y demás
function json2xml($obj_datas, $type = false, $account = false) { switch ($type) { case 'usrkeys': // write keysettings to expansions module $expm = explode("-", $obj_datas['prov'][0]['provision']['endpoint_model']); $module = '0'; foreach ($obj_datas['prov'][0]['provision']['feature_keys'] as $key => $kind) { /* we support 1 or 2 expansions modules */ if ($expm[1] == 2 && $key > 36) { $keydiff = -36; $module = 1; } $xml_keys .= write_xml_keys($kind, $module, $key - $keydiff, $obj_datas, $account); } return "<functionKeys>\n" . $xml_keys . "</functionKeys>\n"; break; case 'usrpbook': // write keysettings to expansions module $expm = explode("-", $obj_datas['prov'][0]['provision']['endpoint_model']); if ($expm[1] == true) { $module = '0'; foreach ($obj_datas['prov'][0]['provision']['feature_keys'] as $key => $kind) { /* we support 1 or 2 expansions modules */ if ($expm[1] == 2 && $key > 36) { $keydiff = -36; $module = 1; } $xml_pbook .= write_xml_keys($kind, $module, $key - $keydiff, $obj_datas); } } return "<tbook e=\"2\">\n" . $xml_pbook . "</tbook>\n" . '</settings>' . "\n"; break; case 'settings': $array = json_decode(json_encode($obj_datas), true); //$array = XML2Array::createArray($xml); $xml = Array2XML::createXML('settings', $array); $str = $xml->saveXML($xml->documentElement); $str = substr($str, strpos($str, "\n") + 1); $str = substr($str, 0, strrpos($str, "\n")); //echo $str; //exit; return $str . "\n"; break; } }
fclose($handle); } else { $logger->error("Falla en la apertura del archivo"); } $logger->log("{$xml_file} created"); } //foreach files end $logger->log("Processed {$curr_file}/{$num_pending_files} files."); }); $app->get('/import/jsonxml/single/{filename}', function ($filename) use($app, $logger) { $logger->log("Starting import method"); $xml_file = DATA_OUTPUT_DIR . $filename . ".xml"; $handle = fopen(DATA_OUTPUT_DIR . $filename, "r"); $file = fopen($xml_file, "w") or die("Could not open {$xml_file} for writing"); fwrite($file, '<?xml version="1.0" encoding="utf-8"?>'); if ($handle) { while (($line = fgets($handle)) !== false) { $xmlstring = json_decode($line, true); if ($xmlstring == null) { $logger->error(json_last_error_msg()); } unset($xmlstring['lastUpdate']); $xml = Array2XML::createXML('book', $xmlstring); fputs($file, $xml->saveXML($xml->documentElement)); } fclose($file); fclose($handle); } else { $logger->error("Falla en la apertura del archivo"); } });
function getXMLDocument() { try { $filePointer = "../reports/{$this->reportDir}/reportStatement.sql"; if (file_exists($filePointer) && is_readable($filePointer)) { // Important connection parameter, this will allow multiple // prepare tags with the same name. $this->conn = Matcha::getConn(); $this->conn->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); // Get the report SQL statement content $fileContent = file_get_contents($filePointer); // Copy all the request variables into the Prepared Values, // also check if it came from the grid form and normal form. // This because we need to do a POST-PREPARE the SQL statement foreach ($this->request as $field) { $PrepareField[':' . $field['name']]['operator'] = isset($field['operator']) ? $field['operator'] : '='; $PrepareField[':' . $field['name']]['value'] = $field['value']; } // Copy all the request filter variables to the XML, // also check if it came from the grid form and normal form. // This because we need to do a POST-PREPARE the SQL statement foreach ($this->request as $field) { $ReturnFilter[$field['name']]['operator'] = isset($field['operator']) ? $field['operator'] : '='; $ReturnFilter[$field['name']]['value'] = $field['value']; } // Prepare all the variable fields in the SQL Statement $PreparedSQL = $this->PostPrepare($fileContent, $PrepareField); $Queries = explode(';', $PreparedSQL); // Run all the SQL Statement separated by `;` in the file foreach ($Queries as $Query) { if (strlen(trim($Query)) > 0) { $SQL = $this->conn->prepare($Query); $SQL->execute(); $records[] = $SQL->fetchAll(PDO::FETCH_ASSOC); } } $ExtraAttributes['xml-stylesheet'] = 'type="text/xsl" href="report.xsl"'; Array2XML::init('1.0', 'UTF-8', true, $ExtraAttributes); $xml = Array2XML::createXML('records', array('filters' => $ReturnFilter, 'record' => $records[count($records) - 1])); return $xml->saveXML(); } else { throw new Exception('Error: Not SQL Statement file was found or readable.'); } } catch (Exception $Error) { error_log(print_r($Error, true)); return $Error; } }
/** * Save Plugin Configuration to XML * @param string $plugins */ public function pluginConfig($pluginchoose = false, $defaultplugin = false) { //Make config Folder and Plugin Config File writeable $this->writeDynamicScript(array('chmod -R 777 ' . APPLICATION_PATH . '/config')); //Check active Plugins $plugins = $this->parsePlugins(); $pos = 100; foreach ($plugins['available'] as $pa) { $pa['active'] = 0; $pa['pos'] = $pos++; foreach ($pluginchoose as $key => $pc) { if ($pc == $pa['name']) { $pa['active'] = 1; $pa['pos'] = $key; } } if ($defaultplugin == $pa['name']) { $pa['default'] = 1; } $newconfig['plugin'][$pa['pos']] = $pa; } ksort($newconfig['plugin']); include_once APPLICATION_PATH . '/library/array2xml.php'; $xml = Array2XML::createXML('config', $newconfig); $xml->save(APPLICATION_PATH . '/config/plugins.xml'); //Reload Plugins global $service; $service->plugins = $this->getActivePlugins(); return _('Plugin configuration updated'); }