function config() { echo "<h2 class=\"trigger\">" . __('Configuration:') . "</h2>\n" . "<div id=\"admin_config\" class=\"trigger\">\n"; config_table_header(); $sql = "select * from " . getTable("config") . " where key_ like\n 'rss.%' order by key_ asc"; $res = rss_query($sql); $cntr = 0; while ($row = rss_fetch_assoc($res)) { // Don't show old/moved config keys in the main config list if (in_array($row['key_'], array('rss.config.plugins', 'rss.output.theme', 'rss.output.barefrontpage', 'rss.output.noreaditems', 'rss.output.cachedir', 'rss.output.showdevloglink', 'rss.output.numitemsonpage'))) { continue; } $class_ = $cntr++ % 2 == 0 ? "even" : "odd"; config_table_row($row, $class_, CST_ADMIN_DOMAIN_CONFIG); } config_table_footer(); echo "</div>\n"; }
function rss_theme_options_configure_overrides($theme, $media, $config_items) { $action = null; if (isset($_REQUEST[CST_ADMIN_METAACTION])) { $action = $_REQUEST[CST_ADMIN_METAACTION]; } else { if (isset($_REQUEST['action'])) { $action = $_REQUEST['action']; } } if (isset($_REQUEST['mediaparam']) && $media === sanitize($_REQUEST['mediaparam'], RSS_SANITIZER_CHARACTERS)) { if (array_key_exists(CST_ADMIN_CONFIRMED, $_POST) && $_POST[CST_ADMIN_CONFIRMED] == __('Yes')) { if (!array_key_exists('key', $_REQUEST)) { rss_error('Invalid config key specified.', RSS_ERROR_ERROR, true); } else { $key = sanitize($_REQUEST['key'], RSS_SANITIZER_NO_SPACES | RSS_SANITIZER_SIMPLE_SQL); rss_theme_delete_config_override_option($key, $theme, $media); } $action = null; //redirect to our theme's admin page } else { if (rss_theme_options_is_submit()) { switch ($action) { case __('Submit Changes'): case 'ACT_ADMIN_SUBMIT_CHANGES': if (!array_key_exists('key', $_REQUEST)) { rss_error('Invalid config key specified.', RSS_ERROR_ERROR, true); break; } if (!array_key_exists('type', $_REQUEST)) { rss_error('Invalid config type specified.', RSS_ERROR_ERROR, true); break; } if (!array_key_exists('value', $_REQUEST)) { rss_error('Invalid config value specified.', RSS_ERROR_ERROR, true); break; } $key = sanitize($_REQUEST['key'], RSS_SANITIZER_NO_SPACES | RSS_SANITIZER_SIMPLE_SQL); $type = sanitize($_POST['type'], RSS_SANITIZER_CHARACTERS); $value = sanitize($_POST['value'], RSS_SANITIZER_SIMPLE_SQL); if ($type == 'enum') { $item = theme_options_fill_override_array($theme, $media, $config_items, $key); if (count($item)) { $arr = explode(',', $item['default_']); $idx = array_pop($arr); $newkey = -1; foreach ($arr as $i => $val) { if ($val == $value) { $newkey = $i; } } reset($arr); if ($newkey > -1) { array_push($arr, $newkey); rss_theme_set_config_override_option($key, implode(',', $arr), $theme, $media); } else { rss_error("Oops, invalid value '{$value}' for this config key", RSS_ERROR_ERROR, true); } } } else { rss_theme_set_config_override_option($key, $value, $theme, $media); } break; default: rss_error('Invalid config action specified.', RSS_ERROR_ERROR, true); break; } $action = null; //redirect to our theme's admin page } } } switch ($action) { case CST_ADMIN_DEFAULT_ACTION: case 'CST_ADMIN_DEFAULT_ACTION': if (isset($_REQUEST['mediaparam']) && $media === sanitize($_REQUEST['mediaparam'], RSS_SANITIZER_CHARACTERS)) { if (!array_key_exists('key', $_REQUEST)) { rss_error('Invalid config key specified.', RSS_ERROR_ERROR, true); break; } $key = sanitize($_REQUEST['key'], RSS_SANITIZER_NO_SPACES | RSS_SANITIZER_SIMPLE_SQL); $item = theme_options_fill_override_array($theme, $media, $config_items, $key); if (count($item)) { extract($item); config_default_form($key_, $type_, $default_, CST_ADMIN_DOMAIN_THEME_OPTIONS); rss_theme_options_form_class('box'); rss_theme_options_rendered_buttons(true); } } break; case CST_ADMIN_EDIT_ACTION: case 'CST_ADMIN_EDIT_ACTION': if (isset($_REQUEST['mediaparam']) && $media === sanitize($_REQUEST['mediaparam'], RSS_SANITIZER_CHARACTERS)) { if (!array_key_exists('key', $_REQUEST)) { rss_error('Invalid config key specified.', RSS_ERROR_ERROR, true); break; } $key = sanitize($_REQUEST['key'], RSS_SANITIZER_NO_SPACES | RSS_SANITIZER_SIMPLE_SQL); $item = theme_options_fill_override_array($theme, $media, $config_items, $key); if (count($item)) { extract($item); $dummy = null; config_edit_form($key_, $value_, $default_, $type_, $desc_, $export_, $dummy); } } break; default: $caption = "Configuration overrides"; if (isset($media)) { $caption .= " for {$media} media"; } config_table_header($caption); $cntr = 0; $items = theme_options_fill_override_array($theme, $media, $config_items); foreach ($items as $item) { config_table_row($item, $cntr++ % 2 == 0 ? "even" : "odd", CST_ADMIN_DOMAIN_THEME_OPTIONS, "&theme={$theme}&mediaparam={$media}"); } config_table_footer(); //no buttons here rss_theme_options_rendered_buttons(true); break; } }