function to_xml(SimpleXMLElement $object, array $data)
{
    foreach ($data as $key => $value) {
        if (is_array($value)) {
            $new_object = $object->addChild($key);
            to_xml($new_object, $value);
        } else {
            $object->addChild($key, $value);
        }
    }
}
Beispiel #2
0
 public static function response($object, $http_code = 200)
 {
     $format = self::detect_response_format();
     switch ($format) {
         case 'json':
             $output = Response::json($object, $http_code);
             break;
         case 'xml':
             $output = Response::make(to_xml($object), $http_code, array('Content-Type' => 'text/xml'));
             break;
         default:
             $output = Response::json($object, $http_code);
     }
     return $output;
 }
Beispiel #3
0
 function to_xml()
 {
     if (empty($this->{0})) {
         return;
     }
     $xml = '<' . strtolower($this->{0}->t()) . '>';
     foreach ($this as $obj) {
         if (method_exists($obj, 'to_xml')) {
             $xml .= $obj->to_xml();
         } else {
             $xml .= to_xml($obj, null, array('skip_instruct' => true));
         }
     }
     $xml .= '</' . strtolower($this->{0}->t()) . '>';
     return $xml;
 }
 static function render($type, $value = null, $params = array())
 {
     if ($type === false) {
         self::$params['nothing'] = true;
         return;
     }
     if (is_int(strpos($type, '#'))) {
         /**
          * We're rendering a controller/action file.
          * In this case, $value holds the params, and we only change
          * the 'render' value and return. We can't call the
          * render file within this or any function because of variables scope.
          * 
          * This is expected to occur in a controller, therefore in the controller one must
          * also return; after calling this function, so further code won't be executed.
          */
         list($ctrl, $act) = explode('#', parse_url_token($type));
         self::parse_parameters($value);
         self::$render = VIEWPATH . "{$ctrl}/{$act}.php";
         return;
     }
     # Running after-filters.
     ActionController::run_after_filters();
     self::parse_parameters($params);
     if ($type == 'json') {
         header('Content-Type: application/json; charset=utf-8');
         if (is_array($value)) {
             $value = to_json($value);
         }
         echo $value;
         exit;
     } elseif ($type == 'xml') {
         header('Content-type: application/rss+xml; charset=UTF-8');
         if (is_array($value) || is_object($value)) {
             $root = isset($params['root']) ? $params['root'] : 'response';
             $value = to_xml($value, $root);
         }
         echo $value;
         exit;
     } elseif ($type == 'inline') {
         self::$params['render_type'] = 'inline';
         self::$params['render_value'] = $value;
         include SYSROOT . 'action_view/render_markup_default.php';
     }
 }
 function _export($status, $client, $type = 'xml')
 {
     $this->load->model('invoices_model');
     // this function does both excel and xml exporting
     // for convenience, let's just load both plugins
     $this->load->plugin('to_excel');
     $this->load->plugin('to_xml');
     $invoices = $this->invoices_model->getInvoicesAJAX($status, $client, $this->settings_model->get_setting('days_payment_due'));
     if ($invoices->num_rows() > 0) {
         if ($type == 'excel') {
             to_excel($invoices, 'invoices');
         } else {
             to_xml($invoices, 'invoices');
         }
     } else {
         show_error($this->lang->line('error_selection'));
     }
 }
Beispiel #6
0
 function export()
 {
     $this->load->plugin('to_xml');
     to_xml($this->db->get('emails'), 'recipients');
 }
 function variableFromDataRow($row)
 {
     $ci =& get_instance();
     $variableID = $row["VariableID"];
     $variableName = $row["VariableName"];
     $variableCode = $row["VariableCode"];
     $valueType = $row["ValueType"];
     $dataType = $row["DataType"];
     $generalCategory = $row["GeneralCategory"];
     $sampleMedium = $row["SampleMedium"];
     $isRegular = $row["IsRegular"] ? "true" : "false";
     $retVal = "<variable>";
     $retVal .= "<variableCode vocabulary=\"" . $ci->config->item('service_code') . "\" default=\"true\" variableID=\"" . $variableID . "\" >" . $variableCode . "</variableCode>";
     $retVal .= to_xml("variableName", $variableName);
     $retVal .= to_xml("valueType", $valueType);
     $retVal .= to_xml("dataType", $dataType);
     $retVal .= to_xml("generalCategory", $generalCategory);
     $retVal .= to_xml("sampleMedium", $sampleMedium);
     $retVal .= "<unit>";
     $retVal .= to_xml("unitName", $row["VariableUnitsName"]);
     $retVal .= to_xml("unitType", $row["VariableUnitsType"]);
     $retVal .= to_xml("unitAbbreviation", $row["VariableUnitsAbbreviation"]);
     $retVal .= to_xml("unitCode", $row["VariableUnitsID"]);
     $retVal .= "</unit>";
     $retVal .= to_xml("noDataValue", $row["NoDataValue"]);
     $retVal .= "<timeScale " . to_attribute("isRegular", $isRegular) . ">";
     $retVal .= "<unit>";
     $retVal .= to_xml("unitName", $row["TimeUnitsName"]);
     $retVal .= to_xml("unitType", $row["TimeUnitsType"]);
     $retVal .= to_xml("unitAbbreviation", $row["TimeUnitsAbbreviation"]);
     $retVal .= to_xml("unitCode", $row["TimeUnitsID"]);
     $retVal .= "</unit>";
     $retVal .= to_xml("timeSupport", $row["TimeSupport"]);
     $retVal .= "</timeScale>";
     $retVal .= to_xml("speciation", $row["Speciation"]);
     $retVal .= "</variable>";
     return $retVal;
 }
Beispiel #8
0
 function to_xml($options = array())
 {
     return to_xml($this->api_attributes(), "forum_post", $options);
 }
Beispiel #9
0
adjustProj($inProj);
adjustProj($outProj);
if (isset($cleaned['inUnits']) && $cleaned['inUnits'] == 'microdeg' && $inProj == '4326') {
    for ($i = 0; $i < 4; $i++) {
        $values[$i] /= 1000000.0;
    }
}
// Native projection of DB is 900913 (Google Mercator)
// 041114 ensure reprojected bbox completely contains original bbox by
// taking the min and max eastings and northings of each corner
list($sw['e'], $sw['n']) = reproject($values[0], $values[1], $inProj, '900913');
list($nw['e'], $nw['n']) = reproject($values[0], $values[3], $inProj, '900913');
list($ne['e'], $ne['n']) = reproject($values[2], $values[3], $inProj, '900913');
list($se['e'], $se['n']) = reproject($values[2], $values[1], $inProj, '900913');
$bbox = array(min($sw["e"], $nw["e"]), min($sw["n"], $se["n"]), max($ne["e"], $se["e"]), max($ne["n"], $nw["n"]));
$bg = new BboxGetter($bbox, $inProj, $outProj);
$data = $bg->getData($cleaned, null, null, $outProj);
switch ($format) {
    case "geojson":
    case "json":
        header("Content-type: application/json");
        echo json_encode($data);
        break;
    default:
        header("Content-type: text/xml");
        echo '<?xml version="1.0"?>';
        echo "<pre>";
        to_xml($data);
        echo "</pre>";
        break;
}
Beispiel #10
0
 function to_xml($options = array())
 {
     return to_xml($this->api_attributes(), "tag", array('skip_instruct' => true));
 }
Beispiel #11
0
/* создаем подготовленное выражение */
if ($stmt = $mysqli->query("SELECT * FROM  `" . $mysqli->escape_string($_REQUEST['table']) . "` ")) {
    $i = 0;
    /* Выбираем результаты запроса: */
    while ($row = $stmt->fetch_assoc()) {
        $i++;
        $arrData['r_' . $i] = $row;
    }
    if ($_REQUEST['format'] == 'csv') {
        sendHeaderAttachment($_REQUEST['table'] . '.csv', 'text/xml');
        $outputBuffer = fopen("php://output", 'w');
        foreach ($arrData as $fields) {
            fputcsv($outputBuffer, $fields);
        }
        fclose($outputBuffer);
    } else {
        if ($_REQUEST['format'] == 'json') {
            sendHeaderAttachment($_REQUEST['table'] . '.json', 'text/xml');
            echo json_encode($arrData);
        } else {
            if ($_REQUEST['format'] == 'xml') {
                sendHeaderAttachment($_REQUEST['table'] . '.xml', 'text/xml');
                $xml = new SimpleXMLElement('<rootTag/>');
                to_xml($xml, $arrData);
                echo $xml->asXML();
            }
        }
    }
} else {
    echo 'нет такой таблицы';
}
Beispiel #12
0
 function to_xml($opts = array())
 {
     return to_xml($this->api_attributes(), 'post', $opts);
 }
Beispiel #13
0
 function to_xml($options = array())
 {
     return to_xml($this->api_attributes(), array_merge(array('root' => 'comment'), $options));
 }
Beispiel #14
0
 function export()
 {
     $this->load->helper('xml');
     to_xml($this->db->get('emails'), 'recipients');
 }