PluginProbe
FeedWordPress / 2010.0903
FeedWordPress v2010.0903
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
feedwordpress / feedwordpresssyndicationpage.class.php

feedwordpresssyndicationpage.class.php in FeedWordPress 2010.0903, at feedwordpresssyndicationpage.class.php

1,144 lines 41.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 require_once(dirname(__FILE__) . '/admin-ui.php');
3 require_once(dirname(__FILE__) . '/feedfinder.class.php');
4
5 ################################################################################
6 ## ADMIN MENU ADD-ONS: implement Dashboard management pages ####################
7 ################################################################################
8
9 define('FWP_UPDATE_CHECKED', 'Update Checked');
10 define('FWP_UNSUB_CHECKED', 'Unsubscribe');
11 define('FWP_DELETE_CHECKED', 'Delete');
12 define('FWP_RESUB_CHECKED', 'Re-subscribe');
13 define('FWP_SYNDICATE_NEW', 'Add →');
14 define('FWP_UNSUB_FULL', 'Unsubscribe from selected feeds →');
15 define('FWP_CANCEL_BUTTON', '× Cancel');
16 define('FWP_CHECK_FOR_UPDATES', 'Update');
17
18 class FeedWordPressSyndicationPage extends FeedWordPressAdminPage {
19 function FeedWordPressSyndicationPage ($filename = NULL) {
20 FeedWordPressAdminPage::FeedWordPressAdminPage('feedwordpresssyndication', /*link=*/ NULL);
21
22 // No over-arching form element
23 $this->dispatch = NULL;
24 if (is_null($filename)) :
25 $this->filename = __FILE__;
26 else :
27 $this->filename = $filename;
28 endif;
29 } /* FeedWordPressSyndicationPage constructor */
30
31 function has_link () { return false; }
32
33 var $_sources = NULL;
34
35 function sources ($visibility = 'Y') {
36 if (is_null($this->_sources)) :
37 $links = FeedWordPress::syndicated_links(array("hide_invisible" => false));
38 $this->_sources = array("Y" => array(), "N" => array());
39 foreach ($links as $link) :
40 $this->_sources[$link->link_visible][] = $link;
41 endforeach;
42 endif;
43 $ret = (
44 array_key_exists($visibility, $this->_sources)
45 ? $this->_sources[$visibility]
46 : $this->_sources
47 );
48 return $ret;
49 } /* FeedWordPressSyndicationPage::sources() */
50
51 function visibility_toggle () {
52 $sources = $this->sources('*');
53
54 $defaultVisibility = 'Y';
55 if ((count($this->sources('N')) > 0)
56 and (count($this->sources('Y'))==0)) :
57 $defaultVisibility = 'N';
58 endif;
59
60 $visibility = (
61 isset($_REQUEST['visibility'])
62 ? $_REQUEST['visibility']
63 : $defaultVisibility
64 );
65
66 return $visibility;
67 } /* FeedWordPressSyndicationPage::visibility_toggle() */
68
69 function show_inactive () {
70 return ($this->visibility_toggle() == 'N');
71 }
72
73 function updates_requested () {
74 global $wpdb;
75
76 if (isset($_POST['update']) or isset($_POST['action']) or isset($_POST['update_uri'])) :
77 // Only do things with side-effects for HTTP POST or command line
78 $fwp_update_invoke = 'post';
79 else :
80 $fwp_update_invoke = 'get';
81 endif;
82
83 $update_set = array();
84 if ($fwp_update_invoke != 'get') :
85 if (isset($_POST['link_ids']) and is_array($_POST['link_ids']) and ($_POST['action']==FWP_UPDATE_CHECKED)) :
86 $targets = $wpdb->get_results("
87 SELECT * FROM $wpdb->links
88 WHERE link_id IN (".implode(",",$_POST['link_ids']).")
89 ");
90 if (is_array($targets)) :
91 foreach ($targets as $target) :
92 $update_set[] = $target->link_rss;
93 endforeach;
94 else : // This should never happen
95 FeedWordPress::critical_bug('fwp_syndication_manage_page::targets', $targets, __LINE__);
96 endif;
97 elseif (isset($_POST['update_uri'])) :
98 $targets = $_POST['update_uri'];
99 if (!is_array($targets)) :
100 $targets = array($targets);
101 endif;
102 $update_set = $targets;
103 endif;
104 endif;
105 return $update_set;
106 }
107
108 function accept_multiadd () {
109 global $fwp_post;
110
111 if (isset($fwp_post['cancel']) and $fwp_post['cancel']==__(FWP_CANCEL_BUTTON)) :
112 return true; // Continue ....
113 endif;
114
115 // If this is a POST, validate source and user credentials
116 FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_feeds', /*capability=*/ 'manage_links');
117
118 $in = (isset($fwp_post['multilookup']) ? $fwp_post['multilookup'] : '')
119 .(isset($fwp_post['opml_lookup']) ? $fwp_post['opml_lookup'] : '');
120 if (isset($fwp_post['confirm']) and $fwp_post['confirm']=='multiadd') :
121 $chex = $fwp_post['multilookup'];
122 $added = array(); $errors = array();
123 foreach ($chex as $feed) :
124 if (isset($feed['add']) and $feed['add']=='yes') :
125 // Then, add in the URL.
126 $link_id = FeedWordPress::syndicate_link(
127 $feed['title'],
128 $feed['link'],
129 $feed['url']
130 );
131 if ($link_id and !is_wp_error($link_id)):
132 $added[] = $link_id;
133 else :
134 $errors[] = array($feed['url'], $link_id);
135 endif;
136 endif;
137 endforeach;
138
139 print "<div class='updated'>\n";
140 print "<p>Added ".count($added)." new syndicated sources.</p>";
141 if (count($errors) > 0) :
142 print "<p>FeedWordPress encountered errors trying to add the following sources:</p>
143 <ul>\n";
144 foreach ($errors as $err) :
145 $url = $err[0];
146 $short = esc_html(feedwordpress_display_url($url));
147 $url = esc_html($url);
148 $wp = $err[1];
149 if (is_wp_error($err[1])) :
150 $error = $err[1];
151 $mesg = " (<code>".$error->get_error_messages()."</code>)";
152 else :
153 $mesg = '';
154 endif;
155 print "<li><a href='$url'>$short</a>$mesg</li>\n";
156 endforeach;
157 print "</ul>\n";
158 endif;
159 print "</div>\n";
160
161 elseif (is_array($in) or strlen($in) > 0) :
162 add_meta_box(
163 /*id=*/ 'feedwordpress_multiadd_box',
164 /*title=*/ __('Add Feeds'),
165 /*callback=*/ array($this, 'multiadd_box'),
166 /*page=*/ $this->meta_box_context(),
167 /*context =*/ $this->meta_box_context()
168 );
169 endif;
170 return true; // Continue...
171 }
172
173 function display_multiadd_line ($line) {
174 $short_feed = esc_html(feedwordpress_display_url($line['feed']));
175 $feed = esc_html($line['feed']);
176 $link = esc_html($line['link']);
177 $title = esc_html($line['title']);
178 $checked = $line['checked'];
179 $i = esc_html($line['i']);
180
181 print "<li><label><input type='checkbox' name='multilookup[$i][add]' value='yes' $checked />
182 $title</label> &middot; <a href='$feed'>$short_feed</a>";
183
184 if (isset($line['extra'])) :
185 print " &middot; ".esc_html($line['extra']);
186 endif;
187
188 print "<input type='hidden' name='multilookup[$i][url]' value='$feed' />
189 <input type='hidden' name='multilookup[$i][link]' value='$link' />
190 <input type='hidden' name='multilookup[$i][title]' value='$title' />
191 </li>\n";
192
193 flush();
194 }
195
196 function multiadd_box ($page, $box = NULL) {
197 global $fwp_post;
198
199 $localData = NULL;
200
201 if (isset($_FILES['opml_upload']['name']) and
202 (strlen($_FILES['opml_upload']['name']) > 0)) :
203 $in = 'tag:localhost';
204 $localData = file_get_contents($_FILES['opml_upload']['tmp_name']);
205 $merge_all = true;
206 elseif (isset($fwp_post['multilookup'])) :
207 $in = $fwp_post['multilookup'];
208 $merge_all = false;
209 elseif (isset($fwp_post['opml_lookup'])) :
210 $in = $fwp_post['opml_lookup'];
211 $merge_all = true;
212 else :
213 $in = '';
214 $merge_all = false;
215 endif;
216
217 if (strlen($in) > 0) :
218 $lines = preg_split(
219 "/\s+/",
220 $in,
221 /*no limit soldier*/ -1,
222 PREG_SPLIT_NO_EMPTY
223 );
224
225 $i = 0;
226 ?>
227 <form id="multiadd-form" action="<?php print $this->form_action(); ?>" method="post">
228 <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?>
229 <input type="hidden" name="multiadd" value="<?php print FWP_SYNDICATE_NEW; ?>" />
230 <input type="hidden" name="confirm" value="multiadd" />
231
232 <input type="hidden" name="multiadd" value="<?php print FWP_SYNDICATE_NEW; ?>" />
233 <input type="hidden" name="confirm" value="multiadd" /></div>
234
235 <div id="multiadd-status">
236 <p><img src="<?php print esc_url ( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
237 Looking up feed information...</p>
238 </div>
239
240 <div id="multiadd-buttons">
241 <input type="submit" class="button" name="cancel" value="<?php _e(FWP_CANCEL_BUTTON); ?>" />
242 <input type="submit" class="button-primary" value="<?php print _e('Subscribe to selected sources →'); ?>" />
243 </div>
244
245 <p><?php _e('Here are the feeds that FeedWordPress has discovered from the addresses that you provided. To opt out of a subscription, unmark the checkbox next to the feed.'); ?></p>
246
247 <?php
248 print "<ul id=\"multiadd-list\">\n"; flush();
249 foreach ($lines as $line) :
250 $url = trim($line);
251 if (strlen($url) > 0) :
252 // First, use FeedFinder to check the URL.
253 if (is_null($localData)) :
254 $finder = new FeedFinder($url, /*verify=*/ false, /*fallbacks=*/ 1);
255 else :
256 $finder = new FeedFinder('tag:localhost', /*verify=*/ false, /*fallbacks=*/ 1);
257 $finder->upload_data($localData);
258 endif;
259
260 $feeds = array_values(
261 array_unique(
262 $finder->find()
263 )
264 );
265
266 $found = false;
267 if (count($feeds) > 0) :
268 foreach ($feeds as $feed) :
269 $pie = FeedWordPress::fetch($feed);
270 if (!is_wp_error($pie)) :
271 $found = true;
272
273 $short_feed = esc_html(feedwordpress_display_url($feed));
274 $feed = esc_html($feed);
275 $title = esc_html($pie->get_title());
276 $checked = ' checked="checked"';
277 $link = esc_html($pie->get_link());
278
279 $this->display_multiadd_line(array(
280 'feed' => $feed,
281 'title' => $pie->get_title(),
282 'link' => $pie->get_link(),
283 'checked' => ' checked="checked"',
284 'i' => $i,
285 ));
286
287 $i++; // Increment field counter
288
289 if (!$merge_all) : // Break out after first find
290 break;
291 endif;
292 endif;
293 endforeach;
294 endif;
295
296 if (!$found) :
297 $this->display_multiadd_line(array(
298 'feed' => $url,
299 'title' => feedwordpress_display_url($url),
300 'extra' => " [FeedWordPress couldn't detect any feeds for this URL.]",
301 'link' => NULL,
302 'checked' => '',
303 'i' => $i,
304 ));
305 $i++; // Increment field counter
306 endif;
307 endif;
308 endforeach;
309 print "</ul>\n";
310 ?>
311 </form>
312
313 <script type="text/javascript">
314 jQuery(document).ready( function () {
315 // Hide it now that we're done.
316 jQuery('#multiadd-status').fadeOut(500 /*ms*/);
317 } );
318 </script>
319 <?php
320 endif;
321
322 $this->_sources = NULL; // Force reload of sources list
323 return true; // Continue
324 }
325
326 function display () {
327 global $wpdb;
328 global $fwp_post;
329
330 if (FeedWordPress::needs_upgrade()) :
331 fwp_upgrade_page();
332 return;
333 endif;
334
335 ?>
336 <?php
337 $cont = true;
338 $dispatcher = array(
339 "feedfinder" => 'fwp_feedfinder_page',
340 FWP_SYNDICATE_NEW => 'fwp_feedfinder_page',
341 "switchfeed" => 'fwp_switchfeed_page',
342 FWP_UNSUB_CHECKED => 'multidelete_page',
343 FWP_DELETE_CHECKED => 'multidelete_page',
344 'Unsubscribe' => 'multidelete_page',
345 FWP_RESUB_CHECKED => 'multiundelete_page',
346 );
347 if (isset($_REQUEST['action']) and isset($dispatcher[$_REQUEST['action']])) :
348 $method = $dispatcher[$_REQUEST['action']];
349 if (method_exists($this, $method)) :
350 $cont = $this->{$method}();
351 else :
352 $cont = call_user_func($method);
353 endif;
354 elseif (isset($fwp_post['multiadd']) and $fwp_post['multiadd']==FWP_SYNDICATE_NEW) :
355 $cont = $this->accept_multiadd($fwp_post);
356 endif;
357
358 if ($cont):
359 $links = $this->sources('Y');
360 $potential_updates = (!$this->show_inactive() and (count($this->sources('Y')) > 0));
361
362 $this->open_sheet('Syndicated Sites');
363 ?>
364 <div id="post-body">
365 <?php
366 if ($potential_updates
367 or (count($this->updates_requested()) > 0)) :
368 add_meta_box(
369 /*id=*/ 'feedwordpress_update_box',
370 /*title=*/ __('Update feeds now'),
371 /*callback=*/ 'fwp_syndication_manage_page_update_box',
372 /*page=*/ $this->meta_box_context(),
373 /*context =*/ $this->meta_box_context()
374 );
375 endif;
376 add_meta_box(
377 /*id=*/ 'feedwordpress_feeds_box',
378 /*title=*/ __('Syndicated sources'),
379 /*callback=*/ array(&$this, 'syndicated_sources_box'),
380 /*page=*/ $this->meta_box_context(),
381 /*context =*/ $this->meta_box_context()
382 );
383
384 do_action('feedwordpress_admin_page_syndication_meta_boxes', $this);
385 ?>
386 <div class="metabox-holder">
387 <?php
388 fwp_do_meta_boxes($this->meta_box_context(), $this->meta_box_context(), $this);
389 ?>
390 </div> <!-- class="metabox-holder" -->
391 </div> <!-- id="post-body" -->
392
393 <?php $this->close_sheet(/*dispatch=*/ NULL); ?>
394
395 <div style="display: none">
396 <div id="tags-input"></div> <!-- avoid JS error from WP 2.5 bug -->
397 </div>
398 <?php
399 endif;
400 } /* FeedWordPressSyndicationPage::display () */
401
402 function dashboard_box ($page, $box = NULL) {
403 global $fwp_path;
404
405 $links = FeedWordPress::syndicated_links(array("hide_invisible" => false));
406 $sources = $this->sources('*');
407
408 $visibility = 'Y';
409 $hrefPrefix = $this->form_action();
410 $activeHref = $hrefPrefix.'&visibility=Y';
411 $inactiveHref = $hrefPrefix.'&visibility=N';
412
413 $lastUpdate = get_option('feedwordpress_last_update_all', NULL);
414 $automatic_updates = get_option('feedwordpress_automatic_updates', NULL);
415
416 if ('init'==$automatic_updates) :
417 $update_setting = 'automatically before page loads';
418 elseif ('shutdown'==$automatic_updates) :
419 $update_setting = 'automatically after page loads';
420 else :
421 $update_setting = 'using a cron job or manual check-ins';
422 endif;
423
424 // Hey ho, let's go...
425 ?>
426 <p class="info" style="margin-bottom: 0px; border-bottom: 1px dotted black;">Managed by <a href="http://feedwordpress.radgeek.com/">FeedWordPress</a>
427 <?php print FEEDWORDPRESS_VERSION; ?>.</p>
428 <?php if (FEEDWORDPRESS_BLEG) : ?>
429 <div style="float: left; background: white; margin-top: 5px; margin-right: 5px;"><a href="<?php print $this->form_action(); ?>"><img src="<?php print esc_html(WP_PLUGIN_URL.'/'.$GLOBALS['fwp_path'].'/feedwordpress.png'); ?>" alt="" /></a></div>
430 <p class="info" style="margin-top: 0px; font-style: italic; font-size: 75%; color: #666;">If you find this tool useful for your daily work, you can
431 contribute to ongoing support and development with
432 <a href="http://feedwordpress.radgeek.com/donate/">a modest donation</a>.</p>
433 <br style="clear: left;" />
434 <?php endif; ?>
435
436 <div class="feedwordpress-actions">
437 <h4>Updates</h4>
438 <ul class="options">
439 <li><strong>Scheduled:</strong> <?php print $update_setting; ?>
440 (<a href="<?php print $this->form_action('feeds-page.php'); ?>">change setting</a>)</li>
441
442 <li><?php if (!is_null($lastUpdate)) : ?>
443 <strong>Last checked:</strong> <?php print fwp_time_elapsed($lastUpdate); ?>
444 <?php else : ?>
445 <strong>Last checked:</strong> none yet
446 <?php endif; ?> </li>
447
448 </ul>
449 </div>
450
451 <div class="feedwordpress-stats">
452 <h4>Subscriptions</h4>
453 <table>
454 <tbody>
455 <tr class="first">
456 <td class="first b b-active"><a href="<?php print esc_html($activeHref); ?>"><?php print count($sources['Y']); ?></a></td>
457 <td class="t active"><a href="<?php print esc_html($activeHref); ?>">Active</a></td>
458 </tr>
459
460 <tr>
461 <td class="b b-inactive"><a href="<?php print esc_html($inactiveHref); ?>"><?php print count($sources['N']); ?></a></td>
462 <td class="t inactive"><a href="<?php print esc_html($inactiveHref); ?>">Inactive</a></td>
463 </tr>
464 </table>
465 </div>
466
467 <div id="add-single-uri">
468 <?php if (count($sources['Y']) > 0) : ?>
469 <form id="check-for-updates" action="<?php print $this->form_action(); ?>" method="POST">
470 <div class="container"><input type="submit" class="button-primary" name"update" value="<?php print FWP_CHECK_FOR_UPDATES; ?>" />
471 <?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?>
472 <input type="hidden" name="update_uri" value="*" /></div>
473 </form>
474 <?php endif; ?>
475
476 <form id="syndicated-links" action="<?php print $hrefPrefix; ?>&amp;visibility=<?php print $visibility; ?>" method="post">
477 <div class="container"><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?>
478 <label for="add-uri">Add:
479 <input type="text" name="lookup" id="add-uri" placeholder="Source URL"
480 value="Source URL" style="width: 55%;" /></label>
481
482 <?php FeedWordPressSettingsUI::magic_input_tip_js('add-uri'); ?>
483
484 <input style="vertical-align: middle;" type="image" src="<?php print WP_PLUGIN_URL.'/'.$fwp_path; ?>/plus.png" alt="<?php print FWP_SYNDICATE_NEW; ?>" name="action" value="<?php print FWP_SYNDICATE_NEW; ?>" /></div>
485 </form>
486 </div> <!-- id="add-single-uri" -->
487
488 <br style="clear: both;" />
489
490 <?php
491 } /* FeedWordPressSyndicationPage::dashboard_box () */
492
493 function syndicated_sources_box ($page, $box = NULL) {
494 global $fwp_path;
495
496 $links = FeedWordPress::syndicated_links(array("hide_invisible" => false));
497 $sources = $this->sources('*');
498
499 $visibility = $this->visibility_toggle();
500 $showInactive = $this->show_inactive();
501
502 $hrefPrefix = $this->form_action();
503 ?>
504 <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div>
505 <div class="tablenav">
506
507 <div id="add-multiple-uri" class="hide-if-js">
508 <form action="<?php print $hrefPrefix; ?>&amp;visibility=<?php print $visibility; ?>" method="post">
509 <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div>
510 <h4>Add Multiple Sources</h4>
511 <div>Enter one feed or website URL per line. If a URL links to a website which provides multiple feeds, FeedWordPress will use the first one listed.</div>
512 <div><textarea name="multilookup" rows="8" cols="60"
513 style="vertical-align: top"></textarea></div>
514 <div style="border-top: 1px dotted black; padding-top: 10px">
515 <div class="alignright"><input type="submit" class="button-primary" name="multiadd" value="<?php print FWP_SYNDICATE_NEW; ?>" /></div>
516 <div class="alignleft"><input type="button" class="button-secondary" name="action" value="<?php print FWP_CANCEL_BUTTON; ?>" id="turn-off-multiple-sources" /></div>
517 </div>
518 </form>
519 </div> <!-- id="add-multiple-uri" -->
520
521 <div id="upload-opml" style="float: right" class="hide-if-js">
522 <h4>Import source list</h4>
523 <p>You can import a list of sources in OPML format, either by providing
524 a URL for the OPML document, or by uploading a copy from your
525 computer.</p>
526
527 <form enctype="multipart/form-data" action="<?php print $hrefPrefix; ?>&amp;visibility=<?php print $visibility; ?>" method="post">
528 <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?><input type="hidden" name="MAX_FILE_SIZE" value="100000" /></div>
529 <div style="clear: both"><label for="opml-lookup" style="float: left; width: 8.0em; margin-top: 5px;">From URL:</label> <input type="text" id="opml-lookup" name="opml_lookup" value="OPML document" /></div>
530 <div style="clear: both"><label for="opml-upload" style="float: left; width: 8.0em; margin-top: 5px;">From file:</label> <input type="file" id="opml-upload" name="opml_upload" /></div>
531
532 <div style="border-top: 1px dotted black; padding-top: 10px">
533 <div class="alignright"><input type="submit" class="button-primary" name="action" value="<?php print FWP_SYNDICATE_NEW; ?>" /></div>
534 <div class="alignleft"><input type="button" class="button-secondary" name="action" value="<?php print FWP_CANCEL_BUTTON; ?>" id="turn-off-opml-upload" /></div>
535 </div>
536 </form>
537 </div> <!-- id="upload-opml" -->
538
539 <div id="add-single-uri" class="alignright">
540 <form id="syndicated-links" action="<?php print $hrefPrefix; ?>&amp;visibility=<?php print $visibility; ?>" method="post">
541 <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div>
542 <ul class="subsubsub">
543 <li><label for="add-uri">New source:</label>
544 <input type="text" name="lookup" id="add-uri" value="Website or feed URI" />
545
546 <?php FeedWordPressSettingsUI::magic_input_tip_js('add-uri'); FeedWordPressSettingsUI::magic_input_tip_js('opml-lookup'); ?>
547
548 <input type="hidden" name="action" value="feedfinder" />
549 <input type="submit" class="button-secondary" name="action" value="<?php print FWP_SYNDICATE_NEW; ?>" />
550 <div style="text-align: right; margin-right: 2.0em"><a id="turn-on-multiple-sources" href="#add-multiple-uri"><img style="vertical-align: middle" src="<?php print WP_PLUGIN_URL.'/'.$fwp_path; ?>/down.png" alt="" /> add multiple</a>
551 <span class="screen-reader-text"> or </span>
552 <a id="turn-on-opml-upload" href="#upload-opml"><img src="<?php print WP_PLUGIN_URL.'/'.$fwp_path; ?>/plus.png" alt="" style="vertical-align: middle" /> import source list</a></div>
553 </li>
554 </ul>
555 </form>
556 </div> <!-- class="alignright" -->
557
558 <div class="alignleft">
559 <?php
560 if (count($sources[$visibility]) > 0) :
561 fwp_syndication_manage_page_links_subsubsub($sources, $showInactive);
562 endif;
563 ?>
564 </div> <!-- class="alignleft" -->
565
566 </div> <!-- class="tablenav" -->
567
568 <form id="syndicated-links" action="<?php print $hrefPrefix; ?>&amp;visibility=<?php print $visibility; ?>" method="post">
569 <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div>
570
571 <?php if ($showInactive) : ?>
572 <div style="clear: right" class="alignright">
573 <p style="font-size: smaller; font-style: italic">FeedWordPress used to syndicate
574 posts from these sources, but you have unsubscribed from them.</p>
575 </div>
576 <?php
577 endif;
578 ?>
579
580 <?php if (count($sources[$visibility]) > 0) : ?>
581 <div style="clear: left" class="alignleft">
582 <?php if ($showInactive) : ?>
583 <input class="button-secondary" type="submit" name="action" value="<?php print FWP_RESUB_CHECKED; ?>" />
584 <input class="button-secondary" type="submit" name="action" value="<?php print FWP_DELETE_CHECKED; ?>" />
585 <?php else : ?>
586 <input class="button-secondary" type="submit" name="action" value="<?php print FWP_UPDATE_CHECKED; ?>" />
587 <input class="button-secondary delete" type="submit" name="action" value="<?php print FWP_UNSUB_CHECKED; ?>" />
588 <?php endif ; ?>
589 </div> <!-- class="alignleft" -->
590
591 <?php else : ?>
592 <?php fwp_syndication_manage_page_links_subsubsub($sources, $showInactive); ?>
593 <?php endif; ?>
594
595 <br class="clear" />
596
597 <?php
598 fwp_syndication_manage_page_links_table_rows($sources[$visibility], $this, $visibility);
599 ?>
600 </form>
601 <?php
602 } /* FeedWordPressSyndicationPage::syndicated_sources_box() */
603
604 function bleg_thanks ($page, $box = NULL) {
605 ?>
606 <div class="donation-thanks">
607 <h4>Thank you!</h4>
608 <p><strong>Thank you</strong> for your contribution to <a href="http://feedwordpress.radgeek.com/">FeedWordPress</a> development.
609 Your generous gifts make ongoing support and development for
610 FeedWordPress possible.</p>
611 <p>If you have any questions about FeedWordPress, or if there
612 is anything I can do to help make FeedWordPress more useful for
613 you, please <a href="http://feedwordpress.radgeek.com/contact">contact me</a>
614 and let me know what you're thinking about.</p>
615 <p class="signature">&#8212;<a href="http://radgeek.com/">Charles Johnson</a>, Developer, <a href="http://feedwordpress.radgeek.com/">FeedWordPress</a>.</p>
616 </div>
617 <?php
618 } /* FeedWordPressSyndicationPage::bleg_thanks () */
619
620 function bleg_box ($page, $box = NULL) {
621 ?>
622 <div class="donation-form">
623 <h4>Keep FeedWordPress improving</h4>
624 <form action="https://www.paypal.com/cgi-bin/webscr" accept-charset="UTF-8" method="post"><div>
625 <p><a href="http://feedwordpress.radgeek.com/">FeedWordPress</a> makes syndication
626 simple and empowers you to stream content from all over the web into your
627 WordPress hub. That's got to be worth a few lattes. If you're finding FWP useful,
628 <a href="http://feedwordpress.radgeek.com/donate/">a modest gift</a>
629 is the best way to support steady progress on development, enhancements,
630 support, and documentation.</p>
631 <div class="donate">
632 <input type="hidden" name="business" value="commerce@radgeek.com" />
633 <input type="hidden" name="cmd" value="_xclick" />
634 <input type="hidden" name="item_name" value="FeedWordPress donation" />
635 <input type="hidden" name="no_shipping" value="1" />
636 <input type="hidden" name="return" value="<?php print admin_url('admin.php'); ?>?page=<?php print $GLOBALS['fwp_path'] ?>/<?php print basename($this->filename); ?>&amp;paid=yes" />
637 <input type="hidden" name="currency_code" value="USD" />
638 <input type="hidden" name="notify_url" value="http://feedwordpress.radgeek.com/ipn/donation" />
639 <input type="hidden" name="custom" value="1" />
640 <input type="image" name="submit" src="https://www.paypal.com/en_GB/i/btn/btn_donate_SM.gif" alt="Donate through PayPal" />
641 </div>
642 </div></form>
643
644 <p>You can make a gift online (or
645 <a href="http://feedwordpress.radgeek.com/donation">set up an automatic
646 regular donation</a>) using an existing PayPal account or any major credit card.</p>
647
648 <div class="sod-off">
649 <form style="text-align: center" action="<?php print $this->form_action(); ?>" method="POST"><div>
650 <input class="button" type="submit" name="maybe_later" value="Maybe Later" />
651 <input class="button" type="submit" name="go_away" value="Dismiss" />
652 </div></form>
653 </div>
654 </div> <!-- class="donation-form" -->
655 <?php
656 } /* FeedWordPressSyndicationPage::bleg_box () */
657
658 /**
659 * Override the default display of a save-settings button and replace
660 * it with nothing.
661 */
662 function interstitial () {
663 /* NOOP */
664 } /* FeedWordPressSyndicationPage::interstitial() */
665
666 function multidelete_page () {
667 global $wpdb;
668 global $fwp_post;
669
670 // If this is a POST, validate source and user credentials
671 FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_feeds', /*capability=*/ 'manage_links');
672
673 if (isset($fwp_post['submit']) and $fwp_post['submit']==FWP_CANCEL_BUTTON) :
674 return true; // Continue without further ado.
675 endif;
676
677 $link_ids = (isset($_REQUEST['link_ids']) ? $_REQUEST['link_ids'] : array());
678 if (isset($_REQUEST['link_id'])) : array_push($link_ids, $_REQUEST['link_id']); endif;
679
680 if (isset($GLOBALS['fwp_post']['confirm']) and $GLOBALS['fwp_post']['confirm']=='Delete'):
681 if (isset($GLOBALS['fwp_post']['link_action']) and is_array($GLOBALS['fwp_post']['link_action'])) :
682 $actions = $GLOBALS['fwp_post']['link_action'];
683 else :
684 $actions = array();
685 endif;
686
687 $do_it = array(
688 'hide' => array(),
689 'nuke' => array(),
690 'delete' => array(),
691 );
692
693 foreach ($actions as $link_id => $what) :
694 $do_it[$what][] = $link_id;
695 endforeach;
696
697 $alter = array();
698 if (count($do_it['hide']) > 0) :
699 $hidem = "(".implode(', ', $do_it['hide']).")";
700 $alter[] = "
701 UPDATE $wpdb->links
702 SET link_visible = 'N'
703 WHERE link_id IN {$hidem}
704 ";
705 endif;
706
707 if (count($do_it['nuke']) > 0) :
708 $nukem = "(".implode(', ', $do_it['nuke']).")";
709
710 // Make a list of the items syndicated from this feed...
711 $post_ids = $wpdb->get_col("
712 SELECT post_id FROM $wpdb->postmeta
713 WHERE meta_key = 'syndication_feed_id'
714 AND meta_value IN {$nukem}
715 ");
716
717 // ... and kill them all
718 if (count($post_ids) > 0) :
719 foreach ($post_ids as $post_id) :
720 if (FeedWordPressCompatibility::test_version(FWP_SCHEMA_29)) :
721 // Force scrubbing of deleted post
722 // rather than sending to Trashcan
723 wp_delete_post(
724 /*postid=*/ $post_id,
725 /*force_delete=*/ true
726 );
727 else :
728 wp_delete_post($post_id);
729 endif;
730 endforeach;
731 endif;
732
733 $alter[] = "
734 DELETE FROM $wpdb->links
735 WHERE link_id IN {$nukem}
736 ";
737 endif;
738
739 if (count($do_it['delete']) > 0) :
740 $deletem = "(".implode(', ', $do_it['delete']).")";
741
742 // Make the items syndicated from this feed appear to be locally-authored
743 $alter[] = "
744 DELETE FROM $wpdb->postmeta
745 WHERE meta_key = 'syndication_feed_id'
746 AND meta_value IN {$deletem}
747 ";
748
749 // ... and delete the links themselves.
750 $alter[] = "
751 DELETE FROM $wpdb->links
752 WHERE link_id IN {$deletem}
753 ";
754 endif;
755
756 $errs = array(); $success = array ();
757 foreach ($alter as $sql) :
758 $result = $wpdb->query($sql);
759 if (!$result):
760 $errs[] = mysql_error();
761 endif;
762 endforeach;
763
764 if (count($alter) > 0) :
765 echo "<div class=\"updated\">\n";
766 if (count($errs) > 0) :
767 echo "There were some problems processing your ";
768 echo "unsubscribe request. [SQL: ".implode('; ', $errs)."]";
769 else :
770 echo "Your unsubscribe request(s) have been processed.";
771 endif;
772 echo "</div>\n";
773 endif;
774
775 return true; // Continue on to Syndicated Sites listing
776 else :
777 $targets = $wpdb->get_results("
778 SELECT * FROM $wpdb->links
779 WHERE link_id IN (".implode(",",$link_ids).")
780 ");
781 ?>
782 <form action="<?php print $this->form_action(); ?>" method="post">
783 <div class="wrap">
784 <?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?>
785 <input type="hidden" name="action" value="Unsubscribe" />
786 <input type="hidden" name="confirm" value="Delete" />
787
788 <h2>Unsubscribe from Syndicated Links:</h2>
789 <?php foreach ($targets as $link) :
790 $subscribed = ('Y' == strtoupper($link->link_visible));
791 $link_url = esc_html($link->link_url);
792 $link_name = esc_html($link->link_name);
793 $link_description = esc_html($link->link_description);
794 $link_rss = esc_html($link->link_rss);
795 ?>
796 <fieldset>
797 <legend><?php echo $link_name; ?></legend>
798 <table class="editform" width="100%" cellspacing="2" cellpadding="5">
799 <tr><th scope="row" width="20%"><?php _e('Feed URI:') ?></th>
800 <td width="80%"><a href="<?php echo $link_rss; ?>"><?php echo $link_rss; ?></a></td></tr>
801 <tr><th scope="row" width="20%"><?php _e('Short description:') ?></th>
802 <td width="80%"><?php echo $link_description; ?></span></td></tr>
803 <tr><th width="20%" scope="row"><?php _e('Homepage:') ?></th>
804 <td width="80%"><a href="<?php echo $link_url; ?>"><?php echo $link_url; ?></a></td></tr>
805 <tr style="vertical-align:top"><th width="20%" scope="row">Subscription <?php _e('Options') ?>:</th>
806 <td width="80%"><ul style="margin:0; padding: 0; list-style: none">
807 <?php if ($subscribed) : ?>
808 <li><input type="radio" id="hide-<?php echo $link->link_id; ?>"
809 name="link_action[<?php echo $link->link_id; ?>]" value="hide" checked="checked" />
810 <label for="hide-<?php echo $link->link_id; ?>">Turn off the subscription for this
811 syndicated link<br/><span style="font-size:smaller">(Keep the feed information
812 and all the posts from this feed in the database, but don't syndicate any
813 new posts from the feed.)</span></label></li>
814 <?php endif; ?>
815 <li><input type="radio" id="nuke-<?php echo $link->link_id; ?>"<?php if (!$subscribed) : ?> checked="checked"<?php endif; ?>
816 name="link_action[<?php echo $link->link_id; ?>]" value="nuke" />
817 <label for="nuke-<?php echo $link->link_id; ?>">Delete this syndicated link and all the
818 posts that were syndicated from it</label></li>
819 <li><input type="radio" id="delete-<?php echo $link->link_id; ?>"
820 name="link_action[<?php echo $link->link_id; ?>]" value="delete" />
821 <label for="delete-<?php echo $link->link_id; ?>">Delete this syndicated link, but
822 <em>keep</em> posts that were syndicated from it (as if they were authored
823 locally).</label></li>
824 <li><input type="radio" id="nothing-<?php echo $link->link_id; ?>"
825 name="link_action[<?php echo $link->link_id; ?>]" value="nothing" />
826 <label for="nothing-<?php echo $link->link_id; ?>">Keep this feed as it is. I changed
827 my mind.</label></li>
828 </ul>
829 </table>
830 </fieldset>
831 <?php endforeach; ?>
832
833 <div class="submit">
834 <input type="submit" name="submit" value="<?php _e(FWP_CANCEL_BUTTON); ?>" />
835 <input class="delete" type="submit" name="submit" value="<?php _e(FWP_UNSUB_FULL) ?>" />
836 </div>
837 </div>
838 <?php
839 return false; // Don't continue on to Syndicated Sites listing
840 endif;
841 } /* FeedWordPressSyndicationPage::multidelete_page() */
842
843 function multiundelete_page () {
844 global $wpdb;
845
846 // If this is a POST, validate source and user credentials
847 FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_feeds', /*capability=*/ 'manage_links');
848
849 $link_ids = (isset($_REQUEST['link_ids']) ? $_REQUEST['link_ids'] : array());
850 if (isset($_REQUEST['link_id'])) : array_push($link_ids, $_REQUEST['link_id']); endif;
851
852 if (isset($GLOBALS['fwp_post']['confirm']) and $GLOBALS['fwp_post']['confirm']=='Undelete'):
853 if (isset($GLOBALS['fwp_post']['link_action']) and is_array($GLOBALS['fwp_post']['link_action'])) :
854 $actions = $GLOBALS['fwp_post']['link_action'];
855 else :
856 $actions = array();
857 endif;
858
859 $do_it = array(
860 'unhide' => array(),
861 );
862
863 foreach ($actions as $link_id => $what) :
864 $do_it[$what][] = $link_id;
865 endforeach;
866
867 $alter = array();
868 if (count($do_it['unhide']) > 0) :
869 $unhiddem = "(".implode(', ', $do_it['unhide']).")";
870 $alter[] = "
871 UPDATE $wpdb->links
872 SET link_visible = 'Y'
873 WHERE link_id IN {$unhiddem}
874 ";
875 endif;
876
877 $errs = array(); $success = array ();
878 foreach ($alter as $sql) :
879 $result = $wpdb->query($sql);
880 if (!$result):
881 $errs[] = mysql_error();
882 endif;
883 endforeach;
884
885 if (count($alter) > 0) :
886 echo "<div class=\"updated\">\n";
887 if (count($errs) > 0) :
888 echo "There were some problems processing your ";
889 echo "re-subscribe request. [SQL: ".implode('; ', $errs)."]";
890 else :
891 echo "Your re-subscribe request(s) have been processed.";
892 endif;
893 echo "</div>\n";
894 endif;
895
896 return true; // Continue on to Syndicated Sites listing
897 else :
898 $targets = $wpdb->get_results("
899 SELECT * FROM $wpdb->links
900 WHERE link_id IN (".implode(",",$link_ids).")
901 ");
902 ?>
903 <form action="<?php print $this->form_action(); ?>" method="post">
904 <div class="wrap">
905 <?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?>
906 <input type="hidden" name="action" value="<?php print FWP_RESUB_CHECKED; ?>" />
907 <input type="hidden" name="confirm" value="Undelete" />
908
909 <h2>Re-subscribe to Syndicated Links:</h2>
910 <?php
911 foreach ($targets as $link) :
912 $subscribed = ('Y' == strtoupper($link->link_visible));
913 $link_url = esc_html($link->link_url);
914 $link_name = esc_html($link->link_name);
915 $link_description = esc_html($link->link_description);
916 $link_rss = esc_html($link->link_rss);
917
918 if (!$subscribed) :
919 ?>
920 <fieldset>
921 <legend><?php echo $link_name; ?></legend>
922 <table class="editform" width="100%" cellspacing="2" cellpadding="5">
923 <tr><th scope="row" width="20%"><?php _e('Feed URI:') ?></th>
924 <td width="80%"><a href="<?php echo $link_rss; ?>"><?php echo $link_rss; ?></a></td></tr>
925 <tr><th scope="row" width="20%"><?php _e('Short description:') ?></th>
926 <td width="80%"><?php echo $link_description; ?></span></td></tr>
927 <tr><th width="20%" scope="row"><?php _e('Homepage:') ?></th>
928 <td width="80%"><a href="<?php echo $link_url; ?>"><?php echo $link_url; ?></a></td></tr>
929 <tr style="vertical-align:top"><th width="20%" scope="row">Subscription <?php _e('Options') ?>:</th>
930 <td width="80%"><ul style="margin:0; padding: 0; list-style: none">
931 <li><input type="radio" id="unhide-<?php echo $link->link_id; ?>"
932 name="link_action[<?php echo $link->link_id; ?>]" value="unhide" checked="checked" />
933 <label for="unhide-<?php echo $link->link_id; ?>">Turn back on the subscription
934 for this syndication source.</label></li>
935 <li><input type="radio" id="nothing-<?php echo $link->link_id; ?>"
936 name="link_action[<?php echo $link->link_id; ?>]" value="nothing" />
937 <label for="nothing-<?php echo $link->link_id; ?>">Leave this feed as it is.
938 I changed my mind.</label></li>
939 </ul>
940 </table>
941 </fieldset>
942 <?php
943 endif;
944 endforeach;
945 ?>
946
947 <div class="submit">
948 <input class="button-primary delete" type="submit" name="submit" value="<?php _e('Re-subscribe to selected feeds &raquo;') ?>" />
949 </div>
950 </div>
951 <?php
952 return false; // Don't continue on to Syndicated Sites listing
953 endif;
954 } /* FeedWordPressSyndicationPage::multiundelete_page() */
955
956
957
958 } /* class FeedWordPressSyndicationPage */
959
960 function fwp_dashboard_update_if_requested ($object) {
961 global $wpdb;
962
963 $update_set = $object->updates_requested();
964
965 if (count($update_set) > 0) :
966 shuffle($update_set); // randomize order for load balancing purposes...
967
968 $feedwordpress = new FeedWordPress;
969 add_action('feedwordpress_check_feed', 'update_feeds_mention');
970 add_action('feedwordpress_check_feed_complete', 'update_feeds_finish', 10, 3);
971
972 $crash_dt = (int) get_option('feedwordpress_update_time_limit');
973 if ($crash_dt > 0) :
974 $crash_ts = time() + $crash_dt;
975 else :
976 $crash_ts = NULL;
977 endif;
978
979 echo "<div class=\"update-results\">\n";
980 echo "<ul>\n";
981 $tdelta = NULL;
982 foreach ($update_set as $uri) :
983 if (!is_null($crash_ts) and (time() > $crash_ts)) :
984 echo "<li><p><strong>Further updates postponed:</strong> update time limit of ".$crash_dt." second".(($crash_dt==1)?"":"s")." exceeded.</p></li>";
985 break;
986 endif;
987
988 if ($uri == '*') : $uri = NULL; endif;
989 $delta = $feedwordpress->update($uri, $crash_ts);
990 if (!is_null($delta)) :
991 if (is_null($tdelta)) :
992 $tdelta = $delta;
993 else :
994 $tdelta['new'] += $delta['new'];
995 $tdelta['updated'] += $delta['updated'];
996 endif;
997 else :
998 echo "<li><p><strong>Error:</strong> There was a problem updating <a href=\"$uri\">$uri</a></p></li>\n";
999 endif;
1000 endforeach;
1001 echo "</ul>\n";
1002
1003 if (!is_null($tdelta)) :
1004 $mesg = array();
1005 if (isset($delta['new'])) : $mesg[] = ' '.$tdelta['new'].' new posts were syndicated'; endif;
1006 if (isset($delta['updated'])) : $mesg[] = ' '.$tdelta['updated'].' existing posts were updated'; endif;
1007 echo "<p>Update complete.".implode(' and', $mesg)."</p>";
1008 echo "\n"; flush();
1009 endif;
1010 echo "</div> <!-- class=\"updated\" -->\n";
1011 endif;
1012 }
1013
1014 define('FEEDWORDPRESS_BLEG_MAYBE_LATER_OFFSET', (60 /*sec/min*/ * 60 /*min/hour*/ * 24 /*hour/day*/ * 31 /*days*/));
1015 define('FEEDWORDPRESS_BLEG_ALREADY_PAID_OFFSET', (60 /*sec/min*/ * 60 /*min/hour*/ * 24 /*hour/day*/ * 183 /*days*/));
1016 function fwp_syndication_manage_page_update_box ($object = NULL, $box = NULL) {
1017 $bleg_box_hidden = null;
1018 if (isset($_POST['maybe_later'])) :
1019 $bleg_box_hidden = time() + FEEDWORDPRESS_BLEG_MAYBE_LATER_OFFSET;
1020 elseif (isset($_REQUEST['paid']) and $_REQUEST['paid']) :
1021 $bleg_box_hidden = time() + FEEDWORDPRESS_BLEG_ALREADY_PAID_OFFSET;
1022 elseif (isset($_POST['go_away'])) :
1023 $bleg_box_hidden = 'permanent';
1024 endif;
1025
1026 if (!is_null($bleg_box_hidden)) :
1027 update_option('feedwordpress_bleg_box_hidden', $bleg_box_hidden);
1028 else :
1029 $bleg_box_hidden = get_option('feedwordpress_bleg_box_hidden');
1030 endif;
1031 ?>
1032 <?php
1033 $bleg_box_ready = (FEEDWORDPRESS_BLEG and (
1034 !$bleg_box_hidden
1035 or (is_numeric($bleg_box_hidden) and $bleg_box_hidden < time())
1036 ));
1037
1038 if (isset($_REQUEST['paid']) and $_REQUEST['paid']) :
1039 $object->bleg_thanks($subject, $box);
1040 elseif ($bleg_box_ready) :
1041 $object->bleg_box($object, $box);
1042 endif;
1043 ?>
1044
1045 <form
1046 action="<?php print $object->form_action(); ?>"
1047 method="POST"
1048 class="update-form<?php if ($bleg_box_ready) : ?> with-donation<?php endif; ?>"
1049 >
1050 <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div>
1051 <p>Check currently scheduled feeds for new and updated posts.</p>
1052
1053 <?php
1054 fwp_dashboard_update_if_requested($object);
1055
1056 if (!get_option('feedwordpress_automatic_updates')) :
1057 ?>
1058 <p class="heads-up"><strong>Note:</strong> Automatic updates are currently turned
1059 <strong>off</strong>. New posts from your feeds will not be syndicated
1060 until you manually check for them here. You can turn on automatic
1061 updates under <a href="admin.php?page=<?php print $GLOBALS['fwp_path']; ?>/feeds-page.php">Feed &amp; Update Settings<a></a>.</p>
1062 <?php
1063 endif;
1064 ?>
1065
1066 <div class="submit"><?php if ($object->show_inactive()) : ?>
1067 <?php foreach ($object->updates_requested() as $req) : ?>
1068 <input type="hidden" name="update_uri[]" value="<?php print esc_html($req); ?>" />
1069 <?php endforeach; ?>
1070 <?php else : ?>
1071 <input type="hidden" name="update_uri" value="*" />
1072 <?php endif; ?>
1073 <input class="button-primary" type="submit" name="update" value="<?php _e(FWP_CHECK_FOR_UPDATES); ?>" /></div>
1074
1075 <br style="clear: both" />
1076 </form>
1077 <?php
1078 } /* function fwp_syndication_manage_page_update_box () */
1079
1080 function fwp_feedfinder_page () {
1081 global $post_source, $fwp_post, $syndicationPage;
1082
1083 if (isset($fwp_post['opml_lookup']) or isset($_FILES['opml_upload'])) :
1084 $syndicationPage->accept_multiadd();
1085 return true;
1086 else :
1087 $post_source = 'feedwordpress_feeds';
1088
1089 // With action=feedfinder, this goes directly to the feedfinder page
1090 include_once(dirname(__FILE__) . '/feeds-page.php');
1091 return false;
1092 endif;
1093 } /* function fwp_feedfinder_page () */
1094
1095 function fwp_switchfeed_page () {
1096 global $wpdb, $wp_db_version;
1097 global $fwp_post;
1098
1099 // If this is a POST, validate source and user credentials
1100 FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_switchfeed', /*capability=*/ 'manage_links');
1101
1102 $changed = false;
1103 if (!isset($fwp_post['Cancel'])):
1104 if (isset($fwp_post['save_link_id']) and ($fwp_post['save_link_id']=='*')) :
1105 $changed = true;
1106 $link_id = FeedWordPress::syndicate_link($fwp_post['feed_title'], $fwp_post['feed_link'], $fwp_post['feed']);
1107 if ($link_id):
1108 $existingLink = new SyndicatedLink($link_id);
1109 ?>
1110 <div class="updated"><p><a href="<?php print $fwp_post['feed_link']; ?>"><?php print esc_html($fwp_post['feed_title']); ?></a>
1111 has been added as a contributing site, using the feed at
1112 &lt;<a href="<?php print $fwp_post['feed']; ?>"><?php print esc_html($fwp_post['feed']); ?></a>&gt;.
1113 | <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>
1114 <?php else: ?>
1115 <div class="updated"><p>There was a problem adding the feed. [SQL: <?php echo esc_html(mysql_error()); ?>]</p></div>
1116 <?php endif;
1117 elseif (isset($fwp_post['save_link_id'])):
1118 $existingLink = new SyndicatedLink($fwp_post['save_link_id']);
1119 $changed = $existingLink->set_uri($fwp_post['feed']);
1120
1121 if ($changed):
1122 $home = $existingLink->homepage(/*from feed=*/ false);
1123 $name = $existingLink->name(/*from feed=*/ false);
1124 ?>
1125 <div class="updated"><p>Feed for <a href="<?php echo esc_html($home); ?>"><?php echo esc_html($name); ?></a>
1126 updated to &lt;<a href="<?php echo esc_html($fwp_post['feed']); ?>"><?php echo esc_html($fwp_post['feed']); ?></a>&gt;.</p></div>
1127 <?php
1128 endif;
1129 endif;
1130 endif;
1131
1132 if (isset($existingLink)) :
1133 do_action('feedwordpress_admin_switchfeed', $fwp_post['feed'], $existingLink);
1134 endif;
1135
1136 if (!$changed) :
1137 ?>
1138 <div class="updated"><p>Nothing was changed.</p></div>
1139 <?php
1140 endif;
1141 return true; // Continue
1142 }
1143
1144