本文整理汇总了PHP中XML::endElement方法的典型用法代码示例。如果您正苦于以下问题:PHP XML::endElement方法的具体用法?PHP XML::endElement怎么用?PHP XML::endElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XML
的用法示例。
在下文中一共展示了XML::endElement方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveLanguageXML
/**
* Save XML file
*
* @param string $language
* @param bool $compress
* @param bool $replace
* @param string $path
* @return bool
*/
public function saveLanguageXML($language, $compress = false, $replace, $path = CC_LANGUAGE_DIR)
{
if (!$this->_checkPath($path)) {
trigger_error('Invalid language path ' . $path, E_USER_ERROR);
}
if ($path !== CC_LANGUAGE_DIR) {
$path = appendDS($path);
}
if (!empty($language)) {
// Load in existing file
$source = $path . $language . '.xml';
$this->exported_lang_file = $replace ? $source : $path . $language . '-custom.xml';
$strings = array();
if (file_exists($source)) {
$data = file_get_contents($source);
$xml = new SimpleXMLElement($data);
foreach ($xml->info as $values) {
foreach ($values as $key => $value) {
$info[$key] = $value;
}
}
if ($xml->translation && $xml->translation->group) {
foreach ($xml->translation->group as $groups) {
$group = $groups->attributes()->name;
foreach ($groups->string as $string) {
$name = $string->attributes()->name;
$strings[(string) $group][(string) $name] = $string;
}
}
}
unset($data, $xml);
// Fetch Database Results
if (($custom = $GLOBALS['db']->select('CubeCart_lang_strings', false, array('language' => $language))) !== false) {
foreach ($custom as $row) {
$strings[$row['type']][$row['name']] = $row['value'];
}
} else {
trigger_error('No custom strings exist', E_USER_NOTICE);
}
$xml = new XML();
$xml->startElement('language', array('version' => '2.0'));
$xml->startElement('info');
foreach ($info as $key => $value) {
$xml->setElement($key, $value, false, false);
}
$xml->endElement();
$xml->startElement('translation');
foreach ($strings as $group => $values) {
$xml->startElement('group', array('name' => $group));
foreach ($values as $name => $value) {
$xml->setElement('string', $value, array('name' => $name));
}
$xml->endElement();
}
$xml->endElement();
$xml->endElement();
if ($compress) {
$output = gzencode($xml->getDocument(), 9, FORCE_GZIP);
$this->exported_lang_file .= '.gz';
} else {
$output = $xml->getDocument();
}
return (bool) file_put_contents($this->exported_lang_file, $output);
}
}
return false;
}
示例2: XML
} else {
if (isset($_POST['export']) && !empty($_POST['export'])) {
if (preg_match(Language::LANG_REGEX, $_POST['export'])) {
## Export language to XML...
if (($emails = $GLOBALS['db']->select('CubeCart_email_content', false, array('language' => $_POST['export']))) !== false) {
$xml = new XML();
$xml->startElement('emails', array('version' => '1.0', 'language' => $_POST['export']));
$content_types = array('html', 'text');
foreach ($emails as $email) {
$xml->startElement('email', array('name' => $email['content_type']));
foreach ($content_types as $type) {
if (!empty($email['content_' . $type])) {
$xml->setElement('content', $email['content_' . $type], array('type' => $type));
}
}
$xml->endElement();
}
$xml->endElement();
$data = $xml->getDocument();
$file = CC_ROOT_DIR . '/language/email_' . $_POST['export'] . '-custom.xml';
if (isset($_POST['export_compress'])) {
$data = gzencode($data, 9, FORCE_GZIP);
$file = $file . '.gz';
}
if (file_put_contents($file, $data)) {
$GLOBALS['main']->setACPNotify($lang['email']['notify_export']);
} else {
$GLOBALS['main']->setACPWarning($lang['email']['error_export']);
}
} else {
$GLOBALS['main']->setACPWarning($lang['email']['error_export']);
示例3: endElement
/**
* End Parent element
* @return void
*/
public function endElement()
{
$this->xmlWriter->endElement();
}