function admin_redirects($group_id) { if ($group_id == 0) { $group_id = Red_Group::get_first_id(); } $group = Red_Group::get($group_id); if ($group === false) { $group = Red_Group::create(array('name' => 'Redirections', 'module_id' => 1)); } $table = new Redirection_Table(Red_Group::get_for_select(), $group); $table->prepare_items(); $this->render('item_list', array('options' => red_get_options(), 'group' => $group, 'table' => $table, 'date_format' => get_option('date_format'))); }
function admin_groups($module) { if (isset($_POST['add']) && check_admin_referer('redirection-add_group')) { if (Red_Group::create(stripslashes_deep($_POST))) { $this->render_message(__('Your group was added successfully', 'redirection')); Red_Module::flush($module); } else { $this->render_error(__('Please specify a group name', 'redirection')); } } if ($module == 0) { $module = Red_Module::get_first_id(); } $table = new Redirection_Group_Table(Red_Module::get_for_select(), $module); $table->prepare_items(); $module = Red_Module::get($module); if ($module) { $this->render_admin('group_list', array('options' => $this->get_options(), 'table' => $table, 'modules' => Red_Module::get_for_select(), 'module' => $module)); } else { $this->render_message(__('Unknown module', 'redirection')); } }
function load($group, $data) { $count = 0; if (function_exists('simplexml_load_string')) { global $wpdb; $xml = simplexml_load_string($data); // Extract module $moduledata = array('type' => (string) $xml->module['type'], 'name' => sprintf(__('%s imported on %s at %s', 'redirection'), (string) $xml->module['name'], date('M d Y'), date('H:i'))); if (isset($xml->module->options)) { foreach ($xml->module->options->option as $option) { $options[(string) $option['name']] = trim((string) $option); } $moduledata['options'] = $options; } $module = Red_Module::create($moduledata); // Look at groups if (count($xml->module->group) > 0) { foreach ($xml->module->group as $group) { $id = Red_Group::create(array('module_id' => $module, 'name' => (string) $group['name'], 'status' => (string) $group['status'], 'position' => (string) $group['position'])); // Look at items if (count($group->item) > 0) { foreach ($group->item as $item) { $actiondata = array(); if (isset($item->action->option) && count($item->action->option) > 0) { foreach ($item->action->option as $option) { $actiondata[(string) $option['key']] = trim((string) $option); } $actiondata = serialize($actiondata); } else { $actiondata = trim((string) $item->action); } $data = array('group_id' => $id, 'url' => trim((string) $item->source), 'position' => intval((string) $item['position']), 'status' => (string) $item['status'], 'regex' => (string) $item->match['regex'], 'match_type' => (string) $item->match['type'], 'action_type' => (string) $item->action['type'], 'action_code' => (string) $item->action['code'], 'action_data' => $actiondata); foreach ($data as $key => $value) { $data[$key] = "'" . $wpdb->escape($value) . "'"; } // Easier to insert it directly here $wpdb->query("INSERT INTO {$wpdb->prefix}redirection_items (" . implode(',', array_keys($data)) . ") VALUES (" . implode(',', $data) . ")"); $count++; } } } } } else { global $redirection; $redirection->render_error(__('XML importing is only available with PHP5 - you have PHP4.', 'redirection')); } return $count; }
function admin_groups($module) { include dirname(__FILE__) . '/models/pager.php'; if (isset($_POST['add']) && check_admin_referer('redirection-add_group')) { if (Red_Group::create(stripslashes_deep($_POST))) { $this->render_message(__('Your group was added successfully', 'redirection')); Red_Module::flush($module); } else { $this->render_error(__('Please specify a group name', 'redirection')); } } if ($module == 0) { $module = Red_Module::get_first_id(); } $pager = new RE_Pager($_GET, $_SERVER['REQUEST_URI'], 'position', 'ASC'); $items = Red_Group::get_all($module, $pager); $this->render_admin('group_list', array('groups' => $items, 'pager' => $pager, 'modules' => Red_Module::get_for_select(), 'module' => Red_Module::get($module))); }
function admin_groups($module) { if (isset($_POST['add']) && check_admin_referer('redirection-add_group')) { if (Red_Group::create(stripslashes($_POST['name']), intval($_POST['module_id']))) { $this->render_message(__('Your group was added successfully', 'redirection')); } else { $this->render_error(__('Please specify a group name', 'redirection')); } } $table = new Redirection_Group_Table(Red_Module::get_for_select()); $table->prepare_items(); $this->render('group-list', array('options' => red_get_options(), 'table' => $table, 'modules' => Red_Module::get_for_select(), 'module' => $module)); }