本文整理汇总了PHP中SimpleXMLExtended::asXML方法的典型用法代码示例。如果您正苦于以下问题:PHP SimpleXMLExtended::asXML方法的具体用法?PHP SimpleXMLExtended::asXML怎么用?PHP SimpleXMLExtended::asXML使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleXMLExtended
的用法示例。
在下文中一共展示了SimpleXMLExtended::asXML方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: items_customfields_header
function items_customfields_header()
{
if (!file_exists(GSDATAOTHERPATH . 'plugincustomfields.xml')) {
$xml = new SimpleXMLExtended('<?xml version="1.0" encoding="UTF-8"?><channel></channel>');
$xml->asXML(GSDATAOTHERPATH . 'plugincustomfields.xml');
return true;
}
?>
<style type="text/css">
form #metadata_window table.formtable td .cke_editor td:first-child { padding: 0; }
form #metadata_window table.formtable .cke_editor td.cke_top { border-bottom: 1px solid #AAAAAA; }
form #metadata_window table.formtable .cke_editor td.cke_contents { border: 1px solid #AAAAAA; }
#customfieldsForm .hidden { display:none; }
.shorts {
width:250px !important;
}
.checkp {
margin-top:17px;
}
.user_sub_tr {
border:0px;border-bottom:0px !important; border-bottom-width:0px !important;border-top:0px;border-top-width:0px !important;
}
.user_sub_tr td{
border:0px;border-bottom:0px !important;border-bottom-width:0px !important;padding-top:6px !important; border-top: 0px !important;
}
.resize_img {
max-height:150px;
}
</style>
<?php
}
示例2: printXML
/**
* @author Panagiotis Vagenas <pan.vagenas@gmail.com>
* @since 150213
*/
public function printXML()
{
if (headers_sent()) {
return;
}
if (!$this->simpleXML instanceof SimpleXMLExtended) {
$fileLocation = $this->getFileLocation();
if (!$this->existsAndReadable($fileLocation)) {
die('EW:X:P');
}
$this->simpleXML = simplexml_load_file($fileLocation);
}
header("Content-Type:text/xml");
echo $this->simpleXML->asXML();
exit(0);
}
示例3: toXml
/**
* Function for converting to an XML document.
* Pass in a multi dimensional array or object and this recrusively loops through and builds up an XML document.
*
* @param array $data
* @param string $rootNodeName - what you want the root node to be - defaultsto data.
* @param SimpleXMLElement $xml - should only be used recursively
* @return string XML
*/
public static function toXml($data, $rootNodeName = 'root', $xml = null, $encoding = 'utf-8', $cdata = false)
{
// turn off compatibility mode as simple xml throws a wobbly if you don't.
if (ini_get('zend.ze1_compatibility_mode') == 1) {
ini_set('zend.ze1_compatibility_mode', 0);
}
if ($xml == null) {
$xml = new SimpleXMLExtended("<?xml version='1.0' encoding='" . $encoding . "'?><{$rootNodeName} />");
}
// loop through the data passed in.
foreach ($data as $key => $value) {
// no numeric keys in our xml please!
if (is_numeric($key)) {
// make string key...
//return;
$key = "row";
}
// if there is another array or object found recrusively call this function
if (is_array($value) || is_object($value)) {
$node = $xml->addChild($key);
// recrusive call.
self::toXml($value, $rootNodeName, $node, $encoding, $cdata);
} else {
// add single node.
$value = is_bool($value) ? $value ? 'true' : 'false' : $value;
$value = htmlspecialchars($value);
if ($cdata === true) {
$node = $xml->addChild($key);
$node->addCData($value);
} else {
$xml->addChild($key, $value);
}
}
}
// pass back as string. or simple xml object if you want!
return $xml->asXML();
}
示例4: foreach
$rssItem->addChild("post_password", "", $namespaces["wp"]);
// TODO make configurable
$rssItem->addChild("is_sticky", 0, $namespaces["wp"]);
// TODO make configurable
// the first tag in comments seem to be the original WordPress category
$theFirstTag = null;
foreach ($item["story_tags"] as $story_tag) {
$rssCategory = $rssItem->addChild("category", null);
$rssCategory->addCData($story_tag);
$rssCategory->addAttribute("domain", "post_tag");
$rssCategory->addAttribute("nicename", sluggify($story_tag));
if (is_null($theFirstTag)) {
$theFirstTag = $story_tag;
}
}
if (is_null($theFirstTag)) {
$theFirstTag = 'Japan';
}
// set default category - should be configurable
$rssCategory = $rssItem->addChild("category", null);
$rssCategory->addCData($theFirstTag);
$rssCategory->addAttribute("domain", "category");
$rssCategory->addAttribute("nicename", sluggify($theFirstTag));
}
// indent
$dom = new DOMDocument('1.0', 'utf-8');
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$dom->loadXML($rss->asXML());
$formattedXml = $dom->saveXML();
file_put_contents("newsblur-exported.xml", $formattedXml);
示例5: toXml
public static function toXml($data, $rootNodeName = 'root', $xml = null, $encoding = 'utf-8', $cdata = false)
{
if (ini_get('zend.ze1_compatibility_mode') == 1) {
ini_set('zend.ze1_compatibility_mode', 0);
}
if ($xml == null) {
$xml = new SimpleXMLExtended("<?xml version='1.0' encoding='" . $encoding . "'?><{$rootNodeName} />");
}
foreach ($data as $key => $value) {
if (is_numeric($key)) {
$key = "row";
}
if (is_array($value) || is_object($value)) {
$node = $xml->addChild($key);
self::toXml($value, $rootNodeName, $node, $encoding, $cdata);
} else {
$value = htmlspecialchars($value);
if ($cdata === true) {
$node = $xml->addChild($key);
$node->addCData($value);
} else {
$xml->addChild($key, $value);
}
}
}
return $xml->asXML();
}
示例6: outputObject
//.........这里部分代码省略.........
$rotation->addChild("m4", $oRotation[4]);
$rotation->addChild("m5", $oRotation[5]);
$rotation->addChild("m6", $oRotation[6]);
$rotation->addChild("m7", $oRotation[7]);
$rotation->addChild("m8", $oRotation[8]);
}
//scale
$scale = $transform->addChild("scale");
$oScale = $oObject->getScale();
$scale->addChild("x", $oScale[0]);
$scale->addChild("y", $oScale[1]);
$scale->addChild("z", $oScale[2]);
} catch (Exception $e) {
return $e;
}
//properties
$pickingEnabled = $oObject->isPickingEnabled();
$cosID = $oObject->getCoordinateSystemID();
$shaderMaterial = $oObject->getShaderMaterial();
$occluding = $oObject->isOccluding();
$transparency = $oObject->getTransparency();
$renderPosition = $oObject->getRenderOrderPosition();
$screenAnchor = $oObject->getScreenAnchor();
if (isset($cosID) || isset($shaderMaterial) || isset($occluding) || isset($pickingEnabled) || isset($screenAnchor) || isset($transparency) || isset($renderPosition)) {
$properties = $assets3D->addChild("properties");
if (isset($cosID)) {
$properties->addChild("coordinatesystemid", $cosID);
}
if (isset($shaderMaterial)) {
$properties->addChild("shadermaterial", $shaderMaterial);
}
if ($occluding) {
$properties->addChild("occluding", "true");
}
if (isset($transparency) && $transparency > 0) {
$properties->addChild("transparency", $oObject->getTransparency());
}
if (isset($pickingEnabled) && !$pickingEnabled) {
$properties->addChild("pickingenabled", "false");
}
if (isset($renderPosition)) {
$properties->addChild("renderorder", $oObject->getRenderOrderPosition());
}
if (isset($screenAnchor)) {
$screenAnchorProperty = $properties->addChild("screenanchor", $oObject->getScreenAnchor());
if ($oObject->getScreenAnchorFlag() != NULL) {
$screenAnchorProperty->addAttribute("flags", $oObject->getScreenAnchorFlag(), null);
}
}
}
}
//viewparameters
if ($oObject->getVisibility() || $oObject->getMinAccuracy() || $oObject->getMinDistance() || $oObject->getMaxDistance()) {
$viewparameter = $object->addChild("viewparameters");
if ($oObject->getVisibility()) {
$visibility = $viewparameter->addChild("visibility");
$oVisibility = $oObject->getVisibility();
if (isset($oVisibility["liveview"]) && !$oVisibility["liveview"]) {
$visibility->addChild("liveview", "false");
}
if (isset($oVisibility["maplist"]) && !$oVisibility["maplist"]) {
$visibility->addChild("maplist", "false");
}
if (isset($oVisibility["radar"]) && !$oVisibility["radar"]) {
$visibility->addChild("radar", "false");
}
//alternatively for 0,1,2
if (isset($oVisibility[0]) && !$oVisibility[0]) {
$visibility->addChild("liveview", "false");
}
if (isset($oVisibility[1]) && !$oVisibility[1]) {
$visibility->addChild("maplist", "false");
}
if (isset($oVisibility[2]) && !$oVisibility[2]) {
$visibility->addChild("radar", "false");
}
}
if ($oObject->getMinAccuracy()) {
$viewparameter->addChild("minaccuracy", $oObject->getMinAccuracy());
}
if ($oObject->getMinDistance()) {
$viewparameter->addChild("mindistance", $oObject->getMinDistance());
}
if ($oObject->getMaxDistance()) {
$viewparameter->addChild("maxdistance", $oObject->getMaxDistance());
}
}
//parameters
if ($oObject->getParameters()) {
$parameters = $object->addChild("parameters");
foreach ($oObject->getParameters() as $key => $parValue) {
$parameter = $parameters->addCData("parameter", $parValue);
$parameter->addAttribute("key", $key);
}
}
$out = $object->asXML();
$pos = strpos($out, "?>");
echo utf8_encode(trim(substr($out, $pos + 2)));
ob_flush();
}
示例7:
$desc = $row['description'];
$distance = $row['distance'];
$item_title = $category . ", " . $price . " " . $currency . ", " . $city_name;
if ($distance != "") {
$item_title .= ", " . $distance . " км от Йошкар-Олы";
}
if ($is_owner != "") {
$item_title .= ", " . $owner_term;
}
$item_description = '<![CDATA[';
if ($photo_name != "") {
$item_description .= '<img src="' . $url_photo . '/' . $kind_id_house . '/' . $property_id . '/' . $photo_name . '" style="float: left"/>';
}
$item_description .= '<p>' . $desc . '</p>';
$item_description .= ']]>';
# запись в xml переменную
$offer_ = $xml->addChild('item');
$offer_->addChild('title', $item_title);
$offer_->link = $url_land;
$offer_->addChild('description', $item_description);
$offer_->addChild('pubDate', $updated_date);
}
$previous_id = $property_id;
}
mysql_free_result($result);
#сохраняем в xml файл
//$rss->asXML('rss1.xml');
}
echo $rss->asXML();
mysql_close;
}
示例8: backup
function backup()
{
$settings = Plugin::getAllSettings('backup_restore');
// All of the tablesnames that belong to Fresh CMS core.
$tablenames = array('layout', 'page', 'page_part', 'page_tag', 'permission', 'plugin_settings', 'setting', 'snippet', 'tag', 'user', 'user_permission');
// All fields that should be wrapped as CDATA
$cdata_fields = array('content', 'content_html');
// Setup XML for backup
$xmltext = '<?xml version="1.0" encoding="UTF-8"?><freshcms></freshcms>';
$xmlobj = new SimpleXMLExtended($xmltext);
$xmlobj->addAttribute('version', CMS_VERSION);
// Retrieve all database information for placement in XML backup
global $__CMS_CONN__;
Record::connection($__CMS_CONN__);
$lasttable = '';
// Generate XML file entry for each table
foreach ($tablenames as $tablename) {
$table = Record::query('SELECT * FROM ' . TABLE_PREFIX . $tablename);
while ($entry = $table->fetchObject()) {
if ($lasttable !== $tablename) {
$lasttable = $tablename;
$child = $xmlobj->addChild($tablename . 's');
}
$subchild = $child->addChild($tablename);
while (list($key, $value) = each($entry)) {
if ($key === 'password' && $settings['pwd'] === '0') {
$value = '';
}
if (in_array($key, $cdata_fields, true)) {
$subchild->addCData($key, $value);
} else {
$subchild->addChild($key, $value);
}
}
}
}
// Create the XML file
$file = $xmlobj->asXML();
$filename = 'freshcms-backup-' . date($settings['stamp']);
// Offer a plain XML file or a zip file for download
if ($settings['zip'] == '1') {
// Create a note file
$note = "---[ NOTES for {$filename}.xml ]---\n\n";
$note .= "This backup was created for a specific Fresh CMS version, please only restore it\n";
$note .= "on the same version.\n\n";
$note .= "When restoring a backup, upload the UNzipped XML file, not this zip file.\n\n";
$note .= 'Created on ' . date('Y-m-d') . ' at ' . date('H:i:s') . ' GTM ' . date('O') . ".\n";
$note .= 'Created with BackupRestore plugin version ' . BR_VERSION . "\n";
$note .= 'Created for Fresh CMS version ' . CMS_VERSION . "\n\n";
$note .= '---[ END NOTES ]---';
use_helper('Zip');
$zip = new Zip();
$zip->clear();
$zip->addFile($note, 'readme.txt');
$zip->addFile($file, $filename . '.xml');
$zip->download($filename . '.zip');
} else {
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: private', false);
header('Content-Type: text/xml; charset=UTF-8');
header('Content-Disposition: attachment; filename=' . $filename . '.xml;');
header('Content-Transfer-Encoding: 8bit');
header('Content-Length: ' . strlen($file));
echo $file;
}
}
示例9: generateXmlFlow
//.........这里部分代码省略.........
$tagsTexts[$tag['iso_code']][] = $tag['name'];
}
$tags_item = $product->addChild('tags');
foreach ($tagsIso as $iso) {
$languageVariant = $tags_item->addChild('language-variant');
$languageVariant->addChild('locale', $iso);
$languageVariant->addCData('value', implode(',', $tagsTexts[$iso]));
}
}
$groupAttributes = Db::getInstance()->ExecuteS('
SELECT DISTINCT agl.id_attribute_group, agl.name, l.iso_code, a.id_attribute, al.name as attribute_name, al.id_lang, pa.id_product_attribute
FROM ' . _DB_PREFIX_ . 'attribute_group_lang agl
LEFT JOIN ' . _DB_PREFIX_ . 'attribute a ON (a.id_attribute_group = agl.id_attribute_group)
LEFT JOIN ' . _DB_PREFIX_ . 'attribute_lang al ON (al.id_attribute = a.id_attribute)
LEFT JOIN ' . _DB_PREFIX_ . 'lang l ON (l.id_lang = al.id_lang)
LEFT JOIN ' . _DB_PREFIX_ . 'product_attribute_combination pac ON (pac.id_attribute = a.id_attribute)
LEFT JOIN ' . _DB_PREFIX_ . 'product_attribute pa ON (pa.id_product_attribute = pac.id_product_attribute)
WHERE pa.id_product = ' . (int) $sqlProduct['id_product'] . '
GROUP BY a.id_attribute, l.iso_code');
$groups = array();
foreach ($groupAttributes as $groupAttribute) {
$id_group_attribute = $groupAttribute['id_attribute_group'];
$id_attribute = $groupAttribute['id_attribute'];
$id_product_attribute = $groupAttribute['id_product_attribute'];
$groups[$id_group_attribute]['name'][$groupAttribute['iso_code']] = $groupAttribute['name'];
$groups[$id_group_attribute]['attributes'][$groupAttribute['id_attribute']][$groupAttribute['iso_code']] = $groupAttribute['attribute_name'];
}
if (!empty($groups)) {
foreach ($groups as $id_group => $group) {
$xml_group = $product->addChild('attribute-group');
$xml_group->addAttribute('id', $id_group);
if (!empty($group['name'])) {
$nameGroup = $xml_group->addChild('name');
$languageVariant = $nameGroup->addChild('language-variant');
foreach ($group['name'] as $iso2 => $name_group) {
$variant = $languageVariant->addChild('variant');
$variant->addChild('locale', $iso2);
$variant->addCData('value', $name_group);
}
}
if (!empty($group['attributes'])) {
foreach ($group['attributes'] as $id_attribute => $attribute) {
$xml_attribute = $xml_group->addChild('attribute');
$xml_attribute->addAttribute('id', $id_attribute);
$languageVariant = $xml_attribute->addChild('language-variant');
foreach ($attribute as $iso2 => $name_attribute) {
$variant = $languageVariant->addChild('variant');
$variant->addChild('locale', $iso2);
$variant->addCData('value', $name_attribute);
}
}
}
}
}
$groupAttributes = Db::getInstance()->ExecuteS('
SELECT agl.id_attribute_group, agl.name, l.iso_code, a.id_attribute, al.name attribute_name, al.id_lang, pa.id_product_attribute
FROM ' . _DB_PREFIX_ . 'attribute_group_lang agl
LEFT JOIN ' . _DB_PREFIX_ . 'lang l ON (l.id_lang = agl.id_lang)
LEFT JOIN ' . _DB_PREFIX_ . 'attribute a ON (a.id_attribute_group = agl.id_attribute_group)
LEFT JOIN ' . _DB_PREFIX_ . 'attribute_lang al ON (al.id_attribute = a.id_attribute)
LEFT JOIN ' . _DB_PREFIX_ . 'product_attribute_combination pac ON (pac.id_attribute = a.id_attribute)
LEFT JOIN ' . _DB_PREFIX_ . 'product_attribute pa ON (pa.id_product_attribute = pac.id_product_attribute)
WHERE pa.id_product = ' . (int) $sqlProduct['id_product']);
$combinaison = array();
foreach ($groupAttributes as $groupAttribute) {
$id_group_attribute = $groupAttribute['id_attribute_group'];
$id_attribute = $groupAttribute['id_attribute'];
$id_product_attribute = $groupAttribute['id_product_attribute'];
$combinaison[$id_product_attribute][$id_group_attribute] = $id_attribute;
}
$productAttributes = Db::getInstance()->ExecuteS('
SELECT pa.id_product_attribute, pa.weight, pa.quantity, pi.id_image
FROM ' . _DB_PREFIX_ . 'product_attribute pa
LEFT JOIN ' . _DB_PREFIX_ . 'product_attribute_image pi ON (pa.id_product_attribute = pi.id_product_attribute)
WHERE pa.id_product = ' . (int) $sqlProduct['id_product']);
if (!empty($productAttributes)) {
foreach ($productAttributes as $productAttribute) {
$id_product_attribute = (int) $productAttribute['id_product_attribute'];
$attributeCombination = $product->addChild('attribute-combination');
$attributeCombination->addAttribute('id', $id_product_attribute);
$attributeCombination->addChild('weight', (double) ($sqlProduct['weight'] + $productAttribute['weight']));
$attributeCombination->addChild('final-retail-price-with-tax', Product::getPriceStatic((int) $sqlProduct['id_product'], true, $id_product_attribute));
$attributeCombination->addChild('final-retail-price-without-tax', Product::getPriceStatic((int) $sqlProduct['id_product'], false, $id_product_attribute));
$attributeCombination->addChild('quantity', $productAttribute['quantity']);
if (isset($productAttribute['id_image']) && !empty($productAttribute['id_image'])) {
$image = $attributeCombination->addChild('image');
$image->addAttribute('ref-id', $productAttribute['id_image']);
}
if (isset($combinaison[$id_product_attribute]) && !empty($combinaison[$id_product_attribute])) {
foreach ($combinaison[$id_product_attribute] as $id_group_attribute => $id_attribute) {
$attribute = $attributeCombination->addChild('attribute');
$attribute->addAttribute('group-ref-id', $id_group_attribute);
$attribute->addAttribute('ref-id', $id_attribute);
}
}
}
}
}
echo $products->asXML();
}
示例10: foreach
$forumThreadXML->addChild('author_name', $forum_thread['author_name']);
$forum_posts = $bot->forum->get_all_forum_posts($forum_id, $thread_id);
if (is_array($forum_posts)) {
foreach ($forum_posts as $post_id => $forum_post) {
$forumPostXML = $forumThreadXML->addChild('post');
$forumPostXML->addCData($forum_post['message']);
$forumPostXML->addAttribute('id', $forum_post['post_id']);
$forumPostXML->addAttribute('author_id', $forum_post['author_id']);
$forumPostXML->addAttribute('author_name', $forum_post['author_name']);
$forumPostXML->addAttribute('last_change', $forum_post['last_change']);
}
}
}
}
$fh = fopen($file_forum, 'w');
fwrite($fh, $forumXML->asXML());
fclose($fh);
}
}
$bot->add_privmsg("Forum backup done!", $data['user']);
} else {
$bot->add_privmsg("Ne Ne Ne!", $data['user']);
}
}, 'operator');
// special functions
if (!function_exists('sanitize_title_with_dashes')) {
function sanitize_title_with_dashes($title)
{
$title = strip_tags($title);
// Preserve escaped octets.
$title = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '---$1---', $title);
示例11: fopen
foreach ($order->get_items() as $item_id => $item) {
$liquid = $liquids->addChild('liquid');
$li_name = $liquid->name = NULL;
$li_name = $liquid->name->addCData($item['name']);
$li_id = $liquid->addChild('id', $item_id);
$li_amount = $liquid->addChild('amount', $item[qty]);
}
//Create the XML file
$fp = fopen("C:/wamp/www/wp/orders/order" . $order_id . ".xml", "wb");
if (!$fp) {
echo 'can not create xml';
} else {
echo 'xml created';
}
//Write the XML nodes
fwrite($fp, $xml->asXML());
//Close the database connection
fclose($fp);
?>
<h2><?php
_e('Order Details', 'woocommerce');
?>
</h2>
<table class="shop_table order_details">
<thead>
<tr>
<th class="product-name"><?php
_e('Product', 'woocommerce');
?>
</th>
<th class="product-total"><?php
示例12: executeGetParlamentoIdParlamentariInCarica
public function executeGetParlamentoIdParlamentariInCarica()
{
$ramo = $this->getRequestParameter('ramo');
$resp_node = new SimpleXMLExtended('<opp xmlns="' . $this->opp_ns . '" ' . ' xmlns:opp="' . $this->op_ns . '" ' . ' xmlns:xlink="' . $this->xlink_ns . '" >' . '</opp>');
// start producing xml
$content_node = $resp_node->addChild('opp:content', null, $this->op_ns);
$c = new Criteria();
if ($ramo == 'C') {
$arr_tipo_id = array(1);
} else {
$arr_tipo_id = array(4, 5);
}
$c->add(OppCaricaPeer::TIPO_CARICA_ID, $arr_tipo_id, Criteria::IN);
$c->add(OppCaricaPeer::DATA_FINE, NULL, Criteria::ISNULL);
$parlamentari = OppCaricaPeer::doSelect($c);
foreach ($parlamentari as $p) {
$p_node = $content_node->addChild('parlamentare', $p->getId());
$p_node->addAttribute('parlamento_id', $p->getParliamentId());
}
$xmlContent = $resp_node->asXML();
$this->_send_output($xmlContent);
return sfView::NONE;
}
示例13: backup
function backup()
{
$settings = Plugin::getAllSettings('backup_restore');
// All of the tablesnames that belong to Wolf CMS core.
$tablenames = array();
if (strpos(DB_DSN, 'mysql') !== false) {
$sql = 'show tables';
}
if (strpos(DB_DSN, 'sqlite') !== false) {
$sql = 'SELECT name FROM SQLITE_MASTER WHERE type="table" ORDER BY name';
}
if (strpos(DB_DSN, 'pgsql') !== false) {
$sql = "select tablename from pg_tables where schemaname='public'";
}
Record::logQuery($sql);
$pdo = Record::getConnection();
$result = $pdo->query($sql);
while ($col = $result->fetchColumn()) {
$tablenames[] = $col;
}
// All fields that should be wrapped as CDATA
$cdata_fields = array('title', 'content', 'content_html');
// Setup XML for backup
$xmltext = '<?xml version="1.0" encoding="UTF-8"?><wolfcms></wolfcms>';
$xmlobj = new SimpleXMLExtended($xmltext);
$xmlobj->addAttribute('version', CMS_VERSION);
// Retrieve all database information for placement in XML backup
global $__CMS_CONN__;
Record::connection($__CMS_CONN__);
// Generate XML file entry for each table
foreach ($tablenames as $tablename) {
$table = Record::query('SELECT * FROM ' . $tablename);
$child = $xmlobj->addChild($tablename . 's');
while ($entry = $table->fetch(PDO::FETCH_ASSOC)) {
$subchild = $child->addChild($tablename);
foreach ($entry as $key => $value) {
if ($key == 'password' && $settings['pwd'] === '0') {
$value = '';
}
if (in_array($key, $cdata_fields, true)) {
$valueChild = $subchild->addCData($key, $value);
} else {
$valueChild = $subchild->addChild($key, str_replace('&', '&', $value));
}
if ($value === null) {
$valueChild->addAttribute('null', true);
}
}
}
}
// Add XML files entries for all files in upload directory
if ($settings['backupfiles'] == '1') {
$dir = realpath(FILES_DIR);
$this->_backup_directory($xmlobj->addChild('files'), $dir, $dir);
}
// Create the XML file
$file = $xmlobj->asXML();
$filename = 'wolfcms-backup-' . date($settings['stamp']) . '.' . $settings['extension'];
// Offer a plain XML file or a zip file for download
if ($settings['zip'] == '1') {
// Create a note file
$note = "---[ NOTES for {$filename} ]---\n\n";
$note .= "This backup was created for a specific Wolf CMS version, please only restore it\n";
$note .= "on the same version.\n\n";
$note .= "When restoring a backup, upload the UNzipped XML backup file, not this zip file.\n\n";
$note .= 'Created on ' . date('Y-m-d') . ' at ' . date('H:i:s') . ' GTM ' . date('O') . ".\n";
$note .= 'Created with BackupRestore plugin version ' . BR_VERSION . "\n";
$note .= 'Created for Wolf CMS version ' . CMS_VERSION . "\n\n";
$note .= '---[ END NOTES ]---';
use_helper('Zip');
$zip = new Zip();
$zip->clear();
$zip->addFile($note, 'readme.txt');
$zip->addFile($file, $filename);
$zip->download($filename . '.zip');
} else {
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: private', false);
header('Content-Type: text/xml; charset=UTF-8');
header('Content-Disposition: attachment; filename=' . $filename . ';');
header('Content-Transfer-Encoding: 8bit');
header('Content-Length: ' . strlen($file));
echo $file;
}
}
示例14: export_category
public function export_category()
{
$id = $this->session->userdata('admin_id');
$cates = $this->catenews_model->list_all_byuser($id);
$xml = new SimpleXMLExtended("<root></root>");
foreach ($cates as $cate) {
$xml_post = $xml->addChild('category');
$xml_post->addChild('cat_id', $cate->id);
$content = $xml_post->addChild('cat_name');
$content->addCData($cate->catenewsname);
}
$dom = new DOMDocument("1.0");
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$dom->loadXML($xml->asXML());
$xml->asXML('export/' . $id . '/category.xml');
}
示例15: Export
function Export()
{
// Create root element
$root = new SimpleXMLExtended('<shortcode-exec-php></shortcode-exec-php>');
// Add each shortcode
$name = WPShortcodeExecPHP::Get_option(c_scep_option_names);
for ($i = 0; $i < count($name); $i++) {
// Get attributes
$enabled = WPShortcodeExecPHP::Get_option(c_scep_option_enabled . $name[$i]);
$buffer = WPShortcodeExecPHP::Get_option(c_scep_option_buffer . $name[$i]);
$description = WPShortcodeExecPHP::Get_option(c_scep_option_description . $name[$i]);
$code = WPShortcodeExecPHP::Get_option(c_scep_option_phpcode . $name[$i]);
// Create element for shortcode
$element = $root->addChild('shortcode');
$element->addAttribute('name', $name[$i]);
$element->addAttribute('enabled', $enabled ? 'true' : 'false');
$element->addAttribute('buffer', $buffer ? 'true' : 'false');
$element->addAttribute('description', $description);
$element->addCData($code);
}
// Output
header('Content-type: text/xml');
header('Content-Disposition: attachment; filename="shortcode-exec-php.xml"');
echo $root->asXML();
}