public function copyAction()
{
$path = $this->parsePath();
$file = $this->_getParam('file');
if (is_array($file)) {
$file = array_shift($file);
}
try {
$nameExt = pathinfo($this->_getParam('name'), PATHINFO_EXTENSION);
$name = $this->formatName($this->_getParam('name'), $nameExt == '' ? pathinfo($file, PATHINFO_EXTENSION) : null);
$this->service->copyItem("{$path}/{$file}", $name);
$this->_helper->flashMessenger(getGS("Template '\$1' was duplicated into '\$2'.", $file, $name));
} catch (\InvalidArgumentException $e) {
$this->_helper->flashMessenger(array('error', $e->getMessage()));
}
$this->_redirect(urldecode($this->_getParam('next')), array('prependBase' => false));
}