help.php
13 years ago
home.php
13 years ago
import.php
13 years ago
manage.php
13 years ago
settings.php
13 years ago
settings.php
56 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Admin Statistics page |
| 4 | * |
| 5 | * @author Pavel Kulbakin <p.kulbakin@gmail.com> |
| 6 | */ |
| 7 | class PMXI_Admin_Settings extends PMXI_Controller_Admin { |
| 8 | |
| 9 | public function index() { |
| 10 | $this->data['post'] = $post = $this->input->post(PMXI_Plugin::getInstance()->getOption()); |
| 11 | |
| 12 | if ($this->input->post('is_settings_submitted')) { // save settings form |
| 13 | check_admin_referer('edit-settings', '_wpnonce_edit-settings'); |
| 14 | |
| 15 | if ( ! preg_match('%^\d+$%', $post['history_file_count'])) { |
| 16 | $this->errors->add('form-validation', __('History File Count must be a non-negative integer', 'pmxi_plugin')); |
| 17 | } |
| 18 | if ( ! preg_match('%^\d+$%', $post['history_file_age'])) { |
| 19 | $this->errors->add('form-validation', __('History Age must be a non-negative integer', 'pmxi_plugin')); |
| 20 | } |
| 21 | if (empty($post['html_entities'])) $post['html_entities'] = 0; |
| 22 | |
| 23 | if ( ! $this->errors->get_error_codes()) { // no validation errors detected |
| 24 | |
| 25 | PMXI_Plugin::getInstance()->updateOption($post); |
| 26 | $files = new PMXI_File_List(); $files->sweepHistory(); // adjust file history to new settings specified |
| 27 | |
| 28 | wp_redirect(add_query_arg('pmxi_nt', urlencode(__('Settings saved', 'pmxi_plugin')), $this->baseUrl)); die(); |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | if ($this->input->post('is_templates_submitted')) { // delete templates form |
| 33 | $templates_ids = $this->input->post('templates', array()); |
| 34 | if (empty($templates_ids)) { |
| 35 | $this->errors->add('form-validation', __('Templates must be selected', 'pmxi_plugin')); |
| 36 | } |
| 37 | if ( ! $this->errors->get_error_codes()) { // no validation errors detected |
| 38 | $template = new PMXI_Template_Record(); |
| 39 | foreach ($templates_ids as $template_id) { |
| 40 | $template->clear()->set('id', $template_id)->delete(); |
| 41 | } |
| 42 | wp_redirect(add_query_arg('pmxi_nt', urlencode(sprintf(_n('%d template deleted', '%d templates deleted', count($templates_ids), 'pmxi_plugin'), count($templates_ids))), $this->baseUrl)); die(); |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | $this->render(); |
| 47 | } |
| 48 | |
| 49 | public function dismiss(){ |
| 50 | |
| 51 | PMXI_Plugin::getInstance()->updateOption("dismiss", 1); |
| 52 | |
| 53 | exit('OK'); |
| 54 | } |
| 55 | |
| 56 | } |