| @@ -1,11 +1,9 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | require_once(dirname(__FILE__) . '/admin-ui.php'); |
| 3 | -require_once(dirname(__FILE__) . '/updatedpostscontrol.class.php'); | |
| 4 | 3 | |
| 5 | 4 | class FeedWordPressPostsPage extends FeedWordPressAdminPage { |
| 6 | 5 | var $link = NULL; |
| 7 | - var $updatedPosts = NULL; | |
| 8 | 6 | |
| 9 | 7 | /** |
| 10 | 8 | * Construct the posts page object. |
| 11 | 9 | * |
| @@ -14,106 +12,10 @@ | ||
| 14 | 12 | function FeedWordPressPostsPage ($link = NULL) { |
| 15 | 13 | FeedWordPressAdminPage::FeedWordPressAdminPage('feedwordpresspostspage', $link); |
| 16 | 14 | $this->dispatch = 'feedwordpress_posts_settings'; |
| 17 | 15 | $this->filename = __FILE__; |
| 18 | - $this->updatedPosts = new UpdatedPostsControl($this); | |
| 19 | 16 | } /* FeedWordPressPostsPage constructor */ |
| 20 | 17 | |
| 21 | - function accept_POST ($post) { | |
| 22 | - global $wpdb; | |
| 23 | - | |
| 24 | - $link_id = $this->link->id; | |
| 25 | - | |
| 26 | - // User mashed a Save Changes button | |
| 27 | - if (isset($post['save']) or isset($post['submit'])) : | |
| 28 | - // custom post settings | |
| 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 | - | |
| 52 | - // Post status, comment status, ping status | |
| 53 | - foreach (array('post', 'comment', 'ping') as $what) : | |
| 54 | - $sfield = "feed_{$what}_status"; | |
| 55 | - if (isset($post[$sfield])) : | |
| 56 | - if ($post[$sfield]=='site-default') : | |
| 57 | - unset($this->link->settings["{$what} status"]); | |
| 58 | - else : | |
| 59 | - $this->link->settings["{$what} status"] = $post[$sfield]; | |
| 60 | - endif; | |
| 61 | - endif; | |
| 62 | - endforeach; | |
| 63 | - | |
| 64 | - $alter[] = "link_notes = '".$wpdb->escape($this->link->settings_to_notes())."'"; | |
| 65 | - $alter_set = implode(", ", $alter); | |
| 66 | - | |
| 67 | - // issue update query | |
| 68 | - $result = $wpdb->query(" | |
| 69 | - UPDATE $wpdb->links | |
| 70 | - SET $alter_set | |
| 71 | - WHERE link_id='$link_id' | |
| 72 | - "); | |
| 73 | - $this->updated = true; | |
| 74 | - | |
| 75 | - // reload link information from DB | |
| 76 | - if (function_exists('clean_bookmark_cache')) : | |
| 77 | - clean_bookmark_cache($link_id); | |
| 78 | - endif; | |
| 79 | - $link =& new SyndicatedLink($link_id); | |
| 80 | - else : | |
| 81 | - // update_option ... | |
| 82 | - if (isset($post['feed_post_status'])) : | |
| 83 | - update_option('feedwordpress_syndicated_post_status', $post['feed_post_status']); | |
| 84 | - endif; | |
| 85 | - | |
| 86 | - update_option('feedwordpress_custom_settings', serialize($custom_settings)); | |
| 87 | - | |
| 88 | - update_option('feedwordpress_munge_permalink', $_REQUEST['munge_permalink']); | |
| 89 | - update_option('feedwordpress_use_aggregator_source_data', $_REQUEST['use_aggregator_source_data']); | |
| 90 | - update_option('feedwordpress_formatting_filters', $_REQUEST['formatting_filters']); | |
| 91 | - | |
| 92 | - if (isset($post['resolve_relative'])) : | |
| 93 | - update_option('feedwordpress_resolve_relative', $post['resolve_relative']); | |
| 94 | - endif; | |
| 95 | - if (isset($_REQUEST['feed_comment_status']) and ($_REQUEST['feed_comment_status'] == 'open')) : | |
| 96 | - update_option('feedwordpress_syndicated_comment_status', 'open'); | |
| 97 | - else : | |
| 98 | - update_option('feedwordpress_syndicated_comment_status', 'closed'); | |
| 99 | - endif; | |
| 100 | - | |
| 101 | - if (isset($_REQUEST['feed_ping_status']) and ($_REQUEST['feed_ping_status'] == 'open')) : | |
| 102 | - update_option('feedwordpress_syndicated_ping_status', 'open'); | |
| 103 | - else : | |
| 104 | - update_option('feedwordpress_syndicated_ping_status', 'closed'); | |
| 105 | - endif; | |
| 106 | - | |
| 107 | - $this->updated = true; | |
| 108 | - endif; | |
| 109 | - | |
| 110 | - // Probably a "Go" button for the drop-down | |
| 111 | - else : | |
| 112 | - $this->updated = false; | |
| 113 | - endif; | |
| 114 | - } | |
| 115 | - | |
| 116 | 18 | /** |
| 117 | 19 | * Outputs "Publication" settings box. |
| 118 | 20 | * |
| 119 | 21 | * @since 2009.0713 |
| @@ -142,10 +44,8 @@ | ||
| 142 | 44 | ); |
| 143 | 45 | if (SyndicatedPost::use_api('post_status_pending')) : |
| 144 | 46 | $setting['pending'] = array('label' => "Hold %s for review; mark as Pending", 'checked' => ''); |
| 145 | 47 | endif; |
| 146 | - | |
| 147 | - | |
| 148 | 48 | if ($page->for_feed_settings()) : |
| 149 | 49 | $href = $fwp_path.'/'.basename(__FILE__); |
| 150 | 50 | $currently = str_replace('%s', '', strtolower(strtok($setting[$post_status_global]['label'], ';'))); |
| 151 | 51 | $setting['site-default'] = array('label' => "Use <a href=\"admin.php?page=${href}\">site-wide setting</a>", 'checked' => ''); |
| @@ -179,9 +79,9 @@ | ||
| 179 | 79 | #syndicated-publication-form td { width: 73%; vertical-align: top; } |
| 180 | 80 | </style> |
| 181 | 81 | |
| 182 | 82 | <table id="syndicated-publication-form" class="form-table" cellspacing="2" cellpadding="5"> |
| 183 | - <tr><th scope="row"><?php _e('New posts:'); ?></th> | |
| 83 | + <tr><th scope="row">Status for new posts:</th> | |
| 184 | 84 | <td><ul class="options"> |
| 185 | 85 | <?php foreach ($selector as $code => $li) : ?> |
| 186 | 86 | <li><label><input type="radio" name="feed_post_status" |
| 187 | 87 | value="<?php print $code; ?>"<?php print $li['checked']; ?> /> |
| @@ -188,10 +88,8 @@ | ||
| 188 | 88 | <?php print str_replace('%s', $thesePosts, $li['label']); ?></label></li> |
| 189 | 89 | <?php endforeach; ?> |
| 190 | 90 | </ul></td> |
| 191 | 91 | </tr> |
| 192 | - | |
| 193 | - <?php $page->updatedPosts->display(); ?> | |
| 194 | 92 | </table> |
| 195 | 93 | |
| 196 | 94 | <?php |
| 197 | 95 | } /* FeedWordPressPostsPage::publication_box () */ |
| @@ -207,59 +105,21 @@ | ||
| 207 | 105 | * @uses fwp_option_box_opener() |
| 208 | 106 | * @uses fwp_option_box_closer() |
| 209 | 107 | */ |
| 210 | 108 | function formatting_box ($page, $box = NULL) { |
| 211 | - global $fwp_path; | |
| 212 | - $thesePosts = $page->these_posts_phrase(); | |
| 213 | - $global_resolve_relative = get_option('feedwordpress_resolve_relative', 'yes'); | |
| 214 | - if ($page->for_feed_settings()) : | |
| 215 | - $formatting_filters = null; | |
| 216 | - $resolve_relative = $page->link->setting('resolve relative', NULL, 'default'); | |
| 217 | - $url = preg_replace('|/+$|', '', $page->link->homepage()); | |
| 218 | - $setting = array( | |
| 219 | - 'yes' => __('resolve relative URIs'), | |
| 220 | - 'no' => __('leave relative URIs unresolved'), | |
| 221 | - ); | |
| 222 | - $href = $fwp_path.'/'.basename(__FILE__); | |
| 223 | - else : | |
| 224 | - $formatting_filters = get_option('feedwordpress_formatting_filters', 'no'); | |
| 225 | - $resolve_relative = $global_resolve_relative; | |
| 226 | - $url = 'http://example.com'; | |
| 227 | - endif; | |
| 109 | + $formatting_filters = get_option('feedwordpress_formatting_filters'); | |
| 228 | 110 | ?> |
| 229 | 111 | <table class="form-table" cellspacing="2" cellpadding="5"> |
| 230 | - <?php if (!is_null($formatting_filters)) : ?> | |
| 231 | - | |
| 232 | - <tr><th scope="row">Formatting filters:</th> | |
| 233 | - <td><select name="formatting_filters" size="1"> | |
| 234 | - <option value="no"<?php echo ($formatting_filters!='yes')?' selected="selected"':''; ?>>Protect syndicated posts from formatting filters</option> | |
| 235 | - <option value="yes"<?php echo ($formatting_filters=='yes')?' selected="selected"':''; ?>>Expose syndicated posts to formatting filters</option> | |
| 236 | - </select> | |
| 237 | - <p class="setting-description">If you have trouble getting plugins to work that are supposed to insert | |
| 238 | - elements after posts (like relevant links or a social networking | |
| 239 | - <q>Share This</q> button), try changing this option to see if it fixes your | |
| 240 | - problem.</p> | |
| 241 | - </td></tr> | |
| 242 | - | |
| 243 | - <?php endif; ?> | |
| 244 | - | |
| 245 | - <tr><th scope="row">Relative URIs:</th> | |
| 246 | - <td>If link or image in a syndicated post from <code><?php print $url; ?></code> | |
| 247 | - refers to a partial URI like <code>/about</code>, where should | |
| 248 | - the syndicated copy point to?</p> | |
| 249 | - | |
| 250 | - <ul> | |
| 251 | - <?php if ($page->for_feed_settings()) : ?> | |
| 252 | - <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/> | |
| 253 | - <small style="margin-left: 2.0em;">Currently: <strong><?php print $setting[$global_resolve_relative]; ?></strong></small></label></p></li> | |
| 254 | - <?php endif; ?> | |
| 255 | - <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/> | |
| 256 | - <small style="margin-left: 2.0em;"><code>/contact</code> is rewritten as <code><?php print $url; ?>/contact</code></label></small></p></li> | |
| 257 | - <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/> | |
| 258 | - <small style="margin-left: 2.0em;"><code>/contact</code> is left as <code>/contact</code></small></label></li> | |
| 259 | - </ul> | |
| 112 | + <tr><th scope="row">Formatting filters:</th> | |
| 113 | + <td><select name="formatting_filters" size="1"> | |
| 114 | + <option value="no"<?php echo ($formatting_filters!='yes')?' selected="selected"':''; ?>>Protect syndicated posts from formatting filters</option> | |
| 115 | + <option value="yes"<?php echo ($formatting_filters=='yes')?' selected="selected"':''; ?>>Expose syndicated posts to formatting filters</option> | |
| 116 | + </select> | |
| 117 | + <p class="setting-description">If you have trouble getting plugins to work that are supposed to insert | |
| 118 | + elements after posts (like relevant links or a social networking | |
| 119 | + <q>Share This</q> button), try changing this option to see if it fixes your | |
| 120 | + problem.</p> | |
| 260 | 121 | </td></tr> |
| 261 | - | |
| 262 | 122 | </table> |
| 263 | 123 | <?php |
| 264 | 124 | } /* FeedWordPressPostsPage::formatting_box() */ |
| 265 | 125 | |
| @@ -446,16 +306,14 @@ | ||
| 446 | 306 | } |
| 447 | 307 | |
| 448 | 308 | function fwp_posts_page () { |
| 449 | 309 | global $wpdb, $wp_db_version; |
| 450 | - global $fwp_post; | |
| 451 | - | |
| 310 | + | |
| 452 | 311 | if (FeedWordPress::needs_upgrade()) : |
| 453 | 312 | fwp_upgrade_page(); |
| 454 | 313 | return; |
| 455 | 314 | endif; |
| 456 | 315 | |
| 457 | - // If this is a POST, validate source and user credentials | |
| 458 | 316 | FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_posts_settings', /*capability=*/ 'manage_links'); |
| 459 | 317 | |
| 460 | 318 | $link = FeedWordPressAdminPage::submitted_link(); |
| 461 | 319 | $link_id = $link->id; |
| @@ -463,18 +321,94 @@ | ||
| 463 | 321 | |
| 464 | 322 | $mesg = null; |
| 465 | 323 | |
| 466 | 324 | //////////////////////////////////////////////// |
| 467 | - // Process POST request, if any //////////////// | |
| 325 | + // Process POST request, if any ///////////////// | |
| 468 | 326 | //////////////////////////////////////////////// |
| 469 | - if (strtoupper($_SERVER['REQUEST_METHOD'])=='POST') : | |
| 470 | - $postsPage->accept_POST($fwp_post); | |
| 471 | - do_action('feedwordpress_admin_page_posts_save', $fwp_post, $postsPage); | |
| 327 | + if (isset($GLOBALS['fwp_post']['save']) or isset($GLOBALS['fwp_post']['submit'])) : | |
| 328 | + // custom post settings | |
| 329 | + foreach ($GLOBALS['fwp_post']['notes'] as $mn) : | |
| 330 | + $mn['key0'] = trim($mn['key0']); | |
| 331 | + $mn['key1'] = trim($mn['key1']); | |
| 332 | + | |
| 333 | + if (strlen($mn['key0']) > 0) : | |
| 334 | + unset($custom_settings[$mn['key0']]); // out with the old | |
| 335 | + endif; | |
| 336 | + | |
| 337 | + if (($mn['action']=='update') and (strlen($mn['key1']) > 0)) : | |
| 338 | + $custom_settings[$mn['key1']] = $mn['value']; // in with the new | |
| 339 | + endif; | |
| 340 | + endforeach; | |
| 341 | + | |
| 342 | + if (is_object($link) and $link->found()) : | |
| 343 | + $alter = array (); | |
| 344 | + | |
| 345 | + $link->settings['postmeta'] = serialize($custom_settings); | |
| 346 | + | |
| 347 | + // Post status, comment status, ping status | |
| 348 | + foreach (array('post', 'comment', 'ping') as $what) : | |
| 349 | + $sfield = "feed_{$what}_status"; | |
| 350 | + if (isset($GLOBALS['fwp_post'][$sfield])) : | |
| 351 | + if ($GLOBALS['fwp_post'][$sfield]=='site-default') : | |
| 352 | + unset($link->settings["{$what} status"]); | |
| 353 | + else : | |
| 354 | + $link->settings["{$what} status"] = $GLOBALS['fwp_post'][$sfield]; | |
| 355 | + endif; | |
| 356 | + endif; | |
| 357 | + endforeach; | |
| 358 | + | |
| 359 | + $alter[] = "link_notes = '".$wpdb->escape($link->settings_to_notes())."'"; | |
| 360 | + | |
| 361 | + $alter_set = implode(", ", $alter); | |
| 362 | + | |
| 363 | + // issue update query | |
| 364 | + $result = $wpdb->query(" | |
| 365 | + UPDATE $wpdb->links | |
| 366 | + SET $alter_set | |
| 367 | + WHERE link_id='$link_id' | |
| 368 | + "); | |
| 369 | + $updated_link = true; | |
| 370 | + | |
| 371 | + // reload link information from DB | |
| 372 | + if (function_exists('clean_bookmark_cache')) : | |
| 373 | + clean_bookmark_cache($link_id); | |
| 374 | + endif; | |
| 375 | + $link =& new SyndicatedLink($link_id); | |
| 376 | + else : | |
| 377 | + // update_option ... | |
| 378 | + if (isset($GLOBALS['fwp_post']['feed_post_status'])) : | |
| 379 | + update_option('feedwordpress_syndicated_post_status', $GLOBALS['fwp_post']['feed_post_status']); | |
| 380 | + endif; | |
| 381 | + | |
| 382 | + update_option('feedwordpress_custom_settings', serialize($custom_settings)); | |
| 383 | + | |
| 384 | + update_option('feedwordpress_munge_permalink', $_REQUEST['munge_permalink']); | |
| 385 | + update_option('feedwordpress_use_aggregator_source_data', $_REQUEST['use_aggregator_source_data']); | |
| 386 | + update_option('feedwordpress_formatting_filters', $_REQUEST['formatting_filters']); | |
| 387 | + | |
| 388 | + if (isset($_REQUEST['feed_comment_status']) and ($_REQUEST['feed_comment_status'] == 'open')) : | |
| 389 | + update_option('feedwordpress_syndicated_comment_status', 'open'); | |
| 390 | + else : | |
| 391 | + update_option('feedwordpress_syndicated_comment_status', 'closed'); | |
| 392 | + endif; | |
| 393 | + | |
| 394 | + if (isset($_REQUEST['feed_ping_status']) and ($_REQUEST['feed_ping_status'] == 'open')) : | |
| 395 | + update_option('feedwordpress_syndicated_ping_status', 'open'); | |
| 396 | + else : | |
| 397 | + update_option('feedwordpress_syndicated_ping_status', 'closed'); | |
| 398 | + endif; | |
| 399 | + | |
| 400 | + $updated_link = true; | |
| 401 | + endif; | |
| 402 | + | |
| 403 | + do_action('feedwordpress_admin_page_posts_save', $GLOBALS['fwp_post'], $postsPage); | |
| 404 | + else : | |
| 405 | + $updated_link = false; | |
| 472 | 406 | endif; |
| 473 | 407 | |
| 474 | 408 | $postsPage->ajax_interface_js(); |
| 475 | 409 | |
| 476 | - if ($postsPage->updated) : ?> | |
| 410 | + if ($updated_link) : ?> | |
| 477 | 411 | <div class="updated"><p>Syndicated posts settings updated.</p></div> |
| 478 | 412 | <?php elseif (!is_null($mesg)) : ?> |
| 479 | 413 | <div class="updated"><p><?php print wp_specialchars($mesg, 1); ?></p></div> |
| 480 | 414 | <?php endif; ?> |
| @@ -490,11 +424,11 @@ | ||
| 490 | 424 | </style> |
| 491 | 425 | <div id="post-body"> |
| 492 | 426 | <?php |
| 493 | 427 | $boxes_by_methods = array( |
| 494 | - 'publication_box' => __('Syndicated Posts'), | |
| 428 | + 'publication_box' => __('Publication'), | |
| 429 | + 'formatting_box' => __('Formatting'), | |
| 495 | 430 | 'links_box' => __('Links'), |
| 496 | - 'formatting_box' => __('Formatting'), | |
| 497 | 431 | 'comments_and_pings_box' => __('Comments & Pings'), |
| 498 | 432 | 'custom_post_settings_box' => __('Custom Post Settings (to apply to each syndicated post)'), |
| 499 | 433 | ); |
| 500 | 434 | |
| @@ -499,8 +433,9 @@ | ||
| 499 | 433 | ); |
| 500 | 434 | |
| 501 | 435 | // Feed-level settings don't exist for these. |
| 502 | 436 | if ($postsPage->for_feed_settings()) : |
| 437 | + unset($boxes_by_methods['formatting_box']); | |
| 503 | 438 | unset($boxes_by_methods['links_box']); |
| 504 | 439 | endif; |
| 505 | 440 | |
| 506 | 441 | foreach ($boxes_by_methods as $method => $title) : |