PluginProbe
FeedWordPress / 2017.0913
FeedWordPress v2017.0913
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 +256 -311 2010.05282017.0913 View file →
@@ -10,109 +10,117 @@
10 10 * Construct the posts page object.
11 11 *
12 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 13 */
14 - function FeedWordPressPostsPage ($link = NULL) {
15 - FeedWordPressAdminPage::FeedWordPressAdminPage('feedwordpresspostspage', $link);
16 - $this->dispatch = 'feedwordpress_posts_settings';
14 + public function __construct( $link = -1 ) {
15 + if (is_numeric($link) and -1 == $link) :
16 + $link = $this->submitted_link();
17 + endif;
18 +
19 + parent::__construct('feedwordpresspostspage', $link);
20 + $this->dispatch = 'feedwordpress_admin_page_posts';
17 21 $this->filename = __FILE__;
18 22 $this->updatedPosts = new UpdatedPostsControl($this);
23 +
24 + $this->pagenames = array(
25 + 'default' => 'Posts',
26 + 'settings-update' => 'Syndicated posts',
27 + 'open-sheet' => 'Syndicated Posts & Links',
28 + );
19 29 } /* FeedWordPressPostsPage constructor */
20 30
21 - function accept_POST ($post) {
22 - global $wpdb;
31 + function save_settings ($post) {
32 + // custom post settings
33 + $custom_settings = $this->custom_post_settings();
23 34
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();
28 -
29 - foreach ($post['notes'] as $mn) :
35 + foreach ($post['notes'] as $mn) :
36 + if (isset($mn['key0'])) :
30 37 $mn['key0'] = trim($mn['key0']);
31 - $mn['key1'] = trim($mn['key1']);
32 -
33 38 if (strlen($mn['key0']) > 0) :
34 39 unset($custom_settings[$mn['key0']]); // out with the old
35 40 endif;
41 + endif;
36 42
43 + if (isset($mn['key1'])) :
44 + $mn['key1'] = trim($mn['key1']);
45 +
37 46 if (($mn['action']=='update') and (strlen($mn['key1']) > 0)) :
38 47 $custom_settings[$mn['key1']] = $mn['value']; // in with the new
39 48 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;
49 + endif;
50 + endforeach;
57 51
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;
52 + $this->updatedPosts->accept_POST($post);
53 + if ($this->for_feed_settings()) :
54 + $alter = array ();
69 55
70 - // Save settings
71 - $this->link->save_settings(/*reload=*/ true);
72 - $this->updated = true;
56 + $this->link->settings['postmeta'] = serialize($custom_settings);
73 57
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;
58 + if (isset($post['resolve_relative'])) :
59 + $this->link->settings['resolve relative'] = $post['resolve_relative'];
60 + endif;
61 + if (isset($post['munge_permalink'])) :
62 + $this->link->settings['munge permalink'] = $post['munge_permalink'];
63 + endif;
64 + if (isset($post['munge_comments_feed_links'])) :
65 + $this->link->settings['munge comments feed links'] = $post['munge_comments_feed_links'];
66 + endif;
83 67
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']);
68 + // Post status, comment status, ping status
69 + foreach (array('post', 'comment', 'ping') as $what) :
70 + $sfield = "feed_{$what}_status";
71 + if (isset($post[$sfield])) :
72 + if ($post[$sfield]=='site-default') :
73 + unset($this->link->settings["{$what} status"]);
74 + else :
75 + $this->link->settings["{$what} status"] = $post[$sfield];
76 + endif;
92 77 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');
78 + endforeach;
79 +
80 + if (isset($post['syndicated_post_type'])) :
81 + if ($post['syndicated_post_type']=='default') :
82 + unset($this->link->settings['syndicated post type']);
98 83 else :
99 - update_option('feedwordpress_syndicated_comment_status', 'closed');
84 + $this->link->settings['syndicated post type'] = $post['syndicated_post_type'];
100 85 endif;
86 + endif;
101 87
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');
106 - endif;
107 -
108 - $this->updated = true;
88 + else :
89 + // update_option ...
90 + if (isset($post['feed_post_status'])) :
91 + update_option('feedwordpress_syndicated_post_status', $post['feed_post_status']);
109 92 endif;
110 93
111 - // Probably a "Go" button for the drop-down
112 - else :
113 - $this->updated = false;
114 - endif;
94 + update_option('feedwordpress_custom_settings', serialize($custom_settings));
95 +
96 + update_option('feedwordpress_munge_permalink', $_REQUEST['munge_permalink']);
97 + update_option('feedwordpress_use_aggregator_source_data', $_REQUEST['use_aggregator_source_data']);
98 + update_option('feedwordpress_formatting_filters', $_REQUEST['formatting_filters']);
99 +
100 + if (isset($post['resolve_relative'])) :
101 + update_option('feedwordpress_resolve_relative', $post['resolve_relative']);
102 + endif;
103 + if (isset($post['munge_comments_feed_links'])) :
104 + update_option('feedwordpress_munge_comments_feed_links', $post['munge_comments_feed_links']);
105 + endif;
106 + if (isset($_REQUEST['feed_comment_status']) and ($_REQUEST['feed_comment_status'] == 'open')) :
107 + update_option('feedwordpress_syndicated_comment_status', 'open');
108 + else :
109 + update_option('feedwordpress_syndicated_comment_status', 'closed');
110 + endif;
111 +
112 + if (isset($_REQUEST['feed_ping_status']) and ($_REQUEST['feed_ping_status'] == 'open')) :
113 + update_option('feedwordpress_syndicated_ping_status', 'open');
114 + else :
115 + update_option('feedwordpress_syndicated_ping_status', 'closed');
116 + endif;
117 +
118 + if (isset($post['syndicated_post_type'])) :
119 + update_option('feedwordpress_syndicated_post_type', $post['syndicated_post_type']);
120 + endif;
121 + endif;
122 + parent::save_settings($post);
115 123 }
116 124
117 125 /**
118 126 * Outputs "Publication" settings box.
@@ -124,71 +132,41 @@
124 132 *
125 133 * @uses FeedWordPressPostsPage::these_posts_phrase()
126 134 * @uses FeedWordPress::syndicated_status()
127 135 * @uses SyndicatedLink::syndicated_status()
128 - * @uses SyndicatedPost::use_api()
129 136 */
130 137 /*static*/ function publication_box ($page, $box = NULL) {
131 - global $fwp_path;
132 -
133 - $post_status_global = FeedWordPress::syndicated_status('post', /*default=*/ 'publish');
134 138 $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' => ''),
139 + $postSelector = array(
140 + 'publish' => "Publish %s immediately",
141 + 'pending' => "Hold %s for review; mark as Pending",
142 + 'draft' => "Save %s as drafts",
143 + 'private' => "Save %s as private posts",
141 144 );
142 - if (SyndicatedPost::use_api('post_status_pending')) :
143 - $setting['pending'] = array('label' => "Hold %s for review; mark as Pending", 'checked' => '');
144 - endif;
145 + $labels = array();
146 + foreach ($postSelector as $index => $value) :
147 + $postSelector[$index] = sprintf(__($value), $thesePosts);
148 + $labels[$index] = __(str_replace(' %s', '', strtolower(strtok($value, ';'))));
149 + endforeach;
150 +
151 + $params = array(
152 + 'input-name' => 'feed_post_status',
153 + 'setting-default' => NULL,
154 + 'global-setting-default' => 'publish',
155 + 'labels' => $labels,
156 + );
145 157
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);
154 - 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];
170 - endif;
171 - endforeach;
172 - $selector[$checked]['checked'] = ' checked="checked"';
173 -
174 158 // Hey ho, let's go...
175 159 ?>
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">
160 + <table id="syndicated-publication-form" class="edit-form narrow">
182 161 <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>
162 + <td><?php
163 + $this->setting_radio_control(
164 + 'post status', 'syndicated_post_status',
165 + $postSelector, $params
166 + );
167 + ?>
168 + </td></tr>
191 169
192 170 <?php $page->updatedPosts->display(); ?>
193 171 </table>
194 172
@@ -204,27 +182,19 @@
204 182 * @param array $box
205 183 *
206 184 */
207 185 function formatting_box ($page, $box = NULL) {
208 - global $fwp_path;
209 186 $thesePosts = $page->these_posts_phrase();
210 - $global_resolve_relative = get_option('feedwordpress_resolve_relative', 'yes');
187 +
211 188 if ($page->for_feed_settings()) :
212 189 $formatting_filters = null;
213 - $resolve_relative = $page->link->setting('resolve relative', NULL, 'default');
214 190 $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 191 else :
221 192 $formatting_filters = get_option('feedwordpress_formatting_filters', 'no');
222 - $resolve_relative = $global_resolve_relative;
223 193 $url = 'http://example.com';
224 194 endif;
225 195 ?>
226 - <table class="form-table" cellspacing="2" cellpadding="5">
196 + <table class="edit-form narrow">
227 197 <?php if (!is_null($formatting_filters)) : ?>
228 198
229 199 <tr><th scope="row">Formatting filters:</th>
230 200 <td><select name="formatting_filters" size="1">
@@ -239,22 +209,32 @@
239 209
240 210 <?php endif; ?>
241 211
242 212 <tr><th scope="row">Relative URIs:</th>
243 - <td>If link or image in a syndicated post from <code><?php print $url; ?></code>
213 + <td><p>If link or image in a syndicated post from <code><?php print $url; ?></code>
244 214 refers to a partial URI like <code>/about</code>, where should
245 215 the syndicated copy point to?</p>
246 216
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>
217 + <?php
218 + $options = array(
219 + 'yes' => 'Resolve the URI so it points to <code>'.$url.'</code><br/><small style="margin-left: 2.0em;"><code>/contact</code> is rewritten as <code>'.$url.'/contact</code></small>',
220 + 'no' => 'Leave relative URIs unchanged, so they point to this site<br/><small style="margin-left: 2.0em;"><code>/contact</code> is left as <code>/contact</code></small>',
221 + );
222 + $params = array(
223 + 'setting-default' => 'default',
224 + 'global-setting-default' => 'yes',
225 + 'labels' => array(
226 + 'yes' => __('resolve relative URIs'),
227 + 'no' => __('leave relative URIs unresolved'),
228 + ),
229 + 'default-input-value' => 'default',
230 + );
231 +
232 + $this->setting_radio_control(
233 + 'resolve relative', 'resolve_relative',
234 + $options, $params
235 + );
236 + ?>
257 237 </td></tr>
258 238
259 239 </table>
260 240 <?php
@@ -271,33 +251,34 @@
271 251 */
272 252 /*static*/ function links_box ($page, $box = NULL) {
273 253 $setting = array(
274 254 'munge_permalink' => array(
275 - 'yes' => 'the copy on the original website',
276 - 'no' => 'the local copy on this website',
255 + 'yes' => __('The copy on the original website'),
256 + 'no' => __('The local copy on this website'),
277 257 ),
278 258 );
279 259
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;
260 + if (!$page->for_feed_settings()) :
285 261 $use_aggregator_source_data = get_option('feedwordpress_use_aggregator_source_data');
286 262 endif;
287 -
288 263 ?>
289 - <table class="form-table" cellspacing="2" cellpadding="5">
264 + <table class="edit-form narrow">
290 265 <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>
266 + <td><?php
299 267
268 + $params = array(
269 + 'setting-default' => 'default',
270 + 'global-setting-default' => 'yes',
271 + 'default-input-value' => 'default',
272 + );
273 + $this->setting_radio_control(
274 + 'munge permalink', 'munge_permalink',
275 + $setting['munge_permalink'], $params
276 + );
277 + ?>
278 +
279 + </td></tr>
280 +
300 281 <?php if (!$page->for_feed_settings()) : ?>
301 282 <tr><th scope="row">Posts from aggregator feeds:</th>
302 283 <td><ul class="options">
303 284 <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>
@@ -322,95 +303,73 @@
322 303 * @param array $box
323 304 *
324 305 */
325 306 /*static*/ function comments_and_pings_box ($page, $box = NULL) {
326 - global $fwp_path;
327 -
328 - $setting = array();
329 - $selector = array();
330 -
331 307 $whatsits = array(
332 308 'comment' => array('label' => __('Comments'), 'accept' => 'Allow comments'),
333 309 'ping' => array('label' => __('Pings'), 'accept' => 'Accept pings'),
334 310 );
335 311 $onThesePosts = 'on '.$page->these_posts_phrase();
336 -
337 - $selected = array(
338 - 'munge_comments_feed_links' => array('yes' => '', 'no' => '')
312 +
313 + $mcflSettings = array(
314 + "yes" => __('Point to comment feeds from the original website (when provided by the syndicated feed)'),
315 + "no" => __('Point to local comment feeds on this website'),
339 316 );
340 -
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;
348 - endif;
349 - $selected['munge_comments_feed_links'][$sel] = ' checked="checked"';
350 -
351 - if ($globalMungeCommentsFeedLinks != 'no') : $siteWide = __('comment feeds from the original website');
352 - else : $siteWide = __('local comment feeds on this website');
353 - endif;
317 + $mcflParams = array(
318 + 'setting-default' => 'default',
319 + 'global-setting-default' => 'yes',
320 + 'labels' => array(
321 + 'yes' => __('comment feeds from the original website'),
322 + 'no' => __('local comment feeds on this website')
323 + ),
324 + 'default-input-value' => 'default',
325 + );
354 326
327 + $settings = array(); $params = array();
355 328 foreach ($whatsits as $what => $how) :
356 329 $whatsits[$what]['default'] = FeedWordPress::syndicated_status($what, /*default=*/ 'closed');
357 330
358 331 // 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' => ''),
332 + $settings[$what] = array(
333 + 'open' => sprintf(__("{$how['accept']} %s"), __($onThesePosts)),
334 + 'closed' => sprintf(__("Don't ".strtolower($how['accept'])." %s"), __($onThesePosts)),
362 335 );
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;
373 -
374 - // Re-order appropriately
375 - $selector[$what] = array();
376 - $order = array(
377 - 'site-default',
378 - 'open',
379 - 'closed',
336 + $params[$what] = array(
337 + 'input-name' => "feed_${what}_status",
338 + 'setting-default' => NULL,
339 + 'global-setting-default' => FeedWordPress::syndicated_status($what, /*default=*/ 'closed'),
340 + 'labels' => array(
341 + 'open' => strtolower(__($how['accept'])),
342 + 'closed' => strtolower(__("Don't ".$how['accept'])),
343 + ),
380 344 );
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 345 endforeach;
388 346
389 347 // Hey ho, let's go...
390 348 ?>
391 - <table class="form-table" cellspacing="2" cellpadding="5">
349 + <table class="edit-form narrow">
392 350 <?php foreach ($whatsits as $what => $how) : ?>
351 +
393 352 <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>
353 + <td><?php
354 + $this->setting_radio_control(
355 + "$what status", "syndicated_${what}_status",
356 + $settings[$what], $params[$what]
357 + );
358 + ?></td></tr>
359 +
401 360 <?php endforeach; ?>
361 +
402 362 <tr><th scope="row"><?php _e('Comment feeds'); ?></th>
403 363 <td><p>When WordPress feeds and templates link to comments
404 364 feeds for <?php print $page->these_posts_phrase(); ?>, the
405 365 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>
366 + <?php
367 + $this->setting_radio_control(
368 + "munge comments feed links", "munge_comments_feed_links",
369 + $mcflSettings, $mcflParams
370 + );
371 + ?></td></tr>
413 372 </table>
414 373
415 374 <?php
416 375 } /* FeedWordPressPostsPage::comments_and_pings_box() */
@@ -420,9 +379,9 @@
420 379 $page = $this;
421 380 endif;
422 381
423 382 if ($page->for_feed_settings()) :
424 - $custom_settings = $page->link->settings["postmeta"];
383 + $custom_settings = $page->link->setting("postmeta", NULL, array());
425 384 else :
426 385 $custom_settings = get_option('feedwordpress_custom_settings');
427 386 endif;
428 387
@@ -458,14 +417,18 @@
458 417 </tr>
459 418
460 419 <?php
461 420 $i = 0;
462 - foreach ($custom_settings as $key => $value) :
421 + $testerButton = '<br/><button id="xpath-test-%d"'
422 + .'class="xpath-test"'
423 + .'>test expression</button>';
424 + foreach ($custom_settings as $key => $value) :
463 425 ?>
464 426 <tr style="vertical-align:top">
465 427 <th width="30%" scope="row"><input type="hidden" name="notes[<?php echo $i; ?>][key0]" value="<?php echo esc_html($key); ?>" />
466 428 <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>
429 + <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>
430 + <?php print sprintf($testerButton, $i); ?></td>
468 431 <td width="10%"><select name="notes[<?php echo $i; ?>][action]">
469 432 <option value="update">save changes</option>
470 433 <option value="delete">delete this setting</option>
471 434 </select></td>
@@ -477,9 +440,9 @@
477 440 ?>
478 441
479 442 <tr style="vertical-align: top">
480 443 <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>
444 + <td><textarea name="notes[<?php echo $i; ?>][value]" rows="2" cols="40"></textarea><?php print sprintf($testerButton, $i); ?>
482 445 <p>Enter a text value, or a path to a data element from the syndicated item.<br/>
483 446 For data elements, you can use an XPath-like syntax wrapped in <code>$( ... )</code>.<br/>
484 447 <code>hello</code> = the text value <code><span style="background-color: #30FFA0;">hello</span></code><br/>
485 448 <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/>
@@ -490,83 +453,65 @@
490 453 </table>
491 454 </div> <!-- id="postcustomstuff" -->
492 455
493 456 <?php
494 - } /* FeedWordPressPostsPage::custom_post_settings_box() */
495 -}
457 + } /* FeedWordPressPostsPage::custom_post_settings_box() */
496 458
497 -function fwp_posts_page () {
498 - global $wpdb, $wp_db_version;
499 - global $fwp_post;
459 + function custom_post_types_box ($page, $box = NULL) {
460 + global $fwp_path;
461 +
462 + // local: syndicated post type // default NULL
463 + // global: syndicated_post_type // default 'post'
464 + // default-input-value => 'default'
465 +
466 + // Get all custom post types
467 + $post_types = get_post_types(array(
468 + '_builtin' => false,
469 + ), 'objects');
500 470
501 - if (FeedWordPress::needs_upgrade()) :
502 - fwp_upgrade_page();
503 - return;
504 - endif;
505 -
506 - // If this is a POST, validate source and user credentials
507 - FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_posts_settings', /*capability=*/ 'manage_links');
508 -
509 - $link = FeedWordPressAdminPage::submitted_link();
510 -
511 - $postsPage = new FeedWordPressPostsPage($link);
512 -
513 - $mesg = null;
514 -
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;
471 + $ul = array();
472 + $ul['post'] = __('Normal WordPress posts');
473 + foreach ($post_types as $post_type) :
474 + $ul[$post_type->name] = __($post_type->labels->name);
475 + endforeach;
476 +
477 + $params = array(
478 + 'global-setting-default' => 'post',
479 + 'default-input-value' => 'default',
480 + );
481 +
482 + // Hey, ho, let's go...
483 + ?>
484 + <table class="edit-form narrow">
485 + <tbody>
486 + <tr><th><?php _e('Custom Post Types:'); ?></th>
487 + <td><p>Incoming syndicated posts should be stored in the
488 + posts database as...</p>
489 + <?php
490 + $this->setting_radio_control(
491 + 'syndicated post type', 'syndicated_post_type',
492 + $ul, $params
493 + );
494 + ?>
495 + </td></tr>
496 + </tbody>
497 + </table>
498 + <?php
499 + } /* FeedWordPressPostsPage::custom_post_types_box() */
522 500
523 - $postsPage->ajax_interface_js();
524 -
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>
529 -<?php endif; ?>
530 -
531 -<?php
532 - $links = FeedWordPress::syndicated_links();
533 - $postsPage->open_sheet('Syndicated Posts & Links');
534 -?>
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">
541 -<?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()
501 + function display () {
502 + $this->boxes_by_methods = array(
503 + 'publication_box' => __('Syndicated Posts'),
504 + 'links_box' => __('Links'),
505 + 'formatting_box' => __('Formatting'),
506 + 'comments_and_pings_box' => __('Comments & Pings'),
507 + 'custom_post_settings_box' => __('Custom Post Settings (to apply to each syndicated post)'),
508 + 'custom_post_types_box' => ('Custom Post Types (advanced database settings)'),
557 509 );
558 - endforeach;
559 - do_action('feedwordpress_admin_page_posts_meta_boxes', $postsPage);
560 -?>
561 - <div class="metabox-holder">
562 -<?php
563 - fwp_do_meta_boxes($postsPage->meta_box_context(), $postsPage->meta_box_context(), $postsPage);
564 -?>
565 - </div> <!-- class="metabox-holder" -->
566 -</div> <!-- id="post-body" -->
567 -<?php
568 - $postsPage->close_sheet();
569 -} /* function fwp_posts_page () */
510 +
511 + parent::display();
512 + } /* FeedWordPressPostsPage::display () */
513 +}
570 514
571 - fwp_posts_page();
515 + $postsPage = new FeedWordPressPostsPage;
516 + $postsPage->display();
572 517