public function edit() { $this->user->restrict('Site.Themes.Access'); $theme_name = $this->input->get('name'); $theme_location = $this->input->get('location'); $url = '?'; $url .= 'name=' . $theme_name . '&location=' . $theme_location; if (!($theme = $this->Themes_model->getTheme($theme_name))) { $this->alert->set('danger', $this->lang->line('error_theme_not_found')); redirect('themes'); } $_GET['extension_id'] = $theme['extension_id']; $theme_config = isset($theme['config']) ? $theme['config'] : FALSE; $this->load->library('customizer'); $this->customizer->initialize($theme); if ($this->input->post() and $this->_updateTheme($theme) === TRUE) { if ($this->input->post('save_close') === '1') { redirect('themes/edit' . '?name=' . $theme_name . '&location=' . $theme_location); } redirect(current_url()); } $this->template->setTitle(sprintf($this->lang->line('text_edit_heading'), $theme['title'])); $this->template->setHeading(sprintf($this->lang->line('text_edit_heading'), $theme['title'])); $this->template->setButton($this->lang->line('button_save'), array('class' => 'btn btn-primary', 'onclick' => '$(\'#edit-form\').submit();')); $this->template->setButton($this->lang->line('button_save_close'), array('class' => 'btn btn-default', 'onclick' => 'saveClose();')); $this->template->setBackButton('btn btn-back', site_url('themes')); $this->template->setStyleTag(root_url('assets/js/colorpicker/css/bootstrap-colorpicker.min.css'), 'bootstrap-colorpicker-css'); $this->template->setStyleTag(root_url('assets/js/codemirror/codemirror.css'), 'codemirror-css'); $this->template->setStyleTag(root_url('assets/js/fancybox/jquery.fancybox.css'), 'jquery-fancybox-css'); $this->template->setScriptTag(root_url('assets/js/colorpicker/js/bootstrap-colorpicker.min.js'), 'bootstrap-colorpicker-js'); $this->template->setScriptTag(root_url('assets/js/codemirror/codemirror.js'), 'codemirror-js', '300'); $this->template->setScriptTag(root_url('assets/js/codemirror/xml/xml.js'), 'codemirror-xml-js', '301'); $this->template->setScriptTag(root_url('assets/js/codemirror/css/css.js'), 'codemirror-css-js', '302'); $this->template->setScriptTag(root_url('assets/js/codemirror/javascript/javascript.js'), 'codemirror-javascript-js', '303'); $this->template->setScriptTag(root_url('assets/js/codemirror/php/php.js'), 'codemirror-php-js', '304'); $this->template->setScriptTag(root_url('assets/js/codemirror/htmlmixed/htmlmixed.js'), 'codemirror-htmlmixed-js', '305'); $this->template->setScriptTag(root_url('assets/js/codemirror/clike/clike.js'), 'codemirror-clike-js', '306'); $this->template->setScriptTag(root_url('assets/js/jquery-sortable.js'), 'jquery-sortable-js'); $this->template->setScriptTag(root_url("assets/js/fancybox/jquery.fancybox.js"), 'jquery-fancybox-js'); $data['file'] = array(); if ($this->input->get('file')) { $url .= '&file=' . $this->input->get('file'); $theme_file = load_theme_file($this->input->get('file'), $theme_name, $theme_location); if (isset($theme_file['type']) and $theme_file['type'] === 'img') { $theme_file['heading'] = sprintf($this->lang->line('text_viewing'), $this->input->get('file'), $theme_name); } else { if (isset($theme_file['type']) and $theme_file['type'] === 'file') { $theme_file['heading'] = sprintf($this->lang->line('text_editing'), $this->input->get('file'), $theme_name); } else { $this->alert->set('danger', $this->lang->line('error_file_not_supported')); } } $data['file'] = $theme_file; } $theme_files = ''; $tree_link = site_url('themes/edit' . $url . '&file={link}'); $theme_files .= $this->_themeTree($theme_name, $theme_location, $tree_link); $data['name'] = $theme['name']; $data['theme_files'] = $theme_files; $data['theme_config'] = $theme_config; $data['is_customizable'] = (isset($theme['customize']) and $theme['customize']) ? TRUE : FALSE; $data['customizer_nav'] = $this->customizer->getNavView(); $data['customizer_sections'] = $this->customizer->getSectionsView(); $data['sections'] = $data['error_fields'] = array(); if (!empty($data['is_customizable'])) { if (isset($theme_config['error_fields']) and is_array($theme_config['error_fields'])) { foreach ($theme_config['error_fields'] as $error_field) { if (isset($error_field['field']) and isset($error_field['error'])) { $data['error_fields'][$error_field['field']] = $error_field['error']; } } } } $data['_action'] = site_url('themes/edit' . $url); $data['mode'] = ''; if (!empty($data['file']['ext'])) { if ($data['file']['ext'] === 'php') { $data['mode'] = 'application/x-httpd-php'; } else { if ($data['file']['ext'] === 'css') { $data['mode'] = 'css'; } else { $data['mode'] = 'javascript'; } } } $this->template->render('themes_edit', $data); }
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); }