当前位置: 首页>>代码示例>>PHP>>正文


PHP XML::getDocument方法代码示例

本文整理汇总了PHP中XML::getDocument方法的典型用法代码示例。如果您正苦于以下问题:PHP XML::getDocument方法的具体用法?PHP XML::getDocument怎么用?PHP XML::getDocument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XML的用法示例。


在下文中一共展示了XML::getDocument方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: XML

     ## 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']);
     }
     httpredir(currentPage());
 }
开发者ID:Dirty-Butter,项目名称:v6,代码行数:31,代码来源:documents.email.inc.php

示例2: 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;
 }
开发者ID:briansandall,项目名称:v6,代码行数:76,代码来源:language.class.php


注:本文中的XML::getDocument方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。