function display () {
		global $wpdb, $wp_db_version, $fwp_path;
		global $fwp_post;
		
		if (FeedWordPress::needs_upgrade()) :
			fwp_upgrade_page();
			return;
		endif;
	
		// If this is a POST, validate source and user credentials
		FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_diagnostics', /*capability=*/ 'manage_options');
	
		if (strtoupper($_SERVER['REQUEST_METHOD'])=='POST') :
			$this->accept_POST($fwp_post);
			do_action('feedwordpress_admin_page_diagnostics_save', $GLOBALS['fwp_post'], $this);
		endif;

		////////////////////////////////////////////////
		// Prepare settings page ///////////////////////
		////////////////////////////////////////////////

		$this->display_update_notice_if_updated('Diagnostics');

		$this->open_sheet('FeedWordPress Diagnostics');
		?>
		<div id="post-body">
		<?php
		$boxes_by_methods = array(
			'info_box' => __('Diagnostic Information'),
			'diagnostics_box' => __('Display Diagnostics'),
			'updates_box' => __('Updates'),
			'tests_box' => __('Diagnostic Tests'),
		);
	
		foreach ($boxes_by_methods as $method => $title) :
			add_meta_box(
				/*id=*/ 'feedwordpress_'.$method,
				/*title=*/ $title,
				/*callback=*/ array('FeedWordPressDiagnosticsPage', $method),
				/*page=*/ $this->meta_box_context(),
				/*context=*/ $this->meta_box_context()
			);
		endforeach;
		do_action('feedwordpress_admin_page_diagnostics_meta_boxes', $this);
		?>
			<div class="metabox-holder">
			<?php
			fwp_do_meta_boxes($this->meta_box_context(), $this->meta_box_context(), $this);
			?>
			</div> <!-- class="metabox-holder" -->
		</div> <!-- id="post-body" -->

		<?php
		$this->close_sheet();
	} /* FeedWordPressDiagnosticsPage::display () */
Пример #2
0
    function display()
    {
        global $wpdb, $wp_db_version, $fwp_path;
        global $fwp_post;
        if (FeedWordPress::needs_upgrade()) {
            fwp_upgrade_page();
            return;
        }
        // If this is a POST, validate source and user credentials
        FeedWordPressCompatibility::validate_http_request('feedwordpress_performance', 'manage_options');
        if (strtoupper($_SERVER['REQUEST_METHOD']) == 'POST') {
            $this->accept_POST($fwp_post);
            do_action('feedwordpress_admin_page_performance_save', $fwp_post, $this);
        }
        ////////////////////////////////////////////////
        // Prepare settings page ///////////////////////
        ////////////////////////////////////////////////
        $this->display_update_notice_if_updated('Performance');
        $this->open_sheet('FeedWordPress Performance');
        ?>
		<div id="post-body">
		<?php 
        $boxes_by_methods = array('performance_box' => __('Performance'));
        foreach ($boxes_by_methods as $method => $title) {
            add_meta_box('feedwordpress_' . $method, $title, array('FeedWordPressPerformancePage', $method), $this->meta_box_context(), $this->meta_box_context());
        }
        do_action('feedwordpress_admin_page_performance_meta_boxes', $this);
        ?>
			<div class="metabox-holder">
			<?php 
        fwp_do_meta_boxes($this->meta_box_context(), $this->meta_box_context(), $this);
        ?>
			</div> <!-- class="metabox-holder" -->
		</div> <!-- id="post-body" -->

		<?php 
        $this->close_sheet();
    }
    function display()
    {
        global $wpdb;
        global $fwp_post;
        if (FeedWordPress::needs_upgrade()) {
            fwp_upgrade_page();
            return;
        }
        $cont = true;
        $dispatcher = array("feedfinder" => 'fwp_feedfinder_page', FWP_SYNDICATE_NEW => 'fwp_feedfinder_page', "switchfeed" => 'fwp_switchfeed_page', FWP_UNSUB_CHECKED => 'multidelete_page', FWP_DELETE_CHECKED => 'multidelete_page', 'Unsubscribe' => 'multidelete_page', FWP_RESUB_CHECKED => 'multiundelete_page');
        $act = MyPHP::request('action');
        if (isset($dispatcher[$act])) {
            $method = $dispatcher[$act];
            if (method_exists($this, $method)) {
                $cont = $this->{$method}();
            } else {
                $cont = call_user_func($method);
            }
        } elseif (isset($fwp_post['multiadd']) and $fwp_post['multiadd'] == FWP_SYNDICATE_NEW) {
            $cont = $this->accept_multiadd($fwp_post);
        }
        if ($cont) {
            $links = $this->sources('Y');
            $potential_updates = (!$this->show_inactive() and count($this->sources('Y')) > 0);
            $this->open_sheet('Syndicated Sites');
            ?>
			<div id="post-body">
			<?php 
            if ($potential_updates or count($this->updates_requested()) > 0) {
                add_meta_box('feedwordpress_update_box', __('Update feeds now'), 'fwp_syndication_manage_page_update_box', $this->meta_box_context(), $this->meta_box_context());
            }
            add_meta_box('feedwordpress_feeds_box', __('Syndicated sources'), array($this, 'syndicated_sources_box'), $this->meta_box_context(), $this->meta_box_context());
            do_action('feedwordpress_admin_page_syndication_meta_boxes', $this);
            ?>
			<div class="metabox-holder">		
			<?php 
            fwp_do_meta_boxes($this->meta_box_context(), $this->meta_box_context(), $this);
            ?>
			</div> <!-- class="metabox-holder" -->
			</div> <!-- id="post-body" -->
		
			<?php 
            $this->close_sheet(NULL);
            ?>
		
			<div style="display: none">
			<div id="tags-input"></div> <!-- avoid JS error from WP 2.5 bug -->
			</div>
		<?php 
        }
    }
Пример #4
0
    function display()
    {
        global $fwp_post;
        if (FeedWordPress::needs_upgrade()) {
            fwp_upgrade_page();
            return;
        }
        FeedWordPressCompatibility::validate_http_request($this->dispatch, 'manage_links');
        ////////////////////////////////////////////////
        // Process POST request, if any ////////////////
        ////////////////////////////////////////////////
        if (strtoupper($_SERVER['REQUEST_METHOD']) == 'POST') {
            $this->accept_POST($fwp_post);
        } else {
            $this->updated = false;
        }
        ////////////////////////////////////////////////
        // Prepare settings page ///////////////////////
        ////////////////////////////////////////////////
        $this->display_update_notice_if_updated($this->pagename('settings-update'), $this->update_message());
        $this->open_sheet($this->pagename('open-sheet'));
        ?>
		<div id="post-body">
		<?php 
        foreach ($this->boxes_by_methods as $method => $row) {
            if (is_array($row)) {
                $id = $row['id'];
                $title = $row['title'];
            } else {
                $id = 'feedwordpress_' . $method;
                $title = $row;
            }
            add_meta_box($id, $title, array($this, $method), $this->meta_box_context(), $this->meta_box_context());
        }
        do_action($this->dispatch . '_meta_boxes', $this);
        ?>
		<div class="metabox-holder">
		<?php 
        fwp_do_meta_boxes($this->meta_box_context(), $this->meta_box_context(), $this);
        ?>
		</div> <!-- class="metabox-holder" -->
		</div> <!-- id="post-body" -->
		<?php 
        $this->close_sheet();
        ?>
	<?php 
    }
function fwp_syndication_options_page()
{
    global $wpdb, $wp_db_version, $fwp_path;
    if (FeedWordPress::needs_upgrade()) {
        fwp_upgrade_page();
        return;
    }
    if (isset($_POST['create_index'])) {
        check_admin_referer();
        if (!current_user_can('manage_options')) {
            die(__("Cheatin' uh ?"));
        } else {
            FeedWordPress::create_guid_index();
            ?>
<div class="updated">
<p><?php 
            _e('Index created on database table.');
            ?>
</p>
</div>
<?php 
        }
    }
    if (isset($_POST['submit']) or isset($_POST['create_index'])) {
        check_admin_referer();
        if (!current_user_can('manage_options')) {
            die(__("Cheatin' uh ?"));
        } else {
            update_option('feedwordpress_cat_id', $_REQUEST['syndication_category']);
            update_option('feedwordpress_munge_permalink', $_REQUEST['munge_permalink']);
            update_option('feedwordpress_use_aggregator_source_data', $_REQUEST['use_aggregator_source_data']);
            update_option('feedwordpress_formatting_filters', $_REQUEST['formatting_filters']);
            update_option('feedwordpress_update_logging', $_REQUEST['update_logging']);
            if ('newuser' == $_REQUEST['unfamiliar_author']) {
                $newuser_name = trim($_REQUEST['unfamiliar_author_newuser']);
                if (strlen($newuser_name) > 0) {
                    $userdata = array();
                    $userdata['ID'] = NULL;
                    $userdata['user_login'] = sanitize_user($newuser_name);
                    $userdata['user_login'] = apply_filters('pre_user_login', $userdata['user_login']);
                    $userdata['user_nicename'] = sanitize_title($newuser_name);
                    $userdata['user_nicename'] = apply_filters('pre_user_nicename', $userdata['user_nicename']);
                    $userdata['display_name'] = $wpdb->escape($newuser_name);
                    $newuser_id = wp_insert_user($userdata);
                    if (is_numeric($newuser_id)) {
                        update_option('feedwordpress_unfamiliar_author', $newuser_id);
                    } else {
                        // TODO: Add some error detection and reporting
                    }
                } else {
                    // TODO: Add some error reporting
                }
            } else {
                update_option('feedwordpress_unfamiliar_author', $_REQUEST['unfamiliar_author']);
            }
            if (isset($_REQUEST['match_author_by_email']) and $_REQUEST['match_author_by_email'] == 'yes') {
                update_option('feedwordpress_do_not_match_author_by_email', 'no');
            } else {
                update_option('feedwordpress_do_not_match_author_by_email', 'yes');
            }
            if (isset($_REQUEST['null_emails'])) {
                update_option('feedwordpress_null_email_set', $_REQUEST['null_emails']);
            }
            update_option('feedwordpress_unfamiliar_category', $_REQUEST['unfamiliar_category']);
            update_option('feedwordpress_syndicated_post_status', $_REQUEST['post_status']);
            update_option('feedwordpress_automatic_updates', $_POST['automatic_updates'] == 'yes');
            update_option('feedwordpress_update_time_limit', $_POST['update_time_limit'] == 'yes' ? (int) $_POST['time_limit_seconds'] : 0);
            update_option('feedwordpress_freshness', $_POST['freshness_interval'] * 60);
            // Categories
            $cats = array();
            if (isset($_POST['post_category'])) {
                $cats = array();
                foreach ($_POST['post_category'] as $cat_id) {
                    $cats[] = '{#' . $cat_id . '}';
                }
            }
            if (!empty($cats)) {
                update_option('feedwordpress_syndication_cats', implode(FEEDWORDPRESS_CAT_SEPARATOR, $cats));
            } else {
                delete_option('feedwordpress_syndication_cats');
            }
            // Tags
            if (isset($_REQUEST['tags_input'])) {
                $tags = explode(",", $_REQUEST['tags_input']);
            } else {
                $tags = array();
            }
            if (!empty($tags)) {
                update_option('feedwordpress_syndication_tags', implode(FEEDWORDPRESS_CAT_SEPARATOR, $tags));
            } else {
                delete_option('feedwordpress_syndication_tags');
            }
            if (isset($_REQUEST['comment_status']) and $_REQUEST['comment_status'] == 'open') {
                update_option('feedwordpress_syndicated_comment_status', 'open');
            } else {
                update_option('feedwordpress_syndicated_comment_status', 'closed');
            }
            if (isset($_REQUEST['ping_status']) and $_REQUEST['ping_status'] == 'open') {
                update_option('feedwordpress_syndicated_ping_status', 'open');
            } else {
                update_option('feedwordpress_syndicated_ping_status', 'closed');
            }
            if (isset($_REQUEST['hardcode_name']) and $_REQUEST['hardcode_name'] == 'no') {
                update_option('feedwordpress_hardcode_name', 'no');
            } else {
                update_option('feedwordpress_hardcode_name', 'yes');
            }
            if (isset($_REQUEST['hardcode_description']) and $_REQUEST['hardcode_description'] == 'no') {
                update_option('feedwordpress_hardcode_description', 'no');
            } else {
                update_option('feedwordpress_hardcode_description', 'yes');
            }
            if (isset($_REQUEST['hardcode_url']) and $_REQUEST['hardcode_url'] == 'no') {
                update_option('feedwordpress_hardcode_url', 'no');
            } else {
                update_option('feedwordpress_hardcode_url', 'yes');
            }
            ?>
<div class="updated">
<p><?php 
            _e('Options saved.');
            ?>
</p>
</div>
<?php 
        }
    }
    $cat_id = FeedWordPress::link_category_id();
    $munge_permalink = get_option('feedwordpress_munge_permalink');
    $use_aggregator_source_data = get_option('feedwordpress_use_aggregator_source_data');
    $formatting_filters = get_option('feedwordpress_formatting_filters');
    $update_logging = get_option('feedwordpress_update_logging');
    $update_time_limit = (int) get_option('feedwordpress_update_time_limit');
    $automatic_updates = get_option('feedwordpress_automatic_updates');
    $freshness_interval = get_option('feedwordpress_freshness');
    if (false === $freshness_interval) {
        $freshness_interval = FEEDWORDPRESS_FRESHNESS_INTERVAL;
    }
    $freshness_interval = $freshness_interval / 60;
    // convert to minutes
    $hardcode_name = get_option('feedwordpress_hardcode_name');
    $hardcode_description = get_option('feedwordpress_hardcode_description');
    $hardcode_url = get_option('feedwordpress_hardcode_url');
    $post_status = get_option("feedwordpress_syndicated_post_status");
    // default="publish"
    $comment_status = get_option("feedwordpress_syndicated_comment_status");
    // default="closed"
    $ping_status = get_option("feedwordpress_syndicated_ping_status");
    // default="closed"
    $unfamiliar_author = array('create' => '', 'default' => '', 'filter' => '');
    $ua = FeedWordPress::on_unfamiliar('author');
    if (is_string($ua) and array_key_exists($ua, $unfamiliar_author)) {
        $unfamiliar_author[$ua] = ' checked="checked"';
    }
    $match_author_by_email = !('yes' == get_option("feedwordpress_do_not_match_author_by_email"));
    $null_emails = FeedWordPress::null_email_set();
    $unfamiliar_category = array('create' => '', 'default' => '', 'filter' => '', 'tag' => '');
    $uc = FeedWordPress::on_unfamiliar('category');
    if (is_string($uc) and array_key_exists($uc, $unfamiliar_category)) {
        $unfamiliar_category[$uc] = ' checked="checked"';
    }
    if (isset($wp_db_version) and $wp_db_version >= 4772) {
        $results = get_categories('type=link');
        // Guarantee that the Contributors category will be in the drop-down chooser, even if it is empty.
        $found_link_category_id = false;
        foreach ($results as $row) {
            if ($row->cat_id == $cat_id) {
                $found_link_category_id = true;
            }
        }
        if (!$found_link_category_id) {
            $results[] = get_category($cat_id);
        }
    } else {
        $results = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM {$wpdb->linkcategories} ORDER BY cat_id");
    }
    $cats = array_map('trim', preg_split(FEEDWORDPRESS_CAT_SEPARATOR_PATTERN, get_option('feedwordpress_syndication_cats')));
    $dogs = SyndicatedPost::category_ids($cats, NULL);
    $tags = array_map('trim', preg_split(FEEDWORDPRESS_CAT_SEPARATOR_PATTERN, get_option('feedwordpress_syndication_tags')));
    if (fwp_test_wp_version(FWP_SCHEMA_27)) {
        $icon = '<div class="icon32"><img src="' . htmlspecialchars(WP_PLUGIN_URL . '/' . $fwp_path . '/feedwordpress.png') . '" alt="" /></div>';
    } else {
        $icon = '';
    }
    if (fwp_test_wp_version(FWP_SCHEMA_26)) {
        $options = __('Settings');
    } else {
        $options = __('Options');
    }
    ?>
<script type="text/javascript">
	function contextual_appearance (item, appear, disappear, value, checkbox) {
		var rollup=document.getElementById(item);
		var newuser=document.getElementById(appear);
		var sitewide=document.getElementById(disappear);
		if (rollup) {
			if ((checkbox && rollup.checked) || (!checkbox && value==rollup.value)) {
				if (newuser) newuser.style.display='block';
				if (sitewide) sitewide.style.display='none';
			} else {
				if (newuser) newuser.style.display='none';
				if (sitewide) sitewide.style.display='block';
			}
		}
	}
</script>

<div class="wrap">
<?php 
    print $icon;
    ?>
<h2>Syndication <?php 
    print $options;
    ?>
</h2>
<div id="poststuff">
<form action="" method="post">
<?php 
    fwp_linkedit_single_submit();
    ?>
<div id="post-body">
<?php 
    fwp_option_box_opener('Syndicated Feeds', 'syndicatedfeedsdiv');
    ?>
<table class="editform" width="100%" cellspacing="2" cellpadding="5">
<tr>
<th width="33%" scope="row">Syndicated Link category:</th>
<td width="67%"><?php 
    echo "\n<select name=\"syndication_category\" size=\"1\">";
    foreach ($results as $row) {
        if (!isset($row->cat_id)) {
            $row->cat_id = $row->cat_ID;
        }
        echo "\n\t<option value=\"{$row->cat_id}\"";
        if ($row->cat_id == $cat_id) {
            echo " selected='selected'";
        }
        echo ">{$row->cat_id}: " . wp_specialchars($row->cat_name);
        if ('Y' == $row->auto_toggle) {
            echo ' (auto toggle)';
        }
        echo "</option>\n";
    }
    echo "\n</select>\n";
    ?>
</td>
</tr>

<tr style="vertical-align: top">
<th width="33%" scope="row">Check for feeds ready to be polled for updates:</th>
<td width="67%"><select name="automatic_updates" size="1" onchange="if (this.value=='yes') { disp = 'inline'; } else { disp = 'none'; }; el=document.getElementById('automatic-update-interval-span'); if (el) el.style.display=disp;">
<option value="yes"<?php 
    echo $automatic_updates ? ' selected="selected"' : '';
    ?>
>automatically</option>
<option value="no"<?php 
    echo !$automatic_updates ? ' selected="selected"' : '';
    ?>
>only when I request</option>
</select>
<span id="automatic-update-interval-span" style="display: <?php 
    echo $automatic_updates ? 'inline' : 'none';
    ?>
"><label for="automatic-update-interval">every</label> <input id="automatic-update-interval" name="freshness_interval" value="<?php 
    echo $freshness_interval;
    ?>
" size="4" /> minutes.</span>
</td>
</tr>

<tr style="vertical-align: top">
<th width="33%" scope="row"><?php 
    print __('Time limit on updates');
    ?>
:</th>
<td width="67%"><select id="time-limit" name="update_time_limit" size="1" onchange="contextual_appearance('time-limit', 'time-limit-box', null, 'yes');">
<option value="no"<?php 
    echo $update_time_limit > 0 ? '' : ' selected="selected"';
    ?>
>no time limit on updates</option>
<option value="yes"<?php 
    echo $update_time_limit > 0 ? ' selected="selected"' : '';
    ?>
>limit updates to no more than...</option>
</select>
<span id="time-limit-box"><label><input type="text" name="time_limit_seconds" value="<?php 
    print $update_time_limit;
    ?>
" size="5" /> seconds</label></span>
</tr>

<script type="text/javascript">
	contextual_appearance('time-limit', 'time-limit-box', null, 'yes');
</script>

<tr><th width="33%" scope="row" style="vertical-align:top">Feed information:</th>
<td width="67%"><ul style="margin:0;padding:0;list-style:none">
<li><input type="checkbox" name="hardcode_name" value="no"<?php 
    echo $hardcode_name == 'yes' ? '' : ' checked="checked"';
    ?>
/> Update the contributor title when the feed title changes</li>
<li><input type="checkbox" name="hardcode_description" value="no"<?php 
    echo $hardcode_description == 'yes' ? '' : ' checked="checked"';
    ?>
/> Update when contributor description if the feed tagline changes</li>
<li><input type="checkbox" name="hardcode_url" value="no"<?php 
    echo $hardcode_url == 'yes' ? '' : ' checked="checked"';
    ?>
/> Update the contributor homepage when the feed link changes</li>
</ul></td></tr>
</table>
<?php 
    fwp_linkedit_periodic_submit();
    fwp_option_box_closer();
    ?>

<?php 
    fwp_option_box_opener(__('Syndicated Posts'), 'syndicatedpostsdiv');
    ?>
<table class="editform" width="75%" cellspacing="2" cellpadding="5">
<tr style="vertical-align: top"><th width="44%" scope="row">Publication:</th>
<td width="56%"><ul style="margin: 0; padding: 0; list-style:none">
<li><label><input type="radio" name="post_status" value="publish"<?php 
    echo (!$post_status or $post_status == 'publish') ? ' checked="checked"' : '';
    ?>
 /> Publish syndicated posts immediately</label></li>
<?php 
    if (SyndicatedPost::use_api('post_status_pending')) {
        ?>
<li><label><input type="radio" name="post_status" value="pending"<?php 
        echo $post_status == 'pending' ? ' checked="checked"' : '';
        ?>
 /> Hold syndicated posts for review; mark as Pending</label></li>
<?php 
    }
    ?>
<li><label><input type="radio" name="post_status" value="draft"<?php 
    echo $post_status == 'draft' ? ' checked="checked"' : '';
    ?>
 /> Save syndicated posts as drafts</label></li>
<li><label><input type="radio" name="post_status" value="private"<?php 
    echo $post_status == 'private' ? ' checked="checked"' : '';
    ?>
 /> Save syndicated posts as private posts</label></li>
</ul></td></tr>

<tr style="vertical-align: top"><th width="44%" scope="row">Permalinks point to:</th>
<td width="56%"><select name="munge_permalink" size="1">
<option value="yes"<?php 
    echo $munge_permalink == 'yes' ? ' selected="selected"' : '';
    ?>
>original website</option>
<option value="no"<?php 
    echo $munge_permalink == 'no' ? ' selected="selected"' : '';
    ?>
>this website</option>
</select></td></tr>

<tr style="vertical-align: top"><th width="44%" scope="row">Posts from aggregator feeds:</th>
<td width="56%"><ul style="margin: 0; padding: 0; list-style: none;">
<li><label><input type="radio" name="use_aggregator_source_data" value="no"<?php 
    echo $use_aggregator_source_data != "yes" ? ' checked="checked"' : '';
    ?>
> Give the aggregator itself as the source of posts from an aggregator feed.</label></li>
<li><label><input type="radio" name="use_aggregator_source_data" value="yes"<?php 
    echo $use_aggregator_source_data == "yes" ? ' checked="checked"' : '';
    ?>
> Give the original source of the post as the source, not the aggregator.</label></li>
</ul>
<p>Some feeds (for example, those produced by FeedWordPress) aggregate content from several different sources, and include information about the original source of the post.
This setting controls what FeedWordPress will give as the source of posts from
such an aggregator feed.</p>
</td></tr>

<tr style="vertical-align:top"><th width="44%" scope="row">Formatting filters:</th>
<td width="56%">
<select name="formatting_filters" size="1">
<option value="no"<?php 
    echo $formatting_filters != 'yes' ? ' selected="selected"' : '';
    ?>
>Protect syndicated posts from formatting filters</option>
<option value="yes"<?php 
    echo $formatting_filters == 'yes' ? ' selected="selected"' : '';
    ?>
>Expose syndicated posts to formatting filters</option>
</select>
<p>If you have trouble getting plugins to work that are supposed to insert
elements after posts (like relevant links or a social networking
<q>Share This</q> button), try changing this option to see if it fixes your
problem.</p>
</td></tr>
</table>
<?php 
    fwp_option_box_closer();
    fwp_linkedit_periodic_submit();
    fwp_option_box_opener(__('Categories for syndicated posts'), 'categorydiv', 'postbox');
    fwp_category_box($dogs, '<em>all syndicated posts</em>');
    ?>
<table class="editform" width="75%" cellspacing="2" cellpadding="5">
<tr style="vertical-align: top"><th width="27%" scope="row" style="vertical-align:top">Unfamiliar categories:</th>
<td><p>When one of the categories on a syndicated post is a category that FeedWordPress has not encountered before ...</p>
<ul style="margin: 0; padding:0; list-style:none">
<li><label><input type="radio" name="unfamiliar_category" value="create"<?php 
    echo $unfamiliar_category['create'];
    ?>
/> create a new category</label></li>
<?php 
    if (fwp_test_wp_version(FWP_SCHEMA_23)) {
        ?>
<li><label><input type="radio" name="unfamiliar_category" value="tag"<?php 
        echo $unfamiliar_category['tag'];
        ?>
/> create a new tag</label></li>
<?php 
    }
    ?>
<li><label><input type="radio" name="unfamiliar_category" value="default"<?php 
    echo $unfamiliar_category['default'];
    ?>
/> don't create new categories<?php 
    if (fwp_test_wp_version(FWP_SCHEMA_23)) {
        ?>
 or tags<?php 
    }
    ?>
</li>
<li><label><input type="radio" name="unfamiliar_category" value="filter"<?php 
    echo $unfamiliar_category['filter'];
    ?>
/> don't create new categories<?php 
    if (fwp_test_wp_version(FWP_SCHEMA_23)) {
        ?>
 or tags<?php 
    }
    ?>
 and don't syndicate posts unless they match at least one familiar category</label></li>
</ul></td></tr>
</table>
<?php 
    fwp_option_box_closer();
    fwp_linkedit_periodic_submit();
    if (isset($wp_db_version) and $wp_db_version >= FWP_SCHEMA_25) {
        fwp_tags_box($tags);
        fwp_linkedit_periodic_submit();
    }
    fwp_option_box_opener(__('Comments & Pings'), 'commentstatus', 'postbox');
    ?>
<table class="editform" width="75%" cellspacing="2" cellpadding="5">
<tr style="vertical-align: top"><th width="44%" scope="row"><?php 
    print __('Comments');
    ?>
:</th>
<td width="56%"><ul style="margin: 0; padding: 0; list-style:none">
<li><label><input type="radio" name="comment_status" value="open"<?php 
    echo $comment_status == 'open' ? ' checked="checked"' : '';
    ?>
 /> Allow comments on syndicated posts</label></li>
<li><label><input type="radio" name="comment_status" value="closed"<?php 
    echo $comment_status != 'open' ? ' checked="checked"' : '';
    ?>
 /> Don't allow comments on syndicated posts</label></li>
</ul></td></tr>

<tr style="vertical-align: top"><th width="44%" scope="row"><?php 
    print __('Pings');
    ?>
:</th>
<td width="56%"><ul style="margin:0; padding: 0; list-style:none">
<li><label><input type="radio" name="ping_status" value="open"<?php 
    echo $ping_status == 'open' ? ' checked="checked"' : '';
    ?>
 /> Accept pings on syndicated posts</label></li>
<li><label><input type="radio" name="ping_status" value="closed"<?php 
    echo $ping_status != 'open' ? ' checked="checked"' : '';
    ?>
 /> Don't accept pings on syndicated posts</label></li>
</ul></td></tr>
</table>
<?php 
    fwp_option_box_closer();
    fwp_linkedit_periodic_submit();
    fwp_option_box_opener('Syndicated Authors', 'authordiv', 'postbox');
    $unfamiliar_author = FeedWordPress::on_unfamiliar('author');
    $authorlist = fwp_author_list();
    ?>
<table>
<tr><th colspan="3" style="text-align: left; padding-top: 1.0em; border-bottom: 1px dotted black;">For posts by authors that haven't been syndicated before:</th></tr>
<tr style="vertical-align: top">
  <th style="text-align: left">Posts by new authors</th>
  <td> 
  <select style="max-width: 16.0em;" id="unfamiliar-author" name="unfamiliar_author" onchange="contextual_appearance('unfamiliar-author', 'unfamiliar-author-newuser', 'unfamiliar-author-default', 'newuser');">
    <option value="create"<?php 
    if ('create' == $unfamiliar_author) {
        ?>
selected="selected"<?php 
    }
    ?>
>create a new author account</option>
    <?php 
    foreach ($authorlist as $author_id => $author_name) {
        ?>
      <option value="<?php 
        echo $author_id;
        ?>
"<?php 
        if ($author_id == $unfamiliar_author) {
            ?>
selected="selected"<?php 
        }
        ?>
>are assigned to <?php 
        echo $author_name;
        ?>
</option>
    <?php 
    }
    ?>
    <option value="newuser">will be assigned to a user named...</option>
    <option value="filter"<?php 
    if ('filter' == $unfamiliar_author) {
        ?>
selected="selected"<?php 
    }
    ?>
>get filtered out</option>
  </select>
  </td>
  <td>
  <div id="unfamiliar-author-newuser"><input type="text" name="unfamiliar_author_newuser" value="" /></div>
  </td>
</tr>
<tr><td></td>
<td colspan="2">
<p>This is a default setting. You can override it for one or more particular feeds using the Edit link in <a href="admin.php?page=<?php 
    print $GLOBALS['fwp_path'];
    ?>
/syndication.php">Syndicated Sites</a></p>
</td>
</table>

<script type="text/javascript">
	contextual_appearance('unfamiliar-author', 'unfamiliar-author-newuser', 'unfamiliar-author-default', 'newuser');
</script>

<h4>Matching Authors</h4>
<ul style="list-style: none; margin: 0; padding: 0;">
<li><div><label><input id="match-author-by-email" type="checkbox" name="match_author_by_email" value="yes" <?php 
    if ($match_author_by_email) {
        ?>
checked="checked" <?php 
    }
    ?>
onchange="contextual_appearance('match-author-by-email', 'unless-null-email', null, 'yes', /*checkbox=*/ true);" /> Treat syndicated authors with the same e-mail address as the same author.</label></div>
<div id="unless-null-email">
<p>Unless the e-mail address is one of the following anonymous e-mail addresses:</p>
<textarea name="null_emails" rows="3" style="width: 100%">
<?php 
    print implode("\n", $null_emails);
    ?>
</textarea>
</div></li>
</ul>

<script type="text/javascript">
contextual_appearance('match-author-by-email', 'unless-null-email', null, 'yes', /*checkbox=*/ true);
</script>

<?php 
    fwp_option_box_closer();
    fwp_linkedit_periodic_submit();
    fwp_option_box_opener('Back End', 'backenddiv', 'postbox');
    ?>
<table class="editform" width="100%" cellspacing="2" cellpadding="5">
<tr style="vertical-align: top">
<th width="33%" scope="row">Update notices:</th>
<td width="67%"><select name="update_logging" size="1">
<option value="yes"<?php 
    echo $update_logging == 'yes' ? ' selected="selected"' : '';
    ?>
>write to PHP logs</option>
<option value="no"<?php 
    echo $update_logging != 'yes' ? ' selected="selected"' : '';
    ?>
>don't write to PHP logs</option>
</select></td>
</tr>
<tr style="vertical-align: top">
<th width="33%" scope="row">Guid index:</th>
<td width="67%"><input class="button" type="submit" name="create_index" value="Create index on guid column in posts database table" />
<p>Creating this index may significantly improve performance on some large
FeedWordPress installations.</p></td>
</tr>
</table>
<?php 
    fwp_option_box_closer();
    fwp_linkedit_periodic_submit();
    fwp_linkedit_single_submit_closer();
    ?>
</div>
</form>

</div> <!-- id="poststuff" -->
</div> <!-- class="wrap" -->
<?php 
}
function fwp_posts_page()
{
    global $wp_db_version;
    global $fwp_post;
    if (FeedWordPress::needs_upgrade()) {
        fwp_upgrade_page();
        return;
    }
    // If this is a POST, validate source and user credentials
    FeedWordPressCompatibility::validate_http_request('feedwordpress_posts_settings', 'manage_links');
    $link = FeedWordPressAdminPage::submitted_link();
    $postsPage = new FeedWordPressPostsPage($link);
    $mesg = null;
    ////////////////////////////////////////////////
    // Process POST request, if any ////////////////
    ////////////////////////////////////////////////
    if (strtoupper($_SERVER['REQUEST_METHOD']) == 'POST') {
        $postsPage->accept_POST($fwp_post);
        do_action('feedwordpress_admin_page_posts_save', $fwp_post, $postsPage);
    }
    $postsPage->ajax_interface_js();
    if ($postsPage->updated) {
        ?>
<div class="updated"><p>Syndicated posts settings updated.</p></div>
<?php 
    } elseif (!is_null($mesg)) {
        ?>
<div class="updated"><p><?php 
        print esc_html($mesg);
        ?>
</p></div>
<?php 
    }
    ?>

<?php 
    $links = FeedWordPress::syndicated_links();
    $postsPage->open_sheet('Syndicated Posts & Links');
    ?>
<style type="text/css">
	table.edit-form th, table.form-table th { width: 27%; vertical-align: top; }
	table.edit-form td, table.form-table td { width: 73%; vertical-align: top; }
	ul.options { margin: 0; padding: 0; list-style: none; }
</style>
<div id="post-body">
<?php 
    $boxes_by_methods = array('publication_box' => __('Syndicated Posts'), 'links_box' => __('Links'), 'formatting_box' => __('Formatting'), 'comments_and_pings_box' => __('Comments & Pings'), 'custom_post_settings_box' => __('Custom Post Settings (to apply to each syndicated post)'));
    foreach ($boxes_by_methods as $method => $title) {
        fwp_add_meta_box('feedwordpress_' . $method, $title, array('FeedWordPressPostsPage', $method), $postsPage->meta_box_context(), $postsPage->meta_box_context());
    }
    do_action('feedwordpress_admin_page_posts_meta_boxes', $postsPage);
    ?>
	<div class="metabox-holder">
<?php 
    fwp_do_meta_boxes($postsPage->meta_box_context(), $postsPage->meta_box_context(), $postsPage);
    ?>
	</div> <!-- class="metabox-holder" -->
</div> <!-- id="post-body" -->
<?php 
    $postsPage->close_sheet();
}
    function display()
    {
        global $fwp_post;
        global $post_source;
        if (FeedWordPress::needs_upgrade()) {
            fwp_upgrade_page();
            return;
        }
        // Allow overriding of normal source for FeedFinder, which may
        // be called from multiple points.
        if (isset($post_source) and !is_null($post_source)) {
            $source = $post_source;
        } else {
            $source = get_class($this);
        }
        // If this is a POST, validate source and user credentials
        FeedWordPressCompatibility::validate_http_request($source, 'manage_links');
        if (isset($_REQUEST['feedfinder']) or isset($_REQUEST['action']) and $_REQUEST['action'] == 'feedfinder' or isset($_REQUEST['action']) and $_REQUEST['action'] == FWP_SYNDICATE_NEW) {
            return $this->display_feedfinder();
            // re-route to Feed Finder page
        } else {
            if (strtoupper($_SERVER['REQUEST_METHOD']) == 'POST') {
                $this->accept_POST($fwp_post);
                do_action('feedwordpress_admin_page_feeds_save', $GLOBALS['fwp_post'], $this);
            }
            ////////////////////////////////////////////////
            // Prepare settings page ///////////////////////
            ////////////////////////////////////////////////
            $this->ajax_interface_js();
            $this->display_update_notice_if_updated('Syndicated feed');
            $this->open_sheet('Feed and Update');
            ?>
			<div id="post-body">
			<?php 
            ////////////////////////////////////////////////
            // Display settings boxes //////////////////////
            ////////////////////////////////////////////////
            $boxes_by_methods = array('feed_information_box' => __('Feed Information'), 'global_feeds_box' => __('Update Scheduling'), 'updated_posts_box' => __('Updated Posts'), 'posts_box' => __('Syndicated Posts, Links, Comments & Pings'), 'authors_box' => __('Syndicated Authors'), 'categories_box' => __('Categories' . FEEDWORDPRESS_AND_TAGS), 'custom_settings_box' => __('Custom Feed Settings (for use in templates)'));
            if ($this->for_default_settings()) {
                unset($boxes_by_methods['custom_settings_box']);
            }
            foreach ($boxes_by_methods as $method => $row) {
                if (is_array($row)) {
                    $id = $row['id'];
                    $title = $row['title'];
                } else {
                    $id = 'feedwordpress_' . $method;
                    $title = $row;
                }
                fwp_add_meta_box($id, $title, array(get_class($this), $method), $this->meta_box_context(), $this->meta_box_context());
            }
            do_action('feedwordpress_admin_page_feeds_meta_boxes', $this);
            ?>
			<div class="metabox-holder">
			<?php 
            fwp_do_meta_boxes($this->meta_box_context(), $this->meta_box_context(), $this);
            ?>
			</div> <!-- class="metabox-holder" -->
			</div> <!-- id="post-body" -->
			<?php 
            $this->close_sheet();
            ?>

			<script type="text/javascript">
				var els = ['name', 'description', 'url'];
				for (var i = 0; i < els.length; i++) {
					contextual_appearance(
						/*item=*/ 'basics-hardcode-'+els[i],
						/*appear=*/ 'basics-'+els[i]+'-view',
						/*disappear=*/ 'basics-'+els[i]+'-edit',
						/*value=*/ 'no',
						/*visibleStyle=*/ 'block',
						/*checkbox=*/ true
					);
				} /* for */
			</script>
			<?php 
        }
        return false;
        // Don't continue
    }
function fwp_authors_page()
{
    global $wp_db_version;
    if (FeedWordPress::needs_upgrade()) {
        fwp_upgrade_page();
        return;
    }
    FeedWordPressCompatibility::validate_http_request('feedwordpress_author_settings', 'manage_links');
    $link = FeedWordPressAdminPage::submitted_link();
    $authorsPage = new FeedWordPressAuthorsPage($link);
    $mesg = null;
    if (isset($GLOBALS['fwp_post']['fix_mismatch'])) {
        $fix_mismatch_to_id = $GLOBALS['fwp_post']['fix_mismatch_to'];
        $fix_mismatch_from_id = (int) $GLOBALS['fwp_post']['fix_mismatch_from'];
        if (is_numeric($fix_mismatch_from_id)) {
            // Make a list of all the items by this author syndicated from this feed...
            $args = array('posts_per_page' => -1, 'meta_key' => 'syndication_feed_id', 'meta_value' => $link->id, 'post_author' => $fix_mismatch_from_id);
            $query = new WP_Query($args);
            $mesg = '';
            $post_ids = array();
            if ($query->have_posts()) {
                while ($query->have_posts()) {
                    global $post;
                    $query->the_post();
                    if (is_numeric($fix_mismatch_to_id)) {
                        $post->post_author = $fix_mismatch_to_id;
                        $new_post = (array) $post;
                        wp_insert_post($new_post);
                        $mesg_action = 'Re-assigned';
                        $post_ids[] = get_the_ID();
                    } else {
                        if ($fix_mismatch_to_id == 'filter') {
                            wp_delete_post($post->ID);
                            $mesg_action = 'Re-assigned';
                            $post_ids[] = get_the_ID();
                        }
                    }
                }
                $mesg = $mesg_action . ' ' . count($post_ids) . ' post' . (count($post_ids) == 1 ? '' : 's') . '.';
            } else {
                $mesg = "Couldn't find any posts that matched your criteria.";
            }
        }
        $updated_link = false;
    } elseif (isset($GLOBALS['fwp_post']['save'])) {
        if (is_object($link) and $link->found()) {
            $alter = array();
            // Unfamiliar author rule
            if (isset($GLOBALS['fwp_post']["unfamiliar_author"])) {
                if ('site-default' == $GLOBALS['fwp_post']["unfamiliar_author"]) {
                    unset($link->settings["unfamiliar author"]);
                } else {
                    $link->settings["unfamiliar author"] = $GLOBALS['fwp_post']["unfamiliar_author"];
                }
            }
            // Handle author mapping rules
            if (isset($GLOBALS['fwp_post']['author_rules_name']) and isset($GLOBALS['fwp_post']['author_rules_action'])) {
                unset($link->settings['map authors']);
                foreach ($GLOBALS['fwp_post']['author_rules_name'] as $key => $name) {
                    // Normalize for case and whitespace
                    $name = strtolower(trim($name));
                    $author_action = strtolower(trim($GLOBALS['fwp_post']['author_rules_action'][$key]));
                    if (strlen($name) > 0) {
                        $link->settings['map authors']['name'][$name] = $author_action;
                    }
                }
            }
            if (isset($GLOBALS['fwp_post']['add_author_rule_name']) and isset($GLOBALS['fwp_post']['add_author_rule_action'])) {
                $name = strtolower(trim($GLOBALS['fwp_post']['add_author_rule_name']));
                $author_action = strtolower(trim($GLOBALS['fwp_post']['add_author_rule_action']));
                if (strlen($name) > 0) {
                    $link->settings['map authors']['name'][$name] = $author_action;
                }
            }
            // Save settings
            $link->save_settings(true);
            $updated_link = true;
            // Reset, reload
            $link_id = $link->id;
            unset($link);
            $link = new SyndicatedLink($link_id);
        } else {
            update_option('feedwordpress_unfamiliar_author', $GLOBALS['fwp_post']['unfamiliar_author']);
            if (isset($GLOBALS['fwp_post']['match_author_by_email']) and $GLOBALS['fwp_post']['match_author_by_email'] == 'yes') {
                update_option('feedwordpress_do_not_match_author_by_email', 'no');
            } else {
                update_option('feedwordpress_do_not_match_author_by_email', 'yes');
            }
            if (isset($GLOBALS['fwp_post']['null_emails'])) {
                update_option('feedwordpress_null_email_set', $GLOBALS['fwp_post']['null_emails']);
            }
            $updated_link = true;
        }
        do_action('feedwordpress_admin_page_authors_save', $GLOBALS['fwp_post'], $authorsPage);
        $authorsPage->refresh_author_list();
    } else {
        $updated_link = false;
    }
    ////////////////////////////////////////////////
    // Prepare settings page ///////////////////////
    ////////////////////////////////////////////////
    if ($updated_link) {
        ?>
<div class="updated"><p>Syndicated author settings updated.</p></div>
<?php 
    } elseif (!is_null($mesg)) {
        ?>
<div class="updated"><p><?php 
        print esc_html($mesg);
        ?>
</p></div>
<?php 
    }
    if (function_exists('add_meta_box')) {
        add_action(FeedWordPressCompatibility::bottom_script_hook(__FILE__), array($authorsPage, 'fix_toggles'), 10000);
        FeedWordPressSettingsUI::ajax_nonce_fields();
    }
    $authorsPage->open_sheet('Syndicated Author');
    ?>
	<div id="post-body">
	<?php 
    ////////////////////////////////////////////////
    // Display settings boxes //////////////////////
    ////////////////////////////////////////////////
    $boxes_by_methods = array('syndicated_authors_box' => __('Syndicated Authors'), 'fix_authors_box' => __('Reassign Authors'));
    if ($authorsPage->for_default_settings()) {
        unset($boxes_by_methods['fix_authors_box']);
    }
    foreach ($boxes_by_methods as $method => $row) {
        if (is_array($row)) {
            $id = $row['id'];
            $title = $row['title'];
        } else {
            $id = 'feedwordpress_' . $method;
            $title = $row;
        }
        fwp_add_meta_box($id, $title, array('FeedWordPressAuthorsPage', $method), $authorsPage->meta_box_context(), $authorsPage->meta_box_context());
    }
    do_action('feedwordpress_admin_page_authors_meta_boxes', $authorsPage);
    ?>
	<div class="metabox-holder">
<?php 
    fwp_do_meta_boxes($authorsPage->meta_box_context(), $authorsPage->meta_box_context(), $authorsPage);
    ?>
	</div> <!-- class="metabox-holder" -->
</div> <!-- id="post-body" -->
<?php 
    $authorsPage->close_sheet();
    ?>

<script type="text/javascript">
<?php 
    if (!is_object($link) or !$link->found()) {
        ?>
	contextual_appearance('match-author-by-email', 'unless-null-email', null, 'yes', 'block', /*checkbox=*/ true);
<?php 
    }
    ?>
</script>
<?php 
}
function fwp_syndication_manage_page()
{
    global $wpdb;
    if (FeedWordPress::needs_upgrade()) {
        fwp_upgrade_page();
        return;
    }
    $cont = true;
    if (isset($_REQUEST['action'])) {
        if ($_REQUEST['action'] == 'feedfinder' or $_REQUEST['action'] == FWP_SYNDICATE_NEW) {
            $cont = fwp_feedfinder_page();
        } elseif ($_REQUEST['action'] == 'switchfeed') {
            $cont = fwp_switchfeed_page();
        } elseif ($_REQUEST['action'] == 'linkedit') {
            $cont = fwp_linkedit_page();
        } elseif ($_REQUEST['action'] == FWP_UNSUB_CHECKED or $_REQUEST['action'] == 'Unsubscribe') {
            $cont = fwp_multidelete_page();
        }
    }
    if ($cont) {
        $links = FeedWordPress::syndicated_links();
        ?>
	<div class="wrap">
<?php 
        if (fwp_test_wp_version(FWP_SCHEMA_27)) {
            ?>
	<div class="icon32"><img src="<?php 
            print htmlspecialchars(WP_PLUGIN_URL . '/' . $GLOBALS['fwp_path'] . '/feedwordpress.png');
            ?>
" alt="" /></div>
	<h2>Syndicated Sites</h2>
<?php 
        }
        if (fwp_test_wp_version(0, FWP_SCHEMA_25)) {
            fwp_dashboard_update_if_requested();
        }
        if (fwp_test_wp_version(FWP_SCHEMA_27)) {
            ?>
		<script type="text/javascript">
			jQuery(document).ready( function($) {
				// In case someone got here first.
				$('.postbox h3, .postbox .handlediv').unbind('click');
				$('.hide-postbox-tog').unbind('click');
				$('.meta-box-sortables').sortable('destroy');

				postboxes.add_postbox_toggles('feedwordpress_syndication');
			} );
		</script>
<?php 
            echo "<form style='display: none' method='get' action=''>\n<p>\n";
            wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
            wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
            echo "</p>\n</form>\n";
            if ($links) {
                add_meta_box('feedwordpress_update_box', __('Update feeds now'), 'fwp_syndication_manage_page_update_box', 'feedwordpress_syndication', 'normal');
            }
            add_meta_box('feedwordpress_feeds_box', __('Syndicated sources'), 'fwp_syndication_manage_page_links_box', 'feedwordpress_syndication', 'normal');
            ?>
	<div class="metabox-holder">		
	<div id="feedwordpress-sortables" class="meta-box-sortables ui-sortable">
<?php 
            do_meta_boxes('feedwordpress_syndication', 'normal', NULL);
        } else {
            if ($links) {
                // only display Update panel if there are some links to update....
                fwp_syndication_manage_page_update_box();
            }
            fwp_syndication_manage_page_links_box();
            ?>
		</div> <!-- class="wrap" -->

		<?php 
            if (fwp_test_wp_version(0, FWP_SCHEMA_25)) {
                ?>
		<div class="wrap">
		<form action="admin.php?page=<?php 
                print $GLOBALS['fwp_path'];
                ?>
/<?php 
                echo basename(__FILE__);
                ?>
" method="post">
		<h2>Add a new syndicated site:</h2>
		<div>
		<label for="add-uri">Website or newsfeed:</label>
		<input type="text" name="lookup" id="add-uri" value="URI" size="64" />
		<input type="hidden" name="action" value="feedfinder" />
		</div>
		<div class="submit"><input type="submit" value="Syndicate &raquo;" /></div>
		</form>
		</div> <!-- class="wrap" -->
		<?php 
            }
            ?>

		<div style="display: none">
		<div id="tags-input"></div> <!-- avoid JS error from WP 2.5 bug -->
		</div>
<?php 
        }
    }
}
Пример #10
0
	function display () {
		if (FeedWordPress::needs_upgrade()) :
			fwp_upgrade_page();
			return;
		endif;

		FeedWordPressCompatibility::validate_http_request(/*action=*/ $this->dispatch, /*capability=*/ 'manage_links');

		////////////////////////////////////////////////
		// Process POST request, if any ////////////////
		////////////////////////////////////////////////
		if (strtoupper($_SERVER['REQUEST_METHOD'])=='POST') :
			$this->accept_POST($GLOBALS['fwp_post']);
		else :
			$this->updated = false;
		endif;

		////////////////////////////////////////////////
		// Prepare settings page ///////////////////////
		////////////////////////////////////////////////

		$this->display_update_notice_if_updated(
			$this->pagename('settings-update'),
			$this->update_message()
		);
		
		$this->open_sheet($this->pagename('open-sheet'));
		?>
		<div id="post-body">
		<?php
		foreach ($this->boxes_by_methods as $method => $row) :
			if (is_array($row)) :
				$id = $row['id'];
				$title = $row['title'];
			else :
				$id = 'feedwordpress_'.$method;
				$title = $row;
			endif;
	
			add_meta_box(
				/*id=*/ $id,
				/*title=*/ $title,
				/*callback=*/ array($this, $method),
				/*page=*/ $this->meta_box_context(),
				/*context=*/ $this->meta_box_context()
			);
		endforeach;
		do_action($this->dispatch.'_meta_boxes', $this);
		?>
		<div class="metabox-holder">
		<?php
			fwp_do_meta_boxes($this->meta_box_context(), $this->meta_box_context(), $this);
		?>
		</div> <!-- class="metabox-holder" -->
		</div> <!-- id="post-body" -->
		<?php $this->close_sheet(); ?>
	<?php
	}
    function display()
    {
        if (FeedWordPress::needs_upgrade()) {
            fwp_upgrade_page();
            return;
        }
        ?>
		<?php 
        $cont = true;
        $dispatcher = array("feedfinder" => 'fwp_feedfinder_page', FWP_SYNDICATE_NEW => 'fwp_feedfinder_page', "switchfeed" => 'fwp_switchfeed_page', FWP_UNSUB_CHECKED => 'fwp_multidelete_page', FWP_DELETE_CHECKED => 'fwp_multidelete_page', 'Unsubscribe' => 'fwp_multidelete_page', FWP_RESUB_CHECKED => 'fwp_multiundelete_page');
        if (isset($_REQUEST['action']) and isset($dispatcher[$_REQUEST['action']])) {
            $method = $dispatcher[$_REQUEST['action']];
            $cont = call_user_func($method);
        }
        if ($cont) {
            ?>
		<style type="text/css">
			.heads-up {
				background-color: #d0d0d0;
				color: black;
				padding: 1.0em;
				margin: 0.5em 4.0em !important;
			}
			.update-form.with-donation {
				margin-right: 50%;
				min-height: 255px;
			}
			.donation-form, .donation-thanks {
				background-color: #ffffcc;
				text-align: left;
				padding: 0.5em 0.5em;
				border-left: thin dashed #777777;
				font-size: 70%;
				position: absolute;
				top: 0; bottom: 0; right: 0; left: auto;
				width: 50%;		
			}
			.donation-thanks {
				background-color: #ccffcc;
			}
			.donation-thanks .signature {
				text-align: right;
				font-style: italic;
			}
			.donation-form h4, .donation-thanks h4 {
				font-size: 10px;
				text-align: center;
				border-bottom: 1px solid #777777;
				margin: 0px;
			}
			.donation-form .donate  {
				text-align: center;
			}
			.donation-form .sod-off {
				padding-top: 0.5em;
				margin-top: 0.5em;
				border-top: thin solid #777777;
			}
			.feed-missing {
				background-color:#FFFFD0;
			}
			.unsubscribed tr {
				background-color: #FFE0E0;
			}
			.unsubscribed tr.alternate {
				background-color: #FFF0F0;
			}
			tr.feed-error {
				background-color: #FFFFD0;
			}
		</style>
		<?php 
            $links = $this->sources('Y');
            $potential_updates = (!$this->show_inactive() and count($this->sources('Y')) > 0);
            $this->open_sheet('Syndicated Sites');
            ?>
			<div id="post-body">
			<?php 
            if ($potential_updates or count($this->updates_requested()) > 0) {
                fwp_add_meta_box('feedwordpress_update_box', __('Update feeds now'), 'fwp_syndication_manage_page_update_box', $this->meta_box_context(), $this->meta_box_context());
            }
            fwp_add_meta_box('feedwordpress_feeds_box', __('Syndicated sources'), 'fwp_syndication_manage_page_links_box', $this->meta_box_context(), $this->meta_box_context());
            if (FeedWordPressCompatibility::test_version(0, FWP_SCHEMA_25)) {
                fwp_add_meta_box('feedwordpress_add_feed_box', 'Add a new syndicated source', 'fwp_syndication_manage_page_add_feed_box', $this->meta_box_context(), $this->meta_box_context());
            }
            do_action('feedwordpress_admin_page_syndication_meta_boxes', $this);
            ?>
			<div class="metabox-holder">		
			<?php 
            fwp_do_meta_boxes($this->meta_box_context(), $this->meta_box_context(), $this);
            ?>
			</div> <!-- class="metabox-holder" -->
			</div> <!-- id="post-body" -->
		
			<?php 
            $this->close_sheet(NULL);
            ?>
		
			<div style="display: none">
			<div id="tags-input"></div> <!-- avoid JS error from WP 2.5 bug -->
			</div>
		<?php 
        }
    }
function fwp_categories_page()
{
    global $wp_db_version;
    if (FeedWordPress::needs_upgrade()) {
        fwp_upgrade_page();
        return;
    }
    FeedWordPressCompatibility::validate_http_request('feedwordpress_categories_settings', 'manage_links');
    $link = FeedWordPressAdminPage::submitted_link();
    $catsPage = new FeedWordPressCategoriesPage($link);
    $mesg = null;
    ////////////////////////////////////////////////
    // Process POST request, if any /////////////////
    ////////////////////////////////////////////////
    if (isset($GLOBALS['fwp_post']['save']) or isset($GLOBALS['fwp_post']['submit'])) {
        $saveCats = array();
        if (isset($GLOBALS['fwp_post']['post_category'])) {
            foreach ($GLOBALS['fwp_post']['post_category'] as $cat_id) {
                $saveCats[] = '{#' . $cat_id . '}';
            }
        }
        // Different variable names to cope with different WordPress AJAX UIs
        $syndicatedTags = array();
        if (isset($GLOBALS['fwp_post']['tax_input']['post_tag'])) {
            $syndicatedTags = explode(",", $GLOBALS['fwp_post']['tax_input']['post_tag']);
        } elseif (isset($GLOBALS['fwp_post']['tags_input'])) {
            $syndicatedTags = explode(",", $GLOBALS['fwp_post']['tags_input']);
        }
        $syndicatedTags = array_map('trim', $syndicatedTags);
        if (is_object($link) and $link->found()) {
            $alter = array();
            // Categories
            if (!empty($saveCats)) {
                $link->settings['cats'] = $saveCats;
            } else {
                unset($link->settings['cats']);
            }
            // Tags
            $link->settings['tags'] = $syndicatedTags;
            // Unfamiliar categories
            if (isset($GLOBALS['fwp_post']["unfamiliar_category"])) {
                if ('site-default' == $GLOBALS['fwp_post']["unfamiliar_category"]) {
                    unset($link->settings["unfamiliar category"]);
                } else {
                    $link->settings["unfamiliar category"] = $GLOBALS['fwp_post']["unfamiliar_category"];
                }
            }
            // Category spitting regex
            if (isset($GLOBALS['fwp_post']['cat_split'])) {
                if (strlen(trim($GLOBALS['fwp_post']['cat_split'])) > 0) {
                    $link->settings['cat_split'] = trim($GLOBALS['fwp_post']['cat_split']);
                } else {
                    unset($link->settings['cat_split']);
                }
            }
            // Save settings
            $link->save_settings(true);
            $catsPage->updated = true;
            // Reset, reload
            $link_id = $link->id;
            unset($link);
            $link = new SyndicatedLink($link_id);
        } else {
            // Categories
            if (!empty($saveCats)) {
                update_option('feedwordpress_syndication_cats', implode(FEEDWORDPRESS_CAT_SEPARATOR, $saveCats));
            } else {
                delete_option('feedwordpress_syndication_cats');
            }
            // Tags
            if (!empty($syndicatedTags)) {
                update_option('feedwordpress_syndication_tags', implode(FEEDWORDPRESS_CAT_SEPARATOR, $syndicatedTags));
            } else {
                delete_option('feedwordpress_syndication_tags');
            }
            update_option('feedwordpress_unfamiliar_category', $_REQUEST['unfamiliar_category']);
            $catsPage->updated = true;
        }
        do_action('feedwordpress_admin_page_categories_save', $GLOBALS['fwp_post'], $catsPage);
    } else {
        $catsPage->updated = false;
    }
    ////////////////////////////////////////////////
    // Prepare settings page ///////////////////////
    ////////////////////////////////////////////////
    $catsPage->display_update_notice_if_updated('Syndicated categories' . FEEDWORDPRESS_AND_TAGS, $mesg);
    $catsPage->open_sheet('Categories' . FEEDWORDPRESS_AND_TAGS);
    ?>
	<style type="text/css">
		table.edit-form th { width: 27%; vertical-align: top; }
		table.edit-form td { width: 73%; vertical-align: top; }
		table.edit-form td ul.options { margin: 0; padding: 0; list-style: none; }
	</style>

	<div id="post-body">
	<?php 
    ////////////////////////////////////////////////
    // Display settings boxes //////////////////////
    ////////////////////////////////////////////////
    $boxes_by_methods = array('feed_categories_box' => __('Feed Categories' . FEEDWORDPRESS_AND_TAGS), 'categories_box' => array('title' => __('Categories'), 'id' => 'categorydiv'), 'tags_box' => __('Tags'));
    if (!FeedWordPressCompatibility::post_tags()) {
        unset($boxes_by_methods['tags_box']);
    }
    foreach ($boxes_by_methods as $method => $row) {
        if (is_array($row)) {
            $id = $row['id'];
            $title = $row['title'];
        } else {
            $id = 'feedwordpress_' . $method;
            $title = $row;
        }
        fwp_add_meta_box($id, $title, array('FeedWordPressCategoriesPage', $method), $catsPage->meta_box_context(), $catsPage->meta_box_context());
    }
    do_action('feedwordpress_admin_page_categories_meta_boxes', $catsPage);
    ?>
	<div class="metabox-holder">
<?php 
    fwp_do_meta_boxes($catsPage->meta_box_context(), $catsPage->meta_box_context(), $catsPage);
    ?>
	</div> <!-- class="metabox-holder" -->
	</div> <!-- id="post-body" -->
	<?php 
    $catsPage->close_sheet();
}