| @@ -1,50 +1,7 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | require_once(dirname(__FILE__) . '/admin-ui.php'); |
| 3 | -require_once(dirname(__FILE__) . '/magpiemocklink.class.php'); | |
| 4 | -require_once(dirname(__FILE__) . '/feedfinder.class.php'); | |
| 5 | 3 | |
| 6 | -$FeedWordPressHTTPStatusMessages = array ( | |
| 7 | - 200 => 'OK. FeedWordPress had no problems retrieving the content at this URL but the content does not seem to be a feed, and does not seem to include links to any feeds.', | |
| 8 | - 201 => 'Created', | |
| 9 | - 202 => 'Accepted', | |
| 10 | - 203 => 'Non-Authoritative information', | |
| 11 | - 204 => 'No Content', | |
| 12 | - 205 => 'Reset Content', | |
| 13 | - 206 => 'Partial Content', | |
| 14 | - 300 => 'Multiple Choices', | |
| 15 | - 301 => 'Moved Permanently', | |
| 16 | - 302 => 'Found', | |
| 17 | - 303 => 'See Other', | |
| 18 | - 304 => 'Not Modified', | |
| 19 | - 305 => 'Use Proxy', | |
| 20 | - 307 => 'Temporary Redirect', | |
| 21 | - 400 => 'Bad Request', | |
| 22 | - 401 => 'Unauthorized. This URL probably needs a username and password for you to access it.', | |
| 23 | - 402 => 'Payment Required', | |
| 24 | - 403 => 'Forbidden. The URL is not made available for the machine that FeedWordPress is running on.', | |
| 25 | - 404 => 'Not Found. There is nothing at this URL. Have you checked the address for typos?', | |
| 26 | - 405 => 'Method Not Allowed', | |
| 27 | - 406 => 'Not Acceptable', | |
| 28 | - 407 => 'Proxy Authentication Required', | |
| 29 | - 408 => 'Request Timeout', | |
| 30 | - 409 => 'Conflict', | |
| 31 | - 410 => 'Gone. This URL is no longer available on this server and no forwarding address is known.', | |
| 32 | - 411 => 'Length Required', | |
| 33 | - 412 => 'Precondition Failed', | |
| 34 | - 413 => 'Request Entity Too Large', | |
| 35 | - 414 => 'Request URI Too Long', | |
| 36 | - 415 => 'Unsupported Media Type', | |
| 37 | - 416 => 'Requested Range Not Satisfiable', | |
| 38 | - 417 => 'Expectation Failed', | |
| 39 | - 500 => 'Internal Server Error. Something unexpected went wrong with the configuration of the server that hosts this URL. You might try again later to see if this issue has been resolved.', | |
| 40 | - 501 => 'Not Implemented', | |
| 41 | - 502 => 'Bad Gateway', | |
| 42 | - 503 => 'Service Unavailable. The server is currently unable to handle the request due to a temporary overloading or maintenance of the server that hosts this URL. This is probably a temporary condition and you should try again later to see if the issue has been resolved.', | |
| 43 | - 504 => 'Gateway Timeout', | |
| 44 | - 505 => 'HTTP Version Not Supported', | |
| 45 | -); | |
| 46 | - | |
| 47 | 4 | ################################################################################ |
| 48 | 5 | ## ADMIN MENU ADD-ONS: implement Dashboard management pages #################### |
| 49 | 6 | ################################################################################ |
| 50 | 7 | |
| @@ -161,97 +118,36 @@ | ||
| 161 | 118 | if ($cont): |
| 162 | 119 | ?> |
| 163 | 120 | <?php |
| 164 | 121 | $links = FeedWordPress::syndicated_links(); |
| 165 | -?> | |
| 166 | - <div class="wrap"> | |
| 167 | -<?php if (fwp_test_wp_version(FWP_SCHEMA_27)) : ?> | |
| 168 | - <div class="icon32"><img src="<?php print htmlspecialchars(WP_PLUGIN_URL.'/'.$GLOBALS['fwp_path'].'/feedwordpress.png'); ?>" alt="" /></div> | |
| 169 | - <h2>Syndicated Sites</h2> | |
| 170 | -<?php endif; | |
| 122 | + | |
| 171 | 123 | if (fwp_test_wp_version(0, FWP_SCHEMA_25)) : |
| 172 | 124 | fwp_dashboard_update_if_requested(); |
| 173 | 125 | endif; |
| 174 | 126 | |
| 175 | - if (fwp_test_wp_version(FWP_SCHEMA_27)) : | |
| 176 | -?> | |
| 177 | - <script type="text/javascript"> | |
| 178 | - jQuery(document).ready( function($) { | |
| 179 | - // In case someone got here first. | |
| 180 | - $('.postbox h3, .postbox .handlediv').unbind('click'); | |
| 181 | - $('.hide-postbox-tog').unbind('click'); | |
| 182 | - $('.meta-box-sortables').sortable('destroy'); | |
| 183 | - | |
| 184 | - postboxes.add_postbox_toggles('feedwordpress_syndication'); | |
| 185 | - } ); | |
| 186 | - </script> | |
| 187 | -<?php | |
| 188 | - echo "<form style='display: none' method='get' action=''>\n<p>\n"; | |
| 189 | - wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); | |
| 190 | - wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); | |
| 191 | - echo "</p>\n</form>\n"; | |
| 192 | - | |
| 193 | - if ($links) : | |
| 194 | - add_meta_box('feedwordpress_update_box', __('Update feeds now'), 'fwp_syndication_manage_page_update_box', /*page=*/ 'feedwordpress_syndication', /*context =*/ 'normal'); | |
| 195 | - endif; | |
| 196 | - add_meta_box('feedwordpress_feeds_box', __('Syndicated sources'), 'fwp_syndication_manage_page_links_box', /*page=*/ 'feedwordpress_syndication', /*context =*/ 'normal'); | |
| 197 | -?> | |
| 198 | - <div class="metabox-holder"> | |
| 199 | - <div id="feedwordpress-sortables" class="meta-box-sortables ui-sortable"> | |
| 200 | -<?php | |
| 201 | - do_meta_boxes('feedwordpress_syndication', 'normal', NULL); | |
| 202 | - else : | |
| 203 | - if ($links): // only display Update panel if there are some links to update.... | |
| 204 | - fwp_syndication_manage_page_update_box(); | |
| 205 | - endif; | |
| 206 | - fwp_syndication_manage_page_links_box(); | |
| 207 | -?> | |
| 208 | - </div> <!-- class="wrap" --> | |
| 209 | - | |
| 210 | - <?php if (fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?> | |
| 127 | + if ($links): // only display Update panel if there are some links to update.... | |
| 128 | + ?> | |
| 129 | + <form action="" method="POST"> | |
| 130 | + <?php if (fwp_test_wp_version(FWP_SCHEMA_25)) : ?> | |
| 211 | 131 | <div class="wrap"> |
| 212 | - <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post"> | |
| 213 | - <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div> | |
| 214 | - <h2>Add a new syndicated site:</h2> | |
| 215 | - <div> | |
| 216 | - <label for="add-uri">Website or feed:</label> | |
| 217 | - <input type="text" name="lookup" id="add-uri" value="URI" size="64" /> | |
| 218 | - <input type="hidden" name="action" value="feedfinder" /> | |
| 219 | - </div> | |
| 220 | - <div class="submit"><input type="submit" value="Syndicate »" /></div> | |
| 221 | - </form> | |
| 222 | - </div> <!-- class="wrap" --> | |
| 223 | - <?php endif; ?> | |
| 224 | - | |
| 225 | - <div style="display: none"> | |
| 226 | - <div id="tags-input"></div> <!-- avoid JS error from WP 2.5 bug --> | |
| 227 | - </div> | |
| 228 | -<?php | |
| 229 | - endif; | |
| 230 | -endif; | |
| 231 | -} /* function fwp_syndication_manage_page () */ | |
| 232 | - | |
| 233 | -function fwp_syndication_manage_page_update_box ($object = NULL, $box = NULL) { | |
| 234 | - $updateFeedsNow = __('Update feeds now'); | |
| 235 | -?> | |
| 236 | - <form action="" method="POST"> | |
| 237 | - <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div> | |
| 238 | - <?php if (fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_27)) : ?> | |
| 239 | 132 | <div id="rightnow"> |
| 240 | - <h3 class="reallynow"><span><?php print $updateFeedsNow; ?></span> | |
| 133 | + <h3 class="reallynow"><span>Update feeds now</span> | |
| 241 | 134 | <input type="hidden" name="update_uri" value="*" /><input style="float: right; border: none;" class="rbutton" type="submit" name="update" value="Update" /> |
| 242 | 135 | <br class="clear"/></h3> |
| 243 | - <?php elseif (fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?> | |
| 244 | - <h2><?php print $updateFeedsNow; ?></h2> | |
| 136 | + <?php else : ?> | |
| 137 | + <div class="wrap"> | |
| 138 | + <h2>Update feeds now</h2> | |
| 245 | 139 | <?php endif; ?> |
| 246 | 140 | |
| 247 | -<?php | |
| 141 | + <?php | |
| 248 | 142 | if (fwp_test_wp_version(FWP_SCHEMA_25)) : |
| 249 | 143 | fwp_dashboard_update_if_requested(); |
| 250 | 144 | else : |
| 251 | 145 | ?> |
| 252 | 146 | <p>Check currently scheduled feeds for new and updated posts.</p> |
| 253 | -<?php endif; ?> | |
| 147 | +<?php | |
| 148 | + endif; | |
| 149 | + ?> | |
| 254 | 150 | |
| 255 | 151 | <?php if (!get_option('feedwordpress_automatic_updates')) : ?> |
| 256 | 152 | <p class="youhave"><strong>Note:</strong> Automatic updates are currently turned |
| 257 | 153 | <strong>off</strong>. New posts from your feeds will not be syndicated |
| @@ -259,35 +155,24 @@ | ||
| 259 | 155 | updates under <a href="admin.php?page=<?php print $GLOBALS['fwp_path']; ?>/syndication-options.php">Syndication |
| 260 | 156 | Options</a>.</p> |
| 261 | 157 | <?php endif; ?> |
| 262 | 158 | |
| 263 | - <?php if (!fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_27)) : ?> | |
| 264 | - <div class="submit"><input type="hidden" name="update_uri" value="*" /><input class="button-primary" type="submit" name="update" value="Update" /></div> | |
| 159 | + <?php if (fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?> | |
| 160 | + <div class="submit"><input type="hidden" name="update_uri" value="*" /><input type="submit" name="update" value="Update" /></div> | |
| 265 | 161 | <?php endif; ?> |
| 266 | - | |
| 267 | - <?php if (fwp_test_wp_version(FWP_SCHEMA_27)) : ?> | |
| 268 | - <br style="clear: both" /> | |
| 269 | - <?php elseif (fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_27)) : ?> | |
| 162 | + | |
| 163 | + <?php if (fwp_test_wp_version(FWP_SCHEMA_25)) : ?> | |
| 270 | 164 | </div> <!-- id="rightnow" --> |
| 271 | - </div> <!-- class="wrap" --> | |
| 272 | - <?php elseif (fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?> | |
| 273 | - </div> <!-- class="wrap" --> | |
| 274 | 165 | <?php endif; ?> |
| 166 | + </div> <!-- class="wrap" --> | |
| 275 | 167 | </form> |
| 276 | 168 | <?php |
| 277 | -} /* function fwp_syndication_manage_page_update_box () */ | |
| 278 | - | |
| 279 | -function fwp_syndication_manage_page_links_box ($object = NULL, $box = NULL) { | |
| 280 | - $links = FeedWordPress::syndicated_links(); | |
| 169 | + endif; | |
| 281 | 170 | ?> |
| 282 | - <?php if (!fwp_test_wp_version(FWP_SCHEMA_27)) : ?> | |
| 283 | - <div class="wrap"> | |
| 284 | - <h2>Syndicated Sites</h2> | |
| 285 | - <?php endif; ?> | |
| 286 | 171 | |
| 172 | + <div class="wrap"> | |
| 287 | 173 | <form id="syndicated-links" action="admin.php?page=<?php print $GLOBALS['fwp_path']; ?>/<?php echo basename(__FILE__); ?>" method="post"> |
| 288 | - <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div> | |
| 289 | - | |
| 174 | + <h2>Syndicated Sites</h2> | |
| 290 | 175 | <?php $alt_row = true; ?> |
| 291 | 176 | |
| 292 | 177 | <?php if (fwp_test_wp_version(FWP_SCHEMA_25)) : ?> |
| 293 | 178 | <div class="tablenav"> |
| @@ -330,14 +215,15 @@ | ||
| 330 | 215 | <table width="100%" cellpadding="3" cellspacing="3"> |
| 331 | 216 | <?php endif; ?> |
| 332 | 217 | <thead> |
| 333 | 218 | <tr> |
| 334 | -<th class="check-column" scope="col"><?php if (fwp_test_wp_version(FWP_SCHEMA_25)) : ?> | |
| 335 | -<input type="checkbox" <?php if (fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_26)) : ?>onclick="checkAll(document.getElementById('syndicated-links'));"<?php endif; ?> /> | |
| 336 | -<?php endif; ?></th> | |
| 337 | -<th scope="col"><?php _e('Name'); ?></th> | |
| 338 | -<th scope="col"><?php _e('Feed'); ?></th> | |
| 339 | -<th scope="col"><?php _e('Updated'); ?></th> | |
| 219 | + <?php if (fwp_test_wp_version(FWP_SCHEMA_25)) : $span = 3; ?> | |
| 220 | + <th class="check-column" scope="col"><input type="checkbox" <?php if (fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_26)) : ?>onclick="checkAll(document.getElementById('syndicated-links'));"<?php endif; ?> /></th> | |
| 221 | + <?php else : $span = 4; ?> | |
| 222 | + <?php endif; ?> | |
| 223 | +<th width="20%" scope="col"><?php _e('Name'); ?></th> | |
| 224 | +<th width="40%" scope="col"><?php _e('Feed'); ?></th> | |
| 225 | +<th class="action-links" scope="col" colspan="<?php print $span; ?>"><?php _e('Action'); ?></th> | |
| 340 | 226 | </tr> |
| 341 | 227 | </thead> |
| 342 | 228 | |
| 343 | 229 | <tbody> |
| @@ -343,31 +229,16 @@ | ||
| 343 | 229 | <tbody> |
| 344 | 230 | <?php if (count($links) > 0): foreach ($links as $link): |
| 345 | 231 | $alt_row = !$alt_row; ?> |
| 346 | 232 | <tr<?php echo ($alt_row?' class="alternate"':''); ?>> |
| 233 | + <?php if (fwp_test_wp_version(FWP_SCHEMA_25)) : ?> | |
| 347 | 234 | <th class="check-column" scope="row"><input type="checkbox" name="link_ids[]" value="<?php echo $link->link_id; ?>" /></th> |
| 348 | -<?php | |
| 349 | - if (strlen($link->link_rss) > 0): | |
| 350 | - $caption=__('Switch Feed'); | |
| 351 | - else : | |
| 352 | - $caption=__('Find Feed'); | |
| 353 | - endif; | |
| 354 | -?> | |
| 355 | -<td> | |
| 356 | -<strong><a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&link_id=<?php echo $link->link_id; ?>&action=linkedit"><?php echo wp_specialchars($link->link_name, 'both'); ?></a></strong> | |
| 357 | -<div class="row-actions"><div><strong>Settings ></strong> | |
| 358 | -<a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&link_id=<?php echo $link->link_id; ?>&action=linkedit"><?php _e('Feed'); ?></a> | |
| 359 | -| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/posts-page.php&link_id=<?php echo $link->link_id; ?>"><?php _e('Posts'); ?></a> | |
| 360 | -| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/authors-page.php&link_id=<?php echo $link->link_id; ?>"><?php _e('Authors'); ?></a> | |
| 361 | -| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/categories-page.php&link_id=<?php echo $link->link_id; ?>"><?php _e('Categories & Tags'); ?></a></div> | |
| 362 | -<div><strong>Actions ></strong> | |
| 363 | -<a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&link_id=<?php echo $link->link_id; ?>&action=feedfinder"><?php echo $caption; ?></a> | |
| 364 | -| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&link_id=<?php echo $link->link_id; ?>&action=Unsubscribe"><?php _e('Unsubscribe'); ?></a> | |
| 365 | -| <a href="<?php echo wp_specialchars($link->link_url, 'both'); ?>"><?php _e('View')?></a></div> | |
| 366 | -</div> | |
| 367 | -</td> | |
| 235 | + <?php endif; ?> | |
| 236 | + | |
| 237 | +<td><a href="<?php echo wp_specialchars($link->link_url, 'both'); ?>"><?php echo wp_specialchars($link->link_name, 'both'); ?></a></td> | |
| 368 | 238 | <?php |
| 369 | 239 | if (strlen($link->link_rss) > 0): |
| 240 | + $caption='Switch Feed'; | |
| 370 | 241 | $uri_bits = parse_url($link->link_rss); |
| 371 | 242 | $uri_bits['host'] = preg_replace('/^www\./i', '', $uri_bits['host']); |
| 372 | 243 | $display_uri = |
| 373 | 244 | (isset($uri_bits['user'])?$uri_bits['user'].'@':'') |
| @@ -376,39 +247,28 @@ | ||
| 376 | 247 | .(isset($uri_bits['path'])?$uri_bits['path']:'') |
| 377 | 248 | .(isset($uri_bits['query'])?'?'.$uri_bits['query']:''); |
| 378 | 249 | if (strlen($display_uri) > 32) : $display_uri = substr($display_uri, 0, 32).'…'; endif; |
| 379 | 250 | ?> |
| 380 | - <td><a href="<?php echo wp_specialchars($link->link_rss, 'both'); ?>"><?php echo wp_specialchars($display_uri, 'both'); ?></a></td> | |
| 381 | - <?php else: ?> | |
| 251 | + <td> | |
| 252 | + <strong><a href="<?php echo wp_specialchars($link->link_rss, 'both'); ?>"><?php echo wp_specialchars($display_uri, 'both'); ?></a></strong></td> | |
| 253 | +<?php | |
| 254 | + else: | |
| 255 | + $caption='Find Feed'; | |
| 256 | +?> | |
| 382 | 257 | <td style="background-color:#FFFFD0"><p><strong>no |
| 383 | 258 | feed assigned</strong></p></td> |
| 384 | - <?php endif; ?> | |
| 385 | - | |
| 386 | - <td><?php | |
| 387 | - $sLink =& new SyndicatedLink($link->link_id); | |
| 388 | - if (isset($sLink->settings['update/last'])) : | |
| 389 | - print fwp_time_elapsed($sLink->settings['update/last']); | |
| 390 | - else : | |
| 391 | - _e('None yet'); | |
| 259 | +<?php | |
| 392 | 260 | endif; |
| 393 | - | |
| 394 | - print "<div style='font-style:italic;size:0.9em'>Ready for next update "; | |
| 395 | - if (isset($sLink->settings['update/ttl']) and is_numeric($sLink->settings['update/ttl'])) : | |
| 396 | - if (isset($sLink->settings['update/timed']) and $sLink->settings['update/timed']=='automatically') : | |
| 397 | - $next = $sLink->settings['update/last'] + ((int) $sLink->settings['update/ttl'] * 60); | |
| 398 | - print fwp_time_elapsed($next); | |
| 399 | - else : | |
| 400 | - echo "every ".$sLink->settings['update/ttl']." minute".(($sLink->settings['update/ttl']!=1)?"s":""); | |
| 401 | - endif; | |
| 402 | - else: | |
| 403 | - echo "as soon as possible"; | |
| 404 | - endif; | |
| 405 | - print "</div>"; | |
| 406 | 261 | ?> |
| 407 | - </td> | |
| 408 | - </tr> | |
| 262 | + <td><a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&link_id=<?php echo $link->link_id; ?>&action=linkedit" class="edit"><?php _e('Edit')?></a></td> | |
| 263 | + <td><a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&link_id=<?php echo $link->link_id; ?>&action=feedfinder" class="edit"><?php echo $caption; ?></a></td> | |
| 264 | + <td><a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&link_id=<?php echo $link->link_id; ?>&action=Unsubscribe" class="delete"><?php _e('Unsubscribe'); ?></a></td> | |
| 265 | + <?php if (fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?> | |
| 266 | + <td><input type="checkbox" name="link_ids[]" value="<?php echo $link->link_id; ?>" /></td> | |
| 409 | 267 | <?php |
| 410 | - endforeach; | |
| 268 | + endif; | |
| 269 | + echo "\n\t</tr>"; | |
| 270 | + endforeach; | |
| 411 | 271 | else : |
| 412 | 272 | ?> |
| 413 | 273 | <tr><td colspan="<?php print $span+2; ?>"><p>There are no websites currently listed for syndication.</p></td></tr> |
| 414 | 274 | <?php |
| @@ -423,14 +283,34 @@ | ||
| 423 | 283 | <input type="submit" name="action" value="<?php print FWP_UPDATE_CHECKED; ?>" /></div> |
| 424 | 284 | <?php endif; ?> |
| 425 | 285 | |
| 426 | 286 | </form> |
| 287 | + | |
| 288 | + </div> <!-- class="wrap" --> | |
| 289 | + | |
| 290 | + <?php if (fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?> | |
| 291 | + <div class="wrap"> | |
| 292 | + <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post"> | |
| 293 | + <h2>Add a new syndicated site:</h2> | |
| 294 | + <div> | |
| 295 | + <label for="add-uri">Website or newsfeed:</label> | |
| 296 | + <input type="text" name="lookup" id="add-uri" value="URI" size="64" /> | |
| 297 | + <input type="hidden" name="action" value="feedfinder" /> | |
| 298 | + </div> | |
| 299 | + <div class="submit"><input type="submit" value="Syndicate »" /></div> | |
| 300 | + </form> | |
| 301 | + </div> <!-- class="wrap" --> | |
| 302 | + <?php endif; ?> | |
| 303 | + | |
| 304 | +<div style="display: none"> | |
| 305 | +<div id="tags-input"></div> <!-- avoid JS error from WP 2.5 bug --> | |
| 306 | +</div> | |
| 427 | 307 | <?php |
| 428 | -} /* function fwp_syndication_manage_page_links_box() */ | |
| 308 | +endif; | |
| 309 | +} | |
| 429 | 310 | |
| 430 | 311 | function fwp_feedfinder_page () { |
| 431 | 312 | global $wpdb; |
| 432 | - global $FeedWordPressHTTPStatusMessages; | |
| 433 | 313 | |
| 434 | 314 | $lookup = (isset($_REQUEST['lookup'])?$_REQUEST['lookup']:NULL); |
| 435 | 315 | |
| 436 | 316 | if (isset($_REQUEST['link_id']) and ($_REQUEST['link_id']!=0)): |
| @@ -444,9 +324,9 @@ | ||
| 444 | 324 | else: |
| 445 | 325 | die (__("Cheatin' uh ?")); |
| 446 | 326 | endif; |
| 447 | 327 | else: |
| 448 | - $name = "<code>".htmlspecialchars($lookup)."</code>"; | |
| 328 | + $name = "New Syndicated Feed"; | |
| 449 | 329 | $link_id = 0; |
| 450 | 330 | endif; |
| 451 | 331 | ?> |
| 452 | 332 | <div class="wrap"> |
| @@ -459,26 +339,10 @@ | ||
| 459 | 339 | $rss = fetch_rss($f); |
| 460 | 340 | if ($rss): |
| 461 | 341 | $feed_title = isset($rss->channel['title'])?$rss->channel['title']:$rss->channel['link']; |
| 462 | 342 | $feed_link = isset($rss->channel['link'])?$rss->channel['link']:''; |
| 463 | - else : | |
| 464 | - // Give us some sucky defaults | |
| 465 | - $uri_bits = parse_url($lookup); | |
| 466 | - $uri_bits['host'] = preg_replace('/^www\./i', '', $uri_bits['host']); | |
| 467 | - $display_uri = | |
| 468 | - (isset($uri_bits['user'])?$uri_bits['user'].'@':'') | |
| 469 | - .(isset($uri_bits['host'])?$uri_bits['host']:'') | |
| 470 | - .(isset($uri_bits['port'])?':'.$uri_bits['port']:'') | |
| 471 | - .(isset($uri_bits['path'])?$uri_bits['path']:'') | |
| 472 | - .(isset($uri_bits['query'])?'?'.$uri_bits['query']:''); | |
| 473 | - if (strlen($display_uri) > 32) : $display_uri = substr($display_uri, 0, 32).'…'; endif; | |
| 474 | - | |
| 475 | - $feed_title = $display_uri; | |
| 476 | - $feed_link = $lookup; | |
| 477 | - endif; | |
| 478 | 343 | ?> |
| 479 | 344 | <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post"> |
| 480 | - <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_switchfeed'); ?></div> | |
| 481 | 345 | <fieldset style="clear: both"> |
| 482 | 346 | <legend><?php echo $rss->feed_type; ?> <?php echo $rss->feed_version; ?> feed</legend> |
| 483 | 347 | |
| 484 | 348 | <?php if ($link_id===0): ?> |
| @@ -492,20 +356,16 @@ | ||
| 492 | 356 | |
| 493 | 357 | <div> |
| 494 | 358 | <div style="float:right; background-color:#D0D0D0; color: black; width:45%; font-size:70%; border-left: 1px dotted #A0A0A0; padding-left: 0.5em; margin-left: 1.0em"> |
| 495 | 359 | <?php if (count($rss->items) > 0): ?> |
| 496 | - <?php | |
| 497 | - // Prepare to display Sample Item | |
| 498 | - $link =& new MagpieMockLink($rss, $f); | |
| 499 | - $post =& new SyndicatedPost($rss->items[0], $link); | |
| 500 | - ?> | |
| 360 | + <?php $item = $rss->items[0]; ?> | |
| 501 | 361 | <h3>Sample Item</h3> |
| 502 | 362 | <ul> |
| 503 | - <li><strong>Title:</strong> <a href="<?php echo $post->post['meta']['syndication_permalink']; ?>"><?php echo $post->post['post_title']; ?></a></li> | |
| 504 | - <li><strong>Date:</strong> <?php print date('d-M-y g:i:s a', $post->published()); ?></li> | |
| 363 | + <li><strong>Title:</strong> <a href="<?php echo $item['link']; ?>"><?php echo $item['title']; ?></a></li> | |
| 364 | + <li><strong>Date:</strong> <?php echo isset($item['date_timestamp']) ? date('d-M-y g:i:s a', $item['date_timestamp']) : 'unknown'; ?></li> | |
| 505 | 365 | </ul> |
| 506 | 366 | <div class="entry"> |
| 507 | - <?php print $post->post['post_content']; ?> | |
| 367 | + <?php echo (isset($item['content']['encoded'])?$item['content']['encoded']:$item['description']); ?> | |
| 508 | 368 | </div> |
| 509 | 369 | <?php else: ?> |
| 510 | 370 | <h3>No Items</h3> |
| 511 | 371 | <p>FeedWordPress found no posts on this feed.</p> |
| @@ -525,39 +385,17 @@ | ||
| 525 | 385 | </div> |
| 526 | 386 | </div> |
| 527 | 387 | </fieldset> |
| 528 | 388 | </form> |
| 529 | -<?php | |
| 389 | +<?php endif; | |
| 530 | 390 | endforeach; |
| 531 | 391 | else: |
| 532 | - print "<p><strong>".__('Error').":</strong> ".__("FeedWordPress couldn't find any feeds at").' <code><a href="'.htmlspecialchars($lookup).'">'.htmlspecialchars($lookup).'</a></code>'; | |
| 533 | - print ". ".__('Try another URL').".</p>"; | |
| 534 | - | |
| 535 | - // Diagnostics | |
| 536 | - $httpObject = _wp_http_get_object(); | |
| 537 | - $transports = $httpObject->_getTransport(); | |
| 538 | - print "<div class=\"updated\" style=\"margin-left: 3.0em; margin-right: 3.0em;\">\n"; | |
| 539 | - print "<h3>".__('Diagnostic information')."</h3>\n"; | |
| 540 | - if (!is_null($f->error())) : | |
| 541 | - print "<h4>".__('HTTP request failure')."</h4>\n"; | |
| 542 | - print "<p>".$f->error()."</p>\n"; | |
| 543 | - else : | |
| 544 | - print "<h4>".__('HTTP request completed')."</h4>\n"; | |
| 545 | - print "<p><strong>Status ".$f->status().":</strong> ".$FeedWordPressHTTPStatusMessages[$f->status()]."</p>\n"; | |
| 546 | - endif; | |
| 547 | - print "<h4>".__('HTTP Transports available').":</h4>\n"; | |
| 548 | - print "<ol>\n"; | |
| 549 | - print "<li>".implode("</li>\n<li>", array_map('get_class', $transports))."</li>\n"; | |
| 550 | - print "</ol>\n"; | |
| 551 | - print "</div>\n"; | |
| 392 | + echo "<p><strong>no feed found</strong></p>"; | |
| 552 | 393 | endif; |
| 553 | 394 | ?> |
| 554 | 395 | </div> |
| 555 | 396 | |
| 556 | 397 | <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post"> |
| 557 | - <div><?php | |
| 558 | - FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); | |
| 559 | - ?></div> | |
| 560 | 398 | <div class="wrap"> |
| 561 | 399 | <h2>Use another feed</h2> |
| 562 | 400 | <div><label>Feed:</label> |
| 563 | 401 | <input type="text" name="lookup" value="URI" /> |
| @@ -572,22 +410,21 @@ | ||
| 572 | 410 | |
| 573 | 411 | function fwp_switchfeed_page () { |
| 574 | 412 | global $wpdb, $wp_db_version; |
| 575 | 413 | |
| 576 | - // If this is a POST, validate source and user credentials | |
| 577 | - FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_switchfeed', /*capability=*/ 'manage_links'); | |
| 578 | - | |
| 414 | + check_admin_referer(); | |
| 579 | 415 | if (!isset($_REQUEST['Cancel'])): |
| 580 | - if (isset($_POST['link_id']) and ($_POST['link_id']==0)): | |
| 416 | + if (!current_user_can('manage_links')): | |
| 417 | + die (__("Cheatin' uh ?")); | |
| 418 | + elseif (isset($_REQUEST['link_id']) and ($_REQUEST['link_id']==0)): | |
| 581 | 419 | $link_id = FeedWordPress::syndicate_link($_REQUEST['feed_title'], $_REQUEST['feed_link'], $_REQUEST['feed']); |
| 582 | 420 | if ($link_id): ?> |
| 583 | -<div class="updated"><p><a href="<?php echo stripslashes($_REQUEST['feed_link']); ?>"><?php echo wp_specialchars(stripslashes($_REQUEST['feed_title']), 'both'); ?></a> | |
| 584 | -has been added as a contributing site, using the feed at <<a href="<?php echo stripslashes($_REQUEST['feed']); ?>"><?php echo wp_specialchars(stripslashes($_REQUEST['feed']), 'both'); ?></a>>. | |
| 585 | -| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&link_id=<?php echo $link_id; ?>&action=linkedit">Configure settings</a>.</div> | |
| 421 | +<div class="updated"><p><a href="<?php echo $_REQUEST['feed_link']; ?>"><?php echo wp_specialchars($_REQUEST['feed_title'], 'both'); ?></a> | |
| 422 | +has been added as a contributing site, using the newsfeed at <<a href="<?php echo $_REQUEST['feed']; ?>"><?php echo wp_specialchars($_REQUEST['feed'], 'both'); ?></a>>.</p></div> | |
| 586 | 423 | <?php else: ?> |
| 587 | -<div class="updated"><p>There was a problem adding the feed. [SQL: <?php echo wp_specialchars(mysql_error(), 'both'); ?>]</p></div> | |
| 424 | +<div class="updated"><p>There was a problem adding the newsfeed. [SQL: <?php echo wp_specialchars(mysql_error(), 'both'); ?>]</p></div> | |
| 588 | 425 | <?php endif; |
| 589 | - elseif (isset($_POST['link_id'])): | |
| 426 | + elseif (isset($_REQUEST['link_id'])): | |
| 590 | 427 | // Update link_rss |
| 591 | 428 | $result = $wpdb->query(" |
| 592 | 429 | UPDATE $wpdb->links |
| 593 | 430 | SET |
| @@ -613,10 +450,9 @@ | ||
| 613 | 450 | |
| 614 | 451 | function fwp_linkedit_page () { |
| 615 | 452 | global $wpdb, $wp_db_version; |
| 616 | 453 | |
| 617 | - // If this is a POST, validate source and user credentials | |
| 618 | - FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_linkedit', /*capability=*/ 'manage_links'); | |
| 454 | + check_admin_referer(); // Make sure we arrived here from the Dashboard | |
| 619 | 455 | |
| 620 | 456 | $special_settings = array ( /* Regular expression syntax is OK here */ |
| 621 | 457 | 'cats', |
| 622 | 458 | 'cat_split', |
| @@ -636,9 +472,11 @@ | ||
| 636 | 472 | 'feed/.*', |
| 637 | 473 | 'link/.*', |
| 638 | 474 | ); |
| 639 | 475 | |
| 640 | - if (isset($_REQUEST['feedfinder'])) : | |
| 476 | + if (!current_user_can('manage_links')) : | |
| 477 | + die (__("Cheatin' uh ?")); | |
| 478 | + elseif (isset($_REQUEST['feedfinder'])) : | |
| 641 | 479 | return fwp_feedfinder_page(); // re-route to Feed Finder page |
| 642 | 480 | else : |
| 643 | 481 | $link_id = (int) $_REQUEST['link_id']; |
| 644 | 482 | $link =& new SyndicatedLink($link_id); |
| @@ -692,8 +530,153 @@ | ||
| 692 | 530 | if (isset($GLOBALS['fwp_post']['update_schedule'])) : |
| 693 | 531 | $link->settings['update/hold'] = $GLOBALS['fwp_post']['update_schedule']; |
| 694 | 532 | endif; |
| 695 | 533 | |
| 534 | + // Categories | |
| 535 | + if (isset($GLOBALS['fwp_post']['post_category'])) : | |
| 536 | + $link->settings['cats'] = array(); | |
| 537 | + foreach ($GLOBALS['fwp_post']['post_category'] as $cat_id) : | |
| 538 | + $link->settings['cats'][] = '{#'.$cat_id.'}'; | |
| 539 | + endforeach; | |
| 540 | + else : | |
| 541 | + unset($link->settings['cats']); | |
| 542 | + endif; | |
| 543 | + | |
| 544 | + // Tags | |
| 545 | + if (isset($GLOBALS['fwp_post']['tags_input'])) : | |
| 546 | + $link->settings['tags'] = array(); | |
| 547 | + foreach (explode(',', $GLOBALS['fwp_post']['tags_input']) as $tag) : | |
| 548 | + $link->settings['tags'][] = trim($tag); | |
| 549 | + endforeach; | |
| 550 | + endif; | |
| 551 | + | |
| 552 | + // Post status, comment status, ping status | |
| 553 | + foreach (array('post', 'comment', 'ping') as $what) : | |
| 554 | + $sfield = "feed_{$what}_status"; | |
| 555 | + if (isset($GLOBALS['fwp_post'][$sfield])) : | |
| 556 | + if ($GLOBALS['fwp_post'][$sfield]=='site-default') : | |
| 557 | + unset($link->settings["{$what} status"]); | |
| 558 | + else : | |
| 559 | + $link->settings["{$what} status"] = $GLOBALS['fwp_post'][$sfield]; | |
| 560 | + endif; | |
| 561 | + endif; | |
| 562 | + endforeach; | |
| 563 | + | |
| 564 | + // Unfamiliar author, unfamiliar categories | |
| 565 | + foreach (array("author", "category") as $what) : | |
| 566 | + $sfield = "unfamiliar_{$what}"; | |
| 567 | + if (isset($GLOBALS['fwp_post'][$sfield])) : | |
| 568 | + if ('site-default'==$GLOBALS['fwp_post'][$sfield]) : | |
| 569 | + unset($link->settings["unfamiliar {$what}"]); | |
| 570 | + elseif ('newuser'==$GLOBALS['fwp_post'][$sfield]) : | |
| 571 | + $newuser_name = trim($GLOBALS['fwp_post']["{$sfield}_newuser"]); | |
| 572 | + if (strlen($newuser_name) > 0) : | |
| 573 | + $userdata = array(); | |
| 574 | + $userdata['ID'] = NULL; | |
| 575 | + | |
| 576 | + $userdata['user_login'] = sanitize_user($newuser_name); | |
| 577 | + $userdata['user_login'] = apply_filters('pre_user_login', $userdata['user_login']); | |
| 578 | + | |
| 579 | + $userdata['user_nicename'] = sanitize_title($newuser_name); | |
| 580 | + $userdata['user_nicename'] = apply_filters('pre_user_nicename', $userdata['user_nicename']); | |
| 581 | + | |
| 582 | + $userdata['display_name'] = $wpdb->escape($newuser_name); | |
| 583 | + | |
| 584 | + $newuser_id = wp_insert_user($userdata); | |
| 585 | + if (is_numeric($newuser_id)) : | |
| 586 | + $link->settings["unfamiliar {$what}"] = $newuser_id; | |
| 587 | + else : | |
| 588 | + // TODO: Add some error detection and reporting | |
| 589 | + endif; | |
| 590 | + else : | |
| 591 | + // TODO: Add some error reporting | |
| 592 | + endif; | |
| 593 | + else : | |
| 594 | + $link->settings["unfamiliar {$what}"] = $GLOBALS['fwp_post'][$sfield]; | |
| 595 | + endif; | |
| 596 | + endif; | |
| 597 | + endforeach; | |
| 598 | + | |
| 599 | + // Handle author mapping rules | |
| 600 | + if (isset($GLOBALS['fwp_post']['author_rules_name']) and isset($GLOBALS['fwp_post']['author_rules_action'])) : | |
| 601 | + unset($link->settings['map authors']); | |
| 602 | + foreach ($GLOBALS['fwp_post']['author_rules_name'] as $key => $name) : | |
| 603 | + // Normalize for case and whitespace | |
| 604 | + $name = strtolower(trim($name)); | |
| 605 | + $author_action = strtolower(trim($GLOBALS['fwp_post']['author_rules_action'][$key])); | |
| 606 | + | |
| 607 | + if (strlen($name) > 0) : | |
| 608 | + if ('newuser' == $author_action) : | |
| 609 | + $newuser_name = trim($GLOBALS['fwp_post']['author_rules_newuser'][$key]); | |
| 610 | + if (strlen($newuser_name) > 0) : | |
| 611 | + $userdata = array(); | |
| 612 | + $userdata['ID'] = NULL; | |
| 613 | + | |
| 614 | + $userdata['user_login'] = sanitize_user($newuser_name); | |
| 615 | + $userdata['user_login'] = apply_filters('pre_user_login', $userdata['user_login']); | |
| 616 | + | |
| 617 | + $userdata['user_nicename'] = sanitize_title($newuser_name); | |
| 618 | + $userdata['user_nicename'] = apply_filters('pre_user_nicename', $userdata['user_nicename']); | |
| 619 | + | |
| 620 | + $userdata['display_name'] = $wpdb->escape($newuser_name); | |
| 621 | + | |
| 622 | + $newuser_id = wp_insert_user($userdata); | |
| 623 | + if (is_numeric($newuser_id)) : | |
| 624 | + $link->settings['map authors']['name'][$name] = $newuser_id; | |
| 625 | + else : | |
| 626 | + // TODO: Add some error detection and reporting | |
| 627 | + endif; | |
| 628 | + else : | |
| 629 | + // TODO: Add some error reporting | |
| 630 | + endif; | |
| 631 | + else : | |
| 632 | + $link->settings['map authors']['name'][$name] = $author_action; | |
| 633 | + endif; | |
| 634 | + endif; | |
| 635 | + endforeach; | |
| 636 | + endif; | |
| 637 | + | |
| 638 | + if (isset($GLOBALS['fwp_post']['add_author_rule_name']) and isset($GLOBALS['fwp_post']['add_author_rule_action'])) : | |
| 639 | + $name = strtolower(trim($GLOBALS['fwp_post']['add_author_rule_name'])); | |
| 640 | + $author_action = strtolower(trim($GLOBALS['fwp_post']['add_author_rule_action'])); | |
| 641 | + if (strlen($name) > 0) : | |
| 642 | + if ('newuser' == $author_action) : | |
| 643 | + $newuser_name = trim($GLOBALS['fwp_post']['add_author_rule_newuser']); | |
| 644 | + if (strlen($newuser_name) > 0) : | |
| 645 | + $userdata = array(); | |
| 646 | + $userdata['ID'] = NULL; | |
| 647 | + | |
| 648 | + $userdata['user_login'] = sanitize_user($newuser_name); | |
| 649 | + $userdata['user_login'] = apply_filters('pre_user_login', $userdata['user_login']); | |
| 650 | + | |
| 651 | + $userdata['user_nicename'] = sanitize_title($newuser_name); | |
| 652 | + $userdata['user_nicename'] = apply_filters('pre_user_nicename', $userdata['user_nicename']); | |
| 653 | + | |
| 654 | + $userdata['display_name'] = $wpdb->escape($newuser_name); | |
| 655 | + | |
| 656 | + $newuser_id = wp_insert_user($userdata); | |
| 657 | + if (is_numeric($newuser_id)) : | |
| 658 | + $link->settings['map authors']['name'][$name] = $newuser_id; | |
| 659 | + else : | |
| 660 | + // TODO: Add some error detection and reporting | |
| 661 | + endif; | |
| 662 | + else : | |
| 663 | + // TODO: Add some error reporting | |
| 664 | + endif; | |
| 665 | + else : | |
| 666 | + $link->settings['map authors']['name'][$name] = $author_action; | |
| 667 | + endif; | |
| 668 | + endif; | |
| 669 | + endif; | |
| 670 | + | |
| 671 | + if (isset($GLOBALS['fwp_post']['cat_split'])) : | |
| 672 | + if (strlen(trim($GLOBALS['fwp_post']['cat_split'])) > 0) : | |
| 673 | + $link->settings['cat_split'] = trim($GLOBALS['fwp_post']['cat_split']); | |
| 674 | + else : | |
| 675 | + unset($link->settings['cat_split']); | |
| 676 | + endif; | |
| 677 | + endif; | |
| 678 | + | |
| 696 | 679 | $alter[] = "link_notes = '".$wpdb->escape($link->settings_to_notes())."'"; |
| 697 | 680 | |
| 698 | 681 | $alter_set = implode(", ", $alter); |
| 699 | 682 | |
| @@ -705,11 +688,8 @@ | ||
| 705 | 688 | "); |
| 706 | 689 | $updated_link = true; |
| 707 | 690 | |
| 708 | 691 | // reload link information from DB |
| 709 | - if (function_exists('clean_bookmark_cache')) : | |
| 710 | - clean_bookmark_cache($link_id); | |
| 711 | - endif; | |
| 712 | 692 | $link =& new SyndicatedLink($link_id); |
| 713 | 693 | else : |
| 714 | 694 | $updated_link = false; |
| 715 | 695 | endif; |
| @@ -718,8 +698,47 @@ | ||
| 718 | 698 | $link_url = wp_specialchars($db_link->link_url, 1); |
| 719 | 699 | $link_name = wp_specialchars($db_link->link_name, 1); |
| 720 | 700 | $link_description = wp_specialchars($db_link->link_description, 'both'); |
| 721 | 701 | $link_rss_uri = wp_specialchars($db_link->link_rss, 'both'); |
| 702 | + | |
| 703 | + $post_status_global = get_option('feedwordpress_syndicated_post_status'); | |
| 704 | + $comment_status_global = get_option('feedwordpress_syndicated_comment_status'); | |
| 705 | + $ping_status_global = get_option('feedwordpress_syndicated_ping_status'); | |
| 706 | + | |
| 707 | + $status['post'] = array('publish' => '', 'private' => '', 'draft' => '', 'site-default' => ''); | |
| 708 | + if (SyndicatedPost::use_api('post_status_pending')) : | |
| 709 | + $status['post']['pending'] = ''; | |
| 710 | + endif; | |
| 711 | + | |
| 712 | + $status['comment'] = array('open' => '', 'closed' => '', 'site-default' => ''); | |
| 713 | + $status['ping'] = array('open' => '', 'closed' => '', 'site-default' => ''); | |
| 714 | + | |
| 715 | + foreach (array('post', 'comment', 'ping') as $what) : | |
| 716 | + if (isset($link->settings["{$what} status"])) : | |
| 717 | + $status[$what][$link->settings["{$what} status"]] = ' checked="checked"'; | |
| 718 | + else : | |
| 719 | + $status[$what]['site-default'] = ' checked="checked"'; | |
| 720 | + endif; | |
| 721 | + endforeach; | |
| 722 | + | |
| 723 | + $unfamiliar['author'] = array ('create' => '','default' => '','filter' => ''); | |
| 724 | + $unfamiliar['category'] = array ('create'=>'','tag' => '','default'=>'','filter'=>''); | |
| 725 | + | |
| 726 | + foreach (array('author', 'category') as $what) : | |
| 727 | + if (is_string($link->settings["unfamiliar {$what}"]) and | |
| 728 | + array_key_exists($link->settings["unfamiliar {$what}"], $unfamiliar[$what])) : | |
| 729 | + $key = $link->settings["unfamiliar {$what}"]; | |
| 730 | + else: | |
| 731 | + $key = 'site-default'; | |
| 732 | + endif; | |
| 733 | + $unfamiliar[$what][$key] = ' checked="checked"'; | |
| 734 | + endforeach; | |
| 735 | + | |
| 736 | + if (is_array($link->settings['cats'])) : $cats = $link->settings['cats']; | |
| 737 | + else : $cats = array(); | |
| 738 | + endif; | |
| 739 | + | |
| 740 | + $dogs = SyndicatedPost::category_ids($cats, /*unfamiliar=*/ NULL); | |
| 722 | 741 | else : |
| 723 | 742 | die( __('Link not found.') ); |
| 724 | 743 | endif; |
| 725 | 744 | |
| @@ -732,8 +751,25 @@ | ||
| 732 | 751 | o = document.getElementById('basics-hardcode-'+item); |
| 733 | 752 | if (o.value=='yes') { ed.style.display='inline'; view.style.display='none'; } |
| 734 | 753 | else { ed.style.display='none'; view.style.display='inline'; } |
| 735 | 754 | } |
| 755 | + function flip_newuser (item) { | |
| 756 | + rollup=document.getElementById(item); | |
| 757 | + newuser=document.getElementById(item+'-newuser'); | |
| 758 | + sitewide=document.getElementById(item+'-default'); | |
| 759 | + if (rollup) { | |
| 760 | + if ('newuser'==rollup.value) { | |
| 761 | + if (newuser) newuser.style.display='block'; | |
| 762 | + if (sitewide) sitewide.style.display='none'; | |
| 763 | + } else if ('site-default'==rollup.value) { | |
| 764 | + if (newuser) newuser.style.display='none'; | |
| 765 | + if (sitewide) sitewide.style.display='block'; | |
| 766 | + } else { | |
| 767 | + if (newuser) newuser.style.display='none'; | |
| 768 | + if (sitewide) sitewide.style.display='none'; | |
| 769 | + } | |
| 770 | + } | |
| 771 | + } | |
| 736 | 772 | </script> |
| 737 | 773 | |
| 738 | 774 | <?php if ($updated_link) : ?> |
| 739 | 775 | <div class="updated"><p>Syndicated feed settings updated.</p></div> |
| @@ -740,19 +776,13 @@ | ||
| 740 | 776 | <?php endif; ?> |
| 741 | 777 | |
| 742 | 778 | <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post"> |
| 743 | 779 | <div class="wrap"> |
| 744 | -<?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_linkedit'); ?> | |
| 745 | 780 | <input type="hidden" name="link_id" value="<?php echo $link_id; ?>" /> |
| 746 | 781 | <input type="hidden" name="action" value="linkedit" /> |
| 747 | 782 | <input type="hidden" name="save" value="link" /> |
| 748 | 783 | |
| 749 | -<?php if (fwp_test_wp_version(FWP_SCHEMA_27)) : ?> | |
| 750 | - <div class="icon32"><img src="<?php print htmlspecialchars(WP_PLUGIN_URL.'/'.$GLOBALS['fwp_path'].'/feedwordpress.png'); ?>" alt="" /></div> | |
| 751 | -<?php endif; ?> | |
| 752 | - | |
| 753 | -<h2><?php _e('Feed settings'); ?><?php if (!is_null($link) and $link->found()) : ?>: <?php echo wp_specialchars($link->link->link_name, 1); ?><?php endif; ?></h2> | |
| 754 | - | |
| 784 | +<h2>Edit a syndicated feed:</h2> | |
| 755 | 785 | <div id="poststuff"> |
| 756 | 786 | <?php fwp_linkedit_single_submit($status); ?> |
| 757 | 787 | |
| 758 | 788 | <div id="post-body"> |
| @@ -806,9 +836,9 @@ | ||
| 806 | 836 | <tr> |
| 807 | 837 | <th width="20%"><?php _e('Last update') ?>:</th> |
| 808 | 838 | <td colspan="2"><?php |
| 809 | 839 | if (isset($link->settings['update/last'])) : |
| 810 | - echo fwp_time_elapsed($link->settings['update/last'])." "; | |
| 840 | + echo strftime('%x %X', $link->settings['update/last'])." "; | |
| 811 | 841 | else : |
| 812 | 842 | echo " none yet"; |
| 813 | 843 | endif; |
| 814 | 844 | ?></td></tr> |
| @@ -849,19 +879,176 @@ | ||
| 849 | 879 | |
| 850 | 880 | <?php fwp_linkedit_periodic_submit(); ?> |
| 851 | 881 | |
| 852 | 882 | <?php |
| 853 | - FeedWordPressSettingsUI::instead_of_posts_box($link_id); | |
| 854 | - FeedWordPressSettingsUI::instead_of_authors_box($link_id); | |
| 855 | - FeedWordPressSettingsUI::instead_of_categories_box($link_id); | |
| 883 | +if (!(isset($wp_db_version) and $wp_db_version >= FWP_SCHEMA_25)) : | |
| 884 | + fwp_option_box_opener('Syndicated Posts', 'syndicatedpostsdiv', 'postbox'); | |
| 885 | +?> | |
| 886 | +<table class="editform" width="75%" cellspacing="2" cellpadding="5"> | |
| 887 | +<tr><th width="27%" scope="row" style="vertical-align:top">Publication:</th> | |
| 888 | +<td width="73%" style="vertical-align:top"><ul style="margin:0; list-style:none"> | |
| 889 | +<li><label><input type="radio" name="feed_post_status" value="site-default" | |
| 890 | +<?php echo $status['post']['site-default']; ?> /> Use site-wide setting from <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/syndication-options.php">Syndication Options</a> | |
| 891 | +(currently: <strong><?php echo ($post_status_global ? $post_status_global : 'publish'); ?></strong>)</label></li> | |
| 892 | +<li><label><input type="radio" name="feed_post_status" value="publish" | |
| 893 | +<?php echo $status['post']['publish']; ?> /> Publish posts from this feed immediately</label></li> | |
| 856 | 894 | |
| 857 | - fwp_option_box_opener('Custom Feed Settings (for use in templates)', 'postcustom', 'postbox'); | |
| 895 | +<?php if (SyndicatedPost::use_api('post_status_pending')) : ?> | |
| 896 | +<li><label><input type="radio" name="feed_post_status" value="pending" | |
| 897 | +<?php echo $status['post']['pending']; ?>/> Hold posts from this feed for review; mark as Pending</label></li> | |
| 898 | +<?php endif; ?> | |
| 899 | + | |
| 900 | +<li><label><input type="radio" name="feed_post_status" value="draft" | |
| 901 | +<?php echo $status['post']['draft']; ?> /> Save posts from this feed as drafts</label></li> | |
| 902 | +<li><label><input type="radio" name="feed_post_status" value="private" | |
| 903 | +<?php echo $status['post']['private']; ?> /> Save posts from this feed as private posts</label></li> | |
| 904 | +</ul></td> | |
| 905 | +</tr> | |
| 906 | +</table> | |
| 907 | +<?php | |
| 908 | + fwp_option_box_closer(); | |
| 909 | + fwp_linkedit_periodic_submit(); | |
| 910 | +endif; | |
| 911 | + | |
| 912 | + fwp_option_box_opener(__('Categories'), 'categorydiv', 'postbox'); | |
| 913 | + fwp_category_box($dogs, 'all syndicated posts from this feed'); | |
| 858 | 914 | ?> |
| 859 | -<p class="setting-description">These custom settings are special fields for the <strong>feed</strong> you are | |
| 860 | -syndicating, to be retrieved in templates using the <code>get_feed_meta()</code> function. They do not create | |
| 861 | -custom fields on syndicated <strong>posts</strong>. If you want to create custom fields that are applied to each | |
| 862 | -individual post from this feed, set up the settings in <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/posts-page.php&link_id=<?php print $link_id; ?>">Syndicated Posts</a>.</p> | |
| 915 | +<table> | |
| 916 | +<tr> | |
| 917 | +<th width="20%" scope="row" style="vertical-align:top">Unfamiliar categories:</th> | |
| 918 | +<td width="80%"><p>When one of the categories on a syndicated post is a category that FeedWordPress has not encountered before ...</p> | |
| 863 | 919 | |
| 920 | +<ul style="margin: 0; list-style:none"> | |
| 921 | +<li><label><input type="radio" name="unfamiliar_category" value="site-default"<?php echo $unfamiliar['category']['site-default']; ?> /> use the site-wide setting from <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/syndication-options.php">Syndication Options</a> | |
| 922 | +(currently <strong><?php echo FeedWordPress::on_unfamiliar('category'); ?></strong>)</label></li> | |
| 923 | +<li><label><input type="radio" name="unfamiliar_category" value="create"<?php echo $unfamiliar['category']['create']; ?> /> create a new category</label></li> | |
| 924 | +<li><label><input type="radio" name="unfamiliar_category" value="tag"<?php echo $unfamiliar['category']['tag']; ?>/> create a new tag</label></li> | |
| 925 | +<li><label><input type="radio" name="unfamiliar_category" value="default"<?php echo $unfamiliar['category']['default']; ?> /> don't create new categories or tags</label></li> | |
| 926 | +<li><label><input type="radio" name="unfamiliar_category" value="filter"<?php echo $unfamiliar['category']['filter']; ?> /> don't create new categories or tags and don't syndicate posts unless they match at least one familiar category</label></li> | |
| 927 | +</ul></td> | |
| 928 | +</tr> | |
| 929 | + | |
| 930 | +<tr> | |
| 931 | +<th width="20%" scope="row" style="vertical-align:top">Multiple categories:</th> | |
| 932 | +<td width="80%"> | |
| 933 | +<input type="text" size="20" id="cat_split" name="cat_split" value="<?php if (isset($link->settings['cat_split'])) : echo htmlspecialchars($link->settings['cat_split']); endif; ?>" /><br/> | |
| 934 | +Enter a <a href="http://us.php.net/manual/en/reference.pcre.pattern.syntax.php">Perl-compatible regular expression</a> here if the feed provides multiple | |
| 935 | +categories in a single category element. The regular expression should match | |
| 936 | +the characters used to separate one category from the next. If the feed uses | |
| 937 | +spaces (like <a href="http://del.icio.us/">del.icio.us</a>), use the pattern "\s". | |
| 938 | +If the feed does not provide multiple categories in a single element, leave this | |
| 939 | +blank.</td> | |
| 940 | +</tr> | |
| 941 | +</table> | |
| 942 | +<?php | |
| 943 | + fwp_option_box_closer(); | |
| 944 | + fwp_linkedit_periodic_submit(); | |
| 945 | + | |
| 946 | +if (isset($wp_db_version) and $wp_db_version >= FWP_SCHEMA_25) : | |
| 947 | + fwp_tags_box($link->settings['tags']); | |
| 948 | + fwp_linkedit_periodic_submit(); | |
| 949 | +endif; ?> | |
| 950 | + | |
| 951 | +<?php fwp_option_box_opener('Syndicated Authors', 'authordiv', 'postbox'); ?> | |
| 952 | +<?php $authorlist = fwp_author_list(); ?> | |
| 953 | +<table> | |
| 954 | +<tr><th colspan="3" style="text-align: left; padding-top: 1.0em; border-bottom: 1px dotted black;">For posts by authors that haven't been syndicated before:</th></tr> | |
| 955 | +<tr> | |
| 956 | + <th style="text-align: left">Posts by new authors</th> | |
| 957 | + <td> | |
| 958 | + <select id="unfamiliar-author" name="unfamiliar_author" onchange="flip_newuser('unfamiliar-author');"> | |
| 959 | + <option value="site-default"<?php if (!isset($link->settings['unfamiliar author'])) : ?>selected="selected"<?php endif; ?>>are handled using site-wide settings</option> | |
| 960 | + <option value="create"<?php if ('create'==$link->settings['unfamiliar author']) : ?>selected="selected"<?php endif; ?>>create a new author account</option> | |
| 961 | + <?php foreach ($authorlist as $author_id => $author_name) : ?> | |
| 962 | + <option value="<?php echo $author_id; ?>"<?php if ($author_id==$link->settings['unfamiliar author']) : ?>selected="selected"<?php endif; ?>>are assigned to <?php echo $author_name; ?></option> | |
| 963 | + <?php endforeach; ?> | |
| 964 | + <option value="newuser">will be assigned to a new user...</option> | |
| 965 | + <option value="filter"<?php if ('filter'==$link->settings['unfamiliar author']) : ?>selected="selected"<?php endif; ?>>get filtered out</option> | |
| 966 | + </select> | |
| 967 | + </td> | |
| 968 | + <td> | |
| 969 | + <div id="unfamiliar-author-default">Site-wide settings can be set in <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/syndication-options.php">Syndication Options</a></div> | |
| 970 | + <div id="unfamiliar-author-newuser">named <input type="text" name="unfamiliar_author_newuser" value="" /></div> | |
| 971 | + </td> | |
| 972 | +</tr> | |
| 973 | + | |
| 974 | +<tr><th colspan="3" style="text-align: left; padding-top: 1.0em; border-bottom: 1px dotted black;">For posts by specific authors. Blank out a name to delete the rule.</th></tr> | |
| 975 | + | |
| 976 | +<?php if (isset($link->settings['map authors'])) : $i=0; foreach ($link->settings['map authors'] as $author_rules) : foreach ($author_rules as $author_name => $author_action) : $i++; ?> | |
| 977 | +<tr> | |
| 978 | + <th style="text-align: left">Posts by <input type="text" name="author_rules_name[]" value="<?php echo htmlspecialchars($author_name); ?>" /></th> | |
| 979 | + <td> | |
| 980 | + <select id="author-rules-<?php echo $i; ?>" name="author_rules_action[]" onchange="flip_newuser('author-rules-<?php echo $i; ?>');"> | |
| 981 | + <?php foreach ($authorlist as $local_author_id => $local_author_name) : ?> | |
| 982 | + <option value="<?php echo $local_author_id; ?>"<?php if ($local_author_id==$author_action) : echo ' selected="selected"'; endif; ?>>are assigned to <?php echo $local_author_name; ?></option> | |
| 983 | + <?php endforeach; ?> | |
| 984 | + <option value="newuser">will be assigned to a new user...</option> | |
| 985 | + <option value="filter"<?php if ('filter'==$author_action) : echo ' selected="selected"'; endif; ?>>get filtered out</option> | |
| 986 | + </select> | |
| 987 | + </td> | |
| 988 | + <td><div id="author-rules-<?php echo $i; ?>-newuser">named <input type="text" name="author_rules_newuser[]" value="" /></div></td> | |
| 989 | +</tr> | |
| 990 | +<?php endforeach; endforeach; endif; ?> | |
| 991 | + | |
| 992 | +<tr><th colspan="3" style="text-align: left; padding-top: 1.0em; border-bottom: 1px dotted black;">Fill in to set up a new rule:</th></tr> | |
| 993 | + | |
| 994 | +<tr> | |
| 995 | + <th style="text-align: left">Posts by <input type="text" name="add_author_rule_name" /></th> | |
| 996 | + <td> | |
| 997 | + <select id="add-author-rule" name="add_author_rule_action" onchange="flip_newuser('add-author-rule');"> | |
| 998 | + <?php foreach ($authorlist as $author_id => $author_name) : ?> | |
| 999 | + <option value="<?php echo $author_id; ?>">are assigned to <?php echo $author_name; ?></option> | |
| 1000 | + <?php endforeach; ?> | |
| 1001 | + <option value="newuser">will be assigned to a new user...</option> | |
| 1002 | + <option value="filter">get filtered out</option> | |
| 1003 | + </select> | |
| 1004 | + </td> | |
| 1005 | + <td><div id="add-author-rule-newuser">named <input type="text" name="add_author_rule_newuser" value="" /></div></td> | |
| 1006 | +</tr> | |
| 1007 | + | |
| 1008 | +</table> | |
| 1009 | +<?php fwp_option_box_closer(); ?> | |
| 1010 | + | |
| 1011 | +<script> | |
| 1012 | + flip_newuser('unfamiliar-author'); | |
| 1013 | +<?php for ($j=1; $j<=$i; $j++) : ?> | |
| 1014 | + flip_newuser('author-rules-<?php echo $j; ?>'); | |
| 1015 | +<?php endfor; ?> | |
| 1016 | + flip_newuser('add-author-rule'); | |
| 1017 | +</script> | |
| 1018 | + | |
| 1019 | +<?php | |
| 1020 | + fwp_linkedit_periodic_submit(); | |
| 1021 | + fwp_option_box_opener('Comments & Pings', 'commentstatusdiv', 'postbox'); | |
| 1022 | +?> | |
| 1023 | +<table class="editform" width="75%" cellspacing="2" cellpadding="5"> | |
| 1024 | +<tr><th width="27%" scope="row" style="vertical-align:top"><?php print __('Comments'); ?>:</th> | |
| 1025 | +<td width="73%"><ul style="margin:0; list-style:none"> | |
| 1026 | +<li><label><input type="radio" name="feed_comment_status" value="site-default" | |
| 1027 | +<?php echo $status['comment']['site-default']; ?> /> Use site-wide setting from <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/syndication-options.php">Syndication Options</a> | |
| 1028 | +(currently: <strong><?php echo ($comment_status_global ? $comment_status_global : 'closed'); ?>)</strong></label></li> | |
| 1029 | +<li><label><input type="radio" name="feed_comment_status" value="open" | |
| 1030 | +<?php echo $status['comment']['open']; ?> /> Allow comments on syndicated posts from this feed</label></li> | |
| 1031 | +<li><label><input type="radio" name="feed_comment_status" value="closed" | |
| 1032 | +<?php echo $status['comment']['closed']; ?> /> Don't allow comments on syndicated posts from this feed</label></li> | |
| 1033 | +</ul></td></tr> | |
| 1034 | + | |
| 1035 | +<tr><th width="27%" scope="row" style="vertical-align:top"><?php print __('Pings'); ?>:</th> | |
| 1036 | +<td width="73%"><ul style="margin:0; list-style:none"> | |
| 1037 | +<li><label><input type="radio" name="feed_ping_status" value="site-default" | |
| 1038 | +<?php echo $status['ping']['site-default']; ?> /> Use site-wide setting from <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/syndication-options.php">Syndication Options</a> | |
| 1039 | +(currently: <strong><?php echo ($ping_status_global ? $ping_status_global : 'closed'); ?>)</strong></label></li> | |
| 1040 | +<li><label><input type="radio" name="feed_ping_status" value="open" | |
| 1041 | +<?php echo $status['ping']['open']; ?> /> Accept pings on syndicated posts from this feed</label></li> | |
| 1042 | +<li><label><input type="radio" name="feed_ping_status" value="closed" | |
| 1043 | +<?php echo $status['ping']['closed']; ?> /> Don't accept pings on syndicated posts from this feed</label></li> | |
| 1044 | +</ul></td></tr> | |
| 1045 | + | |
| 1046 | +</table> | |
| 1047 | +<?php fwp_option_box_closer(); ?> | |
| 1048 | +<?php fwp_linkedit_periodic_submit(); ?> | |
| 1049 | + | |
| 1050 | +<?php fwp_option_box_opener('Custom Settings (for use in templates)', 'postcustom', 'postbox'); ?> | |
| 864 | 1051 | <div id="postcustomstuff"> |
| 865 | 1052 | <table id="meta-list" cellpadding="3"> |
| 866 | 1053 | <tr> |
| 867 | 1054 | <th>Key</th> |
| @@ -896,9 +1083,8 @@ | ||
| 896 | 1083 | </table> |
| 897 | 1084 | <?php fwp_option_box_closer(); ?> |
| 898 | 1085 | |
| 899 | 1086 | <?php fwp_linkedit_periodic_submit(); ?> |
| 900 | -<?php fwp_linkedit_single_submit_closer(); ?> | |
| 901 | 1087 | </div> <!-- id="post-body" --> |
| 902 | 1088 | </div> <!-- id="poststuff" --> |
| 903 | 1089 | </div> |
| 904 | 1090 | <?php |
| @@ -908,15 +1094,16 @@ | ||
| 908 | 1094 | |
| 909 | 1095 | function fwp_multidelete_page () { |
| 910 | 1096 | global $wpdb; |
| 911 | 1097 | |
| 912 | - // If this is a POST, validate source and user credentials | |
| 913 | - FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_feeds', /*capability=*/ 'manage_links'); | |
| 1098 | + check_admin_referer(); // Make sure the referers are kosher | |
| 914 | 1099 | |
| 915 | 1100 | $link_ids = (isset($_REQUEST['link_ids']) ? $_REQUEST['link_ids'] : array()); |
| 916 | 1101 | if (isset($_REQUEST['link_id'])) : array_push($link_ids, $_REQUEST['link_id']); endif; |
| 917 | 1102 | |
| 918 | - if (isset($GLOBALS['fwp_post']['confirm']) and $GLOBALS['fwp_post']['confirm']=='Delete'): | |
| 1103 | + if (!current_user_can('manage_links')): | |
| 1104 | + die (__("Cheatin' uh ?")); | |
| 1105 | + elseif (isset($GLOBALS['fwp_post']['confirm']) and $GLOBALS['fwp_post']['confirm']=='Delete'): | |
| 919 | 1106 | foreach ($GLOBALS['fwp_post']['link_action'] as $link_id => $what) : |
| 920 | 1107 | $do_it[$what][] = $link_id; |
| 921 | 1108 | endforeach; |
| 922 | 1109 | |
| @@ -997,9 +1184,8 @@ | ||
| 997 | 1184 | "); |
| 998 | 1185 | ?> |
| 999 | 1186 | <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post"> |
| 1000 | 1187 | <div class="wrap"> |
| 1001 | -<?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?> | |
| 1002 | 1188 | <input type="hidden" name="action" value="Unsubscribe" /> |
| 1003 | 1189 | <input type="hidden" name="confirm" value="Delete" /> |
| 1004 | 1190 | |
| 1005 | 1191 | <h2>Unsubscribe from Syndicated Links:</h2> |