private function writeCommon(\XMLWriter $writer, Common $common) { if ($common->getAuthor()) { $writer->startElement('itunes:author'); $writer->writeCdata($common->getAuthor()); $writer->endElement(); } if ($common->getSummary()) { $writer->startElement('itunes:summary'); $writer->writeCdata($common->getSummary()); $writer->endElement(); } if ($common->getBlock()) { $writer->writeElement('itunes:block', 'Yes'); } if ($common->getImage()) { $writer->startElement('itunes:image'); $writer->writeAttribute('href', $common->getImage()); $writer->endElement(); } $writer->writeElement('itunes:explicit', true === $common->getExplicit() ? 'Yes' : 'No'); if ($common->getSubtitle()) { $writer->startElement('itunes:subtitle'); $writer->writeCdata($common->getSubtitle()); $writer->endElement(); } }
public function get() { $posts = Model::factory('Article')->where('status', '1')->order_by_desc('point')->limit(100)->find_many(); $xml = new \XMLWriter(); $xml->openMemory(); $xml->startDocument(); $xml->startElement('urlset'); foreach ($posts as $post) { $xml->startElement('url'); $xml->startElement('loc'); $xml->writeCdata($post->permalink()); $xml->endElement(); $xml->startElement('lastmod'); $xml->writeCdata(date(DATE_ATOM, strtotime($post->modified_at ? $post->modified_at : $post->created_at))); $xml->endElement(); $xml->startElement('changefreq'); $xml->writeCdata('always'); $xml->endElement(); $xml->startElement('priority'); $xml->writeCdata('1.0'); $xml->endElement(); $xml->endElement(); } $xml->endElement(); $this->data = $xml->outputMemory(); }
/** * Method for parsing of elements * * @param string $node - node name * @param string $item - node content * @param bool $wrap - should be wrapped in array for singularization * * @return void * * @since 1.0 */ protected function handleElement($node, $item, $wrap = true) { if ($this->dispatcher->listensTo($node)) { $this->dispatcher->trigger($node, array($this->writer, $node, $item)); } else { if ($node === self::COMMENT) { if (!is_array($item)) { $item = array($item); } foreach ($item as $comment) { $this->writer->writeComment($comment); } } elseif ($node === self::CDATA) { $this->writer->writeCdata($item); } else { if ($wrap === true) { if ($this->assertElementName($node)) { if ($this->config->nil_on_null === true && is_null($item)) { $this->writer->startElement($node); $this->writer->writeAttribute('xsi:nil', 'true'); $this->writer->writeRaw($item); $this->writer->endElement(); } else { $this->writer->writeElement($node, $item); } } } else { $this->writer->writeRaw($item); } } } }
protected function dumpElement($key, $value) { $this->xml->startElement(strtolower(preg_replace('/[^a-zA-Z0-9]/', '', $key))); if (is_array($value)) { foreach ($value as $subKey => $subValue) { $this->dumpElement($subKey, $subValue); } } else { //need CDATA if (preg_match('/[<>&]/', $value)) { $this->xml->writeCdata($value); } else { $this->xml->text($value); } } $this->xml->endElement(); }
/** * Generates the export * * @param integer $categoryId Category Id * @param boolean $downwards If true, downwards, otherwise upward ordering * @param string $language Language * * @return string */ public function generate($categoryId = 0, $downwards = true, $language = '') { global $PMF_LANG; // Initialize categories $this->category->transform($categoryId); $faqdata = $this->faq->get(FAQ_QUERY_TYPE_EXPORT_XHTML, $categoryId, $downwards, $language); $version = $this->_config->get('main.currentVersion'); $comment = sprintf('XHTML output by phpMyFAQ %s | Date: %s', $version, PMF_Date::createIsoDate(date("YmdHis"))); $this->xml->startDocument('1.0', 'utf-8'); $this->xml->writeDtd('html', '-//W3C//DTD XHTML 1.0 Transitional//EN', 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'); $this->xml->startElement('html'); $this->xml->writeAttribute('xmlns', 'http://www.w3.org/1999/xhtml'); $this->xml->writeAttribute('xml:lang', $language); $this->xml->writeComment($comment); $this->xml->startElement('head'); $this->xml->writeElement('title', $this->_config->get('main.titleFAQ')); $this->xml->startElement('meta'); $this->xml->writeAttribute('http-equiv', 'Content-Type'); $this->xml->writeAttribute('content', 'application/xhtml+xml; charset=utf-8'); $this->xml->endElement(); $this->xml->endElement(); // </head> $this->xml->startElement('body'); $this->xml->writeAttribute('dir', $PMF_LANG['dir']); if (count($faqdata)) { $lastCategory = 0; foreach ($faqdata as $data) { if ($data['category_id'] != $lastCategory) { $this->xml->writeElement('h1', $this->category->getPath($data['category_id'], ' >> ')); } $this->xml->writeElement('h2', strip_tags($data['topic'])); $this->xml->startElement('p'); $this->xml->writeCdata(html_entity_decode($data['content'], ENT_QUOTES, 'UTF-8')); $this->xml->endElement(); $this->xml->writeElement('p', $PMF_LANG['msgAuthor'] . ': ' . $data['author_email']); $this->xml->writeElement('p', $PMF_LANG['msgLastUpdateArticle'] . PMF_Date::createIsoDate($data['lastmodified'])); $lastCategory = $data['category_id']; } } $this->xml->endElement(); // </body> $this->xml->endElement(); // </html> header('Content-type: text/html'); return $this->xml->outputMemory(); }
/** * Write purchase order info to order * @param Mage_Sales_Model_Order $order * @param XMLWriter $xml */ public function writePoNumber($order, $xml) { $payment = $order->getPayment(); $xml->startElement('PO'); if ($payment) { $xml->writeCdata($payment->getPoNumber()); } $xml->endElement(); }
$rss->writeElement('title', $faqconfig->get('main.titleFAQ') . ' - ' . $PMF_LANG['msgNews']); $rss->writeElement('description', html_entity_decode($faqconfig->get('main.metaDescription'))); $rss->writeElement('link', PMF_Link::getSystemUri('/feed/news/rss.php')); if ($num > 0) { foreach ($rssData as $item) { // Get the url $link = '/index.php?action=news&newsid=' . $item['id'] . '&newslang=' . $item['lang']; if (PMF_RSS_USE_SEO) { if (isset($item['header'])) { $oLink = new PMF_Link($link); $oLink->itemTitle = $item['header']; $link = $oLink->toString(); } } $rss->startElement('item'); $rss->writeElement('title', html_entity_decode($item['header'])); $rss->startElement('description'); $rss->writeCdata($item['content']); $rss->endElement(); $rss->writeElement('link', PMF_Link::getSystemUri('/feed/news/rss.php') . $link); $rss->writeElement('pubDate', PMF_Date::createRFC822Date($item['date'], true)); $rss->endElement(); } } $rss->endElement(); $rss->endElement(); $rssData = $rss->outputMemory(); header('Content-Type: application/rss+xml'); header('Content-Length: ' . strlen($rssData)); print $rssData; $db->dbclose();
private function writeDestino(\XMLWriter $writer, Destino $destino) { if ($destino instanceof DestinoNacional) { $writer->startElement('nacional'); $writer->startElement('bairro_destinatario'); $writer->writeCdata($this->_($destino->getBairro(), 30)); $writer->endElement(); $writer->startElement('cidade_destinatario'); $writer->writeCdata($this->_($destino->getCidade(), 30)); $writer->endElement(); $writer->writeElement('uf_destinatario', $this->_($destino->getUf(), 2, false)); $writer->startElement('cep_destinatario'); $writer->writeCdata($this->_(preg_replace('/[^\\d]/', '', $destino->getCep()), 8)); $writer->endElement(); $writer->writeElement('codigo_usuario_postal'); $writer->writeElement('centro_custo_cliente'); $writer->writeElement('numero_nota_fiscal', $destino->getNumeroNotaFiscal()); $writer->writeElement('serie_nota_fiscal', $this->_($destino->getSerieNotaFiscal(), 20)); $writer->writeElement('valor_nota_fiscal', $destino->getValorNotaFiscal()); $writer->writeElement('natureza_nota_fiscal', $this->_($destino->getNaturezaNotaFiscal(), 20)); $writer->startElement('descricao_objeto'); $writer->writeCdata($this->_($destino->getDescricaoObjeto(), 20)); $writer->endElement(); $writer->writeElement('valor_a_cobrar', (double) $destino->getValorACobrar()); $writer->endElement(); } else { if ($destino instanceof DestinoInternacional) { $writer->startElement('internacional'); $writer->endElement(); } } }
$rss->setIndent(true); $rss->startDocument('1.0', 'utf-8'); $rss->startElement('rss'); $rss->writeAttribute('version', '2.0'); $rss->startElement('channel'); $rss->writeElement('title', $faqconfig->get('main.titleFAQ') . ' - ' . $PMF_LANG['msgOpenQuestions']); $rss->writeElement('description', html_entity_decode($faqconfig->get('main.metaDescription'))); $rss->writeElement('link', PMF_Link::getSystemUri('/feed/openquestions/rss.php')); if ($num > 0) { $counter = 0; foreach ($rssData as $item) { if ($counter < PMF_RSS_OPENQUESTIONS_MAX) { $counter++; $rss->startElement('item'); $rss->writeElement('title', PMF_Utils::makeShorterText(html_entity_decode($item->question), 8) . " (" . $item->username . ")"); $rss->startElement('description'); $rss->writeCdata($item->question); $rss->endElement(); $rss->writeElement('link', (isset($_SERVER['HTTPS']) ? 's' : '') . "://" . $_SERVER["HTTP_HOST"] . str_replace("feed/openquestions/rss.php", "index.php", $_SERVER["PHP_SELF"]) . "?action=open#openq_" . $item->id); $rss->writeElement('pubDate', PMF_Date::createRFC822Date($item->date, true)); $rss->endElement(); } } } $rss->endElement(); $rss->endElement(); $rssData = $rss->outputMemory(); header('Content-Type: application/rss+xml'); header('Content-Length: ' . strlen($rssData)); print $rssData; $db->dbclose();
/** * @param $strTable * @param array $options */ public static function exportTable($strTable, array $options = array()) { // Defaults $preDefinedOptions = array('strSorting' => 'id ASC', 'exportType' => 'csv', 'strSeperator' => ';', 'strEnclosure' => '"', 'arrFilter' => array(), 'strDestinationCharset' => '', 'strDestination' => '', 'arrSelectedFields' => null); $options = array_merge($preDefinedOptions, $options); $strSorting = $options['strSorting']; $exportType = $options['exportType']; $strSeperator = $options['strSeperator']; $strEnclosure = $options['strEnclosure']; $arrFilter = $options['arrFilter']; $strDestinationCharset = $options['strDestinationCharset']; $strDestination = $options['strDestination']; $arrSelectedFields = $options['arrSelectedFields']; $arrData = array(); // Load Datacontainer if (!is_array($GLOBALS['TL_DCA'][$strTable])) { \Controller::loadDataContainer($strTable, true); } $dca = array(); if (is_array($GLOBALS['TL_DCA'][$strTable])) { $dca = $GLOBALS['TL_DCA'][$strTable]; } // If no fields are selected, then list the whole table if ($arrSelectedFields === null || empty($arrSelectedFields)) { $arrSelectedFields = \Database::getInstance()->getFieldNames($strTable); } // create headline $arrHeadline = array(); foreach ($arrSelectedFields as $fieldname) { $arrHeadline[] = $fieldname; } $arrData[] = $arrHeadline; // add rows to $arrData if (empty($arrFilter) || !is_array($arrFilter)) { $arrFilter = array(); } $arrProcedures = []; $arrValues = []; foreach ($arrFilter as $filter) { $arrProcedures[] = $filter[0]; $arrValues[] = $filter[1]; } $arrProcedures[] = "id>=?"; $arrValues[] = 0; $arrFieldInfo = self::listFields($strTable); $objDb = \Database::getInstance()->prepare("SELECT * FROM " . $strTable . " WHERE " . implode(' AND ', $arrProcedures) . " ORDER BY " . $strSorting)->execute($arrValues); while ($dataRecord = $objDb->fetchAssoc()) { $arrRow = array(); foreach ($arrSelectedFields as $field) { $value = $dataRecord[$field]; // Handle binaries if ($value != '') { switch (strtolower($arrFieldInfo[$field]['type'])) { case 'binary': case 'varbinary': case 'blob': case 'tinyblob': case 'mediumblob': case 'longblob': $value = "0x" . bin2hex($value); break; default: // break; } } // HOOK: add custom value if (isset($GLOBALS['TL_HOOKS']['exportTable']) && is_array($GLOBALS['TL_HOOKS']['exportTable'])) { foreach ($GLOBALS['TL_HOOKS']['exportTable'] as $callback) { $objCallback = \System::importStatic($callback[0]); $value = $objCallback->{$callback}[1]($field, $value, $strTable, $dataRecord, $dca); } } $arrRow[] = $value; } $arrData[] = $arrRow; } // xml-output if ($exportType == 'xml') { $objXml = new \XMLWriter(); $objXml->openMemory(); $objXml->setIndent(true); $objXml->setIndentString("\t"); $objXml->startDocument('1.0', $strDestinationCharset != '' ? $strDestinationCharset : 'UTF-8'); $objXml->startElement($strTable); foreach ($arrData as $row => $arrRow) { // Headline if ($row == 0) { continue; } // New row $objXml->startElement('datarecord'); //$objXml->writeAttribute('index', $row); foreach ($arrRow as $i => $fieldvalue) { // New field $objXml->startElement($arrHeadline[$i]); // Write Attributes //$objXml->writeAttribute('name', $arrHeadline[$i]); //$objXml->writeAttribute('type', gettype($fieldvalue)); //$objXml->writeAttribute('origtype', $arrFieldInfo[$arrHeadline[$i]]['type']); // Convert to charset if ($strDestinationCharset != '') { $fieldvalue = iconv("UTF-8", $strDestinationCharset, $fieldvalue); } if (is_numeric($fieldvalue) || is_null($fieldvalue) || $fieldvalue == '') { $objXml->text($fieldvalue); } else { // Write CDATA $objXml->writeCdata($fieldvalue); } $objXml->endElement(); //end field-tag } $objXml->endElement(); // End row-tag } $objXml->endElement(); // End table-tag $objXml->endDocument(); $xml = $objXml->outputMemory(); // Write output to file system if ($strDestination != '') { new \Folder($strDestination); $objFolder = \FilesModel::findByPath($strDestination); if ($objFolder !== null) { if ($objFolder->type == 'folder' && is_dir(TL_ROOT . '/' . $objFolder->path)) { $objFile = new \File($objFolder->path . '/' . $strTable . '_' . \Date::parse('Y-m-d_H-i-s') . '.csv'); $objFile->write($xml); $objFile->close(); return; } } } // Send file to browser header('Content-type: text/xml'); header('Content-Disposition: attachment; filename="' . $strTable . '.xml"'); echo $xml; exit; } // csv-output if ($exportType == 'csv') { // Write output to file system if ($strDestination != '') { new \Folder($strDestination); $objFolder = \FilesModel::findByPath($strDestination); if ($objFolder !== null) { if ($objFolder->type == 'folder' && is_dir(TL_ROOT . '/' . $objFolder->path)) { $objFile = new \File($objFolder->path . '/' . $strTable . '_' . \Date::parse('Y-m-d_H-i-s') . '.csv'); foreach ($arrData as $arrRow) { $arrLine = array_map(function ($v) use($strDestinationCharset) { if ($strDestinationCharset != '') { $v = iconv("UTF-8", $strDestinationCharset, $v); } return html_entity_decode($v); }, $arrRow); self::fputcsv($objFile->handle, $arrLine, $strSeperator, $strEnclosure); } $objFile->close(); } } return; } // Send file to browser header("Content-type: text/csv"); header("Content-Disposition: attachment; filename=" . $strTable . ".csv"); header("Content-Description: csv File"); header("Pragma: no-cache"); header("Expires: 0"); $fh = fopen("php://output", 'w'); foreach ($arrData as $arrRow) { $arrLine = array_map(function ($v) use($strDestinationCharset) { if ($strDestinationCharset != '') { $v = iconv("UTF-8", $strDestinationCharset, $v); } return html_entity_decode($v); }, $arrRow); self::fputcsv($fh, $arrLine, $strSeperator, $strEnclosure); } fclose($fh); exit; } }
/** * Record detail output in Dublin Core XML mode * @return array * */ public function DublinCoreOutput() { // get global configuration vars array global $sysconf; $protocol = isset($_SERVER["HTTPS"]) ? 'https' : 'http'; $xml = new XMLWriter(); $xml->openMemory(); $xml->setIndent(true); // set prefix and suffix $this->detail_prefix = ''; $this->detail_suffix = ''; $_xml_output = ''; $_title_main = utf8_encode($this->record_detail['title']); /* // title $_title_main = utf8_encode($this->record_detail['title']); $_xml_output .= '<dc:title><![CDATA['.$_title_main.']]></dc:title>'."\n"; // 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='.$this->detail_id); while ($_auth_d = $_biblio_authors_q->fetch_assoc()) { $_xml_output .= '<dc:creator><![CDATA['.utf8_encode($_auth_d['author_name']).']]></dc:creator>'."\n"; } $_biblio_authors_q->free_result(); // imprint/publication data $_xml_output .= '<dc:publisher><![CDATA['.utf8_encode($this->record_detail['publisher_name']).']]></dc:publisher>'."\n"; if ($this->record_detail['publish_year']) { $_xml_output .= '<dc:date><![CDATA['.utf8_encode($this->record_detail['publish_year']).']]></dc:date>'."\n"; } else { $_xml_output .= '<dc:date></dc:date>'."\n"; } // edition $_xml_output .= '<dc:hasVersion><![CDATA['.utf8_encode($this->record_detail['edition']).']]></dc:hasVersion>'."\n"; // language $_xml_output .= '<dc:language><![CDATA['.utf8_encode($this->record_detail['language_name']).']]></dc:language>'."\n"; // Physical Description/Collation $_xml_output .= '<dc:medium><![CDATA['.utf8_encode($this->record_detail['gmd_name']).']]></dc:medium>'."\n"; $_xml_output .= '<dc:format><![CDATA['.utf8_encode($this->record_detail['gmd_name']).']]></dc:format>'."\n"; if ((integer)$this->record_detail['frequency_id'] > 0) { $_xml_output .= '<dc:format><![CDATA[Serial]]></dc:format>'."\n"; } $_xml_output .= '<dc:extent><![CDATA['.utf8_encode($this->record_detail['collation']).']]></dc:extent>'."\n"; // Series title if ($this->record_detail['series_title']) { $_xml_output .= '<dc:isPartOf><![CDATA['.utf8_encode($this->record_detail['series_title']).']]></dc:isPartOf>'."\n"; } // Note $_xml_output .= '<dc:description><![CDATA['.utf8_encode($this->record_detail['notes']).']]></dc:description>'."\n"; $_xml_output .= '<dc:abstract><![CDATA['.utf8_encode($this->record_detail['notes']).']]></dc:abstract>'."\n"; // subject/topic $_biblio_topics_q = $this->obj_db->query('SELECT t.topic, t.topic_type, t.auth_list, bt.level FROM mst_topic AS t LEFT JOIN biblio_topic AS bt ON t.topic_id=bt.topic_id WHERE bt.biblio_id='.$this->detail_id.' ORDER BY t.auth_list'); while ($_topic_d = $_biblio_topics_q->fetch_assoc()) { $_xml_output .= '<dc:subject><![CDATA['.utf8_encode($_topic_d['topic']).']]></dc:subject>'."\n"; } // classification $_xml_output .= '<dc:subject><![CDATA['.utf8_encode($this->record_detail['classification']).']]></dc:subject>'; // Permalink $_xml_output .= '<dc:identifier><![CDATA['.$protocol.'://'.$_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].SWB.'index.php?p=show_detail&id='.$this->detail_id.']]></dc:identifier>'; // ISBN/ISSN $_xml_output .= '<dc:identifier><![CDATA['.str_replace(array('-', ' '), '', utf8_encode($this->record_detail['isbn_issn'])).']]></dc:identifier>'; // Call Number $_xml_output .= '<dc:identifier><![CDATA['.utf8_encode($this->record_detail['call_number']).']]></dc:identifier>'."\n"; $_copy_q = $this->obj_db->query('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='.$this->detail_id); if ($_copy_q->num_rows > 0) { while ($_copy_d = $_copy_q->fetch_assoc()) { $_xml_output .= '<dc:hasPart><![CDATA['.utf8_encode($_copy_d['item_code']).']]></dc:hasPart>'."\n"; } } // digital files $attachment_q = $this->obj_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) { while ($attachment_d = $attachment_q->fetch_assoc()) { $dir = ''; if ($attachment_d['file_dir']) { $dir = $attachment_d['file_dir'].'/'; } $_xml_output .= '<dc:relation><![CDATA['; // check member type privileges if ($attachment_d['access_limit']) { continue; } $_xml_output .= $protocol.'://'.$_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].REPO_WBS.$dir.trim(urlencode($attachment_d['file_name'])); $_xml_output .= ']]></dc:relation>'."\n"; } } // image if (!empty($this->record_detail['image'])) { $_image = urlencode($this->record_detail['image']); $_xml_output .= '<dc:relation><![CDATA['.$protocol.'://'.$_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].SWB.'images/docs/'.urlencode($_image).']]></dc:relation>'."\n"; } */ // title $xml->startElementNS('dc', 'title', null); $xml->writeCdata($_title_main); $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=' . $this->detail_id); while ($_auth_d = $_biblio_authors_q->fetch_assoc()) { $xml->startElementNS('dc', 'creator', null); $xml->writeCdata($_auth_d['author_name']); $xml->endElement(); } $_biblio_authors_q->free_result(); // imprint/publication data $xml->startElementNS('dc', 'publisher', null); $xml->writeCdata($this->record_detail['publisher_name']); $xml->endElement(); if ($this->record_detail['publish_year']) { $xml->startElementNS('dc', 'date', null); $xml->writeCdata($this->record_detail['publish_year']); $xml->endElement(); } else { $xml->startElementNS('dc', 'date', null); $xml->fullEndElement(); } // edition $xml->startElementNS('dc', 'hasVersion', null); $xml->writeCdata($this->record_detail['edition']); $xml->endElement(); // language $xml->startElementNS('dc', 'language', null); $xml->writeCdata($this->record_detail['language_name']); $xml->endElement(); // Physical Description/Collation $xml->startElementNS('dc', 'medium', null); $xml->writeCdata($this->record_detail['gmd_name']); $xml->endElement(); $xml->startElementNS('dc', 'format', null); $xml->writeCdata($this->record_detail['gmd_name']); $xml->endElement(); $xml->startElementNS('dc', 'extent', null); $xml->writeCdata($this->record_detail['collation']); $xml->endElement(); if ((int) $this->record_detail['frequency_id'] > 0) { $xml->startElementNS('dc', 'format', null); $xml->writeCdata('serial'); $xml->endElement(); } // Series title if ($this->record_detail['series_title']) { $xml->startElementNS('dc', 'isPartOf', null); $xml->writeCdata($this->record_detail['series_title']); $xml->endElement(); } // Note $xml->startElementNS('dc', 'description', null); $xml->writeCdata($this->record_detail['notes']); $xml->endElement(); $xml->startElementNS('dc', 'abstract', null); $xml->writeCdata($this->record_detail['notes']); $xml->endElement(); // subject/topic $_biblio_topics_q = $this->obj_db->query('SELECT t.topic, t.topic_type, t.auth_list, bt.level FROM mst_topic AS t LEFT JOIN biblio_topic AS bt ON t.topic_id=bt.topic_id WHERE bt.biblio_id=' . $this->detail_id . ' ORDER BY t.auth_list'); while ($_topic_d = $_biblio_topics_q->fetch_assoc()) { $xml->startElementNS('dc', 'subject', null); $xml->writeCdata($_topic_d['topic']); $xml->endElement(); } $_biblio_topics_q->free_result(); // classification $xml->startElementNS('dc', 'subject', null); $xml->writeCdata($this->record_detail['classification']); $xml->endElement(); // Permalink $permalink = $protocol . '://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . SWB . 'index.php?p=show_detail&id=' . $this->detail_id; $xml->startElementNS('dc', 'identifier', null); $xml->writeCdata($permalink); $xml->endElement(); // ISBN/ISSN $xml->startElementNS('dc', 'identifier', null); $xml->writeCdata(str_replace(array('-', ' '), '', $this->record_detail['isbn_issn'])); $xml->endElement(); // Call Number $xml->startElementNS('dc', 'identifier', null); $xml->writeCdata($this->record_detail['call_number']); $xml->endElement(); $_copy_q = $this->obj_db->query('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=' . $this->detail_id); if ($_copy_q->num_rows > 0) { while ($_copy_d = $_copy_q->fetch_assoc()) { $xml->startElementNS('dc', 'hasPart', null); $xml->writeCdata($_copy_d['item_code']); $xml->endElement(); } } $_copy_q->free_result(); // digital files $attachment_q = $this->obj_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) { while ($attachment_d = $attachment_q->fetch_assoc()) { $dir = ''; if ($attachment_d['file_dir']) { $dir = $attachment_d['file_dir'] . '/'; } $_xml_output .= '<dc:relation><![CDATA['; // check member type privileges if ($attachment_d['access_limit']) { continue; } $xml->startElementNS('dc', 'relation', null); $xml->writeCdata($protocol . '://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . REPO_WBS . $dir . trim(urlencode($attachment_d['file_name']))); $xml->endElement(); } } // image if (!empty($this->record_detail['image'])) { $_image = $protocol . '://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . IMGBS . 'docs/' . urlencode($this->record_detail['image']); $xml->startElementNS('dc', 'relation', null); $xml->writeCdata($_image); $xml->endElement(); } return $xml->outputMemory(); }
$writer->startElement('resultset'); $scormcontent = simplexml_load_file('scorm_content.xml') or die('wtf'); foreach ($scormcontent->children() as $scormdetails) { $courseid = (int) $scormdetails->field['0']; $cmid = (int) $scormdetails->field['1']; $scormid = (int) $scormdetails->field['2']; $coursename = (string) $scormdetails->field['3']; $scormname = (string) $scormdetails->field['4']; $filename = (string) $scormdetails->field['5']; if (!file_exists($scormfolder . $filename)) { $notfound[] = $filename; $writer->startElement('row'); // course_id $writer->startElement('field'); $writer->writeAttribute('name', 'course_id'); $writer->writeCdata($courseid); $writer->endElement(); // course_module_id $writer->startElement('field'); $writer->writeAttribute('name', 'course_module_id'); $writer->writeCdata($cmid); $writer->endElement(); // scorm_id $writer->startElement('field'); $writer->writeAttribute('name', 'scorm_id'); $writer->writeCdata($scormid); $writer->endElement(); // course_name $writer->startElement('field'); $writer->writeAttribute('name', 'course_name'); $writer->writeCdata($coursename);
$category = new PMF_Category(); $faq = new PMF_Faq(); $records = $faq->getAllRecordPerCategory($category_id, $faqconfig->get('records.orderby'), $faqconfig->get('records.sortby')); $rss = new XMLWriter(); $rss->openMemory(); $rss->startDocument('1.0', $PMF_LANG['metaCharset']); $rss->startElement('rss'); $rss->writeAttribute('version', '2.0'); $rss->startElement('channel'); $rss->writeElement('title', utf8_encode($PMF_CONF['main.titleFAQ']) . ' - '); $rss->writeElement('description', utf8_encode($PMF_CONF['main.metaDescription'])); $rss->writeElement('link', PMF_Link::getSystemUri('/feed/category/rss.php')); if (is_array($records)) { foreach ($records as $item) { $rss->startElement('item'); $rss->writeElement('title', utf8_encode($item['record_title'] . ' (' . $item['visits'] . ' ' . $PMF_LANG['msgViews'] . ')')); $rss->startElement('description'); $rss->writeCdata(utf8_encode($item['record_preview'])); $rss->endElement(); $rss->writeElement('link', utf8_encode($item['record_link'])); $rss->writeElement('pubDate', PMF_Date::createRFC822Date($item['record_date'], true)); $rss->endElement(); } } $rss->endElement(); $rss->endElement(); $rssData = $rss->outputMemory(); header('Content-Type: application/rss+xml'); header('Content-Length: ' . strlen($rssData)); print $rssData; $db->dbclose();
/** * Handles conversion of objects into a string format that can be exported in our * XML format. * * Note: currently only ImageVariant instances are supported. * * @param $object * @param \XMLWriter $xmlWriter * @return void */ protected function objectToXml($object, \XMLWriter $xmlWriter) { $className = get_class($object); switch ($className) { case 'TYPO3\\Media\\Domain\\Model\\ImageVariant': $xmlWriter->startElement('processingInstructions'); $xmlWriter->writeCdata(serialize($object->getProcessingInstructions())); $xmlWriter->endElement(); $xmlWriter->startElement('originalImage'); $xmlWriter->writeAttribute('__type', 'object'); $xmlWriter->writeAttribute('__classname', '\\TYPO3\\Media\\Domain\\Model\\Image'); $xmlWriter->startElement('resource'); $xmlWriter->writeAttribute('__type', 'object'); $xmlWriter->writeAttribute('__classname', '\\TYPO3\\FLOW3\\Resource\\Resource'); $resource = $object->getOriginalImage()->getResource(); $xmlWriter->writeElement('filename', $resource->getFilename()); $xmlWriter->writeElement('content', base64_encode(file_get_contents($resource->getUri()))); $xmlWriter->endElement(); $xmlWriter->endElement(); break; default: throw new \TYPO3\TYPO3\Domain\Exception('Unsupported object of type "' . get_class($className) . '" hit during XML export.', 1347144928); } }
foreach ($rssData as $item) { // Get the url $link = str_replace($_SERVER['SCRIPT_NAME'], '/index.php', $item['url']); if (PMF_RSS_USE_SEO) { if (isset($item['thema'])) { $oLink = new PMF_Link($link); $oLink->itemTitle = html_entity_decode($item['thema'], ENT_COMPAT, 'UTF-8'); $link = html_entity_decode($oLink->toString(), ENT_COMPAT, 'UTF-8'); } } // Get the content $content = $item['content']; // Fix the content internal image references $content = str_replace("<img src=\"/", "<img src=\"" . PMF_Link::getSystemUri('/feed/latest/rss.php') . "/", $content); $rss->startElement('item'); $rss->writeElement('title', html_entity_decode($item['thema'], ENT_COMPAT, 'UTF-8')); $rss->startElement('description'); $rss->writeCdata($content); $rss->endElement(); $rss->writeElement('link', PMF_Link::getSystemUri('/feed/latest/rss.php') . $link); $rss->writeElement('pubDate', PMF_Date::createRFC822Date($item['datum'], true)); $rss->endElement(); } } $rss->endElement(); $rss->endElement(); $rssData = $rss->outputMemory(); header('Content-Type: application/rss+xml'); header('Content-Length: ' . strlen($rssData)); print $rssData; $db->dbclose();
/** * Create a new XML document based on the $content variable. * * @param string $content * @throws \ErrorException * @return Boolean|string */ private function createXmlDocument(&$content) { libxml_use_internal_errors(true); $xmlContent = simplexml_load_string($content); $document = new \XMLWriter(); if (!$xmlContent) { throw new \ErrorException('The supplied content is not an XML document'); } if (!isset($xmlContent->children()->name)) { return false; } $document->openMemory(); $document->startDocument('1.0', 'UTF-8'); $document->setIndent(true); $document->setIndentString(' '); $document->writeDtd(sprintf('extension PUBLIC "-//Joomla! %s//DTD template 1.0//EN" "https://intowebdevelopment.nl/dtd/joomla/%s/template-install.dtd"', DTD_JOOMLA_VERSION, DTD_JOOMLA_VERSION)); $document->startElement('extension'); $document->writeAttribute('version', TARGET_JOOMLA_VERSION); $document->writeAttribute('type', 'template'); $document->writeAttribute('client', TARGET_JOOMLA_TEMPLATE); $document->writeAttribute('method', 'upgrade'); $document->writeElement('name', (string) $xmlContent->children()->name); $document->writeElement('creationDate', (string) $xmlContent->children()->creationDate ?: date('Y-m-d')); $document->writeElement('author', (string) $xmlContent->children()->author); $document->writeElement('authorEmail', (string) $xmlContent->children()->authorEmail); $document->writeElement('authorUrl', (string) $xmlContent->children()->authorUrl); $document->writeElement('version', (string) $xmlContent->children()->version); $document->writeElement('license', (string) $xmlContent->children()->license); $document->startElement('description'); $document->writeCdata((string) $xmlContent->children()->description); $document->endElement(); $document->startElement('files'); $contains_templateDetails = false; foreach ($xmlContent->children()->files->children() as $file) { if (!is_file($this->directory . DIRECTORY_SEPARATOR . (string) $file)) { throw new FileNotFoundException((string) $file); } $contains_templateDetails = false !== strpos((string) $file, 'templateDetails.xml'); $document->writeElement($file->getName(), (string) $file); } if (!$contains_templateDetails) { $document->writeElement('filename', 'templateDetails.xml'); } $document->endElement(); $document->startElement('positions'); foreach ($xmlContent->children()->positions->children() as $position) { $document->writeElement('position', (string) $position); } $document->endElement(); if (isset($xmlContent->children()->languages)) { $document->startElement('languages'); foreach ($xmlContent->children()->languages->children() as $language) { $document->startElement('language'); $document->writeAttribute('tag', (string) $language->attributes()->tag); $document->text((string) $language); $document->endElement(); } $document->endElement(); } if (isset($xmlContent->children()->params)) { $document->startElement('config'); $document->startElement('fields'); $document->writeAttribute('name', 'params'); if (($addPath = $xmlContent->children()->params->attributes()->addpath) && isset($addPath)) { $document->writeAttribute('addfieldpath', (string) $addPath); } $document->startElement('fieldset'); $document->writeAttribute('name', 'advanced'); foreach ($xmlContent->children()->params->children() as $param) { $document->startElement('field'); $document->writeAttribute('name', (string) $param->attributes()->name); $document->writeAttribute('type', (string) $param->attributes()->type); $document->writeAttribute('default', (string) $param->attributes()->default); $document->writeAttribute('label', (string) $param->attributes()->label); $document->writeAttribute('description', (string) $param->attributes()->description); if (0 < $param->count()) { foreach ($param->children() as $option) { $document->startElement('option'); $document->writeAttribute('value', (string) $option->attributes()->value); $document->text((string) $option); $document->endElement(); } } $document->endElement(); } $document->endElement(); $document->endElement(); $document->endElement(); } $document->endElement(); return $content = $document->outputMemory(true); }
/** * Function for creating a sql/xml dump file. * * @param array $mixTables Table or a list of tables for backup * @param string $strZip Name of zip file * @param bool $booTempFolder Should the tmp folde used instead of backupfolder * @return void */ public function runDump($mixTables, $booTempFolder, $booOnlyMachine = true) { // Set time limit to unlimited set_time_limit(0); // Set limit for db query. Ticket #163 if ($GLOBALS['TL_CONFIG']['syncCto_custom_settings'] == true && intval($GLOBALS['TL_CONFIG']['syncCto_db_query_limt']) > 0) { $intElementsPerRequest = intval($GLOBALS['TL_CONFIG']['syncCto_db_query_limt']); } else { $intElementsPerRequest = 500; } // Add to the backup array all tables if (is_array($mixTables)) { $this->arrBackupTables = array_merge($this->arrBackupTables, $mixTables); } else { if ($mixTables != "" && $mixTables != null) { $this->arrBackupTables[] = $mixTables; } } // make the backup array unique $this->arrBackupTables = array_unique($this->arrBackupTables); // Check if we have some tables for backup if (!is_array($this->arrBackupTables) || $this->arrBackupTables == null || count($this->arrBackupTables) == 0) { throw new Exception("No tables found for backup."); } // Get a list of all Tables $arrTables = $this->Database->listTables(); // Write some tempfiles $strRandomToken = md5(time() . " | " . rand(0, 65535)); // Write SQL file if ($booOnlyMachine == false) { $objFileSQL = new File($this->objSyncCtoHelper->standardizePath($GLOBALS['SYC_PATH']['tmp'], "TempSQLDump.{$strRandomToken}")); $objFileSQL->write(""); } // Write gzip xml file $objGzFile = new File($this->objSyncCtoHelper->standardizePath($GLOBALS['SYC_PATH']['tmp'], "TempSyncCtoDump.{$strRandomToken}")); $objGzFile->write(""); $objGzFile->close(); // Compression $objGzFile = gzopen(TL_ROOT . "/" . $this->objSyncCtoHelper->standardizePath($GLOBALS['SYC_PATH']['tmp'], "TempSyncCtoDump.{$strRandomToken}"), "wb"); // Create XML File $objXml = new XMLWriter(); $objXml->openMemory(); $objXml->setIndent(true); $objXml->setIndentString("\t"); // XML Start $objXml->startDocument('1.0', 'UTF-8'); $objXml->startElement('database'); // Write meta (header) $objXml->startElement('metatags'); $objXml->writeElement('version', $GLOBALS['SYC_VERSION']); $objXml->writeElement('create_unix', time()); $objXml->writeElement('create_date', date('Y-m-d', time())); $objXml->writeElement('create_time', date('H:i', time())); $objXml->endElement(); // End metatags $objXml->startElement('structure'); foreach ($arrTables as $key => $TableName) { // Check if the current table marked as backup if (!in_array($TableName, $this->arrBackupTables)) { continue; } // Get data $arrStructure = $this->getTableStructure($TableName); // Check if empty if (count($arrStructure) == 0) { continue; } $objXml->startElement('table'); $objXml->writeAttribute("name", $TableName); $objXml->startElement('fields'); if (is_array($arrStructure['TABLE_FIELDS'])) { foreach ($arrStructure['TABLE_FIELDS'] as $keyField => $valueField) { $objXml->startElement('field'); $objXml->writeAttribute("name", $keyField); $objXml->text($valueField); $objXml->endElement(); // End field } } $objXml->endElement(); // End fields $objXml->startElement('definitions'); if (is_array($arrStructure['TABLE_CREATE_DEFINITIONS'])) { foreach ($arrStructure['TABLE_CREATE_DEFINITIONS'] as $keyField => $valueField) { $objXml->startElement('def'); $objXml->writeAttribute("name", $keyField); $objXml->text($valueField); $objXml->endElement(); // End field } } $objXml->endElement(); // End fields $objXml->startElement("option"); $objXml->text($arrStructure['TABLE_OPTIONS']); $objXml->endElement(); $objXml->endElement(); // End table } // Push structure into file. $strXMLFlush = $objXml->flush(true); gzputs($objGzFile, $strXMLFlush, strlen($strXMLFlush)); $objXml->endElement(); // End structure $objXml->startElement('data'); foreach ($arrTables as $key => $TableName) { // Check if the current table marked as backup if (!in_array($TableName, $this->arrBackupTables)) { continue; } // Check if table is in blacklist if (!in_array($TableName, $this->arrBackupTables)) { continue; } // Get fields $fields = $this->Database->listFields($TableName); $arrFieldMeta = array(); foreach ($fields as $key => $value) { if ($value["type"] == "index") { continue; } $arrFieldMeta[$value["name"]] = $value; } $objXml->startElement('table'); $objXml->writeAttribute('name', $TableName); for ($i = 0; true; $i++) { // Push into file. $strXMLFlush = $objXml->flush(true); gzputs($objGzFile, $strXMLFlush, strlen($strXMLFlush)); $objData = $this->Database->prepare("SELECT * FROM {$TableName}")->limit($intElementsPerRequest, $i * $intElementsPerRequest)->executeUncached(); if ($objData->numRows == 0) { break; } while ($row = $objData->fetchAssoc()) { $objXml->startElement('row'); $objXml->writeAttribute("id", $row["id"]); foreach ($row as $field_key => $field_data) { $objXml->startElement('field'); $objXml->writeAttribute("name", $field_key); if (!isset($field_data)) { $objXml->writeAttribute("type", "null"); $objXml->text("NULL"); } else { if ($field_data != "") { switch (strtolower($arrFieldMeta[$field_key]['type'])) { case 'binary': case 'varbinary': case 'blob': case 'tinyblob': case 'mediumblob': case 'longblob': $objXml->writeAttribute("type", "blob"); $objXml->text("0x" . bin2hex($field_data)); break; case 'tinyint': case 'smallint': case 'mediumint': case 'int': case 'integer': case 'bigint': $objXml->writeAttribute("type", "int"); $objXml->text($field_data); break; case 'float': case 'double': case 'real': case 'decimal': case 'numeric': $objXml->writeAttribute("type", "decimal"); $objXml->text($field_data); break; case 'date': case 'datetime': case 'timestamp': case 'time': case 'year': $objXml->writeAttribute("type", "date"); $objXml->text("'" . $field_data . "'"); break; case 'char': case 'varchar': case 'text': case 'tinytext': case 'mediumtext': case 'longtext': case 'enum': case 'set': $objXml->writeAttribute("type", "text"); $objXml->writeCdata(base64_encode(str_replace($this->arrSearchFor, $this->arrReplaceWith, $field_data))); break; default: $objXml->writeAttribute("type", "default"); $objXml->writeCdata(base64_encode(str_replace($this->arrSearchFor, $this->arrReplaceWith, $field_data))); break; } } else { $objXml->writeAttribute("type", "empty"); $objXml->text("''"); } } $objXml->endElement(); // End field } $objXml->endElement(); // End row } } $objXml->endElement(); // End table } $objXml->endElement(); // End data $objXml->endElement(); // End database $strXMLFlush = $objXml->flush(true); gzputs($objGzFile, $strXMLFlush, strlen($strXMLFlush)); gzclose($objGzFile); if ($booOnlyMachine == false) { // Write header for sql file $today = date("Y-m-d"); $time = date("H:i:s"); // Write Header $string .= "-- syncCto SQL Dump\r\n"; $string .= "-- Version " . $GLOBALS['SYC_VERSION'] . "\r\n"; $string .= "-- http://men-at-work.de\r\n"; $string .= "-- \r\n"; $string .= "-- Time stamp : {$today} at {$time}\r\n"; $string .= "\r\n"; $string .= "SET SQL_MODE=\"NO_AUTO_VALUE_ON_ZERO\";\r\n"; $string .= "\r\n"; $string .= "-- --------------------------------------------------------\r\n"; $string .= "\r\n"; $objFileSQL->append($string, ""); $objFileSQL->close(); $string = ""; // Run each table foreach ($arrTables as $key => $TableName) { // Check if table is in blacklist if (!in_array($TableName, $this->arrBackupTables)) { continue; } // Get data $arrStructure = $this->getTableStructure($TableName); // Check if empty if (count($arrStructure) == 0) { continue; } // Write SQL $string .= "-- \r\n"; $string .= "-- Dumping table {$TableName} \r\n"; $string .= "-- \r\n"; $string .= "\r\n"; $string .= $this->buildSQLTable($arrStructure, $TableName); $string .= "\r\n"; $string .= "\r\n"; $objFileSQL->append($string, ""); $objFileSQL->close(); $string = ""; // Get fields $fields = $this->Database->listFields($TableName); $arrFieldMeta = array(); foreach ($fields as $key => $value) { if ($value["type"] == "index") { continue; } $arrFieldMeta[$value["name"]] = $value; } $booFirstEntry = true; for ($i = 0; true; $i++) { $objData = $this->Database->prepare("SELECT * FROM {$TableName}")->limit($intElementsPerRequest, $i * $intElementsPerRequest)->executeUncached(); $strSQL = ""; // Check if we have some files if ($objData->numRows == 0) { // if end reach insert ';' if ($booFirstEntry != true) { $strSQL .= ";\r\n\r\n"; } $strSQL .= "-- --------------------------------------------------------\r\n\r\n"; $objFileSQL->append($strSQL, ""); $objFileSQL->close(); break; } // Start INSERT INTO if ($i == 0) { $strSQL .= "INSERT IGNORE INTO " . $TableName . " (`"; $strSQL .= implode("`, `", array_keys($arrFieldMeta)); $strSQL .= "`) VALUES"; } // Run through each row while ($row = $objData->fetchAssoc()) { $arrTableData = array(); foreach (array_keys($arrFieldMeta) as $fieldName) { if (!isset($row[$fieldName])) { $arrTableData[] = "NULL"; } else { if ($row[$fieldName] != "") { switch (strtolower($arrFieldMeta[$fieldName]['type'])) { case 'blob': case 'tinyblob': case 'mediumblob': case 'longblob': $arrTableData[] = "0x" . bin2hex($row[$fieldName]); break; case 'smallint': case 'int': $arrTableData[] = $row[$fieldName]; break; case 'text': case 'mediumtext': if (strpos($row[$fieldName], "'") != false) { $arrTableData[] = "0x" . bin2hex($row[$fieldName]); break; } default: $arrTableData[] = "'" . str_replace($this->arrSearchFor, $this->arrReplaceWith, $row[$fieldName]) . "'"; break; } } else { $arrTableData[] = "''"; } } } if ($booFirstEntry == true) { $booFirstEntry = false; $strSQL .= "\r\n(" . implode(", ", $arrTableData) . ")"; } else { $strSQL .= ",\r\n(" . implode(", ", $arrTableData) . ")"; } if (strlen($strSQL) > 100000) { $objFileSQL->append($strSQL, ""); $objFileSQL->close(); $strSQL = ""; } } if (strlen($strSQL) != 0) { $objFileSQL->append($strSQL, ""); $objFileSQL->close(); $strSQL = ""; } } } } if ($booOnlyMachine == false) { $objFileSQL->close(); } $strFilename = date($this->strTimestampFormat) . "_" . $this->strSuffixZipName; if ($booTempFolder) { $strPath = $GLOBALS['SYC_PATH']['tmp']; } else { $strPath = $GLOBALS['SYC_PATH']['db']; } $objZipArchive = new ZipArchiveCto(); $objZipArchive->open($strPath . $strFilename, ZipArchiveCto::CREATE); if ($booOnlyMachine == false) { $objZipArchive->addFile("system/tmp/TempSQLDump.{$strRandomToken}", $this->strFilenameSQL); } $objZipArchive->addFile("system/tmp/TempSyncCtoDump.{$strRandomToken}", $this->strFilenameSyncCto); $objZipArchive->close(); $objFiles = Files::getInstance(); if ($booOnlyMachine == false) { $objFiles->delete("system/tmp/TempSQLDump.{$strRandomToken}"); } $objFiles->delete("system/tmp/TempSyncCtoDump.{$strRandomToken}"); return $strFilename; }
/** * @param bool $root * @return string */ public function pack($root = false) { $writer = new XMLWriter(); $writer->openMemory(); if ($root) { $writer->startDocument(); } $writer->startElement('mailing_attributes'); if (isset($this->mailClass)) { $writer->writeElement('mail_class', $this->mailClass); } if (isset($this->politicalMailer) && $this->politicalMailer) { $writer->writeElement('political', true); } if (isset($this->csvUrl)) { $writer->startElement('csv_url'); $writer->writeCdata($this->csvUrl); $writer->endElement(); } if (isset($this->clientInvoice)) { $writer->writeElement('client_invoice', $this->clientInvoice); } if (isset($this->shipExtra)) { $writer->writeElement('ship_extra', $this->shipExtra); } $writer->endElement(); return $writer->outputMemory(); }
/** * Write the given database rows to the xml object * * @param string $strTable * @param array $arrRows * @param XMLWriter $objXml */ protected function writeGivenDbTableRows($strTable, $arrRows, &$objXml) { $arrFieldMeta = $this->_objHelper->getTableMetaFields($strTable); if (count($arrRows) > 0) { foreach ($arrRows as $row) { $objXml->startElement('row'); foreach ($row as $field_key => $field_data) { switch ($field_key) { case 'id': case 'pid': break; default: if (!isset($field_data)) { $objXml->startElement('field'); $objXml->writeAttribute("name", $field_key); $objXml->writeAttribute("type", "null"); $objXml->text("NULL"); $objXml->endElement(); // End field } else { if ($field_data != "") { $objXml->startElement('field'); $objXml->writeAttribute("name", $field_key); switch (strtolower($arrFieldMeta[$field_key]['type'])) { case 'binary': case 'varbinary': case 'blob': case 'tinyblob': case 'mediumblob': case 'longblob': $objXml->writeAttribute("type", "blob"); $objXml->text("0x" . bin2hex($field_data)); break; case 'tinyint': case 'smallint': case 'mediumint': case 'int': case 'integer': case 'bigint': $objXml->writeAttribute("type", "int"); $objXml->text($field_data); break; case 'float': case 'double': case 'real': case 'decimal': case 'numeric': $objXml->writeAttribute("type", "decimal"); $objXml->text($field_data); break; case 'date': case 'datetime': case 'timestamp': case 'time': case 'year': $objXml->writeAttribute("type", "date"); $objXml->text("'" . $field_data . "'"); break; case 'char': case 'varchar': case 'text': case 'tinytext': case 'mediumtext': case 'longtext': case 'enum': case 'set': $objXml->writeAttribute("type", "text"); $objXml->writeCdata("'" . str_replace($this->_objHelper->arrSearchFor, $this->_objHelper->arrReplaceWith, $field_data) . "'"); break; default: $objXml->writeAttribute("type", "default"); $objXml->writeCdata("'" . str_replace($this->_objHelper->arrSearchFor, $this->_objHelper->arrReplaceWith, $field_data) . "'"); break; } $objXml->endElement(); // End field } } break; } } $objXml->endElement(); // End row } } }
$rss->writeElement('description', html_entity_decode($faqConfig->get('main.metaDescription'))); $rss->writeElement('link', $faqConfig->get('main.referenceURL')); $rss->startElementNS('atom', 'link', 'http://www.w3.org/2005/Atom'); $rss->writeAttribute('rel', 'self'); $rss->writeAttribute('type', 'application/rss+xml'); $rss->writeAttribute('href', $faqConfig->get('main.referenceURL') . 'feed/openquestions/rss.php'); $rss->endElement(); if ($num > 0) { $counter = 0; foreach ($rssData as $item) { if ($counter < PMF_RSS_OPENQUESTIONS_MAX) { $counter++; $rss->startElement('item'); $rss->writeElement('title', PMF_Utils::makeShorterText(html_entity_decode($item['question'], ENT_COMPAT, 'UTF-8'), 8) . " (" . $item['username'] . ")"); $rss->startElement('description'); $rss->writeCdata($item['question']); $rss->endElement(); $rss->writeElement('link', (isset($_SERVER['HTTPS']) ? 's' : '') . "://" . $_SERVER["HTTP_HOST"] . str_replace("feed/openquestions/rss.php", "index.php", $_SERVER['SCRIPT_NAME']) . "?action=open#openq_" . $item['id']); $rss->writeElement('guid', (isset($_SERVER['HTTPS']) ? 's' : '') . "://" . $_SERVER["HTTP_HOST"] . str_replace("feed/openquestions/rss.php", "index.php", $_SERVER['SCRIPT_NAME']) . "?action=open#openq_" . $item['id']); $rss->writeElement('pubDate', PMF_Date::createRFC822Date($item['created'], true)); $rss->endElement(); } } } $rss->endElement(); $rss->endElement(); $rssData = $rss->outputMemory(); $headers = array('Content-Type: application/rss+xml', 'Content-Length: ' . strlen($rssData)); $http = new PMF_Helper_Http(); $http->sendWithHeaders($rssData, $headers); $faqConfig->getDb()->close();
$rss->writeElement('link', PMF_Link::getSystemUri('/feed/topten/rss.php')); if ($num > 0) { $i = 0; foreach ($rssData as $item) { $i++; // Get the url $link = str_replace($_SERVER['SCRIPT_NAME'], '/index.php', $item['url']); if (PMF_RSS_USE_SEO) { if (isset($item['thema'])) { $oLink = new PMF_Link($link); $oLink->itemTitle = html_entity_decode($item['thema'], ENT_COMPAT, 'UTF-8'); $link = html_entity_decode($oLink->toString(), ENT_COMPAT, 'UTF-8'); } } $rss->startElement('item'); $rss->writeElement('title', PMF_Utils::makeShorterText(html_entity_decode($item['thema'], ENT_COMPAT, 'UTF-8'), 8) . " (" . $item['visits'] . " " . $PMF_LANG['msgViews'] . ")"); $rss->startElement('description'); $rss->writeCdata("[" . $i . ".] " . $item['thema'] . " (" . $item['visits'] . " " . $PMF_LANG['msgViews'] . ")"); $rss->endElement(); $rss->writeElement('link', PMF_Link::getSystemUri('/feed/topten/rss.php') . $link); $rss->writeElement('pubDate', PMF_Date::createRFC822Date($item['last_visit'], false)); $rss->endElement(); } } $rss->endElement(); $rss->endElement(); $rssData = $rss->outputMemory(); header('Content-Type: application/rss+xml'); header('Content-Length: ' . strlen($rssData)); print $rssData; $db->dbclose();
$rss->writeElement('title', $faqConfig->get('main.titleFAQ') . ' - '); $rss->writeElement('description', html_entity_decode($faqConfig->get('main.metaDescription'))); $rss->writeElement('link', $faqConfig->get('main.referenceURL')); if (is_array($records)) { foreach ($records as $item) { $link = str_replace($_SERVER['SCRIPT_NAME'], '/index.php', $item['record_link']); if (PMF_RSS_USE_SEO) { if (isset($item['record_title'])) { $oLink = new PMF_Link($link, $faqConfig); $oLink->itemTitle = $item['record_title']; $link = $oLink->toString(); } } $rss->startElement('item'); $rss->writeElement('title', html_entity_decode($item['record_title'] . ' (' . $item['visits'] . ' ' . $PMF_LANG['msgViews'] . ')', ENT_COMPAT, 'UTF-8')); $rss->startElement('description'); $rss->writeCdata($item['record_preview']); $rss->endElement(); $rss->writeElement('link', $faqConfig->get('main.referenceURL') . $link); $rss->writeElement('pubDate', PMF_Date::createRFC822Date($item['record_date'], true)); $rss->endElement(); } } $rss->endElement(); $rss->endElement(); $rssData = $rss->outputMemory(); $response = Response::create($rssData); $response->headers->set('Content-Type', 'application/rss+xml'); $response->headers->set('Content-Length', strlen($rssData)); $response->send(); $faqConfig->getDb()->close();
$Call['Slug'] = strtolower($Call['Entity']); } foreach ($Call['Output']['Content'] as $Element) { if ($Element['Type'] == 'Template' && isset($Element['Data'])) { $XML->startElement('item'); $XML->startElement('title'); $XML->text($Element['Data']['Title']); $XML->endElement(); // title $XML->startElement('pubDate'); $XML->text(date(DATE_RSS, $Element['Data']['Created'])); $XML->endElement(); // description if (isset($Element['Data']['Description'])) { $XML->startElement('description'); $XML->writeCdata($Element['Data']['Description']); $XML->endElement(); // description } $XML->startElement('link'); if (isset($Element['Data']['Slug'])) { $XML->text($Call['HTTP']['Proto'] . $Call['HTTP']['Host'] . '/' . $Call['Slug']['Entity'] . '/' . $Element['Data']['Slug'] . '?Channel=RSS'); } else { $XML->text($Call['HTTP']['Proto'] . $Call['HTTP']['Host'] . '/' . $Call['Slug']['Entity'] . '/' . $Element['Data']['ID'] . '?Channel=RSS'); } // FIXME It's double shit! $XML->endElement(); // title $XML->endElement(); // item }
$rss->writeElement('title', utf8_encode($PMF_CONF['main.titleFAQ']) . ' - ' . utf8_encode($PMF_LANG['msgNews'])); $rss->writeElement('description', utf8_encode($PMF_CONF['main.metaDescription'])); $rss->writeElement('link', PMF_Link::getSystemUri('/feed/news/rss.php')); if ($num > 0) { foreach ($rssData as $item) { // Get the url $link = '/index.php?action=news&newsid=' . $item['id'] . '&newslang=' . $item['lang']; if (PMF_RSS_USE_SEO) { if (isset($item['header'])) { $oL = new PMF_Link($link); $oL->itemTitle = $item['header']; $link = $oL->toString(); } } $rss->startElement('item'); $rss->writeElement('title', utf8_encode($item['header'])); $rss->startElement('description'); $rss->writeCdata(utf8_encode($item['content'])); $rss->endElement(); $rss->writeElement('link', PMF_Link::getSystemUri('/feed/news/rss.php') . $link); $rss->writeElement('pubDate', PMF_Date::createRFC822Date($item['date'], false)); $rss->endElement(); } } $rss->endElement(); $rss->endElement(); $rssData = $rss->outputMemory(); header('Content-Type: application/rss+xml'); header('Content-Length: ' . strlen($rssData)); print $rssData; $db->dbclose();
/** * @param \XMLWriter $writer * @param mixed $origin * @param Definition $definition */ protected function writeScalar(\XMLWriter $writer, $origin, Definition $definition) { $content = $definition->extract($origin); if (strpbrk($content, '></&![]\\') === false) { $writer->writeRaw($content); } else { $writer->writeCdata($content); } }
/** * @param $texts * @param $source * @param $target * @return string */ private function getTranslateArrayXmlRequest($texts, $source, $target) { $xml = new \XMLWriter(); $xml->openMemory(); $xml->startElement('TranslateArrayRequest'); $xml->startElement('AppId'); $xml->endElement(); //AppId $xml->writeElement('From', $source); $xml->startElement('Options'); $xml->startElement('ContentType'); $xml->writeAttribute('xmlns', 'http://schemas.datacontract.org/2004/07/Microsoft.MT.Web.Service.V2'); $xml->writeRaw('text/plain'); $xml->endElement(); //ContentType $xml->endElement(); //Options $xml->startElement('Texts'); foreach ($texts as $text) { $xml->startElement('string'); $xml->writeAttribute('xmlns', 'http://schemas.microsoft.com/2003/10/Serialization/Arrays'); $xml->writeCdata($text); $xml->endElement(); //string } $xml->endElement(); //Texts $xml->writeElement('To', $target); $xml->endElement(); //TranslateArrayRequest return $xml->flush(); }
/** * 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; }
})); $totalFiles = count($files) > $app['postsPerPage'] ? $app['postsPerPage'] : count($files); // build items for ($i = 0; $i < $totalFiles; $i++) { $file = $files[$i]; $post = getPageContent('blog/' . $file); $body = $post->body->asXML(); $body = str_replace('<body>', '', $body); $body = str_replace('</body>', '', $body); $description = join(' ', explode(' ', strip_tags($body), 50)); $url = 'http://' . $_SERVER['SERVER_NAME'] . buildBlogUrlFromFileName($file); $xml->startElement('item'); $xml->writeElement('title', $post->head->title); $xml->writeElement('link', $url); $xml->startElement('description'); $xml->writeCdata($description); $xml->endElement(); //description $xml->writeElement('pubDate', buildPubDateFromFileName($file, $app)); $xml->startElementNs('content', 'encoded', null); $xml->writeCdata($body); $xml->endElement(); //content:encoded $xml->endElement(); // item } $xml->endElement(); //channel $xml->endElement(); //rss return new Response($xml->outputMemory(), 200, array('Content-Type' => 'text/xml'));
$rss->openMemory(); $rss->startDocument('1.0', $PMF_LANG['metaCharset']); $rss->startElement('rss'); $rss->writeAttribute('version', '2.0'); $rss->startElement('channel'); $rss->writeElement('title', utf8_encode($PMF_CONF['main.titleFAQ']) . ' - ' . utf8_encode($PMF_LANG['msgOpenQuestions'])); $rss->writeElement('description', utf8_encode($PMF_CONF['main.metaDescription'])); $rss->writeElement('link', PMF_Link::getSystemUri('/feed/openquestions/rss.php')); if ($num > 0) { $counter = 0; foreach ($rssData as $item) { if ($counter < PMF_RSS_OPENQUESTIONS_MAX) { $counter++; $rss->startElement('item'); $rss->writeElement('title', utf8_encode(PMF_Utils::makeShorterText($item['question'], 8) . " (" . $item['user'] . ")")); $rss->startElement('description'); $rss->writeCdata(utf8_encode($item['question'])); $rss->endElement(); $rss->writeElement('link', utf8_encode((isset($_SERVER['HTTPS']) ? 's' : '') . "://" . $_SERVER["HTTP_HOST"] . str_replace("feed/openquestions/rss.php", "index.php", $_SERVER["PHP_SELF"]) . "?action=open#openq_" . $item['id'])); $rss->writeElement('pubDate', PMF_Date::createRFC822Date($item['date'], false)); $rss->endElement(); } } } $rss->endElement(); $rss->endElement(); $rssData = $rss->outputMemory(); header('Content-Type: application/rss+xml'); header('Content-Length: ' . strlen($rssData)); print $rssData; $db->dbclose();
foreach ($rssData as $item) { // Get the url $link = str_replace($_SERVER['PHP_SELF'], '/index.php', $item['url']); if (PMF_RSS_USE_SEO) { if (isset($item['thema'])) { $oL = new PMF_Link($link); $oL->itemTitle = $item['thema']; $link = $oL->toString(); } } // Get the content $content = $item['content']; // Fix the content internal image references $content = str_replace("<img src=\"/", "<img src=\"" . PMF_Link::getSystemUri('/feed/latest/rss.php') . "/", $content); $rss->startElement('item'); $rss->writeElement('title', utf8_encode($item['thema'])); $rss->startElement('description'); $rss->writeCdata(utf8_encode($content)); $rss->endElement(); $rss->writeElement('link', utf8_encode(PMF_Link::getSystemUri('/feed/latest/rss.php') . $link)); $rss->writeElement('pubDate', PMF_Date::createRFC822Date($item['datum'], false)); $rss->endElement(); } } $rss->endElement(); $rss->endElement(); $rssData = $rss->outputMemory(); header('Content-Type: application/rss+xml'); header('Content-Length: ' . strlen($rssData)); print $rssData; $db->dbclose();