| @@ -1,33 +1,332 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | require_once(dirname(__FILE__) . '/admin-ui.php'); |
| 3 | 3 | |
| 4 | +class FeedWordPressPostsPage extends FeedWordPressAdminPage { | |
| 5 | + var $link = NULL; | |
| 6 | + | |
| 7 | + /** | |
| 8 | + * Construct the posts page object. | |
| 9 | + * | |
| 10 | + * @param mixed $link An object of class {@link SyndicatedLink} if created for one feed's settings, NULL if created for global default settings | |
| 11 | + */ | |
| 12 | + function FeedWordPressPostsPage ($link = NULL) { | |
| 13 | + FeedWordPressAdminPage::FeedWordPressAdminPage('feedwordpresspostspage', $link); | |
| 14 | + $this->dispatch = 'feedwordpress_posts_settings'; | |
| 15 | + $this->filename = __FILE__; | |
| 16 | + } /* FeedWordPressPostsPage constructor */ | |
| 17 | + | |
| 18 | + /** | |
| 19 | + * Outputs "Publication" settings box. | |
| 20 | + * | |
| 21 | + * @since 2009.0713 | |
| 22 | + * @param object $page of class FeedWordPressPostsPage tells us whether this is | |
| 23 | + * a page for one feed's settings or for global defaults | |
| 24 | + * @param array $box | |
| 25 | + * | |
| 26 | + * @uses FeedWordPressPostsPage::these_posts_phrase() | |
| 27 | + * @uses FeedWordPress::syndicated_status() | |
| 28 | + * @uses SyndicatedLink::syndicated_status() | |
| 29 | + * @uses SyndicatedPost::use_api() | |
| 30 | + * @uses fwp_option_box_opener() | |
| 31 | + * @uses fwp_option_box_closer() | |
| 32 | + */ | |
| 33 | + /*static*/ function publication_box ($page, $box = NULL) { | |
| 34 | + global $fwp_path; | |
| 35 | + | |
| 36 | + $post_status_global = FeedWordPress::syndicated_status('post', /*default=*/ 'publish'); | |
| 37 | + $thesePosts = $page->these_posts_phrase(); | |
| 38 | + | |
| 39 | + // Set up array for selector | |
| 40 | + $setting = array( | |
| 41 | + 'publish' => array ('label' => "Publish %s immediately", 'checked' => ''), | |
| 42 | + 'draft' => array('label' => "Save %s as drafts", 'checked' => ''), | |
| 43 | + 'private' => array('label' => "Save %s as private posts", 'checked' => ''), | |
| 44 | + ); | |
| 45 | + if (SyndicatedPost::use_api('post_status_pending')) : | |
| 46 | + $setting['pending'] = array('label' => "Hold %s for review; mark as Pending", 'checked' => ''); | |
| 47 | + endif; | |
| 48 | + if ($page->for_feed_settings()) : | |
| 49 | + $href = $fwp_path.'/'.basename(__FILE__); | |
| 50 | + $currently = str_replace('%s', '', strtolower(strtok($setting[$post_status_global]['label'], ';'))); | |
| 51 | + $setting['site-default'] = array('label' => "Use <a href=\"admin.php?page=${href}\">site-wide setting</a>", 'checked' => ''); | |
| 52 | + $setting['site-default']['label'] .= " (currently: <strong>${currently}</strong>)"; | |
| 53 | + | |
| 54 | + $checked = $page->link->syndicated_status('post', 'site-default', /*fallback=*/ false); | |
| 55 | + else : | |
| 56 | + $checked = $post_status_global; | |
| 57 | + endif; | |
| 58 | + | |
| 59 | + // Re-order appropriately | |
| 60 | + $selector = array(); | |
| 61 | + $order = array( | |
| 62 | + 'site-default', | |
| 63 | + 'publish', | |
| 64 | + 'pending', | |
| 65 | + 'draft', | |
| 66 | + 'private', | |
| 67 | + ); | |
| 68 | + foreach ($order as $line) : | |
| 69 | + if (isset($setting[$line])) : | |
| 70 | + $selector[$line] = $setting[$line]; | |
| 71 | + endif; | |
| 72 | + endforeach; | |
| 73 | + $selector[$checked]['checked'] = ' checked="checked"'; | |
| 74 | + | |
| 75 | + // Hey ho, let's go... | |
| 76 | + ?> | |
| 77 | + <style type="text/css"> | |
| 78 | + #syndicated-publication-form th { width: 27%; vertical-align: top; } | |
| 79 | + #syndicated-publication-form td { width: 73%; vertical-align: top; } | |
| 80 | + </style> | |
| 81 | + | |
| 82 | + <table id="syndicated-publication-form" class="form-table" cellspacing="2" cellpadding="5"> | |
| 83 | + <tr><th scope="row">Status for new posts:</th> | |
| 84 | + <td><ul class="options"> | |
| 85 | + <?php foreach ($selector as $code => $li) : ?> | |
| 86 | + <li><label><input type="radio" name="feed_post_status" | |
| 87 | + value="<?php print $code; ?>"<?php print $li['checked']; ?> /> | |
| 88 | + <?php print str_replace('%s', $thesePosts, $li['label']); ?></label></li> | |
| 89 | + <?php endforeach; ?> | |
| 90 | + </ul></td> | |
| 91 | + </tr> | |
| 92 | + </table> | |
| 93 | + | |
| 94 | + <?php | |
| 95 | + } /* FeedWordPressPostsPage::publication_box () */ | |
| 96 | + | |
| 97 | + /** | |
| 98 | + * Outputs "Formatting" settings box | |
| 99 | + * | |
| 100 | + * @since 2009.0713 | |
| 101 | + * @param object $page of class FeedWordPressPostsPage tells us whether this is | |
| 102 | + * a page for one feed's settings or for global defaults | |
| 103 | + * @param array $box | |
| 104 | + * | |
| 105 | + * @uses fwp_option_box_opener() | |
| 106 | + * @uses fwp_option_box_closer() | |
| 107 | + */ | |
| 108 | + function formatting_box ($page, $box = NULL) { | |
| 109 | + $formatting_filters = get_option('feedwordpress_formatting_filters'); | |
| 110 | + ?> | |
| 111 | + <table class="form-table" cellspacing="2" cellpadding="5"> | |
| 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> | |
| 121 | + </td></tr> | |
| 122 | + </table> | |
| 123 | + <?php | |
| 124 | + } /* FeedWordPressPostsPage::formatting_box() */ | |
| 125 | + | |
| 126 | + /** | |
| 127 | + * Output "Links" settings box | |
| 128 | + * | |
| 129 | + * @since 2009.0713 | |
| 130 | + * @param object $page of class FeedWordPressPostsPage tells us whether this is | |
| 131 | + * a page for one feed's settings or for global defaults | |
| 132 | + * @param array $box | |
| 133 | + * | |
| 134 | + * @uses fwp_option_box_opener() | |
| 135 | + * @uses fwp_option_box_closer() | |
| 136 | + */ | |
| 137 | + /*static*/ function links_box ($page, $box = NULL) { | |
| 138 | + $munge_permalink = get_option('feedwordpress_munge_permalink'); | |
| 139 | + $use_aggregator_source_data = get_option('feedwordpress_use_aggregator_source_data'); | |
| 140 | + ?> | |
| 141 | + <table class="form-table" cellspacing="2" cellpadding="5"> | |
| 142 | + <tr><th scope="row">Permalinks:</th> | |
| 143 | + <td><select name="munge_permalink" size="1"> | |
| 144 | + <option value="yes"<?php echo ($munge_permalink=='yes')?' selected="selected"':''; ?>>point to the copy on the original website</option> | |
| 145 | + <option value="no"<?php echo ($munge_permalink=='no')?' selected="selected"':''; ?>>point to the local copy on this website</option> | |
| 146 | + </select></td> | |
| 147 | + </tr> | |
| 148 | + | |
| 149 | + <tr><th scope="row">Posts from aggregator feeds:</th> | |
| 150 | + <td><ul class="options"> | |
| 151 | + <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> | |
| 152 | + <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> | |
| 153 | + </ul> | |
| 154 | + <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. | |
| 155 | + This setting controls what FeedWordPress will give as the source of posts from | |
| 156 | + such an aggregator feed.</p> | |
| 157 | + </td></tr> | |
| 158 | + </table> | |
| 159 | + | |
| 160 | + <?php | |
| 161 | + } /* FeedWordPressPostsPage::links_box() */ | |
| 162 | + | |
| 163 | + /** | |
| 164 | + * Output "Comments & Pings" settings box | |
| 165 | + * | |
| 166 | + * @since 2009.0713 | |
| 167 | + * @param object $page of class FeedWordPressPostsPage tells us whether this is | |
| 168 | + * a page for one feed's settings or for global defaults | |
| 169 | + * @param array $box | |
| 170 | + * | |
| 171 | + * @uses fwp_option_box_opener() | |
| 172 | + * @uses fwp_option_box_closer() | |
| 173 | + */ | |
| 174 | + /*static*/ function comments_and_pings_box ($page, $box = NULL) { | |
| 175 | + $setting = array(); | |
| 176 | + $selector = array(); | |
| 177 | + | |
| 178 | + $whatsits = array( | |
| 179 | + 'comment' => array('label' => __('Comments'), 'accept' => 'Allow comments'), | |
| 180 | + 'ping' => array('label' => __('Pings'), 'accept' => 'Accept pings'), | |
| 181 | + ); | |
| 182 | + $onThesePosts = 'on '.$page->these_posts_phrase(); | |
| 183 | + | |
| 184 | + foreach ($whatsits as $what => $how) : | |
| 185 | + $whatsits[$what]['default'] = FeedWordPress::syndicated_status($what, /*default=*/ 'closed'); | |
| 186 | + | |
| 187 | + // Set up array for selector | |
| 188 | + $setting = array( | |
| 189 | + 'open' => array ('label' => "{$how['accept']} %s", 'checked' => ''), | |
| 190 | + 'closed' => array('label' => "Don't ".strtolower($how['accept'])." %s", 'checked' => ''), | |
| 191 | + ); | |
| 192 | + if ($page->for_feed_settings()) : | |
| 193 | + $href = $fwp_path.'/'.basename(__FILE__); | |
| 194 | + $currently = trim(str_replace('%s', '', strtolower(strtok($setting[$whatsits[$what]['default']]['label'], ';')))); | |
| 195 | + $setting['site-default'] = array('label' => "Use <a href=\"admin.php?page=${href}\">site-wide setting</a>", 'checked' => ''); | |
| 196 | + $setting['site-default']['label'] .= " (currently: <strong>${currently}</strong>)"; | |
| 197 | + | |
| 198 | + $checked = $page->link->syndicated_status($what, 'site-default', /*fallback=*/ false); | |
| 199 | + else : | |
| 200 | + $checked = $whatsits[$what]['default']; | |
| 201 | + endif; | |
| 202 | + | |
| 203 | + // Re-order appropriately | |
| 204 | + $selector[$what] = array(); | |
| 205 | + $order = array( | |
| 206 | + 'site-default', | |
| 207 | + 'open', | |
| 208 | + 'closed', | |
| 209 | + ); | |
| 210 | + foreach ($order as $line) : | |
| 211 | + if (isset($setting[$line])) : | |
| 212 | + $selector[$what][$line] = $setting[$line]; | |
| 213 | + endif; | |
| 214 | + endforeach; | |
| 215 | + $selector[$what][$checked]['checked'] = ' checked="checked"'; | |
| 216 | + endforeach; | |
| 217 | + | |
| 218 | + // Hey ho, let's go... | |
| 219 | + ?> | |
| 220 | + <table class="form-table" cellspacing="2" cellpadding="5"> | |
| 221 | + <?php foreach ($whatsits as $what => $how) : ?> | |
| 222 | + <tr><th scope="row"><?php print $how['label']; ?>:</th> | |
| 223 | + <td><ul class="options"> | |
| 224 | + <?php foreach ($selector[$what] as $code => $li) : ?> | |
| 225 | + <li><label><input type="radio" name="feed_<?php print $what; ?>_status" | |
| 226 | + value="<?php print $code; ?>"<?php print $li['checked']; ?> /> | |
| 227 | + <?php print trim(str_replace('%s', $onThesePosts, $li['label'])); ?></label></li> | |
| 228 | + <?php endforeach; ?> | |
| 229 | + </ul></td></tr> | |
| 230 | + <?php endforeach; ?> | |
| 231 | + </table> | |
| 232 | + | |
| 233 | + <?php | |
| 234 | + } /* FeedWordPressPostsPage::comments_and_pings_box() */ | |
| 235 | + | |
| 236 | + /** | |
| 237 | + * Output "Custom Post Settings" settings box | |
| 238 | + * | |
| 239 | + * @since 2009.0713 | |
| 240 | + * @param object $page of class FeedWordPressPostsPage tells us whether this is | |
| 241 | + * a page for one feed's settings or for global defaults | |
| 242 | + * @param array $box | |
| 243 | + * | |
| 244 | + * @uses fwp_option_box_opener() | |
| 245 | + * @uses fwp_option_box_closer() | |
| 246 | + */ | |
| 247 | + /*static*/ function custom_post_settings_box ($page, $box = NULL) { | |
| 248 | + if ($page->for_feed_settings()) : | |
| 249 | + $custom_settings = $page->link->settings["postmeta"]; | |
| 250 | + if ($custom_settings and !is_array($custom_settings)) : | |
| 251 | + $custom_settings = unserialize($custom_settings); | |
| 252 | + endif; | |
| 253 | + | |
| 254 | + if (!is_array($custom_settings)) : | |
| 255 | + $custom_settings = array(); | |
| 256 | + endif; | |
| 257 | + else : | |
| 258 | + $custom_settings = get_option('feedwordpress_custom_settings'); | |
| 259 | + if ($custom_settings and !is_array($custom_settings)) : | |
| 260 | + $custom_settings = unserialize($custom_settings); | |
| 261 | + endif; | |
| 262 | + | |
| 263 | + if (!is_array($custom_settings)) : | |
| 264 | + $custom_settings = array(); | |
| 265 | + endif; | |
| 266 | + endif; | |
| 267 | + | |
| 268 | + ?> | |
| 269 | + <div id="postcustomstuff"> | |
| 270 | + <table id="meta-list" cellpadding="3"> | |
| 271 | + <tr> | |
| 272 | + <th>Key</th> | |
| 273 | + <th>Value</th> | |
| 274 | + <th>Action</th> | |
| 275 | + </tr> | |
| 276 | + | |
| 277 | + <?php | |
| 278 | + $i = 0; | |
| 279 | + foreach ($custom_settings as $key => $value) : | |
| 280 | + ?> | |
| 281 | + <tr style="vertical-align:top"> | |
| 282 | + <th width="30%" scope="row"><input type="hidden" name="notes[<?php echo $i; ?>][key0]" value="<?php echo wp_specialchars($key, 'both'); ?>" /> | |
| 283 | + <input id="notes-<?php echo $i; ?>-key" name="notes[<?php echo $i; ?>][key1]" value="<?php echo wp_specialchars($key, 'both'); ?>" /></th> | |
| 284 | + <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> | |
| 285 | + <td width="10%"><select name="notes[<?php echo $i; ?>][action]"> | |
| 286 | + <option value="update">save changes</option> | |
| 287 | + <option value="delete">delete this setting</option> | |
| 288 | + </select></td> | |
| 289 | + </tr> | |
| 290 | + | |
| 291 | + <?php | |
| 292 | + $i++; | |
| 293 | + endforeach; | |
| 294 | + ?> | |
| 295 | + | |
| 296 | + <tr> | |
| 297 | + <th scope="row"><input type="text" size="10" name="notes[<?php echo $i; ?>][key1]" value="" /></th> | |
| 298 | + <td><textarea name="notes[<?php echo $i; ?>][value]" rows="2" cols="40"></textarea></td> | |
| 299 | + <td><em>add new setting...</em><input type="hidden" name="notes[<?php echo $i; ?>][action]" value="update" /></td> | |
| 300 | + </tr> | |
| 301 | + </table> | |
| 302 | + </div> <!-- id="postcustomstuff" --> | |
| 303 | + | |
| 304 | + <?php | |
| 305 | + } /* FeedWordPressPostsPage::custom_post_settings_box() */ | |
| 306 | +} | |
| 307 | + | |
| 4 | 308 | function fwp_posts_page () { |
| 5 | 309 | global $wpdb, $wp_db_version; |
| 310 | + | |
| 311 | + if (FeedWordPress::needs_upgrade()) : | |
| 312 | + fwp_upgrade_page(); | |
| 313 | + return; | |
| 314 | + endif; | |
| 6 | 315 | |
| 7 | 316 | FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_posts_settings', /*capability=*/ 'manage_links'); |
| 8 | 317 | |
| 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; | |
| 318 | + $link = FeedWordPressAdminPage::submitted_link(); | |
| 319 | + $link_id = $link->id; | |
| 320 | + $postsPage = new FeedWordPressPostsPage($link); | |
| 16 | 321 | |
| 17 | - if (is_numeric($link_id) and $link_id) : | |
| 18 | - $link =& new SyndicatedLink($link_id); | |
| 19 | - else : | |
| 20 | - $link = NULL; | |
| 21 | - endif; | |
| 22 | - | |
| 23 | 322 | $mesg = null; |
| 24 | 323 | |
| 25 | 324 | //////////////////////////////////////////////// |
| 26 | 325 | // Process POST request, if any ///////////////// |
| 27 | 326 | //////////////////////////////////////////////// |
| 28 | - if (isset($GLOBALS['fwp_post']['save'])) : | |
| 29 | - // custom post settings | |
| 327 | + if (isset($GLOBALS['fwp_post']['save']) or isset($GLOBALS['fwp_post']['submit'])) : | |
| 328 | + // custom post settings | |
| 30 | 329 | foreach ($GLOBALS['fwp_post']['notes'] as $mn) : |
| 31 | 330 | $mn['key0'] = trim($mn['key0']); |
| 32 | 331 | $mn['key1'] = trim($mn['key1']); |
| 33 | 332 | |
| @@ -99,345 +398,66 @@ | ||
| 99 | 398 | endif; |
| 100 | 399 | |
| 101 | 400 | $updated_link = true; |
| 102 | 401 | endif; |
| 402 | + | |
| 403 | + do_action('feedwordpress_admin_page_posts_save', $GLOBALS['fwp_post'], $postsPage); | |
| 103 | 404 | else : |
| 104 | 405 | $updated_link = false; |
| 105 | 406 | endif; |
| 106 | - | |
| 107 | - //////////////////////////////////////////////// | |
| 108 | - // Get defaults from database ////////////////// | |
| 109 | - //////////////////////////////////////////////// | |
| 110 | - | |
| 111 | - $post_status_global = get_option('feedwordpress_syndicated_post_status'); | |
| 112 | - if (!$post_status_global) : $post_status_global = 'publish'; endif; | |
| 113 | 407 | |
| 114 | - $comment_status_global = get_option('feedwordpress_syndicated_comment_status'); | |
| 115 | - if (!$comment_status_global) : $comment_status_global = 'closed'; endif; | |
| 408 | + $postsPage->ajax_interface_js(); | |
| 116 | 409 | |
| 117 | - $ping_status_global = get_option('feedwordpress_syndicated_ping_status'); | |
| 118 | - if (!$ping_status_global) : $ping_status_global = 'closed'; endif; | |
| 119 | - | |
| 120 | - $status['post'] = array('publish' => '', 'private' => '', 'draft' => ''); | |
| 121 | - if (SyndicatedPost::use_api('post_status_pending')) : | |
| 122 | - $status['post']['pending'] = ''; | |
| 123 | - endif; | |
| 124 | - | |
| 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; | |
| 139 | - | |
| 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'); | |
| 150 | - | |
| 151 | - $status['post'][$post_status_global] = ' checked="checked"'; | |
| 152 | - $status['comment'][$comment_status_global] = ' checked="checked"'; | |
| 153 | - $status['ping'][$ping_status_global] = ' checked="checked"'; | |
| 154 | - | |
| 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'); | |
| 158 | - | |
| 159 | - $custom_settings = get_option('feedwordpress_custom_settings'); | |
| 160 | - if ($custom_settings) : | |
| 161 | - $custom_settings = unserialize($custom_settings); | |
| 162 | - endif; | |
| 163 | - | |
| 164 | - if (!is_array($custom_settings)) : | |
| 165 | - $custom_settings = array(); | |
| 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'; | |
| 172 | - | |
| 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) : ?> | |
| 410 | + if ($updated_link) : ?> | |
| 189 | 411 | <div class="updated"><p>Syndicated posts settings updated.</p></div> |
| 190 | 412 | <?php elseif (!is_null($mesg)) : ?> |
| 191 | 413 | <div class="updated"><p><?php print wp_specialchars($mesg, 1); ?></p></div> |
| 192 | 414 | <?php endif; ?> |
| 193 | 415 | |
| 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 | 416 | <?php |
| 203 | - else : | |
| 417 | + $links = FeedWordPress::syndicated_links(); | |
| 418 | + $postsPage->open_sheet('Syndicated Posts & Links'); | |
| 204 | 419 | ?> |
| 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 | 420 | <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; } | |
| 421 | + table.edit-form th, table.form-table th { width: 27%; vertical-align: top; } | |
| 422 | + table.edit-form td, table.form-table td { width: 73%; vertical-align: top; } | |
| 423 | + ul.options { margin: 0; padding: 0; list-style: none; } | |
| 222 | 424 | </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) } | |
| 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') ?> »" /> | |
| 280 | -</p> | |
| 281 | -<?php /* endif; */ ?> | |
| 282 | - | |
| 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; ?> | |
| 290 | - | |
| 291 | -<div id="poststuff"> | |
| 292 | 425 | <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"> | |
| 297 | - | |
| 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; ?> | |
| 303 | - | |
| 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> | |
| 306 | - | |
| 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; ?> | |
| 311 | - | |
| 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 | 426 | <?php |
| 320 | - fwp_option_box_closer(); | |
| 321 | -?> | |
| 427 | +$boxes_by_methods = array( | |
| 428 | + 'publication_box' => __('Publication'), | |
| 429 | + 'formatting_box' => __('Formatting'), | |
| 430 | + 'links_box' => __('Links'), | |
| 431 | + 'comments_and_pings_box' => __('Comments & Pings'), | |
| 432 | + 'custom_post_settings_box' => __('Custom Post Settings (to apply to each syndicated post)'), | |
| 433 | +); | |
| 322 | 434 | |
| 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(); ?> | |
| 338 | - | |
| 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> | |
| 349 | - | |
| 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(); | |
| 435 | +// Feed-level settings don't exist for these. | |
| 436 | +if ($postsPage->for_feed_settings()) : | |
| 437 | + unset($boxes_by_methods['formatting_box']); | |
| 438 | + unset($boxes_by_methods['links_box']); | |
| 363 | 439 | endif; |
| 364 | 440 | |
| 365 | - fwp_option_box_opener(__('Comments & Pings'), 'commentstatus', 'postbox'); | |
| 441 | + foreach ($boxes_by_methods as $method => $title) : | |
| 442 | + fwp_add_meta_box( | |
| 443 | + /*id=*/ 'feedwordpress_'.$method, | |
| 444 | + /*title=*/ $title, | |
| 445 | + /*callback=*/ array('FeedWordPressPostsPage', $method), | |
| 446 | + /*page=*/ $postsPage->meta_box_context(), | |
| 447 | + /*context=*/ $postsPage->meta_box_context() | |
| 448 | + ); | |
| 449 | + endforeach; | |
| 450 | + do_action('feedwordpress_admin_page_posts_meta_boxes', $postsPage); | |
| 366 | 451 | ?> |
| 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; ?> | |
| 375 | - | |
| 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> | |
| 379 | - | |
| 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> | |
| 452 | + <div class="metabox-holder"> | |
| 392 | 453 | <?php |
| 393 | - fwp_option_box_closer(); | |
| 394 | - fwp_linkedit_periodic_submit(); | |
| 454 | + fwp_do_meta_boxes($postsPage->meta_box_context(), $postsPage->meta_box_context(), $postsPage); | |
| 395 | 455 | ?> |
| 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 | - | |
| 456 | + </div> <!-- class="metabox-holder" --> | |
| 457 | +</div> <!-- id="post-body" --> | |
| 406 | 458 | <?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 | |
| 459 | + $postsPage->close_sheet(); | |
| 440 | 460 | } /* function fwp_posts_page () */ |
| 441 | 461 | |
| 442 | 462 | fwp_posts_page(); |
| 443 | 463 | |