/** * Checks whether corresponding step of wizard is complete * @param string $action */ protected function _step_ready($action) { // step #1: xml selction - has no prerequisites if ('index' == $action) { return true; } if ('element' == $action) { return true; } $this->data['update_previous'] = $update_previous = new PMXE_Export_Record(); $update_previous->getById(PMXE_Plugin::$session->update_previous); if (!$update_previous->isEmpty()) { $update_previous->fix_template_options(); } if ('options' == $action) { return true; } if (!PMXE_Plugin::$session->has_session()) { wp_redirect_or_javascript($this->baseUrl); die; } if ('process' == $action) { return true; } }
/** * Reexport */ public function update() { $id = $this->input->get('id'); PMXE_Plugin::$session->clean_session($id); $action_type = $this->input->get('type'); $this->data['item'] = $item = new PMXE_Export_Record(); if (!$id or $item->getById($id)->isEmpty()) { wp_redirect($this->baseUrl); die; } $item->fix_template_options(); $default = PMXE_Plugin::get_default_import_options(); $DefaultOptions = $item->options + $default; $this->data['post'] = $post = $this->input->post($DefaultOptions); $this->data['iteration'] = $item->iteration; if ($this->input->post('is_confirmed')) { check_admin_referer('update-export', '_wpnonce_update-export'); $post['main_xml_tag'] = preg_replace('/[^a-z0-9]/i', '', $post['main_xml_tag']); if (empty($post['main_xml_tag'])) { $this->errors->add('form-validation', __('Main XML Tag is required.', 'wp_all_export_plugin')); } $post['record_xml_tag'] = preg_replace('/[^a-z0-9]/i', '', $post['record_xml_tag']); if (empty($post['record_xml_tag'])) { $this->errors->add('form-validation', __('Single Record XML Tag is required.', 'wp_all_export_plugin')); } if ($post['main_xml_tag'] == $post['record_xml_tag']) { $this->errors->add('form-validation', __('Main XML Tag equals to Single Record XML Tag.', 'wp_all_export_plugin')); } $iteration = empty($item->options['creata_a_new_export_file']) && !empty($post['creata_a_new_export_file']) ? 0 : $item->iteration; $item->set(array('options' => $post, 'iteration' => $iteration))->save(); if (!empty($post['friendly_name'])) { $item->set(array('friendly_name' => $post['friendly_name'], 'scheduled' => $post['is_scheduled'] ? $post['scheduled_period'] : ''))->save(); } // compose data to look like result of wizard steps $sesson_data = $post + array('update_previous' => $item->id) + $default; foreach ($sesson_data as $key => $value) { PMXE_Plugin::$session->set($key, $value); } $this->data['engine'] = new XmlExportEngine($sesson_data, $this->errors); $this->data['engine']->init_additional_data(); $this->data['engine']->init_available_data(); PMXE_Plugin::$session->save_data(); if (!$this->errors->get_error_codes()) { // deligate operation to other controller $controller = new PMXE_Admin_Export(); $controller->data['update_previous'] = $item; $controller->process(); return; } $this->errors->remove('count-validation'); if (!$this->errors->get_error_codes()) { ?> <script type="text/javascript"> window.location.href = "<?php echo add_query_arg('pmxe_nt', urlencode(__('Options updated', 'wp_all_export_plugin')), $this->baseUrl); ?> "; </script> <?php die; } } $this->data['isWizard'] = false; $this->data['engine'] = new XmlExportEngine($post, $this->errors); $this->data['engine']->init_available_data(); $this->render(); }