function importAction() { $form = new Am_Form_Admin(); $import = $form->addFile('import')->setLabel('Upload file [email-templates.xml]'); $form->addStatic('')->setContent('WARNING! All existing e-mail templates will be removed from database!'); //$import->addRule('required', 'Please upload file'); //$form->addAdvCheckbox('remove')->setLabel('Remove your existing templates?'); $form->addSaveButton(___('Upload')); if ($form->isSubmitted() && $form->validate()) { $value = $form->getValue(); $fn = DATA_DIR . '/import.email-templates.xml'; if (!move_uploaded_file($value['import']['tmp_name'], $fn)) { throw new Am_Exception_InternalError("Could not move uploaded file"); } $xml = file_get_contents($fn); if (!$xml) { throw new Am_Exception_InputError("Could not read XML"); } $count = $this->getDi()->emailTemplateTable->deleteBy(array())->importXml($xml); $this->view->content = "Import Finished. {$count} templates imported."; } else { $this->view->content = (string) $form; } $this->view->title = "Import E-Mail Templates from XML file"; $this->view->display('admin/layout.phtml'); }