public function actionEditTemplate(array $variables = array())
{
$variables['brandNewTemplate'] = false;
$variables['templateLayouts'] = craft()->formBuilder2_template->getTemplateFiles();
if (!empty($variables['templateId'])) {
if (empty($variables['template'])) {
$variables['template'] = craft()->formBuilder2_template->getTemplateById($variables['templateId']);
if (!$variables['template']) {
throw new HttpException(404, Craft::t('No templates exist.'));
}
}
$variables['title'] = $variables['template']->name;
} else {
if (empty($variables['template'])) {
$variables['template'] = new FormBuilder2_TemplateModel();
$variables['brandNewTemplate'] = true;
}
$variables['title'] = Craft::t('Create a new template');
}
$this->renderTemplate('formbuilder2/templates/_edit', $variables);
}