PluginProbe
FeedWordPress / 2012.1212
FeedWordPress v2012.1212
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 +439 -368 2009.06122012.1212 View file →
@@ -1,86 +1,97 @@
1 1 <?php
2 2 require_once(dirname(__FILE__) . '/admin-ui.php');
3 +require_once(dirname(__FILE__) . '/updatedpostscontrol.class.php');
3 4
4 -function fwp_posts_page () {
5 - global $wpdb, $wp_db_version;
5 +class FeedWordPressPostsPage extends FeedWordPressAdminPage {
6 + var $link = NULL;
7 + var $updatedPosts = NULL;
6 8
7 - FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_posts_settings', /*capability=*/ 'manage_links');
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 = -1) {
15 + if (is_numeric($link) and -1 == $link) :
16 + $link = FeedWordPressAdminPage::submitted_link();
17 + endif;
8 18
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;
19 + FeedWordPressAdminPage::FeedWordPressAdminPage('feedwordpresspostspage', $link);
20 + $this->dispatch = 'feedwordpress_admin_page_posts';
21 + $this->filename = __FILE__;
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 + );
29 + } /* FeedWordPressPostsPage constructor */
16 30
17 - if (is_numeric($link_id) and $link_id) :
18 - $link =& new SyndicatedLink($link_id);
19 - else :
20 - $link = NULL;
21 - endif;
31 + function save_settings ($post) {
32 + // custom post settings
33 + $custom_settings = $this->custom_post_settings();
22 34
23 - $mesg = null;
35 + foreach ($post['notes'] as $mn) :
36 + if (isset($mn['key0'])) :
37 + $mn['key0'] = trim($mn['key0']);
38 + if (strlen($mn['key0']) > 0) :
39 + unset($custom_settings[$mn['key0']]); // out with the old
40 + endif;
41 + endif;
42 +
43 + if (isset($mn['key1'])) :
44 + $mn['key1'] = trim($mn['key1']);
24 45
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']);
33 -
34 - if (strlen($mn['key0']) > 0) :
35 - unset($custom_settings[$mn['key0']]); // out with the old
46 + if (($mn['action']=='update') and (strlen($mn['key1']) > 0)) :
47 + $custom_settings[$mn['key1']] = $mn['value']; // in with the new
48 + endif;
36 49 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 50 endforeach;
42 51
43 - if (is_object($link) and $link->found()) :
52 + $this->updatedPosts->accept_POST($post);
53 + if ($this->for_feed_settings()) :
44 54 $alter = array ();
45 55
46 - $link->settings['postmeta'] = serialize($custom_settings);
56 + $this->link->settings['postmeta'] = serialize($custom_settings);
47 57
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;
67 +
48 68 // Post status, comment status, ping status
49 69 foreach (array('post', 'comment', 'ping') as $what) :
50 70 $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"]);
71 + if (isset($post[$sfield])) :
72 + if ($post[$sfield]=='site-default') :
73 + unset($this->link->settings["{$what} status"]);
54 74 else :
55 - $link->settings["{$what} status"] = $GLOBALS['fwp_post'][$sfield];
75 + $this->link->settings["{$what} status"] = $post[$sfield];
56 76 endif;
57 77 endif;
58 78 endforeach;
59 79
60 - $alter[] = "link_notes = '".$wpdb->escape($link->settings_to_notes())."'";
80 + if (isset($post['syndicated_post_type'])) :
81 + if ($post['syndicated_post_type']=='default') :
82 + unset($this->link->settings['syndicated post type']);
83 + else :
84 + $this->link->settings['syndicated post type'] = $post['syndicated_post_type'];
85 + endif;
86 + endif;
61 87
62 - $alter_set = implode(", ", $alter);
63 -
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;
71 -
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);
77 88 else :
78 89 // update_option ...
79 - if (isset($GLOBALS['fwp_post']['feed_post_status'])) :
80 - update_option('feedwordpress_syndicated_post_status', $GLOBALS['fwp_post']['feed_post_status']);
90 + if (isset($post['feed_post_status'])) :
91 + update_option('feedwordpress_syndicated_post_status', $post['feed_post_status']);
81 92 endif;
82 -
93 +
83 94 update_option('feedwordpress_custom_settings', serialize($custom_settings));
84 95
85 96 update_option('feedwordpress_munge_permalink', $_REQUEST['munge_permalink']);
86 97 update_option('feedwordpress_use_aggregator_source_data', $_REQUEST['use_aggregator_source_data']);
@@ -85,359 +96,419 @@
85 96 update_option('feedwordpress_munge_permalink', $_REQUEST['munge_permalink']);
86 97 update_option('feedwordpress_use_aggregator_source_data', $_REQUEST['use_aggregator_source_data']);
87 98 update_option('feedwordpress_formatting_filters', $_REQUEST['formatting_filters']);
88 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;
89 106 if (isset($_REQUEST['feed_comment_status']) and ($_REQUEST['feed_comment_status'] == 'open')) :
90 107 update_option('feedwordpress_syndicated_comment_status', 'open');
91 108 else :
92 109 update_option('feedwordpress_syndicated_comment_status', 'closed');
93 110 endif;
94 -
111 +
95 112 if (isset($_REQUEST['feed_ping_status']) and ($_REQUEST['feed_ping_status'] == 'open')) :
96 113 update_option('feedwordpress_syndicated_ping_status', 'open');
97 114 else :
98 115 update_option('feedwordpress_syndicated_ping_status', 'closed');
99 116 endif;
100 -
101 - $updated_link = true;
117 +
118 + if (isset($post['syndicated_post_type'])) :
119 + update_option('feedwordpress_syndicated_post_type', $post['syndicated_post_type']);
120 + endif;
102 121 endif;
103 - else :
104 - $updated_link = false;
105 - endif;
122 + parent::save_settings($post);
123 + }
106 124
107 - ////////////////////////////////////////////////
108 - // Get defaults from database //////////////////
109 - ////////////////////////////////////////////////
125 + /**
126 + * Outputs "Publication" settings box.
127 + *
128 + * @since 2009.0713
129 + * @param object $page of class FeedWordPressPostsPage tells us whether this is
130 + * a page for one feed's settings or for global defaults
131 + * @param array $box
132 + *
133 + * @uses FeedWordPressPostsPage::these_posts_phrase()
134 + * @uses FeedWordPress::syndicated_status()
135 + * @uses SyndicatedLink::syndicated_status()
136 + * @uses SyndicatedPost::use_api()
137 + */
138 + /*static*/ function publication_box ($page, $box = NULL) {
139 + $thesePosts = $page->these_posts_phrase();
140 + $postSelector = array(
141 + 'publish' => "Publish %s immediately",
142 + 'pending' => "Hold %s for review; mark as Pending",
143 + 'draft' => "Save %s as drafts",
144 + 'private' => "Save %s as private posts",
145 + );
146 + $labels = array();
147 + foreach ($postSelector as $index => $value) :
148 + $postSelector[$index] = sprintf(__($value), $thesePosts);
149 + $labels[$index] = __(str_replace(' %s', '', strtolower(strtok($value, ';'))));
150 + endforeach;
151 +
152 + $params = array(
153 + 'input-name' => 'feed_post_status',
154 + 'setting-default' => NULL,
155 + 'global-setting-default' => 'publish',
156 + 'labels' => $labels,
157 + );
110 158
111 - $post_status_global = get_option('feedwordpress_syndicated_post_status');
112 - if (!$post_status_global) : $post_status_global = 'publish'; endif;
159 + // Hey ho, let's go...
160 + ?>
161 + <table id="syndicated-publication-form" class="edit-form narrow">
162 + <tr><th scope="row"><?php _e('New posts:'); ?></th>
163 + <td><?php
164 + $this->setting_radio_control(
165 + 'post status', 'syndicated_post_status',
166 + $postSelector, $params
167 + );
168 + ?>
169 + </td></tr>
170 +
171 + <?php $page->updatedPosts->display(); ?>
172 + </table>
113 173
114 - $comment_status_global = get_option('feedwordpress_syndicated_comment_status');
115 - if (!$comment_status_global) : $comment_status_global = 'closed'; endif;
174 + <?php
175 + } /* FeedWordPressPostsPage::publication_box () */
176 +
177 + /**
178 + * Outputs "Formatting" settings box
179 + *
180 + * @since 2009.0713
181 + * @param object $page of class FeedWordPressPostsPage tells us whether this is
182 + * a page for one feed's settings or for global defaults
183 + * @param array $box
184 + *
185 + */
186 + function formatting_box ($page, $box = NULL) {
187 + $thesePosts = $page->these_posts_phrase();
116 188
117 - $ping_status_global = get_option('feedwordpress_syndicated_ping_status');
118 - if (!$ping_status_global) : $ping_status_global = 'closed'; endif;
189 + if ($page->for_feed_settings()) :
190 + $formatting_filters = null;
191 + $url = preg_replace('|/+$|', '', $page->link->homepage());
192 + else :
193 + $formatting_filters = get_option('feedwordpress_formatting_filters', 'no');
194 + $url = 'http://example.com';
195 + endif;
196 + ?>
197 + <table class="edit-form narrow">
198 + <?php if (!is_null($formatting_filters)) : ?>
119 199
120 - $status['post'] = array('publish' => '', 'private' => '', 'draft' => '');
121 - if (SyndicatedPost::use_api('post_status_pending')) :
122 - $status['post']['pending'] = '';
123 - endif;
200 + <tr><th scope="row">Formatting filters:</th>
201 + <td><select name="formatting_filters" size="1">
202 + <option value="no"<?php echo ($formatting_filters!='yes')?' selected="selected"':''; ?>>Protect syndicated posts from formatting filters</option>
203 + <option value="yes"<?php echo ($formatting_filters=='yes')?' selected="selected"':''; ?>>Expose syndicated posts to formatting filters</option>
204 + </select>
205 + <p class="setting-description">If you have trouble getting plugins to work that are supposed to insert
206 + elements after posts (like relevant links or a social networking
207 + <q>Share This</q> button), try changing this option to see if it fixes your
208 + problem.</p>
209 + </td></tr>
124 210
125 - $status['comment'] = array('open' => '', 'closed' => '');
126 - $status['ping'] = array('open' => '', 'closed' => '');
127 -
128 - if (is_object($link) and $link->found()) :
129 - $thePostsPhrase = __('posts from this feed');
130 -
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;
211 + <?php endif; ?>
139 212
140 - $custom_settings = $link->settings["postmeta"];
141 - if ($custom_settings) :
142 - $custom_settings = unserialize($custom_settings);
143 - endif;
144 -
145 - if (!is_array($custom_settings)) :
146 - $custom_settings = array();
147 - endif;
148 - else :
149 - $thePostsPhrase = __('syndicated posts');
213 + <tr><th scope="row">Relative URIs:</th>
214 + <td><p>If link or image in a syndicated post from <code><?php print $url; ?></code>
215 + refers to a partial URI like <code>/about</code>, where should
216 + the syndicated copy point to?</p>
150 217
151 - $status['post'][$post_status_global] = ' checked="checked"';
152 - $status['comment'][$comment_status_global] = ' checked="checked"';
153 - $status['ping'][$ping_status_global] = ' checked="checked"';
218 + <?php
219 + $options = array(
220 + '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>',
221 + '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>',
222 + );
223 + $params = array(
224 + 'setting-default' => 'default',
225 + 'global-setting-default' => 'yes',
226 + 'labels' => array(
227 + 'yes' => __('resolve relative URIs'),
228 + 'no' => __('leave relative URIs unresolved'),
229 + ),
230 + 'default-input-value' => 'default',
231 + );
154 232
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');
233 + $this->setting_radio_control(
234 + 'resolve relative', 'resolve_relative',
235 + $options, $params
236 + );
237 + ?>
238 + </td></tr>
158 239
159 - $custom_settings = get_option('feedwordpress_custom_settings');
160 - if ($custom_settings) :
161 - $custom_settings = unserialize($custom_settings);
162 - endif;
240 + </table>
241 + <?php
242 + } /* FeedWordPressPostsPage::formatting_box() */
243 +
244 + /**
245 + * Output "Links" settings box
246 + *
247 + * @since 2009.0713
248 + * @param object $page of class FeedWordPressPostsPage tells us whether this is
249 + * a page for one feed's settings or for global defaults
250 + * @param array $box
251 + *
252 + */
253 + /*static*/ function links_box ($page, $box = NULL) {
254 + $setting = array(
255 + 'munge_permalink' => array(
256 + 'yes' => __('The copy on the original website'),
257 + 'no' => __('The local copy on this website'),
258 + ),
259 + );
163 260
164 - if (!is_array($custom_settings)) :
165 - $custom_settings = array();
261 + if (!$page->for_feed_settings()) :
262 + $use_aggregator_source_data = get_option('feedwordpress_use_aggregator_source_data');
166 263 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';
264 + ?>
265 + <table class="edit-form narrow">
266 + <tr><th scope="row">Permalinks point to:</th>
267 + <td><?php
268 +
269 + $params = array(
270 + 'setting-default' => 'default',
271 + 'global-setting-default' => 'yes',
272 + 'default-input-value' => 'default',
273 + );
274 + $this->setting_radio_control(
275 + 'munge permalink', 'munge_permalink',
276 + $setting['munge_permalink'], $params
277 + );
278 + ?>
172 279
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>
280 + </td></tr>
281 +
282 + <?php if (!$page->for_feed_settings()) : ?>
283 + <tr><th scope="row">Posts from aggregator feeds:</th>
284 + <td><ul class="options">
285 + <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>
286 + <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>
287 + </ul>
288 + <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.
289 + This setting controls what FeedWordPress will give as the source of posts from
290 + such an aggregator feed.</p>
291 + </td></tr>
292 + <?php endif; ?>
293 + </table>
187 294
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; ?>
295 + <?php
296 + } /* FeedWordPressPostsPage::links_box() */
193 297
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');
298 + /**
299 + * Output "Comments & Pings" settings box
300 + *
301 + * @since 2009.0713
302 + * @param object $page of class FeedWordPressPostsPage tells us whether this is
303 + * a page for one feed's settings or for global defaults
304 + * @param array $box
305 + *
306 + */
307 + /*static*/ function comments_and_pings_box ($page, $box = NULL) {
308 + $whatsits = array(
309 + 'comment' => array('label' => __('Comments'), 'accept' => 'Allow comments'),
310 + 'ping' => array('label' => __('Pings'), 'accept' => 'Accept pings'),
311 + );
312 + $onThesePosts = 'on '.$page->these_posts_phrase();
313 +
314 + $mcflSettings = array(
315 + "yes" => __('Point to comment feeds from the original website (when provided by the syndicated feed)'),
316 + "no" => __('Point to local comment feeds on this website'),
317 + );
318 + $mcflParams = array(
319 + 'setting-default' => 'default',
320 + 'global-setting-default' => 'yes',
321 + 'labels' => array(
322 + 'yes' => __('comment feeds from the original website'),
323 + 'no' => __('local comment feeds on this website')
324 + ),
325 + 'default-input-value' => 'default',
326 + );
198 327
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>
328 + $settings = array(); $params = array();
329 + foreach ($whatsits as $what => $how) :
330 + $whatsits[$what]['default'] = FeedWordPress::syndicated_status($what, /*default=*/ 'closed');
210 331
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>
257 -
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) }
332 + // Set up array for selector
333 + $settings[$what] = array(
334 + 'open' => sprintf(__("{$how['accept']} %s"), __($onThesePosts)),
335 + 'closed' => sprintf(__("Don't ".strtolower($how['accept'])." %s"), __($onThesePosts)),
263 336 );
264 - $('.fwpfs').bind(
265 - 'change',
266 - function () { this.form.submit(); }
337 + $params[$what] = array(
338 + 'input-name' => "feed_${what}_status",
339 + 'setting-default' => NULL,
340 + 'global-setting-default' => FeedWordPress::syndicated_status($what, /*default=*/ 'closed'),
341 + 'labels' => array(
342 + 'open' => strtolower(__($how['accept'])),
343 + 'closed' => strtolower(__("Don't ".$how['accept'])),
344 + ),
267 345 );
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; */ ?>
346 + endforeach;
282 347
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; ?>
348 + // Hey ho, let's go...
349 + ?>
350 + <table class="edit-form narrow">
351 + <?php foreach ($whatsits as $what => $how) : ?>
352 +
353 + <tr><th scope="row"><?php print $how['label']; ?>:</th>
354 + <td><?php
355 + $this->setting_radio_control(
356 + "$what status", "syndicated_${what}_status",
357 + $settings[$what], $params[$what]
358 + );
359 + ?></td></tr>
360 +
361 + <?php endforeach; ?>
362 +
363 + <tr><th scope="row"><?php _e('Comment feeds'); ?></th>
364 + <td><p>When WordPress feeds and templates link to comments
365 + feeds for <?php print $page->these_posts_phrase(); ?>, the
366 + URLs for the feeds should...</p>
367 + <?php
368 + $this->setting_radio_control(
369 + "munge comments feed links", "munge_comments_feed_links",
370 + $mcflSettings, $mcflParams
371 + );
372 + ?></td></tr>
373 + </table>
290 374
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">
375 + <?php
376 + } /* FeedWordPressPostsPage::comments_and_pings_box() */
377 +
378 + /*static*/ function custom_post_settings ($page = NULL) {
379 + if (is_null($page)) :
380 + $page = $this;
381 + endif;
297 382
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; ?>
383 + if ($page->for_feed_settings()) :
384 + $custom_settings = $page->link->setting("postmeta", NULL, array());
385 + else :
386 + $custom_settings = get_option('feedwordpress_custom_settings');
387 + endif;
303 388
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>
389 + if ($custom_settings and !is_array($custom_settings)) :
390 + $custom_settings = unserialize($custom_settings);
391 + endif;
392 +
393 + if (!is_array($custom_settings)) :
394 + $custom_settings = array();
395 + endif;
306 396
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; ?>
397 + return $custom_settings;
398 + } /* FeedWordPressPostsPage::custom_post_settings() */
399 +
400 + /**
401 + * Output "Custom Post Settings" settings box
402 + *
403 + * @since 2009.0713
404 + * @param object $page of class FeedWordPressPostsPage tells us whether this is
405 + * a page for one feed's settings or for global defaults
406 + * @param array $box
407 + */
408 + /*static*/ function custom_post_settings_box ($page, $box = NULL) {
409 + $custom_settings = FeedWordPressPostsPage::custom_post_settings($page);
410 + ?>
411 + <div id="postcustomstuff">
412 + <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>
413 + <table id="meta-list" cellpadding="3">
414 + <tr>
415 + <th>Key</th>
416 + <th>Value</th>
417 + <th>Action</th>
418 + </tr>
311 419
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 -?>
420 + <?php
421 + $i = 0;
422 + foreach ($custom_settings as $key => $value) :
423 + ?>
424 + <tr style="vertical-align:top">
425 + <th width="30%" scope="row"><input type="hidden" name="notes[<?php echo $i; ?>][key0]" value="<?php echo esc_html($key); ?>" />
426 + <input id="notes-<?php echo $i; ?>-key" name="notes[<?php echo $i; ?>][key1]" value="<?php echo esc_html($key); ?>" /></th>
427 + <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>
428 + <td width="10%"><select name="notes[<?php echo $i; ?>][action]">
429 + <option value="update">save changes</option>
430 + <option value="delete">delete this setting</option>
431 + </select></td>
432 + </tr>
322 433
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(); ?>
434 + <?php
435 + $i++;
436 + endforeach;
437 + ?>
338 438
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>
439 + <tr style="vertical-align: top">
440 + <th scope="row"><input type="text" size="10" name="notes[<?php echo $i; ?>][key1]" value="" /></th>
441 + <td><textarea name="notes[<?php echo $i; ?>][value]" rows="2" cols="40"></textarea>
442 + <p>Enter a text value, or a path to a data element from the syndicated item.<br/>
443 + For data elements, you can use an XPath-like syntax wrapped in <code>$( ... )</code>.<br/>
444 + <code>hello</code> = the text value <code><span style="background-color: #30FFA0;">hello</span></code><br/>
445 + <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/>
446 + <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>
447 + </td>
448 + <td><em>add new setting...</em><input type="hidden" name="notes[<?php echo $i; ?>][action]" value="update" /></td>
449 + </tr>
450 + </table>
451 + </div> <!-- id="postcustomstuff" -->
349 452
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;
453 + <?php
454 + } /* FeedWordPressPostsPage::custom_post_settings_box() */
364 455
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; ?>
456 + function custom_post_types_box ($page, $box = NULL) {
457 + global $fwp_path;
458 +
459 + // local: syndicated post type // default NULL
460 + // global: syndicated_post_type // default 'post'
461 + // default-input-value => 'default'
462 +
463 + // Get all custom post types
464 + $post_types = get_post_types(array(
465 + '_builtin' => false,
466 + ), 'objects');
375 467
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>
468 + $ul = array();
469 + $ul['post'] = __('Normal WordPress posts');
470 + foreach ($post_types as $post_type) :
471 + $ul[$post_type->name] = __($post_type->labels->name);
472 + endforeach;
473 +
474 + $params = array(
475 + 'global-setting-default' => 'post',
476 + 'default-input-value' => 'default',
477 + );
478 +
479 + // Hey, ho, let's go...
480 + ?>
481 + <table class="edit-form narrow">
482 + <tbody>
483 + <tr><th><?php _e('Custom Post Types:'); ?></th>
484 + <td><p>Incoming syndicated posts should be stored in the
485 + posts database as...</p>
486 + <?php
487 + $this->setting_radio_control(
488 + 'syndicated post type', 'syndicated_post_type',
489 + $ul, $params
490 + );
491 + ?>
492 + </td></tr>
493 + </tbody>
494 + </table>
495 + <?php
496 + } /* FeedWordPressPostsPage::custom_post_types_box() */
497 +
498 + function display () {
499 + $this->boxes_by_methods = array(
500 + 'publication_box' => __('Syndicated Posts'),
501 + 'links_box' => __('Links'),
502 + 'formatting_box' => __('Formatting'),
503 + 'comments_and_pings_box' => __('Comments & Pings'),
504 + 'custom_post_settings_box' => __('Custom Post Settings (to apply to each syndicated post)'),
505 + 'custom_post_types_box' => ('Custom Post Types (advanced database settings)'),
506 + );
507 +
508 + parent::display();
509 + } /* FeedWordPressPostsPage::display () */
510 +}
379 511
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>
386 -<?php endif; ?>
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>
392 -<?php
393 - fwp_option_box_closer();
394 - fwp_linkedit_periodic_submit();
395 -?>
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 -
406 -<?php
407 - $i = 0;
408 - foreach ($custom_settings as $key => $value) :
409 -?>
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>
419 -<?php
420 - $i++;
421 - endforeach;
422 -?>
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" -->
439 -<?php
440 -} /* function fwp_posts_page () */
441 -
442 - fwp_posts_page();
512 + $postsPage = new FeedWordPressPostsPage;
513 + $postsPage->display();
443 514