1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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

Discussion in 'Closed Suggestions' started by ragtek, Oct 17, 2011.

  1. ragtek

    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($titles0);

            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_COMPILEfalse);
                    
    $dw->setOption(XenForo_DataWriter_Template::OPTION_TEST_COMPILEfalse);
                    
    $dw->setOption(XenForo_DataWriter_Template::OPTION_CHECK_DUPLICATEfalse);
                    
    $dw->setOption(XenForo_DataWriter_Template::OPTION_REBUILD_TEMPLATE_MAPfalse);
                    
    $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);
        }
     

Share This Page