Ejemplo n.º 1
0
 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();
 }
Ejemplo n.º 2
0
 /**
  * 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;
     }
 }
Ejemplo n.º 3
0
 /**
  * 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);
     }
 }
Ejemplo n.º 4
0
 /**
  * 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();
 }
Ejemplo n.º 5
0
/**
 * Create RSS Feed
 * @param entries
 * @param config
 */
function create_rss($entries, $config)
{
    // Inspired from http://www.phpntips.com/xmlwriter-2009-06/
    $xml = new XMLWriter();
    // Output directly to the user
    $xml->openURI('php://output');
    $xml->startDocument('1.0');
    $xml->setIndent(2);
    //rss
    $xml->startElement('rss');
    $xml->writeAttribute('version', '2.0');
    $xml->writeAttribute('xmlns:atom', 'http://www.w3.org/2005/Atom');
    //channel
    $xml->startElement('channel');
    // title, desc, link, date
    $xml->writeElement('title', $config['title']);
    // $xml->writeElement('description', $config['description']);
    // $xml->writeElement('link', 'http://www.example.com/rss.hml');
    $xml->writeElement('pubDate', date('r'));
    if (!empty($entries)) {
        foreach ($entries as $entry) {
            // item
            $xml->startElement('item');
            $xml->writeElement('title', $entry->title);
            if (isset($entry->permalink)) {
                $xml->writeElement('link', $entry->permalink);
            }
            $xml->startElement('description');
            $xml->writeCData($entry->content);
            $xml->endElement();
            $xml->writeElement('pubDate', date('r', strtotime($entry->date)));
            // category
            // $xml->startElement('category');
            // $xml->writeAttribute('domain', 'http://www.example.com/cat1.htm');
            // $xml->text('News');
            // $xml->endElement();
            // end item
            $xml->endElement();
        }
    }
    // end channel
    $xml->endElement();
    // end rss
    $xml->endElement();
    // end doc
    $xml->endDocument();
    // flush
    $xml->flush();
}
 /**
  * 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();
                 }
                 // determine updatetype
                 if ($data['isUpdate'] && stripos($key, 'pl')) {
                     $updateType = 'security';
                 } else {
                     if ($data['isUpdate']) {
                         $updateType = 'update';
                     } else {
                         $updateType = 'install';
                     }
                 }
                 $w->startElement('updatetype');
                 $w->writeCData($updateType);
                 $w->endElement();
                 // use the build time of that package as timestamp
                 $w->startElement('timestamp');
                 $w->writeCData(filemtime($this->source->buildDirectory . $val['file']));
                 $w->endElement();
                 $w->startElement('versiontype');
                 $w->writeCData(self::getTypeByVersion($key));
                 $w->endElement();
                 $w->startElement('file');
                 $w->writeCData(PAGE_URL . '/index.php?page=DownloadPackage&sourceID=' . $this->source->sourceID . '&filename=' . $val['file']);
                 $w->endElement();
                 // version
                 $w->endElement();
             }
             // versions
             $w->endElement();
             // package
             $w->endElement();
         }
     } catch (SystemException $e) {
         $w->writeComment('Fatal Error: ' . $e->getMessage());
     }
     // section
     $w->endElement();
     $w->endDocument();
     return $w->outputMemory();
 }
Ejemplo n.º 7
0
 public function handle()
 {
     $channelTitle = 'Realfagsbiblioteket';
     $channelShortDescription = 'Videoer om vitenskap';
     $channelDescription = 'Vitenskap formidlet fra scenen i Realfagsbiblioteket. Realfagsbiblioteket er Norges største f*g- 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 = '*****@*****.**';
     $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();
         }
         if ($event->updated_at > $lastModified) {
             $lastModified = $event->updated_at;
         }
         $writer->endElement();
     }
     $writer->writeElement('dct:modified', $lastModified->toIso8601String());
     $writer->writeElement('lastBuildDate', $lastModified->toIso8601String());
     $writer->endElement();
     $writer->endDocument();
     echo $writer->outputMemory();
 }
Ejemplo n.º 8
0
 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();
 }
Ejemplo n.º 9
0
 $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']);
Ejemplo n.º 10
0
/**
*	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;
                                            }
                                        }
                                        $xmlWriter->writeElement('file', apply_filters('pmxe_attachment_url', $val, get_the_ID(), $attach->ID));
                                        $xmlWriter->writeElement('title', apply_filters('pmxe_attachment_title', $attach->post_title, get_the_ID(), $attach->ID));
                                        $xmlWriter->writeElement('caption', apply_filters('pmxe_attachment_caption', $attach->post_excerpt, get_the_ID(), $attach->ID));
                                        $xmlWriter->writeElement('description', apply_filters('pmxe_attachment_content', $attach->post_content, get_the_ID(), $attach->ID));
                                        $xmlWriter->writeElement('alt', apply_filters('pmxe_attachment_alt', get_post_meta($record->ID, '_wp_attachment_image_alt', true), get_the_ID(), $attach->ID));
                                        $xmlWriter->endElement();
                                    }
                                }
                            }
                            $xmlWriter->endElement();
                            break;
                        case 'date':
                            if (!empty($exportOptions['cc_options'][$ID])) {
                                switch ($exportOptions['cc_options'][$ID]) {
                                    case 'unix':
                                        $post_date = get_post_time('U', true);
                                        break;
                                    default:
                                        $post_date = date($exportOptions['cc_options'][$ID], get_post_time('U', true));
                                        break;
                                }
                            } else {
                                $post_date = date("Ymd", get_post_time('U', true));
                            }
                            $xmlWriter->writeElement($element_name, apply_filters('pmxe_post_date', pmxe_filter($post_date, $fieldSnipped), get_the_ID()));
                            break;
                        case 'attachments':
                            $xmlWriter->startElement($element_name);
                            $attachment_imgs = get_posts(array('post_type' => 'attachment', 'posts_per_page' => -1, 'post_parent' => $record->ID));
                            if (!empty($attachment_imgs)) {
                                foreach ($attachment_imgs as $attach) {
                                    if (!wp_attachment_is_image($attach->ID)) {
                                        $xmlWriter->startElement('attach');
                                        $xmlWriter->writeElement('url', apply_filters('pmxe_attachment_url', pmxe_filter(wp_get_attachment_url($attach->ID), $fieldSnipped), get_the_ID(), $attach->ID));
                                        $xmlWriter->endElement();
                                    }
                                }
                            }
                            $xmlWriter->endElement();
                            // end attachments
                            break;
                        case 'parent':
                            $xmlWriter->writeElement($element_name, apply_filters('pmxe_post_parent', pmxe_filter($record->post_parent, $fieldSnipped), get_the_ID()));
                            break;
                        case 'template':
                            $xmlWriter->writeElement($element_name, apply_filters('pmxe_post_template', pmxe_filter(get_post_meta($record->ID, '_wp_page_template', true), $fieldSnipped), get_the_ID()));
                            break;
                        case 'order':
                            $xmlWriter->writeElement($element_name, apply_filters('pmxe_menu_order', pmxe_filter($record->menu_order, $fieldSnipped), get_the_ID()));
                            break;
                        case 'status':
                            $xmlWriter->writeElement($element_name, apply_filters('pmxe_post_status', pmxe_filter($record->post_status, $fieldSnipped), get_the_ID()));
                            break;
                        case 'format':
                            $xmlWriter->writeElement($element_name, apply_filters('pmxe_post_format', pmxe_filter(get_post_format($record->ID), $fieldSnipped), get_the_ID()));
                            break;
                        case 'author':
                            $xmlWriter->writeElement($element_name, apply_filters('pmxe_post_author', pmxe_filter($record->post_author, $fieldSnipped), get_the_ID()));
                            break;
                        case 'slug':
                            $xmlWriter->writeElement($element_name, apply_filters('pmxe_post_slug', pmxe_filter($record->post_name, $fieldSnipped), get_the_ID()));
                            break;
                        case 'excerpt':
                            $xmlWriter->startElement($element_name);
                            $xmlWriter->writeCData(apply_filters('pmxe_post_excerpt', pmxe_filter($record->post_excerpt, $fieldSnipped), get_the_ID()));
                            $xmlWriter->endElement();
                            break;
                        case 'cf':
                            if (!empty($exportOptions['cc_value'][$ID])) {
                                $cur_meta_values = get_post_meta($record->ID, $exportOptions['cc_value'][$ID]);
                                if (!empty($cur_meta_values) and is_array($cur_meta_values)) {
                                    foreach ($cur_meta_values as $key => $cur_meta_value) {
                                        $xmlWriter->startElement($element_name);
                                        $xmlWriter->writeCData(apply_filters('pmxe_custom_field', pmxe_filter(maybe_serialize($cur_meta_value), $fieldSnipped), $exportOptions['cc_value'][$ID], get_the_ID()));
                                        $xmlWriter->endElement();
                                    }
                                }
                                if (empty($cur_meta_values)) {
                                    $xmlWriter->startElement($element_name);
                                    $xmlWriter->writeCData(apply_filters('pmxe_custom_field', pmxe_filter('', $fieldSnipped), $exportOptions['cc_value'][$ID], get_the_ID()));
                                    $xmlWriter->endElement();
                                }
                            }
                            break;
                        case 'acf':
                            if (!empty($exportOptions['cc_label'][$ID]) and class_exists('acf')) {
                                global $acf;
                                $field_value = get_field($exportOptions['cc_label'][$ID], $record->ID);
                                $field_options = unserialize($exportOptions['cc_options'][$ID]);
                                pmxe_export_acf_field_xml($field_value, $exportOptions, $ID, $record->ID, $xmlWriter, $element_name, $fieldSnipped, $field_options['group_id']);
                            }
                            break;
                        case 'woo':
                            //$element_name = 'woo' . $element_name;
                            if (!empty($exportOptions['cc_label'][$ID])) {
                                $cur_meta_values = get_post_meta($record->ID, $exportOptions['cc_label'][$ID]);
                                if (!empty($cur_meta_values) and is_array($cur_meta_values)) {
                                    foreach ($cur_meta_values as $key => $cur_meta_value) {
                                        switch ($exportOptions['cc_label'][$ID]) {
                                            case '_downloadable_files':
                                                $files = maybe_unserialize($cur_meta_value);
                                                $file_paths = array();
                                                $file_names = array();
                                                if (!empty($files)) {
                                                    foreach ($files as $key => $file) {
                                                        $file_paths[] = $file['file'];
                                                        $file_names[] = $file['name'];
                                                    }
                                                    $xmlWriter->startElement($element_name . '_paths');
                                                    $xmlWriter->writeCData(implode(',', $file_paths));
                                                    $xmlWriter->endElement();
                                                    $xmlWriter->startElement($element_name . '_names');
                                                    $xmlWriter->writeCData(implode(',', $file_names));
                                                    $xmlWriter->endElement();
                                                }
                                                break;
                                            case '_crosssell_ids':
                                            case '_upsell_ids':
                                                $_upsell_ids = maybe_unserialize($cur_meta_value);
                                                $_upsell_skus = array();
                                                if (!empty($_upsell_ids)) {
                                                    foreach ($_upsell_ids as $_upsell_id) {
                                                        $_upsell_skus[] = get_post_meta($_upsell_id, '_sku', true);
                                                    }
                                                    $xmlWriter->startElement($element_name);
                                                    $xmlWriter->writeCData(apply_filters('woo_field', pmxe_filter(implode(',', $_upsell_skus), $fieldSnipped), $exportOptions['cc_value'][$ID], get_the_ID()));
                                                    $xmlWriter->endElement();
                                                }
                                                break;
                                            default:
                                                $xmlWriter->startElement($element_name);
                                                $xmlWriter->writeCData(apply_filters('woo_field', pmxe_filter(maybe_serialize($cur_meta_value), $fieldSnipped), $exportOptions['cc_value'][$ID], get_the_ID()));
                                                $xmlWriter->endElement();
                                                break;
                                        }
                                    }
                                }
                                if (empty($cur_meta_values)) {
                                    $xmlWriter->startElement($element_name);
                                    $xmlWriter->writeCData(apply_filters('woo_field', pmxe_filter('', $fieldSnipped), $exportOptions['cc_value'][$ID], get_the_ID()));
                                    $xmlWriter->endElement();
                                }
                            }
                            break;
                        case 'woo_order':
                            XmlExportWooCommerceOrder::getInstance()->export_xml($xmlWriter, $record, $exportOptions, $ID);
                            break;
                        case 'attr':
                            //$element_name = 'woo_' . $element_name;
                            if (!empty($exportOptions['cc_value'][$ID])) {
                                if ($record->post_parent == 0) {
                                    $is_variable_product = false;
                                    $product_terms = wp_get_post_terms($record->ID, 'product_type');
                                    if (!empty($product_terms)) {
                                        if (!is_wp_error($product_terms)) {
                                            foreach ($product_terms as $term) {
                                                if ('variable' == $term->slug) {
                                                    $is_variable_product = true;
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                    $txes_list = get_the_terms($record->ID, $exportOptions['cc_value'][$ID]);
                                    if (!is_wp_error($txes_list)) {
                                        $attr_new = array();
                                        if (!empty($txes_list)) {
                                            foreach ($txes_list as $t) {
                                                $attr_new[] = $t->slug;
                                            }
                                            $xmlWriter->startElement($is_variable_product ? $element_name : 'attribute_' . $element_name);
                                            $xmlWriter->writeCData(apply_filters('pmxe_woo_attribute', pmxe_filter(implode('|', $attr_new), $fieldSnipped), get_the_ID()));
                                            $xmlWriter->endElement();
                                        }
                                    }
                                } else {
                                    $attribute_pa = get_post_meta($record->ID, 'attribute_' . $exportOptions['cc_value'][$ID], true);
                                    if (!empty($attribute_pa)) {
                                        $xmlWriter->startElement('attribute_' . $element_name);
                                        $xmlWriter->writeCData(apply_filters('woo_field', $attribute_pa));
                                        $xmlWriter->endElement();
                                    }
                                }
                            }
                            break;
                        case 'cats':
                            if (!empty($exportOptions['cc_value'][$ID])) {
                                $txes_list = get_the_terms($record->ID, $exportOptions['cc_value'][$ID]);
                                if (!is_wp_error($txes_list)) {
                                    $txes_ids = array();
                                    $hierarchy_groups = array();
                                    if (!empty($txes_list)) {
                                        foreach ($txes_list as $t) {
                                            $txes_ids[] = $t->term_id;
                                        }
                                        foreach ($txes_list as $t) {
                                            if (wp_all_export_check_children_assign($t->term_id, $exportOptions['cc_value'][$ID], $txes_ids)) {
                                                $ancestors = get_ancestors($t->term_id, $exportOptions['cc_value'][$ID]);
                                                if (count($ancestors) > 0) {
                                                    $hierarchy_group = array();
                                                    for ($i = count($ancestors) - 1; $i >= 0; $i--) {
                                                        $term = get_term_by('id', $ancestors[$i], $exportOptions['cc_value'][$ID]);
                                                        if ($term) {
                                                            $hierarchy_group[] = $term->slug;
                                                        }
                                                    }
                                                    $hierarchy_group[] = $t->slug;
                                                    $hierarchy_groups[] = implode(">", $hierarchy_group);
                                                } else {
                                                    $hierarchy_groups[] = $t->slug;
                                                }
                                            }
                                        }
                                        if (!empty($hierarchy_groups)) {
                                            $xmlWriter->startElement($element_name);
                                            $xmlWriter->writeCData(apply_filters('pmxe_post_taxonomy', pmxe_filter(implode('|', $hierarchy_groups), $fieldSnipped), get_the_ID()));
                                            $xmlWriter->endElement();
                                        }
                                    }
                                }
                                if ($exportOptions['cc_label'][$ID] == 'product_type' and get_post_type() == 'product_variation') {
                                    $xmlWriter->writeElement('parent_sku', get_post_meta($record->post_parent, '_sku', true));
                                    $xmlWriter->writeElement($element_name, 'variable');
                                }
                            }
                            break;
                        case 'sql':
                            if (!empty($exportOptions['cc_sql'][$ID])) {
                                $val = $wpdb->get_var($wpdb->prepare(stripcslashes(str_replace("%%ID%%", "%d", $exportOptions['cc_sql'][$ID])), get_the_ID()));
                                if (!empty($exportOptions['cc_php'][$ID]) and !empty($exportOptions['cc_code'][$ID])) {
                                    // if shortcode defined
                                    if (strpos($exportOptions['cc_code'][$ID], '[') === 0) {
                                        $val = do_shortcode(str_replace("%%VALUE%%", $val, $exportOptions['cc_code'][$ID]));
                                    } else {
                                        $val = eval('return ' . stripcslashes(str_replace("%%VALUE%%", $val, $exportOptions['cc_code'][$ID])) . ';');
                                    }
                                }
                                $xmlWriter->startElement($element_name);
                                $xmlWriter->writeCData(apply_filters('pmxe_sql_field', $val, $element_name, get_the_ID()));
                                $xmlWriter->endElement();
                            }
                            break;
                        default:
                            # code...
                            break;
                    }
                }
            }
        }
        $xmlWriter->endElement();
        // end post
        if ($preview) {
            break;
        }
    }
    $xmlWriter->endElement();
    // end data
    if ($preview) {
        return wp_all_export_remove_colons($xmlWriter->flush(true));
    }
    if ($is_cron) {
        $xml = $xmlWriter->flush(true);
        if (file_exists($file_path)) {
            file_put_contents($file_path, wp_all_export_remove_colons(substr(substr($xml, 45), 0, -8)), FILE_APPEND);
        } else {
            file_put_contents($file_path, wp_all_export_remove_colons(substr($xml, 0, -8)));
        }
        return $file_path;
    } else {
        if (empty(PMXE_Plugin::$session->file)) {
            $is_secure_import = PMXE_Plugin::getInstance()->getOption('secure');
            $wp_uploads = wp_upload_dir();
            $target = $is_secure_import ? wp_all_export_secure_file($wp_uploads['basedir'] . DIRECTORY_SEPARATOR . PMXE_Plugin::UPLOADS_DIRECTORY) : $wp_uploads['path'];
            $export_file = $target . DIRECTORY_SEPARATOR . time() . '.' . $exportOptions['export_to'];
            file_put_contents($export_file, wp_all_export_remove_colons(substr($xmlWriter->flush(true), 0, -8)));
            PMXE_Plugin::$session->set('file', $export_file);
            PMXE_Plugin::$session->save_data();
        } else {
            file_put_contents(PMXE_Plugin::$session->file, wp_all_export_remove_colons(substr(substr($xmlWriter->flush(true), 45), 0, -8)), FILE_APPEND);
        }
        return true;
    }
}
Ejemplo n.º 11
0
}
//
// 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']));
Ejemplo n.º 12
0
/**
*	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]);
                                if (!empty($cur_meta_values) and is_array($cur_meta_values)) {
                                    foreach ($cur_meta_values as $key => $cur_meta_value) {
                                        $xmlWriter->startElement($element_name);
                                        $xmlWriter->writeCData(apply_filters('pmxe_custom_field', pmxe_filter(maybe_serialize($cur_meta_value), $fieldSnipped), $exportOptions['cc_value'][$ID], $user->ID));
                                        $xmlWriter->endElement();
                                    }
                                }
                                if (empty($cur_meta_values)) {
                                    $xmlWriter->startElement($element_name);
                                    $xmlWriter->writeCData(apply_filters('pmxe_custom_field', pmxe_filter('', $fieldSnipped), $exportOptions['cc_value'][$ID], $user->ID));
                                    $xmlWriter->endElement();
                                }
                            }
                            break;
                        case 'acf':
                            if (!empty($exportOptions['cc_label'][$ID]) and class_exists('acf')) {
                                global $acf;
                                $field_value = get_field($exportOptions['cc_label'][$ID], $user->ID);
                                $field_options = unserialize($exportOptions['cc_options'][$ID]);
                                pmxe_export_acf_field_xml($field_value, $exportOptions, $ID, $user->ID, $xmlWriter, $element_name, $fieldSnipped, $field_options['group_id']);
                            }
                            break;
                        case 'sql':
                            if (!empty($exportOptions['cc_sql'][$ID])) {
                                global $wpdb;
                                $val = $wpdb->get_var($wpdb->prepare(stripcslashes(str_replace("%%ID%%", "%d", $exportOptions['cc_sql'][$ID])), get_the_ID()));
                                if (!empty($exportOptions['cc_php'][$ID]) and !empty($exportOptions['cc_code'][$ID])) {
                                    // if shortcode defined
                                    if (strpos($exportOptions['cc_code'][$ID], '[') === 0) {
                                        $val = do_shortcode(str_replace("%%VALUE%%", $val, $exportOptions['cc_code'][$ID]));
                                    } else {
                                        $val = eval('return ' . stripcslashes(str_replace("%%VALUE%%", $val, $exportOptions['cc_code'][$ID])) . ';');
                                    }
                                }
                                $xmlWriter->startElement($element_name);
                                $xmlWriter->writeCData(apply_filters('pmxe_sql_field', $val, $element_name, get_the_ID()));
                                $xmlWriter->endElement();
                            }
                            break;
                        default:
                            # code...
                            break;
                    }
                }
            }
        }
        $xmlWriter->endElement();
        // end post
        if ($preview) {
            break;
        }
    }
    $xmlWriter->endElement();
    // end data
    if ($preview) {
        return wp_all_export_remove_colons($xmlWriter->flush(true));
    }
    if ($is_cron) {
        $xml = $xmlWriter->flush(true);
        if (file_exists($file_path)) {
            file_put_contents($file_path, wp_all_export_remove_colons(substr(substr($xml, 45), 0, -8)), FILE_APPEND);
        } else {
            file_put_contents($file_path, wp_all_export_remove_colons(substr($xml, 0, -8)));
        }
        return $file_path;
    } else {
        if (empty(PMXE_Plugin::$session->file)) {
            $is_secure_import = PMXE_Plugin::getInstance()->getOption('secure');
            $wp_uploads = wp_upload_dir();
            $target = $is_secure_import ? wp_all_export_secure_file($wp_uploads['basedir'] . DIRECTORY_SEPARATOR . PMXE_Plugin::UPLOADS_DIRECTORY) : $wp_uploads['path'];
            $export_file = $target . DIRECTORY_SEPARATOR . time() . '.' . $exportOptions['export_to'];
            file_put_contents($export_file, wp_all_export_remove_colons(substr($xmlWriter->flush(true), 0, -8)));
            PMXE_Plugin::$session->set('file', $export_file);
            PMXE_Plugin::$session->save_data();
        } else {
            file_put_contents(PMXE_Plugin::$session->file, wp_all_export_remove_colons(substr(substr($xmlWriter->flush(true), 45), 0, -8)), FILE_APPEND);
        }
        return true;
    }
}
 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++;
     }
     if ($c === 1) {
         $xmlWriter->startElement('node');
         $xmlWriter->endElement();
     }
     fclose($res);
     $xmlWriter->endElement();
     $xmlWriter->flush(true);
     return true;
 }
Ejemplo n.º 14
0
 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();
Ejemplo n.º 15
0
 /**
  * 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');
         $xml->startElement('placeTerm');
         $xml->writeAttribute('type', 'text');
         $xml->writeCData($_biblio_d['publish_place']);
         $xml->endElement();
         $xml->startElement('publisher');
         $xml->writeCData($_biblio_d['publisher']);
         $xml->endElement();
         $xml->startElement('dateIssued');
         $xml->writeCData($_biblio_d['publish_year']);
         $xml->endElement();
         $xml->endElement();
         $xml->endElement();
         // images
         $_image = '';
         if (!empty($_biblio_d['image'])) {
             $_image = urlencode($_biblio_d['image']);
             $xml->startElementNS('slims', 'image', null);
             $xml->writeCdata($_image);
             $xml->endElement();
         }
         $xml->endElement();
         // MODS
     }
     // free resultset memory
     $this->resultset->free_result();
     $_buffer .= $xml->outputMemory();
     $_buffer .= '</modsCollection>';
     return $_buffer;
 }
Ejemplo n.º 16
0
                $prev_latitude = $latitude;
                $prev_longitude = $longitude;
                $seconds = isset($prev_dateoccured) ? strtotime($dateoccured) - strtotime($prev_dateoccured) : 0;
                $prev_dateoccured = $dateoccured;
                $totalMeters += $distance;
                $totalSeconds += $seconds;
                $xml->startElement("trkpt");
                $xml->writeAttribute("lat", $latitude);
                $xml->writeAttribute("lon", $longitude);
                if ($altitude) {
                    $xml->writeElement("ele", $altitude);
                }
                $xml->writeElement("time", str_replace(" ", "T", $dateoccured));
                $xml->writeElement("name", ++$i);
                $xml->startElement("desc");
                $description = $lang_user . ": " . strtoupper($username) . " " . $lang_track . ": " . strtoupper($trackname) . " " . $lang_time . ": " . $dateoccured . ($speed ? " " . $lang_speed . ": " . round($speed * 3.6, 2 * $factor_kmh) . " " . $unit_kmh : "") . ($altitude != null ? " " . $lang_altitude . ": " . round($altitude * $factor_m) . " " . $unit_m : "") . " " . $lang_ttime . ": " . toHMS($totalSeconds) . "" . " " . $lang_aspeed . ": " . ($totalSeconds != 0 ? round($totalMeters / $totalSeconds * 3.6 * $factor_kmh, 2) : 0) . " " . $unit_kmh . " " . $lang_tdistance . ": " . round($totalMeters / 1000 * $factor_km, 2) . " " . $unit_km . " " . $lang_point . " " . $i . " " . $lang_of . " " . ($query->num_rows - 1);
                $xml->writeCData($description);
                $xml->endElement();
                $xml->endElement();
            }
            $xml->endElement();
            $xml->endElement();
            $xml->endElement();
            $xml->endDocument();
            $xml->flush();
            break;
    }
    $query->free_result();
    $query->close();
}
$mysqli->close();
Ejemplo n.º 17
0
 function getXML()
 {
     //Set the default timezone
     @date_default_timezone_set("GMT");
     //Create the xml write object
     $writer = new XMLWriter();
     //XMLWriter Output method:
     //------------------------------------------------------------------------------------------
     $writer->openMemory();
     //	Xml stored in memory (store in variable, output
     //  to file, print/echo	to user, etc.
     //$this->$writer->openURI('php://output');  	//	Send xml to browser/user
     //-----------------------------------------------------------------------------------------
     //XML Version
     $writer->startDocument('1.0');
     //Indent level
     $writer->setIndent($this->indent);
     //Create first element / main block	(Xml type - RSS 2.0)
     $writer->startElement('rss');
     //Start RSS--------------------------------------------------------------------------------
     //*****************************************************************************************
     //RSS attribute(s)
     $writer->writeAttribute('version', '2.0');
     $writer->startElement("channel");
     //Start Channel------------------------------------------------------------------------
     //Required Channel Elements
     //---------------------------------------------------------
     $writer->writeElement('title', $this->feedData['title']);
     $writer->writeElement('description', $this->feedData['description']);
     $writer->writeElement('link', $this->feedData['link']);
     //Optional Channel Elements
     //---------------------------------------------------------
     foreach ($this->channelCategories as $category) {
         //Category block
         $writer->startElement('category');
         if ($category[1] != null) {
             //category has an associated domain
             $writer->writeAttribute('domain', $category[1]);
         }
         $writer->text($category[0]);
         //Category Name
         $writer->endElement();
     }
     if ($this->channelCloud != null) {
         //Cloud block - Allow registration with a cloud to recieve notification of feed updates
         $writer->startElement('cloud');
         $writer->writeAttribute('domain', $this->channelCloud[0]);
         $writer->writeAttribute('port', $this->channelCloud[1]);
         $writer->writeAttribute('path', $this->channelCloud[2]);
         $writer->writeAttribute('registerProcedure', $this->channelCloud[3]);
         $writer->writeAttribute('protocol', $this->channelCloud[4]);
         $writer->endElement();
     }
     if ($this->channelImage != null) {
         //Channel Image (Optional)
         $writer->startElement('image');
         $writer->writeElement('title', $this->channelImage[0]);
         $writer->writeElement('link', $this->channelImage[1]);
         $writer->writeElement('url', $this->channelImage[2]);
         $writer->writeElement('width', $this->channelImage[3]);
         $writer->writeElement('height', $this->channelImage[4]);
         $writer->endElement();
     }
     foreach ($this->channelData as $element) {
         //Other Optional Elements
         $writer->startElement($element['elementName']);
         foreach ($element['attributes'] as $attribute) {
             $writer->writeAttribute($attribute[0], $attribute[1]);
         }
         if ($element['value'] != null) {
             $writer->text($element['value']);
         }
         //Element Value
         $writer->endElement();
     }
     //Output the items
     foreach ($this->itemsArray as $item) {
         $writer->startElement("item");
         //Start Item-----------------------------------------------------------------------
         if ($this->useCDATA) {
             /*=============Changes By abasit83 v2.1 ===============*/
             $writer->startElement("title");
             $writer->writeCData($item['title']);
             $writer->endElement();
             $writer->startElement("link");
             $writer->writeCData($item['link']);
             $writer->endElement();
             /* REMOVED so that guid can be set manually : Michael Chisari 12-04-2010 */
             // $writer->startElement("guid");
             // $writer->writeCData($item['link']);
             // $writer->endElement();
             /*=============END Changes By abasit83===============*/
         } else {
             $writer->writeElement('title', $item['title']);
             $writer->writeElement('link', $item['link']);
             /* REMOVED so that guid can be set manually : Michael Chisari 12-04-2010 */
             // $writer->writeElement('guid', $item['link']);
         }
         foreach ($item['optionalElements'] as $element) {
             $writer->writeElement($element['elementName'], $element['value']);
         }
         foreach ($item['itemCategories'] as $category) {
             //Category block
             $writer->startElement('category');
             if ($category[1] != null) {
                 //category has an associated domain
                 $writer->writeAttribute('domain', $category[1]);
             }
             $writer->text($category[0]);
             //Category Name
             $writer->endElement();
         }
         //Item Content
         if ($this->useCDATA) {
             /*=============Changes By abasit83 v2.1===============*/
             $writer->startElement("description");
             $writer->writeCData($item['description']);
             $writer->endElement();
             /*=============END Changes By abasit83===============*/
         } else {
             $writer->writeElement('description', $item['description']);
         }
         $writer->endElement();
         //End Item ------------------------------------------------------------------------
     }
     /*
     $writer->startElement('atom:link'); 
     	$writer->writeAttribute('href', $this->feedData['link']); 
     	$writer->writeAttribute('rel', 'self'); 
     	$writer->writeAttribute('type', 'application/rss+xml'); 
     $writer->endElement();
     */
     $writer->endElement();
     //End channel -------------------------------------------------------------------------
     // End rss
     $writer->endElement();
     //-----------------------------------------------------------------------------------------
     //*****************************************************************************************
     //End Xml Document
     $writer->endDocument();
     $this->xml = $writer->outputMemory(true);
     return $this->xml;
 }
Ejemplo n.º 18
0
$xmlRetour->endElement();
//var_dump($picturesThumnailColumn);
//now we generate the real datas
$xmlRetour->startElement("data");
//we put the datas in this variable
$datas = $datasManager->getDatas($page);
//we loop on the datas
foreach ($datas as $key => $value) {
    $xmlRetour->startElement("row");
    //and start a row
    $xmlRetour->writeAttribute("id", $key);
    foreach ($value as $columnName => $columnValue) {
        $xmlRetour->startElement("column");
        $xmlRetour->writeAttribute("name", $columnName);
        if (in_array($columnName, array_keys($picturesThumnailColumn))) {
            $xmlRetour->writeCData("<img src='" . $picturesThumnailColumn[$columnName] . $columnValue . "'/>");
        } else {
            //id there is a display column node in the xml
            if ((string) $xml->{"" . $columnName . ""}->displayColumn != null && (string) $xml->{"" . $columnName . ""}->displayColumn != "") {
                //we extract the informations in the relation table
                $sqlChoicesQuery = "SELECT * FROM " . $oneElement->arrayRelations[$columnName]["assoc_table"] . " WHERE " . $oneElement->arrayRelations[$columnName]["assoc_col"] . " ='" . $columnValue . "'";
                $resultChoices = $dbh->query($sqlChoicesQuery);
                $resultChoices->setFetchMode(PDO::FETCH_ASSOC);
                $resultChoices = $resultChoices->fetchAll();
                if (count(explode("|", (string) $xml->{"" . $columnName . ""}->displayColumn)) > 1) {
                    $concatDisplay = "";
                    foreach (explode("|", (string) $xml->{"" . $columnName . ""}->displayColumn) as $columnConcat) {
                        $concatDisplay .= $resultChoices[0][$columnConcat] . " ";
                    }
                    $xmlRetour->text($concatDisplay);
                } else {
Ejemplo n.º 19
0
 protected function toXML()
 {
     $fp = fopen($this->_filename, 'rb');
     fseek($fp, 0);
     $xmlWriter = new XMLWriter();
     $xmlWriter->openURI($this->xml_path);
     $xmlWriter->setIndent(true);
     $xmlWriter->setIndentString("\t");
     $xmlWriter->startDocument('1.0', 'UTF-8');
     $xmlWriter->startElement('data');
     while (!feof($fp)) {
         //reset time limit for big files
         set_time_limit(0);
         $sql = fread($fp, 1024 * 8);
         $count = preg_match_all("%INSERT INTO .*;%Uis", $sql, $matches);
         if ($count) {
             foreach ($matches[0] as $key => $insert) {
                 $current_table = 'node';
                 $table = preg_match_all("%INTO\\s*[^\\(].*\\(%Uis", $insert, $table_matches);
                 if ($table) {
                     $current_table = sanitize_key(trim(trim(str_replace('INTO', '', trim($table_matches[0][0], '('))), '`'));
                 }
                 $rawData = array();
                 $headers = preg_match_all("%\\(.*\\)\\s*VALUES%Uis", $insert, $headers_matches);
                 if ($headers) {
                     foreach ($headers_matches[0] as $key => $founded_headers) {
                         $hdrs = explode(',', rtrim(ltrim(trim(rtrim(trim($founded_headers), 'VALUES')), '('), ')'));
                         if (!empty($hdrs)) {
                             foreach ($hdrs as $header) {
                                 $rawData[sanitize_key(trim(trim($header), '`'))] = '';
                             }
                         }
                     }
                     $values = preg_match_all("%\\([^`].*\\)\\s*[,|;]{1}%Uis", $insert, $values_matches);
                     if ($values) {
                         foreach ($values_matches[0] as $key => $value) {
                             $insertData = array();
                             $vals = explode(',', rtrim(ltrim(trim(rtrim(rtrim(trim($value), ','), ';')), '('), ')'));
                             if (!empty($vals)) {
                                 $i = 0;
                                 foreach ($rawData as $r_key => $v) {
                                     foreach ($vals as $k => $val) {
                                         if ($i == $k) {
                                             $insertData[$r_key] = trim(trim($val), "'");
                                         }
                                     }
                                     $i++;
                                 }
                             }
                             if (!empty($insertData)) {
                                 $xmlWriter->startElement($current_table);
                                 foreach ($insertData as $h => $xml_value) {
                                     $xmlWriter->startElement($h);
                                     $xmlWriter->writeCData($xml_value);
                                     $xmlWriter->endElement();
                                 }
                                 $xmlWriter->endElement();
                             }
                         }
                     }
                 }
             }
         }
     }
     fclose($fp);
     $xmlWriter->endElement();
     $xmlWriter->flush(true);
     return true;
 }
Ejemplo n.º 20
0
 private function writeRow(XMLWriter $xml, $row, $muni_names)
 {
     $row = $row['hit'];
     #Ignore rows without coords
     if (!empty($row['lat']) and !empty($row['lon'])) {
         $xml->startElement('Placemark');
         $placemarkId = $row['id'];
         $xml->writeAttribute('id', htmlspecialchars($placemarkId));
         if (!empty($row['title'])) {
             $xml->startElement('title');
             if ($row['removed'] == 1) {
                 $xml->text(htmlspecialchars($row['title'] . ' (borttagen)'));
             } else {
                 $xml->text(htmlspecialchars($row['title']));
             }
             $xml->endElement();
         }
         $xml->startElement('description');
         $desc = '';
         if (!empty($row['image'])) {
             #if inside & unfree show link otherwise show image
             if ($row['inside'] == 1 and $row['free'] == 'unfree') {
                 $showImage = 'Commons-icon.svg';
             } else {
                 $showImage = $row['image'];
             }
             $imgsize = 100;
             $desc .= '<a href="http://commons.wikimedia.org/wiki/File:' . rawurlencode($row['image']) . '" target="_blank">';
             $desc .= '<img src="' . ApiBase::getImageFromCommons($showImage, $imgsize) . '" align="right" />';
             $desc .= '</a>';
             $styleUrl = '#picStyle';
         } else {
             $styleUrl = '#noPicStyle';
         }
         $desc .= '<ul>';
         if (!empty($row['title'])) {
             $desc .= '<li> ';
             #title
             $desc .= '<b>' . htmlspecialchars($row['title']) . '</b>';
             $desc .= '</li>';
         }
         $desc .= '<li> ';
         #artist - year
         $artist_info = ApiBase::getArtistInfo($row['id']);
         if (!empty($artist_info)) {
             foreach ($artist_info as $ai) {
                 if ($ai['wiki']) {
                     #$desc .= '<a href="https://wikidata.org/wiki/' . rawurlencode($ai['wiki']) . '">';
                     $desc .= '<a href="' . ApiBase::getArticleFromWikidata($ai['wiki']) . '" target="_blank">';
                     $desc .= '' . htmlspecialchars($ai['name']);
                     $desc .= '</a>';
                 } else {
                     $desc .= '' . htmlspecialchars($ai['name']);
                 }
                 $desc .= ', ';
             }
             $desc = substr($desc, 0, -2);
             #remove trailing ","
             if (!empty($row['year'])) {
                 $desc .= ' - ' . htmlspecialchars($row['year']);
             }
         } elseif (!empty($row['artist'])) {
             $desc .= htmlspecialchars($row['artist']);
             if (!empty($row['year'])) {
                 $desc .= ' - ' . htmlspecialchars($row['year']);
             }
         } elseif (!empty($row['year'])) {
             $desc .= htmlspecialchars($row['year']);
         }
         $desc .= '</li><li> ';
         #Muni - address
         $desc .= htmlspecialchars($muni_names[$row['muni']]);
         if (!empty($row['district'])) {
             $desc .= ' (' . htmlspecialchars($row['district']) . ')';
         }
         if (!empty($row['address'])) {
             $desc .= ' - ' . htmlspecialchars($row['address']);
         }
         #Description
         if (!empty($row['wiki'])) {
             #get descrition from wikipage
             $desc .= '</li><br/><li>' . ApiBase::getArticleIntro(ApiBase::getArticleFromWikidata($row['wiki'], $getUrl = false));
             $desc .= '  <a href="' . ApiBase::getArticleFromWikidata($row['wiki']) . '" target="_blank">';
             $desc .= htmlspecialchars('Läs mer om konstverket på Wikipedia');
             $desc .= '</a>.';
         } else {
             if (!empty($row['descr'])) {
                 $desc .= '</li><br/><li>' . htmlspecialchars($row['descr']);
             }
         }
         $desc .= '</li></ul>';
         $xml->writeCData($desc);
         $xml->endElement();
         $xml->startElement('styleUrl');
         $xml->text($styleUrl);
         $xml->endElement();
         $xml->startElement('Point');
         $xml->startElement('coordinates');
         $xml->text($row['lon'] . ',' . $row['lat']);
         $xml->endElement();
         $xml->endElement();
         $xml->endElement();
     }
 }
Ejemplo n.º 21
0
 function toXML($fixBrokenSymbols = false)
 {
     $c = 0;
     $d = "" != $this->delimiter ? $this->delimiter : $this->settings['delimiter'];
     $e = $this->settings['escape'];
     $l = $this->settings['length'];
     PMXI_Plugin::$is_csv = $d;
     $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');
     $create_new_headers = false;
     while ($keys = fgetcsv($res, $l, $d, $e)) {
         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;
                 }
                 $value = trim(strtolower(preg_replace('/^[0-9]{1}/', 'el_', preg_replace('/[^a-z0-9_]/i', '', $value))));
                 $keys[$key] = !empty($value) ? $value : 'undefined' . $key;
             }
             $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);
                         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++;
     }
     fclose($res);
     $xmlWriter->endElement();
     $xmlWriter->flush(true);
     return true;
 }
Ejemplo n.º 22
0
 /**
  * Record detail output in MODS (Metadata Object Description Schema) XML mode
  * @return  array
  *
  */
 public function MODSoutput()
 {
     // get global configuration vars array
     global $sysconf;
     $mods_version = '3.3';
     $xml = new XMLWriter();
     $xml->openMemory();
     $xml->setIndent(true);
     // set prefix and suffix
     $this->detail_prefix = '<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";
     $this->detail_suffix = '</modsCollection>';
     // $_xml_output = '<mods version="3.3" ID="'.$this->detail_id.'">'."\n";
     // MODS main tag
     $xml->startElement('mods');
     $xml->writeAttribute('version', $mods_version);
     $xml->writeAttribute('id', $this->detail_id);
     // parse title
     $_title_sub = '';
     $_title_statement_resp = '';
     if (stripos($this->record_detail['title'], ':') !== false) {
         $_title_main = trim(substr_replace($this->record_detail['title'], '', stripos($this->record_detail['title'], ':') + 1));
         $_title_sub = trim(substr_replace($this->record_detail['title'], '', 0, stripos($this->record_detail['title'], ':') + 1));
     } else {
         if (stripos($this->record_detail['title'], '/') !== false) {
             $_title_statement_resp = trim(substr_replace($this->record_detail['title'], '', stripos($this->record_detail['title'], '/') + 1));
         } else {
             $_title_main = trim($this->record_detail['title']);
         }
     }
     // $_xml_output .= '<titleInfo>'."\n".'<title><![CDATA['.$_title_main.']]></title>'."\n";
     $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();
     // personal name
     // get the authors data
     foreach ($this->record_detail['authors'] as $_auth_d) {
         /* 
                     $_xml_output .= '<name type="'.$_auth_d['authority_type'].'" authority="'.$_auth_d['auth_list'].'">'."\n"
         .'<namePart><![CDATA['.$_auth_d['author_name'].']]></namePart>'."\n"
         .'<role><roleTerm type="text"><![CDATA['.$sysconf['authority_level'][$_auth_d['level']].']]></roleTerm></role>'."\n"
         .'</name>'."\n";
         */
         // $xml->startElement('name'); $xml->writeAttribute('type', $sysconf['authority_type'][$_auth_d['authority_type']]); $xml->writeAttribute('authority', $_auth_d['auth_list']);
         $xml->startElement('name');
         $xml->writeAttribute('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();
     }
     // resources type
     // $_xml_output .= '<typeOfResource manuscript="yes" collection="yes"><![CDATA[mixed material]]></typeOfResource>'."\n";
     $xml->startElement('typeOfResource');
     $xml->writeAttribute('manuscript', 'no');
     $xml->writeAttribute('collection', 'yes');
     $xml->writeCData('mixed material');
     $xml->endElement();
     // $_xml_output .= '<genre authority="marcgt"><![CDATA[bibliography]]></genre>'."\n";
     $xml->startElement('genre');
     $xml->writeAttribute('authority', 'marcgt');
     $xml->writeCData('bibliography');
     $xml->endElement();
     // imprint/publication data
     /*
     $_xml_output .= '<originInfo>'."\n";
     $_xml_output .= '<place><placeTerm type="text"><![CDATA['.$this->record_detail['publish_place'].']]></placeTerm></place>'."\n"
       .'<publisher><![CDATA['.$this->record_detail['publisher_name'].']]></publisher>'."\n"
       .'<dateIssued><![CDATA['.$this->record_detail['publish_year'].']]></dateIssued>'."\n";
     if ((integer)$this->record_detail['frequency_id'] > 0) {
         $_xml_output .= '<issuance>continuing</issuance>'."\n";
         $_xml_output .= '<frequency><![CDATA['.$this->record_detail['frequency'].']]></frequency>'."\n";
     } else {
         $_xml_output .= '<issuance><![CDATA[monographic]]></issuance>'."\n";
     }
     $_xml_output .= '<edition><![CDATA['.$this->record_detail['edition'].']]></edition>'."\n";
     $_xml_output .= '</originInfo>'."\n";
     */
     $xml->startElement('originInfo');
     $xml->startElement('place');
     $xml->startElement('placeTerm');
     $xml->writeAttribute('type', 'text');
     $xml->writeCData($this->record_detail['publish_place']);
     $xml->endElement();
     $xml->startElement('publisher');
     $xml->writeCData($this->record_detail['publisher_name']);
     $xml->endElement();
     $xml->startElement('dateIssued');
     $xml->writeCData($this->record_detail['publish_year']);
     $xml->endElement();
     $xml->endElement();
     $xml->endElement();
     // language
     /*
     $_xml_output .= '<language>'."\n";
     $_xml_output .= '<languageTerm type="code"><![CDATA['.$this->record_detail['language_id'].']]></languageTerm>'."\n";
     $_xml_output .= '<languageTerm type="text"><![CDATA['.$this->record_detail['language_name'].']]></languageTerm>'."\n";
     $_xml_output .= '</language>'."\n";
     */
     $xml->startElement('language');
     $xml->startElement('languageTerm');
     $xml->writeAttribute('type', 'code');
     $xml->writeCData($this->record_detail['language_id']);
     $xml->endElement();
     $xml->startElement('languageTerm');
     $xml->writeAttribute('type', 'text');
     $xml->writeCData($this->record_detail['language_name']);
     $xml->endElement();
     $xml->endElement();
     // Physical Description/Collation
     /*
     $_xml_output .= '<physicalDescription>'."\n";
     $_xml_output .= '<form authority="gmd"><![CDATA['.$this->record_detail['gmd_name'].']]></form>'."\n";
     $_xml_output .= '<extent><![CDATA['.$this->record_detail['collation'].']]></extent>'."\n";
     $_xml_output .= '</physicalDescription>'."\n";
     */
     $xml->startElement('physicalDescription');
     $xml->startElement('form');
     $xml->writeAttribute('authority', 'gmd');
     $xml->writeCData($this->record_detail['gmd_name']);
     $xml->endElement();
     $xml->startElement('extent');
     $xml->writeCData($this->record_detail['collation']);
     $xml->endElement();
     $xml->endElement();
     // Series title
     if ($this->record_detail['series_title']) {
         /*
         $_xml_output .= '<relatedItem type="series">'."\n";
         $_xml_output .= '<titleInfo>'."\n";
         $_xml_output .= '<title><![CDATA['.$this->record_detail['series_title'].']]></title>'."\n";
         $_xml_output .= '</titleInfo>'."\n";
         $_xml_output .= '</relatedItem>'."\n";
         */
         $xml->startElement('relatedItem');
         $xml->writeAttribute('type', 'series');
         $xml->startElement('titleInfo');
         $xml->endElement();
         $xml->startElement('title');
         $xml->writeCData($this->record_detail['series_title']);
         $xml->endElement();
         $xml->endElement();
         $xml->endElement();
     }
     // Note
     // $_xml_output .= '<note>'.$this->record_detail['notes'].'</note>'."\n";
     $xml->startElement('note');
     $xml->writeCData($this->record_detail['notes']);
     $xml->endElement();
     if (isset($this->record_detail['sor'])) {
         $xml->startElement('note');
         $xml->writeAttribute('type', 'statement of responsibility');
         $xml->writeCData($this->record_detail['sor']);
         $xml->endElement();
         // $_xml_output .= '<note type="statement of responsibility"><![CDATA['.$_title_statement_resp.']]></note>';
     }
     // subject/topic
     foreach ($this->record_detail['subjects'] as $_topic_d) {
         $_subject_type = strtolower($sysconf['subject_type'][$_topic_d['topic_type']]);
         /*
         $_xml_output .= '<subject authority="'.$_topic_d['auth_list'].'">';
         $_xml_output .= '<'.$_subject_type.'><![CDATA['.$_topic_d['topic'].']]></'.$_subject_type.'>';
         $_xml_output .= '</subject>'."\n";
         */
         $xml->startElement('subject');
         $xml->writeAttribute('authority', $_topic_d['auth_list']);
         $xml->startElement($_subject_type);
         $xml->writeCData($_topic_d['topic']);
         $xml->endElement();
         $xml->endElement();
     }
     // classification
     // $_xml_output .= '<classification><![CDATA['.$this->record_detail['classification'].']]></classification>';
     $xml->startElement('classification');
     $xml->writeCData($this->record_detail['classification']);
     $xml->endElement();
     // ISBN/ISSN
     // $_xml_output .= '<identifier type="isbn"><![CDATA['.str_replace(array('-', ' '), '', $this->record_detail['isbn_issn']).']]></identifier>';
     $xml->startElement('identifier');
     $xml->writeAttribute('type', 'isbn');
     $xml->writeCData(str_replace(array('-', ' '), '', $this->record_detail['isbn_issn']));
     $xml->endElement();
     // Location and Copies information
     $_copy_q = $this->db->query(sprintf('SELECT i.item_code, i.call_number, stat.item_status_name, loc.location_name, stat.rules, i.site FROM item AS i ' . 'LEFT JOIN mst_item_status AS stat ON i.item_status_id=stat.item_status_id ' . 'LEFT JOIN mst_location AS loc ON i.location_id=loc.location_id ' . 'WHERE i.biblio_id=%d', $this->detail_id));
     /*
     $_xml_output .= '<location>'."\n";
     $_xml_output .= '<physicalLocation><![CDATA['.$sysconf['library_name'].' '.$sysconf['library_subname'].']]></physicalLocation>'."\n";
     $_xml_output .= '<shelfLocator><![CDATA['.$this->record_detail['call_number'].']]></shelfLocator>'."\n";
     if ($_copy_q->num_rows > 0) {
         $_xml_output .= '<holdingSimple>'."\n";
         while ($_copy_d = $_copy_q->fetch_assoc()) {
             $_xml_output .= '<copyInformation>'."\n";
             $_xml_output .= '<numerationAndChronology type="1"><![CDATA['.$_copy_d['item_code'].']]></numerationAndChronology>'."\n";
             $_xml_output .= '<sublocation><![CDATA['.$_copy_d['location_name'].( $_copy_d['site']?' ('.$_copy_d['site'].')':'' ).']]></sublocation>'."\n";
             $_xml_output .= '<shelfLocator><![CDATA['.$_copy_d['call_number'].']]></shelfLocator>'."\n";
             $_xml_output .= '</copyInformation>'."\n";
         }
         $_xml_output .= '</holdingSimple>'."\n";
     }
     $_xml_output .= '</location>'."\n";
     */
     $xml->startElement('location');
     $xml->startElement('physicalLocation');
     $xml->writeCData($sysconf['library_name'] . ' ' . $sysconf['library_subname']);
     $xml->endElement();
     $xml->startElement('shelfLocator');
     $xml->writeCData($this->record_detail['call_number']);
     $xml->endElement();
     if ($_copy_q->num_rows > 0) {
         $xml->startElement('holdingSimple');
         while ($_copy_d = $_copy_q->fetch_assoc()) {
             $xml->startElement('copyInformation');
             $xml->startElement('numerationAndChronology');
             $xml->writeAttribute('type', '1');
             $xml->writeCData($_copy_d['item_code']);
             $xml->endElement();
             $xml->startElement('sublocation');
             $xml->writeCData($_copy_d['location_name'] . ($_copy_d['site'] ? ' (' . $_copy_d['site'] . ')' : ''));
             $xml->endElement();
             $xml->startElement('shelfLocator');
             $xml->writeCData($_copy_d['call_number']);
             $xml->endElement();
             $xml->endElement();
         }
         $xml->endElement();
     }
     $xml->endElement();
     // digital files
     $attachment_q = $this->db->query('SELECT att.*, f.* FROM biblio_attachment AS att
         LEFT JOIN files AS f ON att.file_id=f.file_id WHERE att.biblio_id=' . $this->detail_id . ' AND att.access_type=\'public\' LIMIT 20');
     if ($attachment_q->num_rows > 0) {
         /*
         $_xml_output .= '<slims:digitals>'."\n";
         while ($attachment_d = $attachment_q->fetch_assoc()) {
             // check member type privileges
             if ($attachment_d['access_limit']) { continue; }
             $_xml_output .= '<slims:digital_item id="'.$attachment_d['file_id'].'" url="'.trim($attachment_d['file_url']).'" '
                 .'path="'.$attachment_d['file_dir'].'/'.$attachment_d['file_name'].'" mimetype="'.$attachment_d['mime_type'].'">';
             $_xml_output .= '<![CDATA['.$attachment_d['file_title'].']]>';
             $_xml_output .= '</slims:digital_item>'."\n";
         }
         $_xml_output .= '</slims:digitals>';
         */
         $xml->startElementNS('slims', 'digitals', null);
         while ($attachment_d = $attachment_q->fetch_assoc()) {
             // check member type privileges
             if ($attachment_d['access_limit']) {
                 continue;
             }
             $xml->startElementNS('slims', 'digital_item', null);
             $xml->writeAttribute('id', $attachment_d['file_id']);
             $xml->writeAttribute('url', trim($attachment_d['file_url']));
             $xml->writeAttribute('path', $attachment_d['file_dir'] . '/' . $attachment_d['file_name']);
             $xml->writeAttribute('mimetype', $attachment_d['mime_type']);
             $xml->writeCData($attachment_d['file_title']);
             $xml->endElement();
         }
         $xml->endElement();
     }
     // image
     if (!empty($this->record_detail['image'])) {
         $_image = urlencode($this->record_detail['image']);
         $xml->startElementNS('slims', 'image', null);
         $xml->writeCData(urlencode($_image));
         $xml->endElement();
     }
     // record info
     /*
     $_xml_output .= '<recordInfo>'."\n";
     $_xml_output .= '<recordIdentifier><![CDATA['.$this->detail_id.']]></recordIdentifier>'."\n";
     $_xml_output .= '<recordCreationDate encoding="w3cdtf"><![CDATA['.$this->record_detail['input_date'].']]></recordCreationDate>'."\n";
     $_xml_output .= '<recordChangeDate encoding="w3cdtf"><![CDATA['.$this->record_detail['last_update'].']]></recordChangeDate>'."\n";
     $_xml_output .= '<recordOrigin><![CDATA[machine generated]]></recordOrigin>'."\n";
     $_xml_output .= '</recordInfo>';
     */
     $xml->startElement('recordInfo');
     $xml->startElement('recordIdentifier');
     $xml->writeCData($this->detail_id);
     $xml->endElement();
     $xml->startElement('recordCreationDate');
     $xml->writeAttribute('encoding', 'w3cdtf');
     $xml->writeCData($this->record_detail['input_date']);
     $xml->endElement();
     $xml->startElement('recordChangeDate');
     $xml->writeAttribute('encoding', 'w3cdtf');
     $xml->writeCData($this->record_detail['last_update']);
     $xml->endElement();
     $xml->startElement('recordOrigin');
     $xml->writeCData('machine generated');
     $xml->endElement();
     $xml->endElement();
     // $_xml_output .= '</mods>';
     $xml->endElement();
     return $xml->outputMemory();
 }
Ejemplo n.º 23
0
 /**
  * Write an element with namespace if used
  *
  * @param  \XMLWriter $xmlWriter XML writer resource
  * @param  string     $prefix    Namespace prefix if any
  * @param  string     $name      Element name
  * @param  string     $namespace The uri of the namespace
  * @param  string     $value     The element content
  */
 protected function writeElement(\XMLWriter $xmlWriter, $prefix, $name, $namespace, $value)
 {
     $xmlWriter->startElementNS($prefix, $name, $namespace);
     if (strpbrk($value, '<>&')) {
         $xmlWriter->writeCData($value);
     } else {
         $xmlWriter->writeRaw($value);
     }
     $xmlWriter->endElement();
 }
Ejemplo n.º 24
0
		where l_isactive=1 and www_site_type=2 and (l_make<>'' and l_model<>'') and l_gear<>'' and 
			(l_geo_city='Москва' or l_geo_city='Санкт-Петербург' or l_region='Ленинградская область' or l_region='Москва' or l_region='Московская область') order by l_www_id"; */
$sql = "\n\t\tselect\n\t\t\tl_url, l_www_id, l_subcategory, l_make, l_model, l_year, l_price, l_region, l_geo_city, l_geo_street, l_metro, www_name as l_contact_name, \n\t\t\twww_telephone as l_contact_phone, www_email as l_contact_email, l_image, l_description, l_km, l_color, l_trtype, l_encapacity, \n\t\t\tl_fuel, l_gear, l_condition, l_wheelside, l_moreinfo, l_postdate,l_id,www_city,www_street\n\t\tfrom `ru_eyezeek`.`vehicles` v join ru_eyezeek.np_wwwsite w on v.l_www_id=w.www_id\n\t\twhere l_isactive=1 and www_site_type=2 and (l_make<>'' and l_model<>'') and l_gear<>'' order by l_www_id";
$current_name = '';
$current_wwwid = 0;
if ($result = $mysqli->query($sql)) {
    while ($arr = $result->fetch_assoc()) {
        if ($arr['l_www_id'] != $current_wwwid) {
            $current_name = $arr['l_contact_name'];
            $current_wwwid = $arr['l_www_id'];
            $feeds->startElement('Feed');
            $feeds->startElement('ID');
            $feeds->text($current_wwwid);
            $feeds->endElement();
            $feeds->startElement('Name');
            $feeds->writeCData($current_name);
            $feeds->endElement();
            $feeds->startElement('Phone');
            $feeds->writeCData($arr['l_contact_phone']);
            $feeds->endElement();
            $feeds->startElement('City');
            $feeds->writeCData($arr['www_city']);
            $feeds->endElement();
            $feeds->startElement('Address');
            $feeds->writeCData($arr['www_street']);
            $feeds->endElement();
            $feeds->startElement('URL');
            $feeds->writeCData("http://pingola.ru/files/export_mail_ru/" . $current_wwwid . ".gz");
            $feeds->endElement();
            $feeds->endElement();
            if (is_object($writer)) {