本文整理汇总了PHP中XenForo_Helper_DevelopmentXml::readMetaDataFile方法的典型用法代码示例。如果您正苦于以下问题:PHP XenForo_Helper_DevelopmentXml::readMetaDataFile方法的具体用法?PHP XenForo_Helper_DevelopmentXml::readMetaDataFile怎么用?PHP XenForo_Helper_DevelopmentXml::readMetaDataFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XenForo_Helper_DevelopmentXml
的用法示例。
在下文中一共展示了XenForo_Helper_DevelopmentXml::readMetaDataFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: importTemplatesFromDevelopment
/**
* Imports all templates from the templates directory into the database
*/
public function importTemplatesFromDevelopment()
{
$db = $this->_getDb();
$templateDir = $this->getTemplateDevelopmentDirectory();
if (!$templateDir && !is_dir($templateDir)) {
throw new XenForo_Exception("Template development directory not enabled or doesn't exist");
}
$files = glob("{$templateDir}/*.html");
if (!$files) {
throw new XenForo_Exception("Template development directory does not have any templates");
}
$metaData = XenForo_Helper_DevelopmentXml::readMetaDataFile($templateDir . '/_metadata.xml');
$addOnTemplates = $this->getMasterTemplatesInAddOn('XenForo');
XenForo_Db::beginTransaction($db);
$titles = array();
foreach ($files as $templateFile) {
$filename = basename($templateFile);
if (preg_match('/^(.+)\\.html$/', $filename, $match)) {
$titles[] = $match[1];
}
}
$existingTemplates = $this->getTemplatesInStyleByTitles($titles, 0);
foreach ($files as $templateFile) {
if (!is_readable($templateFile)) {
throw new XenForo_Exception("Template file '{$templateFile}' not readable");
}
$filename = basename($templateFile);
if (preg_match('/^(.+)\\.html$/', $filename, $match)) {
$templateName = $match[1];
$data = file_get_contents($templateFile);
$dw = XenForo_DataWriter::create('XenForo_DataWriter_Template');
if (isset($existingTemplates[$templateName])) {
$dw->setExistingData($existingTemplates[$templateName], true);
}
$dw->setOption(XenForo_DataWriter_Template::OPTION_DEV_OUTPUT_DIR, '');
$dw->setOption(XenForo_DataWriter_Template::OPTION_FULL_COMPILE, false);
$dw->setOption(XenForo_DataWriter_Template::OPTION_TEST_COMPILE, false);
$dw->setOption(XenForo_DataWriter_Template::OPTION_CHECK_DUPLICATE, false);
$dw->setOption(XenForo_DataWriter_Template::OPTION_REBUILD_TEMPLATE_MAP, false);
$dw->bulkSet(array('style_id' => 0, 'title' => $templateName, 'template' => $data, 'addon_id' => 'XenForo', 'version_id' => 0, 'version_string' => ''));
if (isset($metaData[$templateName])) {
$dw->bulkSet($metaData[$templateName]);
}
$dw->save();
unset($addOnTemplates[$templateName]);
}
}
// removed templates
foreach ($addOnTemplates as $addOnTemplate) {
$dw = XenForo_DataWriter::create('XenForo_DataWriter_Template');
$dw->setExistingData($addOnTemplate, true);
$dw->setOption(XenForo_DataWriter_Template::OPTION_DEV_OUTPUT_DIR, '');
$dw->setOption(XenForo_DataWriter_Template::OPTION_FULL_COMPILE, false);
$dw->setOption(XenForo_DataWriter_Template::OPTION_TEST_COMPILE, false);
$dw->setOption(XenForo_DataWriter_Template::OPTION_CHECK_DUPLICATE, false);
$dw->setOption(XenForo_DataWriter_Template::OPTION_REBUILD_TEMPLATE_MAP, false);
$dw->delete();
}
XenForo_Db::commit($db);
}
示例2: importPhrasesFromDevelopment
/**
* Imports all phrases from the phrases directory into the database
*/
public function importPhrasesFromDevelopment()
{
$db = $this->_getDb();
$phraseDir = $this->getPhraseDevelopmentDirectory();
if (!$phraseDir && !is_dir($phraseDir)) {
throw new XenForo_Exception("Phrase development directory not enabled or doesn't exist");
}
$files = glob("{$phraseDir}/*.txt");
if (!$files) {
throw new XenForo_Exception("Phrase development directory does not have any phrases");
}
$metaData = XenForo_Helper_DevelopmentXml::readMetaDataFile($phraseDir . '/_metadata.xml');
XenForo_Db::beginTransaction($db);
$this->deletePhrasesForAddOn('XenForo');
$titles = array();
foreach ($files as $templateFile) {
$filename = basename($templateFile);
if (preg_match('/^(.+)\\.txt$/', $filename, $match)) {
$titles[] = $match[1];
}
}
$existingPhrases = $this->getPhrasesInLanguageByTitles($titles, 0);
foreach ($files as $file) {
if (!is_readable($file)) {
throw new XenForo_Exception("Phrase file '{$file}' not readable");
}
$filename = basename($file);
if (preg_match('/^(.+)\\.txt$/', $filename, $match)) {
$title = $match[1];
$dw = XenForo_DataWriter::create('XenForo_DataWriter_Phrase');
if (isset($existingPhrases[$title])) {
$dw->setExistingData($existingPhrases[$title], true);
}
$dw->setOption(XenForo_DataWriter_Phrase::OPTION_DEV_OUTPUT_DIR, '');
$dw->setOption(XenForo_DataWriter_Phrase::OPTION_REBUILD_LANGUAGE_CACHE, false);
$dw->setOption(XenForo_DataWriter_Phrase::OPTION_FULL_RECOMPILE, false);
$dw->setOption(XenForo_DataWriter_Phrase::OPTION_REBUILD_PHRASE_MAP, false);
$dw->setOption(XenForo_DataWriter_Phrase::OPTION_CHECK_DUPLICATE, false);
$dw->bulkSet(array('title' => $title, 'phrase_text' => file_get_contents($file), 'language_id' => 0, 'addon_id' => 'XenForo', 'version_id' => 0, 'version_string' => ''));
if (isset($metaData[$title])) {
$dw->bulkSet($metaData[$title]);
}
$dw->save();
unset($dw);
}
}
XenForo_Db::commit($db);
}