PluginProbe
FeedWordPress / 2014.0805
FeedWordPress v2014.0805
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 2014.0805, at feedwordpresssyndicationpage.class.php

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