public function writeTemplates($fileClass, $styleId) { DevTools_Helper_File::createDirectory(XenForo_Application::getInstance()->getRootDir() . DIRECTORY_SEPARATOR . 'templates'); $templates = $this->getTemplates($styleId); $fileTemplate = new $fileClass(); foreach ($templates as $template) { $template['id'] = $template['template_id']; $filePath = $fileTemplate->getDirectory($template) . DIRECTORY_SEPARATOR . $fileTemplate->getFileName($template); if (!file_exists($filePath)) { $contents = $this->getModelFromCache('XenForo_Model_StyleProperty')->replacePropertiesInTemplateForEditor($template['template'], $styleId, $fileTemplate->getPropertiesInStyle($styleId)); $contents = $this->getModelFromCache('XenForo_Model_Template')->replaceIncludesWithLinkRel($contents); $fileTemplate->printDebugInfo('Writing ' . $fileTemplate->getDataType() . ' "' . $template['title'] . '" to ' . $filePath . '...'); DevTools_Helper_File::write($filePath, $contents); $file = new $fileClass($filePath); $file->touchDb(); $fileTemplate->printDebugInfo(" done\n"); } } foreach ($this->getModelFromCache('XenForo_Model_AddOn')->getAllAddOns() as $addon) { DevTools_Helper_File::createDirectory($fileTemplate->getDirectory($addon)); } }
public function trashFile(array $oldData) { $trashPath = $this->getDirectory($oldData) . self::$s . '.trash' . self::$s . '__' . $oldData['id'] . '.' . $this->getFileName($oldData); if (DevTools_Helper_File::createDirectory(dirname($trashPath))) { DevTools_Helper_File::write($trashPath, $oldData['contents']); $this->printDebugInfo("- backed up to \"{$trashPath}\"\n"); } }