Lack of interest remove hardcoded xenforo addon_id in templates &phrase model

  • Thread starter Thread starter ragtek
  • Start date Start date
This suggestion has been closed automatically because it did not receive enough votes over an extended period of time. If you wish to see this, please search for an open suggestion and, if you don't find any, post a new one.
R

ragtek

Guest
It would be great, if you would remove the hardcoded xenforo addon_id in the template, admin template, phrase, e-mail template "importfromfilesystemdev" methods...

I think easiest way for you would be to add variable;)
PHP:
public function importTemplatesFromDevelopment($addon_id = 'XenForo')
    {
        $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');

        XenForo_Db::beginTransaction($db);
        $this->deleteTemplatesForAddOn($addon_id);

        $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' => $addon_id
                ));
                if (isset($metaData[$templateName]))
                {
                    $dw->bulkSet($metaData[$templateName]);
                }
                $dw->save();
            }
        }

        XenForo_Db::commit($db);
    }
 
Upvote 0
This suggestion has been closed. Votes are no longer accepted.

Similar threads

Top Bottom