本文整理汇总了PHP中XMLWriter::writeDtd方法的典型用法代码示例。如果您正苦于以下问题:PHP XMLWriter::writeDtd方法的具体用法?PHP XMLWriter::writeDtd怎么用?PHP XMLWriter::writeDtd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLWriter
的用法示例。
在下文中一共展示了XMLWriter::writeDtd方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate
/**
* 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();
}
示例2: createXmlDocument
/**
* 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);
}