PluginProbe
FeedWordPress / 2011.0211.2
FeedWordPress v2011.0211.2
trunk 0.8 0.9 0.91 0.95 0.96 0.97 0.98 0.981 0.99 0.991 0.992 0.993 2008.1030 2008.1101 2008.1105 2008.1214 2009.0612 2009.0613 2009.0618 2009.0707 2009.1111 2009.1112 2010.0127 2010.0528 All 65 releases
← All changes | syndication.php +2 -687 2010.05282011.0211.2 View file →
@@ -1,691 +1,6 @@
1 1 <?php
2 -require_once(dirname(__FILE__) . '/admin-ui.php');
2 + require_once(dirname(__FILE__).'/feedwordpresssyndicationpage.class.php');
3 3
4 -################################################################################
5 -## ADMIN MENU ADD-ONS: implement Dashboard management pages ####################
6 -################################################################################
7 -
8 -if (fwp_test_wp_version(0, FWP_SCHEMA_25)) :
9 - define('FWP_UPDATE_CHECKED', 'Update Checked Links');
10 - define('FWP_UNSUB_CHECKED', 'Unsubscribe from Checked Links');
11 - define('FWP_SYNDICATE_NEW', 'Syndicate ...');
12 -else :
13 - define('FWP_UPDATE_CHECKED', 'Update Checked');
14 - define('FWP_UNSUB_CHECKED', 'Unsubscribe');
15 - define('FWP_SYNDICATE_NEW', 'Syndicate ...');
16 -endif;
17 -
18 -class FeedWordPressSyndicationPage extends FeedWordPressAdminPage {
19 - function FeedWordPressSyndicationPage () {
20 - FeedWordPressAdminPage::FeedWordPressAdminPage('feedwordpresssyndication', /*link=*/ NULL);
21 -
22 - // No over-arching form element
23 - $this->dispatch = NULL;
24 - $this->filename = __FILE__;
25 - } /* FeedWordPressSyndicationPage constructor */
26 -
27 - function has_link () { return false; }
28 -
29 - function display () {
30 - global $wpdb;
31 -
32 - if (FeedWordPress::needs_upgrade()) :
33 - fwp_upgrade_page();
34 - return;
35 - endif;
36 -
37 - ?>
38 - <?php $cont = true;
39 - if (isset($_REQUEST['action'])):
40 - if ($_REQUEST['action'] == 'feedfinder' or $_REQUEST['action']==FWP_SYNDICATE_NEW) : $cont = fwp_feedfinder_page();
41 - elseif ($_REQUEST['action'] == 'switchfeed') : $cont = fwp_switchfeed_page();
42 - elseif ($_REQUEST['action'] == FWP_UNSUB_CHECKED or $_REQUEST['action'] == 'Unsubscribe') : $cont = fwp_multidelete_page();
43 - endif;
44 - endif;
45 -
46 - if ($cont):
47 - ?>
48 - <style type="text/css">
49 - .heads-up {
50 - background-color: #d0d0d0;
51 - color: black;
52 - padding: 1.0em;
53 - margin: 0.5em 4.0em !important;
54 - }
55 - .update-form.with-donation {
56 - margin-right: 50%;
57 - min-height: 255px;
58 - }
59 - .donation-form, .donation-thanks {
60 - background-color: #ffffcc;
61 - text-align: left;
62 - padding: 0.5em 0.5em;
63 - border-left: thin dashed #777777;
64 - font-size: 70%;
65 - position: absolute;
66 - top: 0; bottom: 0; right: 0; left: auto;
67 - width: 50%;
68 - }
69 - .donation-thanks {
70 - background-color: #ccffcc;
71 - }
72 - .donation-thanks .signature {
73 - text-align: right;
74 - font-style: italic;
75 - }
76 - .donation-form h4, .donation-thanks h4 {
77 - font-size: 10px;
78 - text-align: center;
79 - border-bottom: 1px solid #777777;
80 - margin: 0px;
81 - }
82 - .donation-form .donate {
83 - text-align: center;
84 - }
85 - .donation-form .sod-off {
86 - padding-top: 0.5em;
87 - margin-top: 0.5em;
88 - border-top: thin solid #777777;
89 - }
90 - </style>
91 - <?php
92 - $links = FeedWordPress::syndicated_links();
93 - $this->open_sheet('Syndicated Sites');
94 - ?>
95 - <div id="post-body">
96 - <?php
97 - if ($links) :
98 - fwp_add_meta_box(
99 - /*id=*/ 'feedwordpress_update_box',
100 - /*title=*/ __('Update feeds now'),
101 - /*callback=*/ 'fwp_syndication_manage_page_update_box',
102 - /*page=*/ $this->meta_box_context(),
103 - /*context =*/ $this->meta_box_context()
104 - );
105 - endif;
106 - fwp_add_meta_box(
107 - /*id=*/ 'feedwordpress_feeds_box',
108 - /*title=*/ __('Syndicated sources'),
109 - /*callback=*/ 'fwp_syndication_manage_page_links_box',
110 - /*page=*/ $this->meta_box_context(),
111 - /*context =*/ $this->meta_box_context()
112 - );
113 - if (FeedWordPressCompatibility::test_version(0, FWP_SCHEMA_25)) :
114 - fwp_add_meta_box(
115 - /*id=*/ 'feedwordpress_add_feed_box',
116 - /*title=*/ 'Add a new syndicated source',
117 - /*callback=*/ 'fwp_syndication_manage_page_add_feed_box',
118 - /*page=*/ $this->meta_box_context(),
119 - /*context=*/ $this->meta_box_context()
120 - );
121 - endif;
122 -
123 - do_action('feedwordpress_admin_page_syndication_meta_boxes', $this);
124 - ?>
125 - <div class="metabox-holder">
126 - <?php
127 - fwp_do_meta_boxes($this->meta_box_context(), $this->meta_box_context(), $this);
128 - ?>
129 - </div> <!-- class="metabox-holder" -->
130 - </div> <!-- id="post-body" -->
131 -
132 - <?php $this->close_sheet(/*dispatch=*/ NULL); ?>
133 -
134 - <div style="display: none">
135 - <div id="tags-input"></div> <!-- avoid JS error from WP 2.5 bug -->
136 - </div>
137 - <?php
138 - endif;
139 - } /* FeedWordPressSyndicationPage::display () */
140 -
141 - function bleg_thanks ($page, $box = NULL) {
142 - ?>
143 - <div class="donation-thanks">
144 - <h4>Thank you!</h4>
145 - <p><strong>Thank you</strong> for your contribution to <a href="http://feedwordpress.radgeek.com/">FeedWordPress</a> development.
146 - Your generous gifts make ongoing support and development for
147 - FeedWordPress possible.</p>
148 - <p>If you have any questions about FeedWordPress, or if there
149 - is anything I can do to help make FeedWordPress more useful for
150 - you, please <a href="http://feedwordpress.radgeek.com/contact">contact me</a>
151 - and let me know what you're thinking about.</p>
152 - <p class="signature">&#8212;<a href="http://radgeek.com/">Charles Johnson</a>, Developer, <a href="http://feedwordpress.radgeek.com/">FeedWordPress</a>.</p>
153 - </div>
154 - <?php
155 - } /* FeedWordPressSyndicationPage::bleg_thanks () */
156 -
157 - function bleg_box ($page, $box = NULL) {
158 - ?>
159 -<div class="donation-form">
160 -<h4>Keep FeedWordPress improving</h4>
161 -<form action="https://www.paypal.com/cgi-bin/webscr" accept-charset="UTF-8" method="post"><div>
162 -<p><a href="http://feedwordpress.radgeek.com/">FeedWordPress</a> makes syndication
163 -simple and empowers you to stream content from all over the web into your
164 -WordPress hub. That's got to be worth a few lattes. If you're finding FWP useful,
165 -<a href="http://feedwordpress.radgeek.com/donation/">a modest gift</a>
166 -is the best way to support steady progress on development, enhancements,
167 -support, and documentation.</p>
168 -<div class="donate">
169 -<input type="hidden" name="business" value="commerce@radgeek.com" />
170 -<input type="hidden" name="cmd" value="_xclick" />
171 -<input type="hidden" name="item_name" value="FeedWordPress donation" />
172 -<input type="hidden" name="no_shipping" value="1" />
173 -<input type="hidden" name="return" value="<?php bloginfo('url'); ?>/wp-admin/admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php print basename(__FILE__); ?>&amp;paid=yes" />
174 -<input type="hidden" name="currency_code" value="USD" />
175 -<input type="hidden" name="notify_url" value="http://feedwordpress.radgeek.com/ipn/donation" />
176 -<input type="hidden" name="custom" value="1" />
177 -<input type="image" name="submit" src="https://www.paypal.com/en_GB/i/btn/btn_donate_SM.gif" alt="Donate through PayPal" />
178 -</div>
179 -</div></form>
180 -
181 -<p>You can make a gift online (or
182 -<a href="http://feedwordpress.radgeek.com/donation">set up an automatic
183 -regular donation</a>) using an existing PayPal account or any major credit card.</p>
184 -
185 -<div class="sod-off">
186 -<form style="text-align: center" action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php print basename(__FILE__); ?>" method="POST"><div>
187 -<input class="button-primary" type="submit" name="maybe_later" value="Maybe Later" />
188 -<input class="button-secondary" type="submit" name="go_away" value="Dismiss" />
189 -</div></form>
190 -</div>
191 -</div> <!-- class="donation-form" -->
192 - <?php
193 - } /* FeedWordPressSyndicationPage::bleg_box () */
194 -
195 - /**
196 - * Override the default display of a save-settings button and replace
197 - * it with nothing.
198 - */
199 - function interstitial () {
200 - /* NOOP */
201 - } /* FeedWordPressSyndicationPage::interstitial() */
202 -} /* class FeedWordPressSyndicationPage */
203 -
204 -function fwp_dashboard_update_if_requested () {
205 - global $wpdb;
206 -
207 - if (isset($_POST['update']) or isset($_POST['action']) or isset($_POST['update_uri'])) :
208 - $fwp_update_invoke = 'post';
209 - else :
210 - $fwp_update_invoke = 'get';
211 - endif;
212 -
213 - $update_set = array();
214 - if (isset($_POST['link_ids']) and is_array($_POST['link_ids']) and ($_POST['action']==FWP_UPDATE_CHECKED)) :
215 - $targets = $wpdb->get_results("
216 - SELECT * FROM $wpdb->links
217 - WHERE link_id IN (".implode(",",$_POST['link_ids']).")
218 - ");
219 - if (is_array($targets)) :
220 - foreach ($targets as $target) :
221 - $update_set[] = $target->link_rss;
222 - endforeach;
223 - else : // This should never happen
224 - FeedWordPress::critical_bug('fwp_syndication_manage_page::targets', $targets, __LINE__);
225 - endif;
226 - elseif (isset($_POST['update_uri'])) :
227 - $update_set[] = $_POST['update_uri'];
228 - endif;
229 -
230 - shuffle($update_set); // randomize order for load balancing purposes...
231 - if ($fwp_update_invoke != 'get' and count($update_set) > 0) : // Only do things with side-effects for HTTP POST or command line
232 - $feedwordpress = new FeedWordPress;
233 - add_action('feedwordpress_check_feed', 'update_feeds_mention');
234 - add_action('feedwordpress_check_feed_complete', 'update_feeds_finish', 10, 3);
235 -
236 - $crash_dt = (int) get_option('feedwordpress_update_time_limit');
237 - if ($crash_dt > 0) :
238 - $crash_ts = time() + $crash_dt;
239 - else :
240 - $crash_ts = NULL;
241 - endif;
242 -
243 - if (fwp_test_wp_version(FWP_SCHEMA_25)) :
244 - echo "<div class=\"youare\">\n";
245 - else :
246 - echo "<div class=\"updated\">\n";
247 - endif;
248 - echo "<ul>\n";
249 - $tdelta = NULL;
250 - foreach ($update_set as $uri) :
251 - if (!is_null($crash_ts) and (time() > $crash_ts)) :
252 - echo "<li><p><strong>Further updates postponed:</strong> update time limit of ".$crash_dt." second".(($crash_dt==1)?"":"s")." exceeded.</p></li>";
253 - break;
254 - endif;
255 -
256 - if ($uri == '*') : $uri = NULL; endif;
257 - $delta = $feedwordpress->update($uri, $crash_ts);
258 - if (!is_null($delta)) :
259 - if (is_null($tdelta)) :
260 - $tdelta = $delta;
261 - else :
262 - $tdelta['new'] += $delta['new'];
263 - $tdelta['updated'] += $delta['updated'];
264 - endif;
265 - else :
266 - echo "<li><p><strong>Error:</strong> There was a problem updating <a href=\"$uri\">$uri</a></p></li>\n";
267 - endif;
268 - endforeach;
269 - echo "</ul>\n";
270 -
271 - if (!is_null($tdelta)) :
272 - $mesg = array();
273 - if (isset($delta['new'])) : $mesg[] = ' '.$tdelta['new'].' new posts were syndicated'; endif;
274 - if (isset($delta['updated'])) : $mesg[] = ' '.$tdelta['updated'].' existing posts were updated'; endif;
275 - echo "<p>Update complete.".implode(' and', $mesg)."</p>";
276 - echo "\n"; flush();
277 - endif;
278 - echo "</div> <!-- class=\"updated\" -->\n";
279 - endif;
280 -}
281 -
282 -function fwp_syndication_manage_page_add_feed_box ($object = NULL, $box = NULL) {
283 - ?>
284 - <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php print basename(__FILE__); ?>" method="post">
285 - <div>
286 - <?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?>
287 - <label for="add-uri">Website or feed:</label>
288 - <input type="text" name="lookup" id="add-uri" value="URI" size="64" />
289 - <input type="hidden" name="action" value="feedfinder" />
290 - </div>
291 - <div class="submit"><input type="submit" value="<?php print FWP_SYNDICATE_NEW; ?>" /></div>
292 - </form>
293 - <?php
294 -}
295 -
296 -define('FEEDWORDPRESS_BLEG_MAYBE_LATER_OFFSET', (60 /*sec/min*/ * 60 /*min/hour*/ * 24 /*hour/day*/ * 31 /*days*/));
297 -define('FEEDWORDPRESS_BLEG_ALREADY_PAID_OFFSET', (60 /*sec/min*/ * 60 /*min/hour*/ * 24 /*hour/day*/ * 183 /*days*/));
298 -function fwp_syndication_manage_page_update_box ($object = NULL, $box = NULL) {
299 - $bleg_box_hidden = null;
300 - if (isset($_POST['maybe_later'])) :
301 - $bleg_box_hidden = time() + FEEDWORDPRESS_BLEG_MAYBE_LATER_OFFSET;
302 - elseif (isset($_REQUEST['paid']) and $_REQUEST['paid']) :
303 - $bleg_box_hidden = time() + FEEDWORDPRESS_BLEG_ALREADY_PAID_OFFSET;
304 - elseif (isset($_POST['go_away'])) :
305 - $bleg_box_hidden = 'permanent';
306 - endif;
307 -
308 - if (!is_null($bleg_box_hidden)) :
309 - update_option('feedwordpress_bleg_box_hidden', $bleg_box_hidden);
310 - else :
311 - $bleg_box_hidden = get_option('feedwordpress_bleg_box_hidden');
312 - endif;
313 -?>
314 - <?php
315 - $bleg_box_ready = (!$bleg_box_hidden or (is_numeric($bleg_box_hidden) and $bleg_box_hidden < time()));
316 - if (isset($_REQUEST['paid']) and $_REQUEST['paid']) :
317 - $object->bleg_thanks($subject, $box);
318 - elseif ($bleg_box_ready) :
319 - $object->bleg_box($object, $box);
320 - endif;
321 - ?>
322 -
323 - <form
324 - action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php print basename(__FILE__); ?>"
325 - method="POST"
326 - class="update-form<?php if ($bleg_box_ready) : ?> with-donation<?php endif; ?>"
327 - >
328 - <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div>
329 - <p>Check currently scheduled feeds for new and updated posts.</p>
330 -
331 - <?php
332 - fwp_dashboard_update_if_requested();
333 -
334 - if (!get_option('feedwordpress_automatic_updates')) :
335 - ?>
336 - <p class="heads-up"><strong>Note:</strong> Automatic updates are currently turned
337 - <strong>off</strong>. New posts from your feeds will not be syndicated
338 - until you manually check for them here. You can turn on automatic
339 - updates under <a href="admin.php?page=<?php print $GLOBALS['fwp_path']; ?>/feeds-page.php">Feed &amp; Update Settings<a></a>.</p>
340 - <?php
341 - endif;
342 - ?>
343 -
344 - <div class="submit"><input type="hidden" name="update_uri" value="*" /><input class="button-primary" type="submit" name="update" value="Update" /></div>
345 -
346 - <?php if (fwp_test_wp_version(FWP_SCHEMA_27)) : ?>
347 - <br style="clear: both" />
348 - <?php /* elseif (fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_27)) :
349 - </div> <!-- id="rightnow" -->
350 - <?php */ endif; ?>
351 - </form>
352 -<?php
353 -} /* function fwp_syndication_manage_page_update_box () */
354 -
355 -function fwp_syndication_manage_page_links_box ($object = NULL, $box = NULL) {
356 - $links = FeedWordPress::syndicated_links();
357 -?>
358 - <form id="syndicated-links" action="admin.php?page=<?php print $GLOBALS['fwp_path']; ?>/<?php echo basename(__FILE__); ?>" method="post">
359 - <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div>
360 -
361 -<?php $alt_row = true; ?>
362 -
363 - <?php if (fwp_test_wp_version(FWP_SCHEMA_25)) : ?>
364 - <div class="tablenav">
365 - <div class="alignright">
366 - <label for="add-uri">Add new source:</label>
367 - <input type="text" name="lookup" id="add-uri" value="Website or feed URI" />
368 - <?php FeedWordPressSettingsUI::magic_input_tip_js('add-uri'); ?>
369 -
370 - <input type="hidden" name="action" value="feedfinder" />
371 - <input type="submit" class="button-secondary" name="action" value="<?php print FWP_SYNDICATE_NEW; ?>" /></div>
372 -
373 -<?php if (count($links) > 0) : ?>
374 - <div class="alignleft">
375 - <input class="button-secondary" type="submit" name="action" value="<?php print FWP_UPDATE_CHECKED; ?>" />
376 - <input class="button-secondary delete" type="submit" class="delete" name="action" value="<?php print FWP_UNSUB_CHECKED; ?>" />
377 - </div>
378 -<?php endif; ?>
379 -
380 - <br class="clear" />
381 - </div>
382 - <br class="clear" />
383 -
384 - <table class="widefat">
385 - <?php else : ?>
386 - <table width="100%" cellpadding="3" cellspacing="3">
387 - <?php endif; ?>
388 -<thead>
389 -<tr>
390 -<th class="check-column" scope="col"><?php if (fwp_test_wp_version(FWP_SCHEMA_25)) : ?>
391 -<input type="checkbox" <?php if (fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_26)) : ?>onclick="checkAll(document.getElementById('syndicated-links'));"<?php endif; ?> />
392 -<?php endif; ?></th>
393 -<th scope="col"><?php _e('Name'); ?></th>
394 -<th scope="col"><?php _e('Feed'); ?></th>
395 -<th scope="col"><?php _e('Updated'); ?></th>
396 -</tr>
397 -</thead>
398 -
399 -<tbody>
400 -<?php if (count($links) > 0): foreach ($links as $link):
401 - $alt_row = !$alt_row; ?>
402 -<tr<?php echo ($alt_row?' class="alternate"':''); ?>>
403 -<th class="check-column" scope="row"><input type="checkbox" name="link_ids[]" value="<?php echo $link->link_id; ?>" /></th>
404 -<?php
405 - if (strlen($link->link_rss) > 0):
406 - $caption=__('Switch Feed');
407 - else :
408 - $caption=__('Find Feed');
409 - endif;
410 -?>
411 -<td>
412 -<strong><a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/feeds-page.php&amp;link_id=<?php echo $link->link_id; ?>"><?php echo esc_html($link->link_name); ?></a></strong>
413 -<div class="row-actions"><div><strong>Settings &gt;</strong>
414 -<a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/feeds-page.php&amp;link_id=<?php echo $link->link_id; ?>"><?php _e('Feed'); ?></a>
415 -| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/posts-page.php&amp;link_id=<?php echo $link->link_id; ?>"><?php _e('Posts'); ?></a>
416 -| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/authors-page.php&amp;link_id=<?php echo $link->link_id; ?>"><?php _e('Authors'); ?></a>
417 -| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/categories-page.php&amp;link_id=<?php echo $link->link_id; ?>"><?php print htmlspecialchars(__('Categories'.FEEDWORDPRESS_AND_TAGS)); ?></a></div>
418 -<div><strong>Actions &gt;</strong>
419 -<a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&amp;link_id=<?php echo $link->link_id; ?>&amp;action=feedfinder"><?php echo $caption; ?></a>
420 -| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&amp;link_id=<?php echo $link->link_id; ?>&amp;action=Unsubscribe"><?php _e('Unsubscribe'); ?></a>
421 -| <a href="<?php echo esc_html($link->link_url); ?>"><?php _e('View')?></a></div>
422 -</div>
423 -</td>
424 - <?php if (strlen($link->link_rss) > 0): ?>
425 - <td><a href="<?php echo esc_html($link->link_rss); ?>"><?php echo esc_html(feedwordpress_display_url($link->link_rss, 32)); ?></a></td>
426 - <?php else: ?>
427 - <td style="background-color:#FFFFD0"><p><strong>no
428 - feed assigned</strong></p></td>
429 - <?php endif; ?>
430 -
431 - <td><?php
432 - $sLink = new SyndicatedLink($link->link_id);
433 - if (isset($sLink->settings['update/last'])) :
434 - print fwp_time_elapsed($sLink->settings['update/last']);
435 - else :
436 - _e('None yet');
437 - endif;
438 -
439 - print "<div style='font-style:italic;size:0.9em'>Ready for next update ";
440 - if (isset($sLink->settings['update/ttl']) and is_numeric($sLink->settings['update/ttl'])) :
441 - if (isset($sLink->settings['update/timed']) and $sLink->settings['update/timed']=='automatically') :
442 - $next = $sLink->settings['update/last'] + ((int) $sLink->settings['update/ttl'] * 60);
443 - print fwp_time_elapsed($next);
444 - if (FEEDWORDPRESS_DEBUG) : print " [".(($next-time())/60)." minutes]"; endif;
445 - else :
446 - echo "every ".$sLink->settings['update/ttl']." minute".(($sLink->settings['update/ttl']!=1)?"s":"");
447 - endif;
448 - else:
449 - echo "as soon as possible";
450 - endif;
451 - unset($sLink);
452 - print "</div>";
453 -?>
454 - </td>
455 - </tr>
456 -<?php
457 - endforeach;
458 - else :
459 -?>
460 -<tr><td colspan="<?php print $span+2; ?>"><p>There are no websites currently listed for syndication.</p></td></tr>
461 -<?php
462 - endif;
463 -?>
464 -</tbody>
465 -</table>
466 -
467 -<?php if (count($links) > 0 and fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?>
468 -<br/><hr/>
469 -<div class="submit"><input type="submit" class="delete" name="action" value="<?php print FWP_UNSUB_CHECKED; ?>" />
470 -<input type="submit" name="action" value="<?php print FWP_UPDATE_CHECKED; ?>" /></div>
471 -<?php endif; ?>
472 -
473 - </form>
474 -<?php
475 -} /* function fwp_syndication_manage_page_links_box() */
476 -
477 -function fwp_feedfinder_page () {
478 - global $post_source;
479 -
480 - $post_source = 'feedwordpress_feeds';
481 -
482 - // With action=feedfinder, this goes directly to the feedfinder page
483 - include_once(dirname(__FILE__) . '/feeds-page.php');
484 - return false;
485 -} /* function fwp_feedfinder_page () */
486 -
487 -function fwp_switchfeed_page () {
488 - global $wpdb, $wp_db_version;
489 - global $fwp_post;
490 -
491 - // If this is a POST, validate source and user credentials
492 - FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_switchfeed', /*capability=*/ 'manage_links');
493 -
494 - $changed = false;
495 - if (!isset($fwp_post['Cancel'])):
496 - if (isset($fwp_post['save_link_id']) and ($fwp_post['save_link_id']=='*')) :
497 - $changed = true;
498 - $link_id = FeedWordPress::syndicate_link($fwp_post['feed_title'], $fwp_post['feed_link'], $fwp_post['feed']);
499 - if ($link_id):
500 - $existingLink = new SyndicatedLink($link_id);
501 - ?>
502 -<div class="updated"><p><a href="<?php print $fwp_post['feed_link']; ?>"><?php print esc_html($fwp_post['feed_title']); ?></a>
503 -has been added as a contributing site, using the feed at
504 -&lt;<a href="<?php print $fwp_post['feed']; ?>"><?php print esc_html($fwp_post['feed']); ?></a>&gt;.
505 -| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/feeds-page.php&amp;link_id=<?php print $link_id; ?>">Configure settings</a>.</p></div>
506 -<?php else: ?>
507 -<div class="updated"><p>There was a problem adding the feed. [SQL: <?php echo esc_html(mysql_error()); ?>]</p></div>
508 -<?php endif;
509 - elseif (isset($fwp_post['save_link_id'])):
510 - $existingLink = new SyndicatedLink($fwp_post['save_link_id']);
511 - $changed = $existingLink->set_uri($fwp_post['feed']);
512 -
513 - if ($changed):
514 - $home = $existingLink->homepage(/*from feed=*/ false);
515 - $name = $existingLink->name(/*from feed=*/ false);
516 - ?>
517 -<div class="updated"><p>Feed for <a href="<?php echo esc_html($home); ?>"><?php echo esc_html($name); ?></a>
518 -updated to &lt;<a href="<?php echo esc_html($fwp_post['feed']); ?>"><?php echo esc_html($fwp_post['feed']); ?></a>&gt;.</p></div>
519 - <?php
520 - endif;
521 - endif;
522 - endif;
523 -
524 - if (isset($existingLink)) :
525 - do_action('feedwordpress_admin_switchfeed', $fwp_post['feed'], $existingLink);
526 - endif;
527 -
528 - if (!$changed) :
529 - ?>
530 -<div class="updated"><p>Nothing was changed.</p></div>
531 - <?php
532 - endif;
533 - return true; // Continue
534 -}
535 -
536 -function fwp_multidelete_page () {
537 - global $wpdb;
538 -
539 - // If this is a POST, validate source and user credentials
540 - FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_feeds', /*capability=*/ 'manage_links');
541 -
542 - $link_ids = (isset($_REQUEST['link_ids']) ? $_REQUEST['link_ids'] : array());
543 - if (isset($_REQUEST['link_id'])) : array_push($link_ids, $_REQUEST['link_id']); endif;
544 -
545 - if (isset($GLOBALS['fwp_post']['confirm']) and $GLOBALS['fwp_post']['confirm']=='Delete'):
546 - if (isset($GLOBALS['fwp_post']['link_action']) and is_array($GLOBALS['fwp_post']['link_action'])) :
547 - $actions = $GLOBALS['fwp_post']['link_action'];
548 - else :
549 - $actions = array();
550 - endif;
551 -
552 - foreach ($actions as $link_id => $what) :
553 - $do_it[$what][] = $link_id;
554 - endforeach;
555 -
556 - $alter = array();
557 - if (count($do_it['hide']) > 0) :
558 - $hidem = "(".implode(', ', $do_it['hide']).")";
559 - $alter[] = "
560 - UPDATE $wpdb->links
561 - SET link_visible = 'N'
562 - WHERE link_id IN {$hidem}
563 - ";
564 - endif;
565 -
566 - if (count($do_it['nuke']) > 0) :
567 - $nukem = "(".implode(', ', $do_it['nuke']).")";
568 -
569 - // Make a list of the items syndicated from this feed...
570 - $post_ids = $wpdb->get_col("
571 - SELECT post_id FROM $wpdb->postmeta
572 - WHERE meta_key = 'syndication_feed_id'
573 - AND meta_value IN {$nukem}
574 - ");
575 -
576 - // ... and kill them all
577 - if (count($post_ids) > 0) :
578 - foreach ($post_ids as $post_id) :
579 - wp_delete_post($post_id);
580 - endforeach;
581 - endif;
582 -
583 - $alter[] = "
584 - DELETE FROM $wpdb->links
585 - WHERE link_id IN {$nukem}
586 - ";
587 - endif;
588 -
589 - if (count($do_it['delete']) > 0) :
590 - $deletem = "(".implode(', ', $do_it['delete']).")";
591 -
592 - // Make the items syndicated from this feed appear to be locally-authored
593 - $alter[] = "
594 - DELETE FROM $wpdb->postmeta
595 - WHERE meta_key = 'syndication_feed_id'
596 - AND meta_value IN {$deletem}
597 - ";
598 -
599 - // ... and delete the links themselves.
600 - $alter[] = "
601 - DELETE FROM $wpdb->links
602 - WHERE link_id IN {$deletem}
603 - ";
604 - endif;
605 -
606 - $errs = array(); $success = array ();
607 - foreach ($alter as $sql) :
608 - $result = $wpdb->query($sql);
609 - if (!$result):
610 - $errs[] = mysql_error();
611 - endif;
612 - endforeach;
613 -
614 - if (count($alter) > 0) :
615 - echo "<div class=\"updated\">\n";
616 - if (count($errs) > 0) :
617 - echo "There were some problems processing your ";
618 - echo "unsubscribe request. [SQL: ".implode('; ', $errs)."]";
619 - else :
620 - echo "Your unsubscribe request(s) have been processed.";
621 - endif;
622 - echo "</div>\n";
623 - endif;
624 -
625 - return true; // Continue on to Syndicated Sites listing
626 - else :
627 - $targets = $wpdb->get_results("
628 - SELECT * FROM $wpdb->links
629 - WHERE link_id IN (".implode(",",$link_ids).")
630 - ");
631 -?>
632 -<form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
633 -<div class="wrap">
634 -<?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?>
635 -<input type="hidden" name="action" value="Unsubscribe" />
636 -<input type="hidden" name="confirm" value="Delete" />
637 -
638 -<h2>Unsubscribe from Syndicated Links:</h2>
639 -<?php foreach ($targets as $link) :
640 - $link_url = esc_html($link->link_url);
641 - $link_name = esc_html($link->link_name);
642 - $link_description = esc_html($link->link_description);
643 - $link_rss = esc_html($link->link_rss);
644 -?>
645 -<fieldset>
646 -<legend><?php echo $link_name; ?></legend>
647 -<table class="editform" width="100%" cellspacing="2" cellpadding="5">
648 -<tr><th scope="row" width="20%"><?php _e('Feed URI:') ?></th>
649 -<td width="80%"><a href="<?php echo $link_rss; ?>"><?php echo $link_rss; ?></a></td></tr>
650 -<tr><th scope="row" width="20%"><?php _e('Short description:') ?></th>
651 -<td width="80%"><?php echo $link_description; ?></span></td></tr>
652 -<tr><th width="20%" scope="row"><?php _e('Homepage:') ?></th>
653 -<td width="80%"><a href="<?php echo $link_url; ?>"><?php echo $link_url; ?></a></td></tr>
654 -<tr style="vertical-align:top"><th width="20%" scope="row">Subscription <?php _e('Options') ?>:</th>
655 -<td width="80%"><ul style="margin:0; padding: 0; list-style: none">
656 -<li><input type="radio" id="hide-<?php echo $link->link_id; ?>"
657 -name="link_action[<?php echo $link->link_id; ?>]" value="hide" />
658 -<label for="hide-<?php echo $link->link_id; ?>">Turn off the subscription for this
659 -syndicated link<br/><span style="font-size:smaller">(Keep the feed information
660 -and all the posts from this feed in the database, but don't syndicate any
661 -new posts from the feed.)</span></label></li>
662 -<li><input type="radio" id="nuke-<?php echo $link->link_id; ?>"
663 -name="link_action[<?php echo $link->link_id; ?>]" value="nuke" />
664 -<label for="nuke-<?php echo $link->link_id; ?>">Delete this syndicated link and all the
665 -posts that were syndicated from it</label></li>
666 -<li><input type="radio" id="delete-<?php echo $link->link_id; ?>"
667 -name="link_action[<?php echo $link->link_id; ?>]" value="delete" />
668 -<label for="delete-<?php echo $link->link_id; ?>">Delete this syndicated link, but
669 -<em>keep</em> posts that were syndicated from it (as if they were authored
670 -locally).</label></li>
671 -<li><input type="radio" id="nothing-<?php echo $link->link_id; ?>"
672 -name="link_action[<?php echo $link->link_id; ?>]" value="nothing" />
673 -<label for="nothing-<?php echo $link->link_id; ?>">Keep this feed as it is. I changed
674 -my mind.</label></li>
675 -</ul>
676 -</table>
677 -</fieldset>
678 -<?php endforeach; ?>
679 -
680 -<div class="submit">
681 -<input class="delete" type="submit" name="submit" value="<?php _e('Unsubscribe from selected feeds &raquo;') ?>" />
682 -</div>
683 -</div>
684 -<?php
685 - return false; // Don't continue on to Syndicated Sites listing
686 - endif;
687 -}
688 -
689 - $syndicationPage = new FeedWordPressSyndicationPage;
4 + $syndicationPage = new FeedWordPressSyndicationPage(__FILE__);
690 5 $syndicationPage->display();
691 6