PluginProbe
FeedWordPress / 2009.0613
FeedWordPress v2009.0613
trunk 0.8 0.9 0.91 0.95 0.96 0.97 0.98 0.981 0.99 0.991 0.992 0.993 2008.1030 2008.1101 2008.1105 2008.1214 2009.0612 2009.0613 2009.0618 2009.0707 2009.1111 2009.1112 2010.0127 2010.0528 All 65 releases
← All changes | posts-page.php +374 -503 2010.05282009.0613 View file →
@@ -1,572 +1,443 @@
1 1 <?php
2 2 require_once(dirname(__FILE__) . '/admin-ui.php');
3 -require_once(dirname(__FILE__) . '/updatedpostscontrol.class.php');
4 3
5 -class FeedWordPressPostsPage extends FeedWordPressAdminPage {
6 - var $link = NULL;
7 - var $updatedPosts = NULL;
4 +function fwp_posts_page () {
5 + global $wpdb, $wp_db_version;
8 6
9 - /**
10 - * Construct the posts page object.
11 - *
12 - * @param mixed $link An object of class {@link SyndicatedLink} if created for one feed's settings, NULL if created for global default settings
13 - */
14 - function FeedWordPressPostsPage ($link = NULL) {
15 - FeedWordPressAdminPage::FeedWordPressAdminPage('feedwordpresspostspage', $link);
16 - $this->dispatch = 'feedwordpress_posts_settings';
17 - $this->filename = __FILE__;
18 - $this->updatedPosts = new UpdatedPostsControl($this);
19 - } /* FeedWordPressPostsPage constructor */
7 + FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_posts_settings', /*capability=*/ 'manage_links');
20 8
21 - function accept_POST ($post) {
22 - global $wpdb;
9 + if (isset($GLOBALS['fwp_post']['save']) or isset($GLOBALS['fwp_post']['fix_mismatch'])) :
10 + $link_id = $_REQUEST['save_link_id'];
11 + elseif (isset($_REQUEST['link_id'])) :
12 + $link_id = $_REQUEST['link_id'];
13 + else :
14 + $link_id = NULL;
15 + endif;
23 16
24 - // User mashed a Save Changes button
25 - if (isset($post['save']) or isset($post['submit'])) :
26 - // custom post settings
27 - $custom_settings = $this->custom_post_settings();
17 + if (is_numeric($link_id) and $link_id) :
18 + $link =& new SyndicatedLink($link_id);
19 + else :
20 + $link = NULL;
21 + endif;
28 22
29 - foreach ($post['notes'] as $mn) :
30 - $mn['key0'] = trim($mn['key0']);
31 - $mn['key1'] = trim($mn['key1']);
32 -
33 - if (strlen($mn['key0']) > 0) :
34 - unset($custom_settings[$mn['key0']]); // out with the old
35 - endif;
36 -
37 - if (($mn['action']=='update') and (strlen($mn['key1']) > 0)) :
38 - $custom_settings[$mn['key1']] = $mn['value']; // in with the new
39 - endif;
40 - endforeach;
41 -
42 - $this->updatedPosts->accept_POST($post);
43 - if ($this->for_feed_settings()) :
44 - $alter = array ();
45 -
46 - $this->link->settings['postmeta'] = serialize($custom_settings);
47 -
48 - if (isset($post['resolve_relative'])) :
49 - $this->link->settings['resolve relative'] = $post['resolve_relative'];
50 - endif;
51 - if (isset($post['munge_permalink'])) :
52 - $this->link->settings['munge permalink'] = $post['munge_permalink'];
53 - endif;
54 - if (isset($post['munge_comments_feed_links'])) :
55 - $this->link->settings['munge comments feed links'] = $post['munge_comments_feed_links'];
56 - endif;
23 + $mesg = null;
57 24
58 - // Post status, comment status, ping status
59 - foreach (array('post', 'comment', 'ping') as $what) :
60 - $sfield = "feed_{$what}_status";
61 - if (isset($post[$sfield])) :
62 - if ($post[$sfield]=='site-default') :
63 - unset($this->link->settings["{$what} status"]);
64 - else :
65 - $this->link->settings["{$what} status"] = $post[$sfield];
66 - endif;
67 - endif;
68 - endforeach;
25 + ////////////////////////////////////////////////
26 + // Process POST request, if any /////////////////
27 + ////////////////////////////////////////////////
28 + if (isset($GLOBALS['fwp_post']['save'])) :
29 + // custom post settings
30 + foreach ($GLOBALS['fwp_post']['notes'] as $mn) :
31 + $mn['key0'] = trim($mn['key0']);
32 + $mn['key1'] = trim($mn['key1']);
69 33
70 - // Save settings
71 - $this->link->save_settings(/*reload=*/ true);
72 - $this->updated = true;
34 + if (strlen($mn['key0']) > 0) :
35 + unset($custom_settings[$mn['key0']]); // out with the old
36 + endif;
37 +
38 + if (($mn['action']=='update') and (strlen($mn['key1']) > 0)) :
39 + $custom_settings[$mn['key1']] = $mn['value']; // in with the new
40 + endif;
41 + endforeach;
73 42
74 - // Reset, reload
75 - $link_id = $this->link->id;
76 - unset($this->link);
77 - $this->link = new SyndicatedLink($link_id);
78 - else :
79 - // update_option ...
80 - if (isset($post['feed_post_status'])) :
81 - update_option('feedwordpress_syndicated_post_status', $post['feed_post_status']);
82 - endif;
43 + if (is_object($link) and $link->found()) :
44 + $alter = array ();
83 45
84 - update_option('feedwordpress_custom_settings', serialize($custom_settings));
85 -
86 - update_option('feedwordpress_munge_permalink', $_REQUEST['munge_permalink']);
87 - update_option('feedwordpress_use_aggregator_source_data', $_REQUEST['use_aggregator_source_data']);
88 - update_option('feedwordpress_formatting_filters', $_REQUEST['formatting_filters']);
89 -
90 - if (isset($post['resolve_relative'])) :
91 - update_option('feedwordpress_resolve_relative', $post['resolve_relative']);
92 - endif;
93 - if (isset($post['munge_comments_feed_links'])) :
94 - update_option('feedwordpress_munge_comments_feed_links', $post['munge_comments_feed_links']);
95 - endif;
96 - if (isset($_REQUEST['feed_comment_status']) and ($_REQUEST['feed_comment_status'] == 'open')) :
97 - update_option('feedwordpress_syndicated_comment_status', 'open');
98 - else :
99 - update_option('feedwordpress_syndicated_comment_status', 'closed');
100 - endif;
46 + $link->settings['postmeta'] = serialize($custom_settings);
101 47
102 - if (isset($_REQUEST['feed_ping_status']) and ($_REQUEST['feed_ping_status'] == 'open')) :
103 - update_option('feedwordpress_syndicated_ping_status', 'open');
104 - else :
105 - update_option('feedwordpress_syndicated_ping_status', 'closed');
48 + // Post status, comment status, ping status
49 + foreach (array('post', 'comment', 'ping') as $what) :
50 + $sfield = "feed_{$what}_status";
51 + if (isset($GLOBALS['fwp_post'][$sfield])) :
52 + if ($GLOBALS['fwp_post'][$sfield]=='site-default') :
53 + unset($link->settings["{$what} status"]);
54 + else :
55 + $link->settings["{$what} status"] = $GLOBALS['fwp_post'][$sfield];
56 + endif;
106 57 endif;
107 -
108 - $this->updated = true;
109 - endif;
58 + endforeach;
59 +
60 + $alter[] = "link_notes = '".$wpdb->escape($link->settings_to_notes())."'";
110 61
111 - // Probably a "Go" button for the drop-down
112 - else :
113 - $this->updated = false;
114 - endif;
115 - }
62 + $alter_set = implode(", ", $alter);
116 63
117 - /**
118 - * Outputs "Publication" settings box.
119 - *
120 - * @since 2009.0713
121 - * @param object $page of class FeedWordPressPostsPage tells us whether this is
122 - * a page for one feed's settings or for global defaults
123 - * @param array $box
124 - *
125 - * @uses FeedWordPressPostsPage::these_posts_phrase()
126 - * @uses FeedWordPress::syndicated_status()
127 - * @uses SyndicatedLink::syndicated_status()
128 - * @uses SyndicatedPost::use_api()
129 - */
130 - /*static*/ function publication_box ($page, $box = NULL) {
131 - global $fwp_path;
132 -
133 - $post_status_global = FeedWordPress::syndicated_status('post', /*default=*/ 'publish');
134 - $thesePosts = $page->these_posts_phrase();
135 -
136 - // Set up array for selector
137 - $setting = array(
138 - 'publish' => array ('label' => "Publish %s immediately", 'checked' => ''),
139 - 'draft' => array('label' => "Save %s as drafts", 'checked' => ''),
140 - 'private' => array('label' => "Save %s as private posts", 'checked' => ''),
141 - );
142 - if (SyndicatedPost::use_api('post_status_pending')) :
143 - $setting['pending'] = array('label' => "Hold %s for review; mark as Pending", 'checked' => '');
144 - endif;
64 + // issue update query
65 + $result = $wpdb->query("
66 + UPDATE $wpdb->links
67 + SET $alter_set
68 + WHERE link_id='$link_id'
69 + ");
70 + $updated_link = true;
145 71
146 -
147 - if ($page->for_feed_settings()) :
148 - $href = $fwp_path.'/'.basename(__FILE__);
149 - $currently = str_replace('%s', '', strtolower(strtok($setting[$post_status_global]['label'], ';')));
150 - $setting['site-default'] = array('label' => "Use <a href=\"admin.php?page=${href}\">site-wide setting</a>", 'checked' => '');
151 - $setting['site-default']['label'] .= " (currently: <strong>${currently}</strong>)";
152 -
153 - $checked = $page->link->syndicated_status('post', 'site-default', /*fallback=*/ false);
72 + // reload link information from DB
73 + if (function_exists('clean_bookmark_cache')) :
74 + clean_bookmark_cache($link_id);
75 + endif;
76 + $link =& new SyndicatedLink($link_id);
154 77 else :
155 - $checked = $post_status_global;
156 - endif;
157 -
158 - // Re-order appropriately
159 - $selector = array();
160 - $order = array(
161 - 'site-default',
162 - 'publish',
163 - 'pending',
164 - 'draft',
165 - 'private',
166 - );
167 - foreach ($order as $line) :
168 - if (isset($setting[$line])) :
169 - $selector[$line] = $setting[$line];
78 + // update_option ...
79 + if (isset($GLOBALS['fwp_post']['feed_post_status'])) :
80 + update_option('feedwordpress_syndicated_post_status', $GLOBALS['fwp_post']['feed_post_status']);
170 81 endif;
171 - endforeach;
172 - $selector[$checked]['checked'] = ' checked="checked"';
173 -
174 - // Hey ho, let's go...
175 - ?>
176 - <style type="text/css">
177 - #syndicated-publication-form th { width: 27%; vertical-align: top; }
178 - #syndicated-publication-form td { width: 73%; vertical-align: top; }
179 - </style>
180 -
181 - <table id="syndicated-publication-form" class="form-table" cellspacing="2" cellpadding="5">
182 - <tr><th scope="row"><?php _e('New posts:'); ?></th>
183 - <td><ul class="options">
184 - <?php foreach ($selector as $code => $li) : ?>
185 - <li><label><input type="radio" name="feed_post_status"
186 - value="<?php print $code; ?>"<?php print $li['checked']; ?> />
187 - <?php print str_replace('%s', $thesePosts, $li['label']); ?></label></li>
188 - <?php endforeach; ?>
189 - </ul></td>
190 - </tr>
82 +
83 + update_option('feedwordpress_custom_settings', serialize($custom_settings));
191 84
192 - <?php $page->updatedPosts->display(); ?>
193 - </table>
85 + update_option('feedwordpress_munge_permalink', $_REQUEST['munge_permalink']);
86 + update_option('feedwordpress_use_aggregator_source_data', $_REQUEST['use_aggregator_source_data']);
87 + update_option('feedwordpress_formatting_filters', $_REQUEST['formatting_filters']);
88 +
89 + if (isset($_REQUEST['feed_comment_status']) and ($_REQUEST['feed_comment_status'] == 'open')) :
90 + update_option('feedwordpress_syndicated_comment_status', 'open');
91 + else :
92 + update_option('feedwordpress_syndicated_comment_status', 'closed');
93 + endif;
194 94
195 - <?php
196 - } /* FeedWordPressPostsPage::publication_box () */
95 + if (isset($_REQUEST['feed_ping_status']) and ($_REQUEST['feed_ping_status'] == 'open')) :
96 + update_option('feedwordpress_syndicated_ping_status', 'open');
97 + else :
98 + update_option('feedwordpress_syndicated_ping_status', 'closed');
99 + endif;
197 100
198 - /**
199 - * Outputs "Formatting" settings box
200 - *
201 - * @since 2009.0713
202 - * @param object $page of class FeedWordPressPostsPage tells us whether this is
203 - * a page for one feed's settings or for global defaults
204 - * @param array $box
205 - *
206 - */
207 - function formatting_box ($page, $box = NULL) {
208 - global $fwp_path;
209 - $thesePosts = $page->these_posts_phrase();
210 - $global_resolve_relative = get_option('feedwordpress_resolve_relative', 'yes');
211 - if ($page->for_feed_settings()) :
212 - $formatting_filters = null;
213 - $resolve_relative = $page->link->setting('resolve relative', NULL, 'default');
214 - $url = preg_replace('|/+$|', '', $page->link->homepage());
215 - $setting = array(
216 - 'yes' => __('resolve relative URIs'),
217 - 'no' => __('leave relative URIs unresolved'),
218 - );
219 - $href = $fwp_path.'/'.basename(__FILE__);
220 - else :
221 - $formatting_filters = get_option('feedwordpress_formatting_filters', 'no');
222 - $resolve_relative = $global_resolve_relative;
223 - $url = 'http://example.com';
101 + $updated_link = true;
224 102 endif;
225 - ?>
226 - <table class="form-table" cellspacing="2" cellpadding="5">
227 - <?php if (!is_null($formatting_filters)) : ?>
103 + else :
104 + $updated_link = false;
105 + endif;
228 106
229 - <tr><th scope="row">Formatting filters:</th>
230 - <td><select name="formatting_filters" size="1">
231 - <option value="no"<?php echo ($formatting_filters!='yes')?' selected="selected"':''; ?>>Protect syndicated posts from formatting filters</option>
232 - <option value="yes"<?php echo ($formatting_filters=='yes')?' selected="selected"':''; ?>>Expose syndicated posts to formatting filters</option>
233 - </select>
234 - <p class="setting-description">If you have trouble getting plugins to work that are supposed to insert
235 - elements after posts (like relevant links or a social networking
236 - <q>Share This</q> button), try changing this option to see if it fixes your
237 - problem.</p>
238 - </td></tr>
107 + ////////////////////////////////////////////////
108 + // Get defaults from database //////////////////
109 + ////////////////////////////////////////////////
239 110
240 - <?php endif; ?>
241 -
242 - <tr><th scope="row">Relative URIs:</th>
243 - <td>If link or image in a syndicated post from <code><?php print $url; ?></code>
244 - refers to a partial URI like <code>/about</code>, where should
245 - the syndicated copy point to?</p>
246 -
247 - <ul>
248 - <?php if ($page->for_feed_settings()) : ?>
249 - <li><p><label><input type="radio" name="resolve_relative" value='default' <?php echo ($resolve_relative=='default')?' checked="checked"':''; ?>/> Use <a href="admin.php?page=<?php print $href; ?>">site-wide setting</a><br/>
250 - <small style="margin-left: 2.0em;">Currently: <strong><?php print $setting[$global_resolve_relative]; ?></strong></small></label></p></li>
251 - <?php endif; ?>
252 - <li><p><label><input type="radio" name="resolve_relative" value="yes"<?php echo ($resolve_relative!='no' and $resolve_relative!='default')?' checked="checked"':''; ?>/> Resolve the URI so it points to <code><?php print $url; ?></code><br/>
253 - <small style="margin-left: 2.0em;"><code>/contact</code> is rewritten as <code><?php print $url; ?>/contact</code></label></small></p></li>
254 - <li><p><label><input type="radio" name="resolve_relative" value="no"<?php echo ($resolve_relative=='no')?' checked="checked"':''; ?>/> Leave relative URIs unchanged, so they point to this site<br/>
255 - <small style="margin-left: 2.0em;"><code>/contact</code> is left as <code>/contact</code></small></label></li>
256 - </ul>
257 - </td></tr>
258 -
259 - </table>
260 - <?php
261 - } /* FeedWordPressPostsPage::formatting_box() */
111 + $post_status_global = get_option('feedwordpress_syndicated_post_status');
112 + if (!$post_status_global) : $post_status_global = 'publish'; endif;
262 113
263 - /**
264 - * Output "Links" settings box
265 - *
266 - * @since 2009.0713
267 - * @param object $page of class FeedWordPressPostsPage tells us whether this is
268 - * a page for one feed's settings or for global defaults
269 - * @param array $box
270 - *
271 - */
272 - /*static*/ function links_box ($page, $box = NULL) {
273 - $setting = array(
274 - 'munge_permalink' => array(
275 - 'yes' => 'the copy on the original website',
276 - 'no' => 'the local copy on this website',
277 - ),
278 - );
114 + $comment_status_global = get_option('feedwordpress_syndicated_comment_status');
115 + if (!$comment_status_global) : $comment_status_global = 'closed'; endif;
279 116
280 - $global_munge_permalink = get_option('feedwordpress_munge_permalink');
281 - if ($page->for_feed_settings()) :
282 - $munge_permalink = $page->link->setting('munge permalink', NULL);
283 - else :
284 - $munge_permalink = $global_munge_permalink;
285 - $use_aggregator_source_data = get_option('feedwordpress_use_aggregator_source_data');
286 - endif;
117 + $ping_status_global = get_option('feedwordpress_syndicated_ping_status');
118 + if (!$ping_status_global) : $ping_status_global = 'closed'; endif;
287 119
288 - ?>
289 - <table class="form-table" cellspacing="2" cellpadding="5">
290 - <tr><th scope="row">Permalinks point to:</th>
291 - <td><ul class="options">
292 - <?php if ($page->for_feed_settings()) : ?>
293 - <li><label><input type="radio" name="munge_permalink" value="default"<?php echo ($munge_permalink!='yes' and $munge_permalink != 'no')?' checked="checked"':''; ?>/> use site-wide setting (currently <?php print $setting['munge_permalink'][$global_munge_permalink]; ?>)</label></li>
294 - <?php endif; ?>
295 - <li><label><input type="radio" name="munge_permalink" value="yes"<?php echo ($munge_permalink=='yes')?' checked="checked"':''; ?>><?php print $setting['munge_permalink']['yes']; ?></label></li>
296 - <li><label><input type="radio" name="munge_permalink" value="no"<?php echo ($munge_permalink=='no')?' checked="checked"':''; ?>><?php print $setting['munge_permalink']['no']; ?></label></li>
297 - </ul></td>
298 - </tr>
299 -
300 - <?php if (!$page->for_feed_settings()) : ?>
301 - <tr><th scope="row">Posts from aggregator feeds:</th>
302 - <td><ul class="options">
303 - <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>
304 - <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>
305 - </ul>
306 - <p class="setting-description">Some feeds (for example, those produced by FeedWordPress) aggregate content from several different sources, and include information about the original source of the post.
307 - This setting controls what FeedWordPress will give as the source of posts from
308 - such an aggregator feed.</p>
309 - </td></tr>
310 - <?php endif; ?>
311 - </table>
120 + $status['post'] = array('publish' => '', 'private' => '', 'draft' => '');
121 + if (SyndicatedPost::use_api('post_status_pending')) :
122 + $status['post']['pending'] = '';
123 + endif;
312 124
313 - <?php
314 - } /* FeedWordPressPostsPage::links_box() */
125 + $status['comment'] = array('open' => '', 'closed' => '');
126 + $status['ping'] = array('open' => '', 'closed' => '');
315 127
316 - /**
317 - * Output "Comments & Pings" settings box
318 - *
319 - * @since 2009.0713
320 - * @param object $page of class FeedWordPressPostsPage tells us whether this is
321 - * a page for one feed's settings or for global defaults
322 - * @param array $box
323 - *
324 - */
325 - /*static*/ function comments_and_pings_box ($page, $box = NULL) {
326 - global $fwp_path;
128 + if (is_object($link) and $link->found()) :
129 + $thePostsPhrase = __('posts from this feed');
327 130
328 - $setting = array();
329 - $selector = array();
330 -
331 - $whatsits = array(
332 - 'comment' => array('label' => __('Comments'), 'accept' => 'Allow comments'),
333 - 'ping' => array('label' => __('Pings'), 'accept' => 'Accept pings'),
334 - );
335 - $onThesePosts = 'on '.$page->these_posts_phrase();
336 -
337 - $selected = array(
338 - 'munge_comments_feed_links' => array('yes' => '', 'no' => '')
339 - );
131 + foreach (array('post', 'comment', 'ping') as $what) :
132 + $status[$what]['site-default'] = '';
133 + if (isset($link->settings["{$what} status"])) :
134 + $status[$what][$link->settings["{$what} status"]] = ' checked="checked"';
135 + else :
136 + $status[$what]['site-default'] = ' checked="checked"';
137 + endif;
138 + endforeach;
340 139
341 - $globalMungeCommentsFeedLinks = get_option('feedwordpress_munge_comments_feed_links', 'yes');
342 - if ($page->for_feed_settings()) :
343 - $selected['munge_comments_feed_links']['default'] = '';
344 -
345 - $sel = $page->link->setting('munge comments feed links', NULL, 'default');
346 - else :
347 - $sel = $globalMungeCommentsFeedLinks;
140 + $custom_settings = $link->settings["postmeta"];
141 + if ($custom_settings) :
142 + $custom_settings = unserialize($custom_settings);
348 143 endif;
349 - $selected['munge_comments_feed_links'][$sel] = ' checked="checked"';
350 144
351 - if ($globalMungeCommentsFeedLinks != 'no') : $siteWide = __('comment feeds from the original website');
352 - else : $siteWide = __('local comment feeds on this website');
145 + if (!is_array($custom_settings)) :
146 + $custom_settings = array();
353 147 endif;
148 + else :
149 + $thePostsPhrase = __('syndicated posts');
354 150
355 - foreach ($whatsits as $what => $how) :
356 - $whatsits[$what]['default'] = FeedWordPress::syndicated_status($what, /*default=*/ 'closed');
151 + $status['post'][$post_status_global] = ' checked="checked"';
152 + $status['comment'][$comment_status_global] = ' checked="checked"';
153 + $status['ping'][$ping_status_global] = ' checked="checked"';
357 154
358 - // Set up array for selector
359 - $setting = array(
360 - 'open' => array ('label' => "{$how['accept']} %s", 'checked' => ''),
361 - 'closed' => array('label' => "Don't ".strtolower($how['accept'])." %s", 'checked' => ''),
362 - );
363 - if ($page->for_feed_settings()) :
364 - $href = $fwp_path.'/'.basename(__FILE__);
365 - $currently = trim(str_replace('%s', '', strtolower(strtok($setting[$whatsits[$what]['default']]['label'], ';'))));
366 - $setting['site-default'] = array('label' => "Use <a href=\"admin.php?page=${href}\">site-wide setting</a>", 'checked' => '');
367 - $setting['site-default']['label'] .= " (currently: <strong>${currently}</strong>)";
368 -
369 - $checked = $page->link->syndicated_status($what, 'site-default', /*fallback=*/ false);
370 - else :
371 - $checked = $whatsits[$what]['default'];
372 - endif;
155 + $munge_permalink = get_option('feedwordpress_munge_permalink');
156 + $formatting_filters = get_option('feedwordpress_formatting_filters');
157 + $use_aggregator_source_data = get_option('feedwordpress_use_aggregator_source_data');
373 158
374 - // Re-order appropriately
375 - $selector[$what] = array();
376 - $order = array(
377 - 'site-default',
378 - 'open',
379 - 'closed',
380 - );
381 - foreach ($order as $line) :
382 - if (isset($setting[$line])) :
383 - $selector[$what][$line] = $setting[$line];
384 - endif;
385 - endforeach;
386 - $selector[$what][$checked]['checked'] = ' checked="checked"';
387 - endforeach;
388 -
389 - // Hey ho, let's go...
390 - ?>
391 - <table class="form-table" cellspacing="2" cellpadding="5">
392 - <?php foreach ($whatsits as $what => $how) : ?>
393 - <tr><th scope="row"><?php print $how['label']; ?>:</th>
394 - <td><ul class="options">
395 - <?php foreach ($selector[$what] as $code => $li) : ?>
396 - <li><label><input type="radio" name="feed_<?php print $what; ?>_status"
397 - value="<?php print $code; ?>"<?php print $li['checked']; ?> />
398 - <?php print trim(str_replace('%s', $onThesePosts, $li['label'])); ?></label></li>
399 - <?php endforeach; ?>
400 - </ul></td></tr>
401 - <?php endforeach; ?>
402 - <tr><th scope="row"><?php _e('Comment feeds'); ?></th>
403 - <td><p>When WordPress feeds and templates link to comments
404 - feeds for <?php print $page->these_posts_phrase(); ?>, the
405 - URLs for the feeds should...</p>
406 - <ul class="options">
407 - <?php if ($page->for_feed_settings()) : ?>
408 - <li><label><input type="radio" name="munge_comments_feed_links" value="default"<?php print $selected['munge_comments_feed_links']['default']; ?> /> Use <a href="admin.php?page=<?php print $href; ?>">site-wide setting</a> (currently: <strong><?php _e($siteWide); ?></strong>)</label></li>
409 - <?php endif; ?>
410 - <li><label><input type="radio" name="munge_comments_feed_links" value="yes"<?php print $selected['munge_comments_feed_links']['yes']; ?> /> <?php _e('Point to comment feeds from the original website (when provided by the syndicated feed)'); ?></label></li>
411 - <li><label><input type="radio" name="munge_comments_feed_links" value="no"<?php print $selected['munge_comments_feed_links']['no']; ?> /> <?php _e('Point to local comment feeds on this website'); ?></label></li>
412 - </ul></td></tr>
413 - </table>
414 -
415 - <?php
416 - } /* FeedWordPressPostsPage::comments_and_pings_box() */
417 -
418 - /*static*/ function custom_post_settings ($page = NULL) {
419 - if (is_null($page)) :
420 - $page = $this;
159 + $custom_settings = get_option('feedwordpress_custom_settings');
160 + if ($custom_settings) :
161 + $custom_settings = unserialize($custom_settings);
421 162 endif;
422 163
423 - if ($page->for_feed_settings()) :
424 - $custom_settings = $page->link->settings["postmeta"];
425 - else :
426 - $custom_settings = get_option('feedwordpress_custom_settings');
427 - endif;
428 -
429 - if ($custom_settings and !is_array($custom_settings)) :
430 - $custom_settings = unserialize($custom_settings);
431 - endif;
432 -
433 164 if (!is_array($custom_settings)) :
434 165 $custom_settings = array();
435 166 endif;
167 + endif;
168 +?>
169 +<script type="text/javascript">
170 + function contextual_appearance (item, appear, disappear, value, visibleStyle, checkbox) {
171 + if (typeof(visibleStyle)=='undefined') visibleStyle = 'block';
436 172
437 - return $custom_settings;
438 - } /* FeedWordPressPostsPage::custom_post_settings() */
173 + var rollup=document.getElementById(item);
174 + var newuser=document.getElementById(appear);
175 + var sitewide=document.getElementById(disappear);
176 + if (rollup) {
177 + if ((checkbox && rollup.checked) || (!checkbox && value==rollup.value)) {
178 + if (newuser) newuser.style.display=visibleStyle;
179 + if (sitewide) sitewide.style.display='none';
180 + } else {
181 + if (newuser) newuser.style.display='none';
182 + if (sitewide) sitewide.style.display=visibleStyle;
183 + }
184 + }
185 + }
186 +</script>
187 +
188 +<?php if ($updated_link) : ?>
189 +<div class="updated"><p>Syndicated posts settings updated.</p></div>
190 +<?php elseif (!is_null($mesg)) : ?>
191 +<div class="updated"><p><?php print wp_specialchars($mesg, 1); ?></p></div>
192 +<?php endif; ?>
193 +
194 +<div class="wrap">
195 +<form style="position: relative" action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
196 +<div><?php
197 + FeedWordPressCompatibility::stamp_nonce('feedwordpress_posts_settings');
198 +
199 + if (is_numeric($link_id) and $link_id) :
200 +?>
201 +<input type="hidden" name="save_link_id" value="<?php echo $link_id; ?>" />
202 +<?php
203 + else :
204 +?>
205 +<input type="hidden" name="save_link_id" value="*" />
206 +<?php
207 + endif;
208 +?>
209 +</div>
210 +
211 +<?php $links = FeedWordPress::syndicated_links(); ?>
212 +<?php if (fwp_test_wp_version(FWP_SCHEMA_27)) : ?>
213 + <div class="icon32"><img src="<?php print htmlspecialchars(WP_PLUGIN_URL.'/'.$GLOBALS['fwp_path'].'/feedwordpress.png'); ?>" alt="" /></div>
214 +<?php endif; ?>
215 +
216 +<h2>Syndicated Post Settings<?php if (!is_null($link) and $link->found()) : ?>: <?php echo wp_specialchars($link->link->link_name, 1); ?><?php endif; ?></h2>
217 +
218 +<style type="text/css">
219 + table.edit-form th { width: 27%; vertical-align: top; }
220 + table.edit-form td { width: 73%; vertical-align: top; }
221 + table.edit-form td ul.options { margin: 0; padding: 0; list-style: none; }
222 +</style>
223 +
224 +<?php if (fwp_test_wp_version(FWP_SCHEMA_27)) : ?>
225 + <style type="text/css">
226 + #post-search {
227 + float: right;
228 + margin:11px 12px 0;
229 + min-width: 130px;
230 + position:relative;
231 + }
232 + .fwpfs {
233 + color: #dddddd;
234 + background:#797979 url(<?php bloginfo('home') ?>/wp-admin/images/fav.png) repeat-x scroll left center;
235 + border-color:#777777 #777777 #666666 !important; -moz-border-radius-bottomleft:12px;
236 + -moz-border-radius-bottomright:12px;
237 + -moz-border-radius-topleft:12px;
238 + -moz-border-radius-topright:12px;
239 + border-style:solid;
240 + border-width:1px;
241 + line-height:15px;
242 + padding:3px 30px 4px 12px;
243 + }
244 + .fwpfs.slide-down {
245 + border-bottom-color: #626262;
246 + -moz-border-radius-bottomleft:0;
247 + -moz-border-radius-bottomright:0;
248 + -moz-border-radius-topleft:12px;
249 + -moz-border-radius-topright:12px;
250 + background-image:url(<?php bloginfo('home') ?>/wp-admin/images/fav-top.png);
251 + background-position:0 top;
252 + background-repeat:repeat-x;
253 + border-bottom-style:solid;
254 + border-bottom-width:1px;
255 + }
256 + </style>
439 257
440 - /**
441 - * Output "Custom Post Settings" settings box
442 - *
443 - * @since 2009.0713
444 - * @param object $page of class FeedWordPressPostsPage tells us whether this is
445 - * a page for one feed's settings or for global defaults
446 - * @param array $box
447 - */
448 - /*static*/ function custom_post_settings_box ($page, $box = NULL) {
449 - $custom_settings = FeedWordPressPostsPage::custom_post_settings($page);
450 - ?>
451 - <div id="postcustomstuff">
452 - <p>Custom fields can be used to add extra metadata to a post that you can <a href="http://codex.wordpress.org/Using_Custom_Fields">use in your theme</a>.</p>
453 - <table id="meta-list" cellpadding="3">
454 - <tr>
455 - <th>Key</th>
456 - <th>Value</th>
457 - <th>Action</th>
458 - </tr>
258 + <script type="text/javascript">
259 + jQuery(document).ready(function($){
260 + $('.fwpfs').toggle(
261 + function(){$('.fwpfs').removeClass('slideUp').addClass('slideDown'); setTimeout(function(){if ( $('.fwpfs').hasClass('slideDown') ) { $('.fwpfs').addClass('slide-down'); }}, 10) },
262 + function(){$('.fwpfs').removeClass('slideDown').addClass('slideUp'); setTimeout(function(){if ( $('.fwpfs').hasClass('slideUp') ) { $('.fwpfs').removeClass('slide-down'); }}, 10) }
263 + );
264 + $('.fwpfs').bind(
265 + 'change',
266 + function () { this.form.submit(); }
267 + );
268 + $('#post-search .button').css( 'display', 'none' );
269 + });
270 + </script>
271 +<?php endif; /* else : */?>
272 +<p id="post-search">
273 +<select name="link_id" class="fwpfs" style="max-width: 20.0em;">
274 + <option value="*"<?php if (is_null($link) or !$link->found()) : ?> selected="selected"<?php endif; ?>>- defaults for all feeds -</option>
275 +<?php if ($links) : foreach ($links as $ddlink) : ?>
276 + <option value="<?php print (int) $ddlink->link_id; ?>"<?php if (!is_null($link) and ($link->link->link_id==$ddlink->link_id)) : ?> selected="selected"<?php endif; ?>><?php print wp_specialchars($ddlink->link_name, 1); ?></option>
277 +<?php endforeach; endif; ?>
278 +</select>
279 +<input class="button" type="submit" name="go" value="<?php _e('Go') ?> &raquo;" />
280 +</p>
281 +<?php /* endif; */ ?>
459 282
460 - <?php
461 - $i = 0;
462 - foreach ($custom_settings as $key => $value) :
463 - ?>
464 - <tr style="vertical-align:top">
465 - <th width="30%" scope="row"><input type="hidden" name="notes[<?php echo $i; ?>][key0]" value="<?php echo esc_html($key); ?>" />
466 - <input id="notes-<?php echo $i; ?>-key" name="notes[<?php echo $i; ?>][key1]" value="<?php echo esc_html($key); ?>" /></th>
467 - <td width="60%"><textarea rows="2" cols="40" id="notes-<?php echo $i; ?>-value" name="notes[<?php echo $i; ?>][value]"><?php echo esc_html($value); ?></textarea></td>
468 - <td width="10%"><select name="notes[<?php echo $i; ?>][action]">
469 - <option value="update">save changes</option>
470 - <option value="delete">delete this setting</option>
471 - </select></td>
472 - </tr>
283 +<?php if (!is_null($link) and $link->found()) : ?>
284 + <p>These settings only affect posts syndicated from
285 + <strong><?php echo wp_specialchars($link->link->link_name, 1); ?></strong>.</p>
286 +<?php else : ?>
287 + <p>These settings affect posts syndicated from any feed unless they are overridden
288 + by settings for that specific feed.</p>
289 +<?php endif; ?>
473 290
474 - <?php
475 - $i++;
476 - endforeach;
477 - ?>
291 +<div id="poststuff">
292 +<div id="post-body">
293 +<?php fwp_option_box_opener('Publication', 'publicationdiv', 'postbox'); ?>
294 +<table class="form-table" cellspacing="2" cellpadding="5">
295 +<tr><th width="27%" scope="row" style="vertical-align:top">Status for new posts:</th>
296 +<td width="73%" style="vertical-align:top"><ul style="margin:0; list-style:none">
478 297
479 - <tr style="vertical-align: top">
480 - <th scope="row"><input type="text" size="10" name="notes[<?php echo $i; ?>][key1]" value="" /></th>
481 - <td><textarea name="notes[<?php echo $i; ?>][value]" rows="2" cols="40"></textarea>
482 - <p>Enter a text value, or a path to a data element from the syndicated item.<br/>
483 - For data elements, you can use an XPath-like syntax wrapped in <code>$( ... )</code>.<br/>
484 - <code>hello</code> = the text value <code><span style="background-color: #30FFA0;">hello</span></code><br/>
485 - <code>$(author/email)</code> = the contents of <code>&lt;author&gt;&lt;email&gt;<span style="background-color: #30FFA0">...</span>&lt;/email&gt;&lt;/author&gt;</code><br/>
486 - <code>$(media:content/@url)</code> = the contents of <code>&lt;media:content url="<span style="background-color: #30FFA0">...</span>"&gt;...&lt;/media:content&gt;</code></p>
487 - </td>
488 - <td><em>add new setting...</em><input type="hidden" name="notes[<?php echo $i; ?>][action]" value="update" /></td>
489 - </tr>
490 - </table>
491 - </div> <!-- id="postcustomstuff" -->
298 +<?php if (is_object($link) and $link->found()) : ?>
299 +<li><label><input type="radio" name="feed_post_status" value="site-default"
300 +<?php echo $status['post']['site-default']; ?> /> Use <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php print basename(__FILE__); ?>">site-wide setting</a>
301 +(currently: <strong><?php echo ($post_status_global ? $post_status_global : 'publish'); ?></strong>)</label></li>
302 +<?php endif; ?>
492 303
493 - <?php
494 - } /* FeedWordPressPostsPage::custom_post_settings_box() */
495 -}
304 +<li><label><input type="radio" name="feed_post_status" value="publish"
305 +<?php echo $status['post']['publish']; ?> /> Publish <?php print $thePostsPhrase; ?> immediately</label></li>
496 306
497 -function fwp_posts_page () {
498 - global $wpdb, $wp_db_version;
499 - global $fwp_post;
307 +<?php if (SyndicatedPost::use_api('post_status_pending')) : ?>
308 +<li><label><input type="radio" name="feed_post_status" value="pending"
309 +<?php echo $status['post']['pending']; ?>/> Hold <?php print $thePostsPhrase; ?> for review; mark as Pending</label></li>
310 +<?php endif; ?>
500 311
501 - if (FeedWordPress::needs_upgrade()) :
502 - fwp_upgrade_page();
503 - return;
504 - endif;
312 +<li><label><input type="radio" name="feed_post_status" value="draft"
313 +<?php echo $status['post']['draft']; ?> /> Save <?php print $thePostsPhrase; ?> as drafts</label></li>
314 +<li><label><input type="radio" name="feed_post_status" value="private"
315 +<?php echo $status['post']['private']; ?> /> Save <?php print $thePostsPhrase; ?> as private posts</label></li>
316 +</ul></td>
317 +</tr>
318 +</table>
319 +<?php
320 + fwp_option_box_closer();
321 +?>
505 322
506 - // If this is a POST, validate source and user credentials
507 - FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_posts_settings', /*capability=*/ 'manage_links');
323 +<?php if (!(is_object($link) and $link->found())) : ?>
324 +<?php fwp_option_box_opener('Formatting', 'formattingdiv', 'postbox'); ?>
325 +<table class="form-table" cellspacing="2" cellpadding="5">
326 +<tr><th scope="row">Formatting filters:</th>
327 +<td><select name="formatting_filters" size="1">
328 +<option value="no"<?php echo ($formatting_filters!='yes')?' selected="selected"':''; ?>>Protect syndicated posts from formatting filters</option>
329 +<option value="yes"<?php echo ($formatting_filters=='yes')?' selected="selected"':''; ?>>Expose syndicated posts to formatting filters</option>
330 +</select>
331 +<p class="setting-description">If you have trouble getting plugins to work that are supposed to insert
332 +elements after posts (like relevant links or a social networking
333 +<q>Share This</q> button), try changing this option to see if it fixes your
334 +problem.</p>
335 +</td></tr>
336 +</table>
337 +<?php fwp_option_box_closer(); ?>
508 338
509 - $link = FeedWordPressAdminPage::submitted_link();
339 +<?php
340 + fwp_option_box_opener('Links', 'linksdiv', 'postbox');
341 +?>
342 +<table class="form-table" cellspacing="2" cellpadding="5">
343 +<tr><th scope="row">Permalinks:</th>
344 +<td><select name="munge_permalink" size="1">
345 +<option value="yes"<?php echo ($munge_permalink=='yes')?' selected="selected"':''; ?>>point to the copy on the original website</option>
346 +<option value="no"<?php echo ($munge_permalink=='no')?' selected="selected"':''; ?>>point to the local copy on this website</option>
347 +</select></td>
348 +</tr>
510 349
511 - $postsPage = new FeedWordPressPostsPage($link);
350 +<tr><th scope="row">Posts from aggregator feeds:</th>
351 +<td><ul class="options">
352 +<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>
353 +<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>
354 +</ul>
355 +<p class="setting-description">Some feeds (for example, those produced by FeedWordPress) aggregate content from several different sources, and include information about the original source of the post.
356 +This setting controls what FeedWordPress will give as the source of posts from
357 +such an aggregator feed.</p>
358 +</td></tr>
359 +</table>
360 +<?php
361 + fwp_option_box_closer();
362 + fwp_linkedit_periodic_submit();
363 +endif;
512 364
513 - $mesg = null;
365 + fwp_option_box_opener(__('Comments & Pings'), 'commentstatus', 'postbox');
366 +?>
367 +<table class="form-table" cellspacing="2" cellpadding="5">
368 +<tr><th scope="row"><?php print __('Comments') ?>:</th>
369 +<td><ul class="options">
370 +<?php if (is_object($link) and $link->found()) : ?>
371 +<li><label><input type="radio" name="feed_comment_status" value="site-default"
372 +<?php echo $status['comment']['site-default']; ?> /> Use <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php print basename(__FILE__); ?>">site-wide setting</a>
373 +(currently: <strong><?php echo $comment_status_global; ?></strong>)</label></li>
374 +<?php endif; ?>
514 375
515 - ////////////////////////////////////////////////
516 - // Process POST request, if any ////////////////
517 - ////////////////////////////////////////////////
518 - if (strtoupper($_SERVER['REQUEST_METHOD'])=='POST') :
519 - $postsPage->accept_POST($fwp_post);
520 - do_action('feedwordpress_admin_page_posts_save', $fwp_post, $postsPage);
521 - endif;
522 -
523 - $postsPage->ajax_interface_js();
376 +<li><label><input type="radio" name="feed_comment_status" value="open"<?php echo $status['comment']['open'] ?> /> Allow comments on syndicated posts</label></li>
377 +<li><label><input type="radio" name="feed_comment_status" value="closed"<?php echo $status['comment']['closed']; ?> /> Don't allow comments on syndicated posts</label></li>
378 +</ul></td></tr>
524 379
525 - if ($postsPage->updated) : ?>
526 -<div class="updated"><p>Syndicated posts settings updated.</p></div>
527 -<?php elseif (!is_null($mesg)) : ?>
528 -<div class="updated"><p><?php print esc_html($mesg); ?></p></div>
380 +<tr><th scope="row"><?php print __('Pings') ?>:</th>
381 +<td><ul class="options">
382 +<?php if (is_object($link) and $link->found()) : ?>
383 +<li><label><input type="radio" name="feed_ping_status" value="site-default"
384 +<?php echo $status['ping']['site-default']; ?> /> Use <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php print basename(__FILE__); ?>">site-wide setting</a>
385 +(currently: <strong><?php echo $ping_status_global; ?></strong>)</label></li>
529 386 <?php endif; ?>
530 387
388 +<li><label><input type="radio" name="feed_ping_status" value="open"<?php echo $status['ping']['open']; ?> /> Accept pings on syndicated posts</label></li>
389 +<li><label><input type="radio" name="feed_ping_status" value="closed"<?php echo $status['ping']['closed']; ?> /> Don't accept pings on syndicated posts</label></li>
390 +</ul></td></tr>
391 +</table>
531 392 <?php
532 - $links = FeedWordPress::syndicated_links();
533 - $postsPage->open_sheet('Syndicated Posts & Links');
393 + fwp_option_box_closer();
394 + fwp_linkedit_periodic_submit();
534 395 ?>
535 -<style type="text/css">
536 - table.edit-form th, table.form-table th { width: 27%; vertical-align: top; }
537 - table.edit-form td, table.form-table td { width: 73%; vertical-align: top; }
538 - ul.options { margin: 0; padding: 0; list-style: none; }
539 -</style>
540 -<div id="post-body">
396 +
397 +<?php fwp_option_box_opener('Custom Post Settings (to apply to each syndicated post)', 'postcustom', 'postbox'); ?>
398 +<div id="postcustomstuff">
399 +<table id="meta-list" cellpadding="3">
400 + <tr>
401 + <th>Key</th>
402 + <th>Value</th>
403 + <th>Action</th>
404 + </tr>
405 +
541 406 <?php
542 -$boxes_by_methods = array(
543 - 'publication_box' => __('Syndicated Posts'),
544 - 'links_box' => __('Links'),
545 - 'formatting_box' => __('Formatting'),
546 - 'comments_and_pings_box' => __('Comments & Pings'),
547 - 'custom_post_settings_box' => __('Custom Post Settings (to apply to each syndicated post)'),
548 -);
549 -
550 - foreach ($boxes_by_methods as $method => $title) :
551 - fwp_add_meta_box(
552 - /*id=*/ 'feedwordpress_'.$method,
553 - /*title=*/ $title,
554 - /*callback=*/ array('FeedWordPressPostsPage', $method),
555 - /*page=*/ $postsPage->meta_box_context(),
556 - /*context=*/ $postsPage->meta_box_context()
557 - );
558 - endforeach;
559 - do_action('feedwordpress_admin_page_posts_meta_boxes', $postsPage);
407 + $i = 0;
408 + foreach ($custom_settings as $key => $value) :
560 409 ?>
561 - <div class="metabox-holder">
410 + <tr style="vertical-align:top">
411 + <th width="30%" scope="row"><input type="hidden" name="notes[<?php echo $i; ?>][key0]" value="<?php echo wp_specialchars($key, 'both'); ?>" />
412 + <input id="notes-<?php echo $i; ?>-key" name="notes[<?php echo $i; ?>][key1]" value="<?php echo wp_specialchars($key, 'both'); ?>" /></th>
413 + <td width="60%"><textarea rows="2" cols="40" id="notes-<?php echo $i; ?>-value" name="notes[<?php echo $i; ?>][value]"><?php echo wp_specialchars($value, 'both'); ?></textarea></td>
414 + <td width="10%"><select name="notes[<?php echo $i; ?>][action]">
415 + <option value="update">save changes</option>
416 + <option value="delete">delete this setting</option>
417 + </select></td>
418 + </tr>
562 419 <?php
563 - fwp_do_meta_boxes($postsPage->meta_box_context(), $postsPage->meta_box_context(), $postsPage);
420 + $i++;
421 + endforeach;
564 422 ?>
565 - </div> <!-- class="metabox-holder" -->
566 -</div> <!-- id="post-body" -->
423 + <tr>
424 + <th scope="row"><input type="text" size="10" name="notes[<?php echo $i; ?>][key1]" value="" /></th>
425 + <td><textarea name="notes[<?php echo $i; ?>][value]" rows="2" cols="40"></textarea></td>
426 + <td><em>add new setting...</em><input type="hidden" name="notes[<?php echo $i; ?>][action]" value="update" /></td>
427 + </tr>
428 +</table>
429 +<?php fwp_option_box_closer(); ?>
430 +
431 +</div>
432 +</div>
433 +
434 +<p class="submit">
435 +<input class="button-primary" type="submit" name="save" value="Save Changes" />
436 +</p>
437 +</form>
438 +</div> <!-- class="wrap" -->
567 439 <?php
568 - $postsPage->close_sheet();
569 440 } /* function fwp_posts_page () */
570 441
571 442 fwp_posts_page();
572 443