本文整理汇总了PHP中XMLWriter::writeCData方法的典型用法代码示例。如果您正苦于以下问题:PHP XMLWriter::writeCData方法的具体用法?PHP XMLWriter::writeCData怎么用?PHP XMLWriter::writeCData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLWriter
的用法示例。
在下文中一共展示了XMLWriter::writeCData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getXmlLostCart
protected function getXmlLostCart(LostCart $lostCart)
{
$xml = new \XMLWriter();
$xml->openMemory();
$xml->startDocument('1.0', 'UTF-8');
$xml->startElement("event");
if ($lostCart->getLostCartUrl()) {
$xml->writeAttribute('RESTORE_CART_URL', $lostCart->getLostCartUrl());
// slevovy kupon
$discountCoupon = $lostCart->getDiscountCoupon();
if ($discountCoupon instanceof Discount) {
$xml->writeAttribute('COUPON_CODE', $discountCoupon->getCode());
$xml->writeAttribute('COUPON_VALUE', $discountCoupon->getValue());
$xml->writeAttribute('COUPON_VALIDITY', $this->dayToDate($discountCoupon->getValidityDay()));
$xml->writeAttribute('COUPON_ORDER_VALUE', $discountCoupon->getMinOrderValue());
}
}
$xml->startElement("products");
foreach ($lostCart->getProducts() as $product) {
$xml->startElement("product");
$xml->startElement("name");
$xml->writeCData($product->getName());
$xml->endElement();
$xml->startElement("url");
$xml->writeCData($product->getUrl());
$xml->endElement();
$xml->startElement("img");
$xml->writeCData($product->getImage());
$xml->endElement();
$xml->startElement("price-old");
$xml->writeCData($product->getPriceOld());
$xml->endElement();
$xml->startElement("price");
$xml->writeCData($product->getPrice());
$xml->endElement();
$xml->startElement("sale");
$xml->writeCData($product->getSale());
$xml->endElement();
$xml->startElement("buy-text");
$xml->writeCData($this->getBuyText());
$xml->endElement();
$xml->endElement();
}
$xml->endElement();
$xml->endElement();
$xml->endDocument();
return $xml->flush();
}
示例2: writeAttr
/**
* Write keys in $data prefixed with @ as XML attributes, if $data is an array.
* When an @ prefixed key is found, a '%' key is expected to indicate the element itself,
* and '#' prefixed key indicates CDATA content
*
* @param object $xml XMLWriter Object
* @param array $data with attributes filtered out
*/
protected function writeAttr(XMLWriter $xml, $data)
{
if (is_array($data)) {
$nonAttributes = array();
foreach ($data as $key => $val) {
//handle an attribute with elements
if ($key[0] == '@') {
$xml->writeAttribute(substr($key, 1), $val);
} else {
if ($key[0] == '%') {
if (is_array($val)) {
$nonAttributes = $val;
} else {
$xml->text($val);
}
} elseif ($key[0] == '#') {
if (is_array($val)) {
$nonAttributes = $val;
} else {
$xml->startElement(substr($key, 1));
$xml->writeCData($val);
$xml->endElement();
}
} else {
$nonAttributes[$key] = $val;
}
}
}
return $nonAttributes;
} else {
return $data;
}
}
示例3: writeCData
/**
* Write Element's CData
*
* @param $value
*/
public function writeCData($value)
{
if (is_array($value)) {
foreach ($value as $attrValue) {
$this->context->writeCData($attrValue);
}
} else {
$this->context->writeCData($value);
}
}
示例4: writeElement
/**
* Writes an element directly.
*
* @param string $element
* @param string $cdata
* @param array<string> $attributes
*/
public function writeElement($element, $cdata, array $attributes = array())
{
$this->startElement($element);
// write attributes
if (!empty($attributes)) {
$this->writeAttributes($attributes);
}
// content
$this->xml->writeCData(StringUtil::escapeCDATA($cdata));
$this->endElement();
}
示例5: create_rss
/**
* 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();
}
示例6: renderXML
/**
* builds the XML out of the provided data
*
* @return string the built xml
*/
public function renderXML()
{
$w = new XMLWriter();
$w->openMemory();
// only indent when NICE_XML is true
$w->setIndent(self::NICE_XML);
// use tabs as indents
$w->setIndentString("\t");
$w->startDocument("1.0", CHARSET);
$w->startElement('section');
$w->writeAttribute('name', 'packages');
if (self::SIGNATURE) {
$w->writeComment('Generated by PackageBuilder @ ' . gmdate('r'));
}
try {
if (PAGE_URL == '') {
throw new SystemException('PAGE_URL is empty');
}
foreach ($this->packages as $package) {
// if package has no valid versions just continue
if (self::countValidVersions($package, $this->type) == 0) {
continue;
}
$generalData = self::getPackageData($package);
$w->startElement('package');
$w->writeAttribute('name', $generalData['packageIdentifier']);
$w->startElement('packageinformation');
if ($generalData['packageName'] !== null) {
$w->startElement('packagename');
$w->writeCData($generalData['packageName']);
$w->endElement();
}
if ($generalData['packageDescription'] !== null) {
$w->startElement('packagedescription');
$w->writeCData($generalData['packageDescription']);
$w->endElement();
}
if ($generalData['plugin'] !== null) {
$w->startElement('plugin');
$w->writeCData($generalData['plugin']);
$w->endElement();
}
if ($generalData['standalone'] !== null) {
$w->startElement('standalone');
$w->writeCData($generalData['standalone']);
$w->endElement();
}
// packageinformation
$w->endElement();
$w->startElement('authorinformation');
if ($generalData['author'] !== null) {
$w->startElement('author');
$w->writeCData($generalData['author']);
$w->endElement();
}
if ($generalData['authorURL'] !== null) {
$w->startElement('authorurl');
$w->writeCData($generalData['authorURL']);
$w->endElement();
}
// authorinformation
$w->endElement();
$w->startElement('versions');
// list each version
foreach ($package as $key => $val) {
// get type, dont display if this type is not wanted
if (self::getTypeByVersion($key) != $this->type && $this->type != 'all') {
continue;
}
$data = self::getPackageData($package, $key);
$w->startElement('version');
$w->writeAttribute('name', $key);
if (!empty($data['fromVersions'])) {
$w->startElement('fromversions');
foreach ($data['fromVersions'] as $fromVersion) {
$w->startElement('fromversion');
$w->writeCData($fromVersion);
$w->endElement();
}
// fromversions
$w->endElement();
}
if (!empty($data['requirements'])) {
$w->startElement('requiredpackages');
foreach ($data['requirements'] as $required) {
$w->startElement('requiredpackage');
if (isset($required['minversion'])) {
$w->writeAttribute('minversion', $required['minversion']);
}
$w->writeCData($required['name']);
$w->endElement();
}
// requiredpackages
$w->endElement();
}
//.........这里部分代码省略.........
示例7: handle
public function handle()
{
$channelTitle = 'Realfagsbiblioteket';
$channelShortDescription = 'Videoer om vitenskap';
$channelDescription = 'Vitenskap formidlet fra scenen i Realfagsbiblioteket. Realfagsbiblioteket er Norges største fag- og forskningsbibliotek innen fagområdene fagområdene fysikk, astrofysikk, biofag, farmasi, geofag, kjemi, informatikk og matematikk.';
$channelUrl = 'https://www.ub.uio.no/om/aktuelt/arrangementer/ureal/';
$channelAuthor = 'Realfagsbiblioteket';
$channelAuthorEmail = 'realfagsbiblioteket@ub.uio.no';
$channelImage = 'http://titan.uio.no/sites/default/files/thumbnails/image/realfagsbiblioteket_topp_titan.png';
$parser = new GithubMarkdown();
$writer = new \XMLWriter();
$writer->openMemory();
$writer->startDocument('1.0', 'UTF-8');
$writer->setIndent(true);
$writer->setIndentString(' ');
$writer->startElement('rss');
$writer->writeAttribute('version', '2.0');
$writer->writeAttribute('xmlns:media', 'http://search.yahoo.com/mrss/');
$writer->writeAttribute('xmlns:atom', 'http://www.w3.org/2005/Atom');
$writer->writeAttribute('xmlns:dct', 'http://dublincore.org/documents/2012/06/14/dcmi-terms/');
$writer->writeAttribute('xmlns:itunes', 'http://www.itunes.com/dtds/podcast-1.0.dtd');
$writer->startElement('channel');
$writer->writeElement('title', $channelTitle);
$writer->writeElement('link', $channelUrl);
$writer->writeElement('description', $channelDescription);
$writer->writeElement('itunes:subtitle', $channelShortDescription);
$writer->writeElement('itunes:author', $channelAuthor);
$writer->writeElement('itunes:summary', $channelDescription);
$writer->startElement('itunes:owner');
$writer->writeAttribute('itunes:name', $channelAuthor);
$writer->writeAttribute('itunes:email', $channelAuthorEmail);
$writer->writeAttribute('href', 'https://www.ub.uio.no/om/aktuelt/arrangementer/ureal/feed-til-titan.xml');
$writer->endElement();
$writer->startElement('itunes:image');
$writer->writeAttribute('href', $channelImage);
$writer->endElement();
$writer->startElement('atom:link');
$writer->writeAttribute('rel', 'self');
$writer->writeAttribute('type', 'application/rss+xml');
$writer->writeAttribute('href', 'https://www.ub.uio.no/om/aktuelt/arrangementer/ureal/feed-til-titan.xml');
$writer->endElement();
$lastModified = Carbon::createFromDate(2000, 1, 1);
foreach (Recording::with('presentation', 'presentation.event')->orderBy('recorded_at', 'desc')->get() as $video) {
if (!$video->presentation) {
continue;
}
$event = $video->presentation->event;
if (count($event->presentations) != 1) {
continue;
}
$body = $parser->parse($event->intro);
$body = str_replace('<hr />', '', $body);
$primaryResource = null;
foreach ($event->resources as $resource) {
if ($resource->filetype == 'image') {
$primaryResource = $resource;
}
}
$mp4Url = null;
$mp4filesize = 0;
$writer->startElement('item');
$writer->startElement('guid');
$writer->writeAttribute('isPermaLink', 'false');
$writer->writeRaw($event->uuid);
$writer->endElement();
//$event->start_date . ' ' . $video->presentation->start_time
$writer->writeElement('pubDate', $video->presentation->getStartDateTime()->toRssString());
$writer->writeElement('dct:created', $video->presentation->getStartDateTime()->toIso8601String());
$writer->writeElement('dct:modified', $event->updated_at->toIso8601String());
$writer->writeElement('dct:language', $video->language);
$writer->writeElement('title', $event->title);
// $writer->writeElement('recordDate', $video->recorded_at);
// $writer->writeElement('bodyLength', mb_strlen($body));
$writer->startElement('description');
$writer->writeCData($body);
$writer->endElement();
$content = '<iframe width="560" height="315" src="https://www.youtube.com/embed/' . $video->youtube_id . '" frameborder="0" allowfullscreen></iframe>';
$writer->startElement('content');
$writer->writeCData($content);
$writer->endElement();
$writer->startElement('media:embed');
// ???
$writer->writeAttribute('url', $video->youtubeLink('embed'));
$writer->endElement();
if (!is_null($mp4Url)) {
$writer->startElement('enclosure');
$writer->writeAttribute('url', $mp4Url);
$writer->writeAttribute('length', $mp4filesize);
$writer->writeAttribute('type', 'video/mp4');
}
if (!is_null($primaryResource)) {
$writer->startElement('media:content');
$writer->writeAttribute('url', $primaryResource->url('webdav'));
$writer->writeAttribute('width', $primaryResource->width);
$writer->writeAttribute('height', $primaryResource->height);
$writer->writeAttribute('type', 'image/jpeg');
// $writer->writeElement('attribution', $primaryResource->attribution);
// Se: http://www.rssboard.org/media-rss#media-license
//$writer->writeElement('media:license', $primaryResource->license);
$writer->endElement();
//.........这里部分代码省略.........
示例8: writeRemetente
private function writeRemetente(\XMLWriter $writer, PreListaDePostagem $data)
{
$writer->startElement('remetente');
$writer->writeElement('numero_contrato', $data->getAccessData()->getNumeroContrato());
$writer->writeElement('numero_diretoria', $data->getRemetente()->getDiretoria()->getNumero());
$writer->writeElement('codigo_administrativo', $data->getAccessData()->getCodAdministrativo());
$writer->startElement('nome_remetente');
$writer->writeCData($this->_($data->getRemetente()->getNome(), 50));
$writer->endElement();
$writer->startElement('logradouro_remetente');
$writer->writeCdata($this->_($data->getRemetente()->getLogradouro(), 40));
$writer->endElement();
$writer->startElement('numero_remetente');
$numero_remetente = $data->getRemetente()->getNumero();
$writer->writeCdata($this->_($numero_remetente ? $numero_remetente : 's/n', 6));
$writer->endElement();
$writer->startElement('complemento_remetente');
$writer->writeCdata($this->_($data->getRemetente()->getComplemento(), 20));
$writer->endElement();
$writer->startElement('bairro_remetente');
$writer->writeCdata($this->_($data->getRemetente()->getBairro(), 20));
$writer->endElement();
$writer->startElement('cep_remetente');
$writer->writeCdata($this->_(preg_replace('/[^\\d]/', '', $data->getRemetente()->getCep()), 8));
$writer->endElement();
$writer->startElement('cidade_remetente');
$writer->writeCdata($this->_($data->getRemetente()->getCidade(), 30));
$writer->endElement();
$writer->writeElement('uf_remetente', $this->_($data->getRemetente()->getUf(), 2, false));
$writer->startElement('telefone_remetente');
$writer->writeCdata($this->_(preg_replace('/[^\\d]/', '', $data->getRemetente()->getTelefone()), 12));
$writer->endElement();
$writer->startElement('fax_remetente');
$writer->writeCdata($this->_(preg_replace('/[^\\d]/', '', $data->getRemetente()->getFax()), 12));
$writer->endElement();
$writer->startElement('email_remetente');
$writer->writeCdata($this->_($data->getRemetente()->getEmail(), 50));
$writer->endElement();
$writer->endElement();
}
示例9: while
$xml->startElement('jargonItems');
while ($row = mysql_fetch_assoc($result)) {
//echo $row[1];
//ID
//JargonItem
//Definition
//Description
//Category
//Similiar
//Company
//Type
//DateModified
$xml->startElement('jargonItem');
//$xml->writeAttribute('udid', $row['ID']);
$xml->startElement('udid');
$xml->writeCData($row['ID']);
$xml->endElement();
$xml->startElement('item');
$xml->writeCData($row['JargonItem']);
$xml->endElement();
$xml->startElement('definition');
$xml->writeCData($row['Definition']);
$xml->endElement();
$xml->startElement('description');
$xml->writeCData($row['Description']);
$xml->endElement();
$xml->startElement('category');
$xml->writeCData($row['Category']);
$xml->endElement();
$xml->startElement('similiar');
$xml->writeCData($row['Similiar']);
示例10: pmxe_export_xml
/**
* Export XML helper
*/
function pmxe_export_xml($exportQuery, $exportOptions, $preview = false, $is_cron = false, $file_path = false)
{
$xmlWriter = new XMLWriter();
$xmlWriter->openMemory();
$xmlWriter->setIndent(true);
$xmlWriter->setIndentString("\t");
$xmlWriter->startDocument('1.0', $exportOptions['encoding']);
$xmlWriter->startElement('data');
global $wpdb;
while ($exportQuery->have_posts()) {
$exportQuery->the_post();
$record = get_post(get_the_ID());
// global $wpdb;
// $table_prefix = $wpdb->prefix;
// $order_items = null;
// if ( "shop_order" == get_post_type() )
// {
// $order_items = $wpdb->get_results("SELECT * FROM {$table_prefix}woocommerce_order_items WHERE order_id = {$record->ID}");
// }
$xmlWriter->startElement('post');
if ($exportOptions['ids']) {
if (wp_all_export_is_compatible() and $exportOptions['is_generate_import'] and $exportOptions['import_id']) {
$postRecord = new PMXI_Post_Record();
$postRecord->clear();
$postRecord->getBy(array('post_id' => $record->ID, 'import_id' => $exportOptions['import_id']));
if ($postRecord->isEmpty()) {
$postRecord->set(array('post_id' => $record->ID, 'import_id' => $exportOptions['import_id'], 'unique_key' => $record->ID, 'product_key' => get_post_meta($record->ID, '_sku', true)))->save();
}
unset($postRecord);
}
foreach ($exportOptions['ids'] as $ID => $value) {
if (is_numeric($ID)) {
if (empty($exportOptions['cc_name'][$ID]) or empty($exportOptions['cc_type'][$ID])) {
continue;
}
$element_name = !empty($exportOptions['cc_name'][$ID]) ? str_replace(" ", "_", $exportOptions['cc_name'][$ID]) : 'untitled_' . $ID;
$fieldSnipped = (!empty($exportOptions['cc_php'][$ID]) and !empty($exportOptions['cc_code'][$ID])) ? $exportOptions['cc_code'][$ID] : false;
switch ($exportOptions['cc_type'][$ID]) {
case 'id':
$xmlWriter->writeElement($element_name, apply_filters('pmxe_post_id', pmxe_filter(get_the_ID(), $fieldSnipped), get_the_ID()));
break;
case 'permalink':
$xmlWriter->writeElement($element_name, apply_filters('pmxe_post_guid', pmxe_filter(get_permalink(), $fieldSnipped), get_the_ID()));
break;
case 'post_type':
$pType = get_post_type();
if ($pType == 'product_variation') {
$pType = 'product';
}
$xmlWriter->writeElement($element_name, apply_filters('pmxe_post_type', pmxe_filter($pType, $fieldSnipped), get_the_ID()));
break;
case 'title':
$xmlWriter->startElement($element_name);
$xmlWriter->writeCData(apply_filters('pmxe_post_title', pmxe_filter($record->post_title, $fieldSnipped), get_the_ID()));
$xmlWriter->endElement();
break;
case 'content':
$xmlWriter->startElement($element_name);
$xmlWriter->writeCData(apply_filters('pmxe_post_content', pmxe_filter($record->post_content, $fieldSnipped), get_the_ID()));
$xmlWriter->endElement();
break;
case 'media':
$xmlWriter->startElement($element_name);
$attachment_ids = array();
$_featured_image = get_post_meta(get_the_ID(), '_thumbnail_id', true);
if (!empty($_featured_image)) {
$attachment_ids[] = $_featured_image;
}
$_gallery = get_post_meta(get_the_ID(), '_product_image_gallery', true);
if (!empty($_gallery)) {
$gallery = explode(',', $_gallery);
if (!empty($gallery) and is_array($gallery)) {
foreach ($gallery as $aid) {
if (!in_array($aid, $attachment_ids)) {
$attachment_ids[] = $aid;
}
}
}
}
if (!empty($attachment_ids)) {
foreach ($attachment_ids as $attach_id) {
$attach = get_post($attach_id);
if (wp_attachment_is_image($attach->ID)) {
$xmlWriter->startElement('image');
$val = wp_get_attachment_url($attach->ID);
if (!empty($exportOptions['cc_options'][$ID])) {
switch ($exportOptions['cc_options'][$ID]) {
case 'filenames':
$val = basename(wp_get_attachment_url($attach->ID));
break;
case 'filepaths':
$val = get_attached_file($attach->ID);
break;
default:
# code...
break;
}
//.........这里部分代码省略.........
示例11: XMLWriter
}
//
// AFFICHAGE D'UN MEDIA
if (isset($_POST['show_picture']) or isset($_POST['show_video'])) {
$writer = new XMLWriter();
$writer->openURI($xml_file_name);
$writer->startDocument('1.0', 'UTF-8');
$writer->setIndent(4);
$writer->startElement('SETTINGS');
$writer->startElement('TEXT');
if (isset($_POST['show_picture'])) {
$writer->text("image");
$writer->endElement();
$writer->startElement('IMAGE');
}
$writer->writeCData($target_file);
$writer->endElement();
$datetime = 0;
if (isset($_POST['datetime'])) {
$datetime = 1;
}
$writer->writeElement('DATETIME', $datetime);
$writer->endElement();
$writer->endElement();
$writer->flush();
}
// ADMINISTRATION
// AFFICHAGE D'UNE LANGUE POUR MODIFICATION (APPEL AJAX)
if (isset($_POST['action']) and $_POST['action'] == "select_langue") {
$stmt = $dbh->prepare('SELECT * FROM langue WHERE langue_id=?');
$stmt->execute(array($_POST['langue_id']));
示例12: pmxe_export_users_xml
/**
* Export XML helper
*/
function pmxe_export_users_xml($exportQuery, $exportOptions, $preview = false, $is_cron = false, $file_path = false)
{
$xmlWriter = new XMLWriter();
$xmlWriter->openMemory();
$xmlWriter->setIndent(true);
$xmlWriter->setIndentString("\t");
$xmlWriter->startDocument('1.0', $exportOptions['encoding']);
$xmlWriter->startElement('data');
foreach ($exportQuery->results as $user) {
//$exportQuery->the_post(); $record = get_post( get_the_ID() );
$xmlWriter->startElement('post');
if ($exportOptions['ids']) {
if (wp_all_export_is_compatible() and $exportOptions['is_generate_import'] and $exportOptions['import_id']) {
$postRecord = new PMXI_Post_Record();
$postRecord->clear();
$postRecord->getBy(array('post_id' => $user->ID, 'import_id' => $exportOptions['import_id']));
if ($postRecord->isEmpty()) {
$postRecord->set(array('post_id' => $user->ID, 'import_id' => $exportOptions['import_id'], 'unique_key' => $user->ID))->save();
}
unset($postRecord);
}
foreach ($exportOptions['ids'] as $ID => $value) {
if (is_numeric($ID)) {
if (empty($exportOptions['cc_name'][$ID]) or empty($exportOptions['cc_type'][$ID])) {
continue;
}
$element_name = !empty($exportOptions['cc_name'][$ID]) ? str_replace(" ", "_", $exportOptions['cc_name'][$ID]) : 'untitled_' . $ID;
$fieldSnipped = (!empty($exportOptions['cc_php'][$ID]) and !empty($exportOptions['cc_code'][$ID])) ? $exportOptions['cc_code'][$ID] : false;
switch ($exportOptions['cc_type'][$ID]) {
case 'id':
$xmlWriter->writeElement($element_name, apply_filters('pmxe_user_id', pmxe_filter($user->ID, $fieldSnipped), $user->ID));
break;
case 'user_login':
$xmlWriter->writeElement($element_name, apply_filters('pmxe_user_login', pmxe_filter($user->user_login, $fieldSnipped), $user->ID));
break;
case 'user_pass':
$xmlWriter->writeElement($element_name, apply_filters('pmxe_user_pass', pmxe_filter($user->user_pass, $fieldSnipped), $user->ID));
break;
case 'user_email':
$xmlWriter->writeElement($element_name, apply_filters('pmxe_user_email', pmxe_filter($user->user_email, $fieldSnipped), $user->ID));
break;
case 'user_nicename':
$xmlWriter->writeElement($element_name, apply_filters('pmxe_user_nicename', pmxe_filter($user->user_nicename, $fieldSnipped), $user->ID));
break;
case 'user_url':
$xmlWriter->writeElement($element_name, apply_filters('pmxe_user_url', pmxe_filter($user->user_url, $fieldSnipped), $user->ID));
break;
/*case 'user_activation_key':
$xmlWriter->writeElement($element_name, apply_filters('pmxe_user_activation_key', pmxe_filter($user->user_activation_key, $fieldSnipped), $user->ID));
break;
case 'user_status':
$xmlWriter->writeElement($element_name, apply_filters('pmxe_user_status', pmxe_filter($user->user_status, $fieldSnipped), $user->ID));
break;*/
/*case 'user_activation_key':
$xmlWriter->writeElement($element_name, apply_filters('pmxe_user_activation_key', pmxe_filter($user->user_activation_key, $fieldSnipped), $user->ID));
break;
case 'user_status':
$xmlWriter->writeElement($element_name, apply_filters('pmxe_user_status', pmxe_filter($user->user_status, $fieldSnipped), $user->ID));
break;*/
case 'display_name':
$xmlWriter->writeElement($element_name, apply_filters('pmxe_user_display_name', pmxe_filter($user->display_name, $fieldSnipped), $user->ID));
break;
case 'user_registered':
if (!empty($exportOptions['cc_options'][$ID])) {
switch ($exportOptions['cc_options'][$ID]) {
case 'unix':
$post_date = strtotime($user->user_registered);
break;
default:
$post_date = date($exportOptions['cc_options'][$ID], strtotime($user->user_registered));
break;
}
} else {
$post_date = $user->user_registered;
}
$xmlWriter->writeElement($element_name, apply_filters('pmxe_user_registered', pmxe_filter($post_date, $fieldSnipped), $user->ID));
break;
case 'nickname':
$xmlWriter->writeElement($element_name, apply_filters('pmxe_user_nickname', pmxe_filter($user->nickname, $fieldSnipped), $user->ID));
break;
case 'first_name':
$xmlWriter->writeElement($element_name, apply_filters('pmxe_user_first_name', pmxe_filter($user->first_name, $fieldSnipped), $user->ID));
break;
case 'last_name':
$xmlWriter->writeElement($element_name, apply_filters('pmxe_user_last_name', pmxe_filter($user->last_name, $fieldSnipped), $user->ID));
break;
case 'wp_capabilities':
$xmlWriter->writeElement($element_name, apply_filters('pmxe_user_wp_capabilities', pmxe_filter(implode(",", $user->roles), $fieldSnipped), $user->ID));
break;
case 'description':
$xmlWriter->startElement($element_name);
$xmlWriter->writeCData(apply_filters('pmxe_user_description', pmxe_filter($user->description, $fieldSnipped), $user->ID));
$xmlWriter->endElement();
break;
case 'cf':
if (!empty($exportOptions['cc_value'][$ID])) {
$cur_meta_values = get_user_meta($user->ID, $exportOptions['cc_value'][$ID]);
//.........这里部分代码省略.........
示例13: toXML
function toXML($fixBrokenSymbols = false)
{
$c = 0;
$d = "" != $this->delimiter ? $this->delimiter : $this->settings['delimiter'];
$e = $this->settings['escape'];
$l = $this->settings['length'];
$this->is_csv = $d;
$is_html = false;
$f = @fopen($this->_filename, "rb");
while (!@feof($f)) {
$chunk = @fread($f, 1024);
if (strpos($chunk, "<!DOCTYPE") === 0) {
$is_html = true;
}
break;
}
if ($is_html) {
return;
}
$res = fopen($this->_filename, 'rb');
$xmlWriter = new XMLWriter();
$xmlWriter->openURI($this->xml_path);
$xmlWriter->setIndent(true);
$xmlWriter->setIndentString("\t");
$xmlWriter->startDocument('1.0', $this->csv_encoding);
$xmlWriter->startElement('data');
$import_id = 0;
if (!empty($_GET['id'])) {
$import_id = $_GET['id'];
}
if (!empty($_GET['import_id'])) {
$import_id = $_GET['import_id'];
}
$create_new_headers = apply_filters('wp_all_import_auto_create_csv_headers', false, $import_id);
$replace_first_number = apply_filters('wp_all_import_replace_first_number_in_headers', true, $import_id);
$headers = array();
while ($keys = fgetcsv($res, $l, $d, $e)) {
$empty_columns = 0;
foreach ($keys as $key) {
if ($key == '') {
$empty_columns++;
}
}
// skip empty lines
if ($empty_columns == count($keys)) {
continue;
}
if ($c == 0) {
$buf_keys = $keys;
foreach ($keys as $key => $value) {
if (!$create_new_headers and (preg_match('%\\W(http:|https:|ftp:)$%i', $value) or is_numeric($value))) {
$create_new_headers = true;
}
if ($replace_first_number) {
$value = trim(strtolower(preg_replace('/^[0-9]{1}/', 'el_', preg_replace('/[^a-z0-9_]/i', '', $value))));
} else {
$value = preg_replace('/[^a-z0-9_]/i', '', $value);
if (preg_match('/^[0-9]{1}/', $value)) {
$value = 'el_' . trim(strtolower($value));
}
}
$value = !empty($value) ? $value : 'undefined' . $key;
if (empty($headers[$value])) {
$headers[$value] = 1;
} else {
$headers[$value]++;
}
$keys[$key] = $headers[$value] === 1 ? $value : $value . '_' . $headers[$value];
}
$this->headers = $keys;
if ($create_new_headers) {
$this->createHeaders('column');
$keys = $buf_keys;
}
}
if ($c or $create_new_headers) {
if (!empty($keys)) {
$chunk = array();
foreach ($this->headers as $key => $header) {
$chunk[$header] = $this->fixEncoding($keys[$key]);
}
if (!empty($chunk)) {
$xmlWriter->startElement('node');
foreach ($chunk as $header => $value) {
$xmlWriter->startElement($header);
$value = preg_replace('/\\]\\]>/s', '', preg_replace('/<!\\[CDATA\\[/s', '', $value));
if ($fixBrokenSymbols) {
// Remove non ASCII symbols and write CDATA
$xmlWriter->writeCData(preg_replace('/[^\\x{0009}\\x{000a}\\x{000d}\\x{0020}-\\x{D7FF}\\x{E000}-\\x{FFFD}]+/u', ' ', $value));
} else {
$xmlWriter->writeCData($value);
}
$xmlWriter->endElement();
}
$xmlWriter->endElement();
}
}
}
$c++;
}
//.........这里部分代码省略.........
示例14: while
while ($arr = $result->fetch_assoc()) {
$writer->startElement('vehicle');
foreach ($arr as $name => $value) {
if ($name == 'market_id') {
$market_id = $value;
} elseif ($name == 'make') {
$make = $value;
} elseif ($name == 'model') {
$model = $value;
} elseif ($name == 'year') {
$year = $value;
}
$writer->startElement($name);
if ($name == 'market_url') {
$tmp = 'http://auto.pingola.ru/item/' . $market_id . '/' . $make . '-' . $model . '-' . $year;
$writer->writeCData($tmp);
} elseif ($name == 'make' || $name == 'model' || $name == 'description') {
$writer->writeCData($value);
} else {
$writer->text($value);
}
$writer->endElement();
if ($name == 'market_url') {
$id = substr($value, strpos($value, 'id_vehicle=') + strlen('id_vehicle='));
$writer->startElement('carcopy_id');
$writer->text($id);
$writer->endElement();
} elseif ($name == 'price') {
$writer->startElement('price_currency');
$writer->text('rur');
$writer->endElement();
示例15: XMLresult
/**
* Method to make an output of document records in simple XML format
*
* @return string
*/
public function XMLresult()
{
global $sysconf;
$mods_version = '3.3';
// loop data
$_buffer = '<modsCollection xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.loc.gov/mods/v3" xmlns:slims="http://slims.web.id" xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-3.xsd">' . "\n";
$xml = new XMLWriter();
$xml->openMemory();
$xml->setIndent(true);
$xml->startElementNS('slims', 'resultInfo', null);
$xml->startElementNS('slims', 'modsResultNum', null);
$xml->writeCdata($this->num_rows);
$xml->endElement();
$xml->startElementNS('slims', 'modsResultPage', null);
$xml->writeCdata($this->current_page);
$xml->endElement();
$xml->startElementNS('slims', 'modsResultShowed', null);
$xml->writeCdata($this->num2show);
$xml->endElement();
$xml->endElement();
while ($_biblio_d = $this->resultset->fetch_assoc()) {
$xml->startElement('mods');
$xml->writeAttribute('version', $mods_version);
$xml->writeAttribute('id', $_biblio_d['biblio_id']);
// parse title
$_title_sub = '';
if (stripos($_biblio_d['title'], ':') !== false) {
$_title_main = trim(substr_replace($_biblio_d['title'], '', stripos($_biblio_d['title'], ':') + 1));
$_title_sub = trim(substr_replace($_biblio_d['title'], '', 0, stripos($_biblio_d['title'], ':') + 1));
} else {
$_title_main = trim($_biblio_d['title']);
}
// parse title
$_title_main = trim($_biblio_d['title']);
$_title_sub = '';
$_title_statement_resp = '';
if (stripos($_biblio_d['title'], '/') !== false) {
$_title_main = trim(substr_replace($_biblio_d['title'], '', stripos($_biblio_d['title'], '/') + 1));
$_title_statement_resp = trim(substr_replace($_biblio_d['title'], '', 0, stripos($_biblio_d['title'], '/') + 1));
}
if (stripos($_biblio_d['title'], ':') !== false) {
$_title_main = trim(substr_replace($_biblio_d['title'], '', stripos($_biblio_d['title'], ':') + 1));
$_title_sub = trim(substr_replace($_biblio_d['title'], '', 0, stripos($_biblio_d['title'], ':') + 1));
}
$xml->startElement('titleInfo');
$xml->startElement('title');
$xml->writeCData($_title_main);
$xml->endElement();
if ($_title_sub) {
// $_xml_output .= '<subTitle><![CDATA['.$_title_sub.']]></subTitle>'."\n";
$xml->startElement('subTitle');
$xml->writeCData($_title_sub);
$xml->endElement();
}
// $_xml_output .= '</titleInfo>'."\n";
$xml->endElement();
// get the authors data
$_biblio_authors_q = $this->obj_db->query('SELECT a.*,ba.level FROM mst_author AS a' . ' LEFT JOIN biblio_author AS ba ON a.author_id=ba.author_id WHERE ba.biblio_id=' . $_biblio_d['biblio_id']);
while ($_auth_d = $_biblio_authors_q->fetch_assoc()) {
// some rules to set name type in mods standard
if ($sysconf['authority_type'][$_auth_d['authority_type']] == 'Personal Name') {
$sysconf['authority_type'][$_auth_d['authority_type']] = 'personal';
} elseif ($sysconf['authority_type'][$_auth_d['authority_type']] == 'Organizational Body') {
$sysconf['authority_type'][$_auth_d['authority_type']] = 'corporate';
} elseif ($sysconf['authority_type'][$_auth_d['authority_type']] == 'Conference') {
$sysconf['authority_type'][$_auth_d['authority_type']] = 'conference';
} else {
$sysconf['authority_type'][$_auth_d['authority_type']] = 'personal';
}
$xml->startElement('name');
$xml->writeAttribute('type', $sysconf['authority_type'][$_auth_d['authority_type']]);
$xml->writeAttribute('authority', $_auth_d['auth_list']);
$xml->startElement('namePart');
$xml->writeCData($_auth_d['author_name']);
$xml->endElement();
$xml->startElement('role');
$xml->startElement('roleTerm');
$xml->writeAttribute('type', 'text');
$xml->writeCData($sysconf['authority_level'][$_auth_d['level']]);
$xml->endElement();
$xml->endElement();
$xml->endElement();
}
$_biblio_authors_q->free_result();
$xml->startElement('typeOfResource');
$xml->writeAttribute('collection', 'yes');
$xml->writeCData('mixed material');
$xml->endElement();
$xml->startElement('identifier');
$xml->writeAttribute('type', 'isbn');
$xml->writeCData(str_replace(array('-', ' '), '', $_biblio_d['isbn_issn']));
$xml->endElement();
// imprint/publication data
$xml->startElement('originInfo');
$xml->startElement('place');
//.........这里部分代码省略.........