public function copy()
{
$this->user->restrict('Site.Themes.Manage');
$this->template->setTitle($this->lang->line('text_copy_heading'));
$this->template->setHeading($this->lang->line('text_copy_heading'));
$theme = $this->Themes_model->getTheme($this->uri->rsegment(3));
if (!$this->uri->rsegment(3) or empty($theme)) {
redirect(referrer_url());
}
$data['theme_title'] = $theme['title'];
$data['theme_name'] = $theme['name'];
$data['theme_data'] = !empty($theme['data']) ? TRUE : FALSE;
$data['copy_action'] = !empty($theme['data']) ? $this->lang->line('text_files_data') : $this->lang->line('text_files');
$data['files_to_copy'] = array();
$files[] = load_theme_file('theme_config.php', $theme['name']);
$files[] = load_theme_file('screenshot.png', $theme['name']);
foreach ($files as $file) {
$data['files_to_copy'][] = str_replace(ROOTPATH, '', $file['path']);
}
if ($this->input->post('confirm_copy') === $theme['name']) {
$copy_data = $this->input->post('copy_data') === '1' ? TRUE : FALSE;
if ($this->Themes_model->copyTheme($theme['name'], $files, $copy_data)) {
log_activity($this->user->getStaffId(), 'copied', 'themes', get_activity_message('activity_custom_no_link', array('{staff}', '{action}', '{context}', '{item}'), array($this->user->getStaffName(), 'copied', 'theme', $data['theme_title'])));
$this->alert->set('success', sprintf($this->lang->line('alert_success'), 'Theme [' . $theme['name'] . '] ' . $this->lang->line('text_copied')));
} else {
$this->alert->set('warning', $this->lang->line('alert_error_try_again'));
}
redirect('themes');
}
$this->template->render('themes_copy', $data);
}