class Ragtek_DeveloperTools_Generator_Template{
/**
*
* @static
* @param array $addOn
* @param $title
* @param $template
* @return mixed
* @throws XenForo_Exception
*/
public static function generatePublicTemplate(array $addOn, $title, $template){
if (self::checkPublicTemplateExists($title)) {
throw new XenForo_Exception(sprintf('public template %s exists already', $title));
}
$propertyModel = self::_getStylePropertyModel();
$properties = $propertyModel->keyPropertiesByName(
$propertyModel->getEffectiveStylePropertiesInStyle(-1)
);
$propertyChanges = $propertyModel->translateEditorPropertiesToArray(
$template, $template, $properties
);
/** @var $writer XenForo_DataWriter_Template */
$writer = XenForo_DataWriter::create('XenForo_DataWriter_Template');
$writer->bulkSet(array(
'title' => $title,
'template' => $template,
'addon_id' => $addOn['addon_id'],
'style_id' => 0
));
try {
$writer->save();
} catch (Exception $ex) {
throw new XenForo_Exception("Exception creating template $title: " . $ex->getMessage() . '<br/><pre>' . htmlentities($template) . '</pre>');
}
$propertyModel->saveStylePropertiesInStyleFromTemplate(-1, $propertyChanges, $properties);
return $title;
}