| 1 |
<?php |
| 2 |
require_once(dirname(__FILE__) . '/admin-ui.php'); |
| 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">—<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__); ?>&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 & 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&link_id=<?php echo $link->link_id; ?>"><?php echo wp_specialchars($link->link_name, 'both'); ?></a></strong> |
| 413 |
<div class="row-actions"><div><strong>Settings ></strong> |
| 414 |
<a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/feeds-page.php&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&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&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&link_id=<?php echo $link->link_id; ?>"><?php print htmlspecialchars(__('Categories'.FEEDWORDPRESS_AND_TAGS)); ?></a></div> |
| 418 |
<div><strong>Actions ></strong> |
| 419 |
<a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&link_id=<?php echo $link->link_id; ?>&action=feedfinder"><?php echo $caption; ?></a> |
| 420 |
| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&link_id=<?php echo $link->link_id; ?>&action=Unsubscribe"><?php _e('Unsubscribe'); ?></a> |
| 421 |
| <a href="<?php echo wp_specialchars($link->link_url, 'both'); ?>"><?php _e('View')?></a></div> |
| 422 |
</div> |
| 423 |
</td> |
| 424 |
<?php |
| 425 |
if (strlen($link->link_rss) > 0): |
| 426 |
$uri_bits = parse_url($link->link_rss); |
| 427 |
$uri_bits['host'] = preg_replace('/^www\./i', '', $uri_bits['host']); |
| 428 |
$display_uri = |
| 429 |
(isset($uri_bits['user'])?$uri_bits['user'].'@':'') |
| 430 |
.(isset($uri_bits['host'])?$uri_bits['host']:'') |
| 431 |
.(isset($uri_bits['port'])?':'.$uri_bits['port']:'') |
| 432 |
.(isset($uri_bits['path'])?$uri_bits['path']:'') |
| 433 |
.(isset($uri_bits['query'])?'?'.$uri_bits['query']:''); |
| 434 |
if (strlen($display_uri) > 32) : $display_uri = substr($display_uri, 0, 32).'…'; endif; |
| 435 |
?> |
| 436 |
<td><a href="<?php echo wp_specialchars($link->link_rss, 'both'); ?>"><?php echo wp_specialchars($display_uri, 'both'); ?></a></td> |
| 437 |
<?php else: ?> |
| 438 |
<td style="background-color:#FFFFD0"><p><strong>no |
| 439 |
feed assigned</strong></p></td> |
| 440 |
<?php endif; ?> |
| 441 |
|
| 442 |
<td><?php |
| 443 |
$sLink =& new SyndicatedLink($link->link_id); |
| 444 |
if (isset($sLink->settings['update/last'])) : |
| 445 |
print fwp_time_elapsed($sLink->settings['update/last']); |
| 446 |
else : |
| 447 |
_e('None yet'); |
| 448 |
endif; |
| 449 |
|
| 450 |
print "<div style='font-style:italic;size:0.9em'>Ready for next update "; |
| 451 |
if (isset($sLink->settings['update/ttl']) and is_numeric($sLink->settings['update/ttl'])) : |
| 452 |
if (isset($sLink->settings['update/timed']) and $sLink->settings['update/timed']=='automatically') : |
| 453 |
$next = $sLink->settings['update/last'] + ((int) $sLink->settings['update/ttl'] * 60); |
| 454 |
print fwp_time_elapsed($next); |
| 455 |
if (FEEDWORDPRESS_DEBUG) : print " [".(($next-time())/60)." minutes]"; endif; |
| 456 |
else : |
| 457 |
echo "every ".$sLink->settings['update/ttl']." minute".(($sLink->settings['update/ttl']!=1)?"s":""); |
| 458 |
endif; |
| 459 |
else: |
| 460 |
echo "as soon as possible"; |
| 461 |
endif; |
| 462 |
print "</div>"; |
| 463 |
?> |
| 464 |
</td> |
| 465 |
</tr> |
| 466 |
<?php |
| 467 |
endforeach; |
| 468 |
else : |
| 469 |
?> |
| 470 |
<tr><td colspan="<?php print $span+2; ?>"><p>There are no websites currently listed for syndication.</p></td></tr> |
| 471 |
<?php |
| 472 |
endif; |
| 473 |
?> |
| 474 |
</tbody> |
| 475 |
</table> |
| 476 |
|
| 477 |
<?php if (count($links) > 0 and fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?> |
| 478 |
<br/><hr/> |
| 479 |
<div class="submit"><input type="submit" class="delete" name="action" value="<?php print FWP_UNSUB_CHECKED; ?>" /> |
| 480 |
<input type="submit" name="action" value="<?php print FWP_UPDATE_CHECKED; ?>" /></div> |
| 481 |
<?php endif; ?> |
| 482 |
|
| 483 |
</form> |
| 484 |
<?php |
| 485 |
} /* function fwp_syndication_manage_page_links_box() */ |
| 486 |
|
| 487 |
function fwp_feedfinder_page () { |
| 488 |
global $post_source; |
| 489 |
|
| 490 |
$post_source = 'feedwordpress_feeds'; |
| 491 |
|
| 492 |
// With action=feedfinder, this goes directly to the feedfinder page |
| 493 |
include_once(dirname(__FILE__) . '/feeds-page.php'); |
| 494 |
return false; |
| 495 |
} /* function fwp_feedfinder_page () */ |
| 496 |
|
| 497 |
function fwp_switchfeed_page () { |
| 498 |
global $wpdb, $wp_db_version; |
| 499 |
global $fwp_post; |
| 500 |
|
| 501 |
// If this is a POST, validate source and user credentials |
| 502 |
FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_switchfeed', /*capability=*/ 'manage_links'); |
| 503 |
|
| 504 |
$changed = false; |
| 505 |
if (!isset($fwp_post['Cancel'])): |
| 506 |
if (isset($fwp_post['save_link_id']) and ($fwp_post['save_link_id']=='*')) : |
| 507 |
$changed = true; |
| 508 |
$link_id = FeedWordPress::syndicate_link($fwp_post['feed_title'], $fwp_post['feed_link'], $fwp_post['feed']); |
| 509 |
if ($link_id): ?> |
| 510 |
<div class="updated"><p><a href="<?php print $fwp_post['feed_link']; ?>"><?php print wp_specialchars($fwp_post['feed_title'], 'both'); ?></a> |
| 511 |
has been added as a contributing site, using the feed at |
| 512 |
<<a href="<?php print $fwp_post['feed']; ?>"><?php print wp_specialchars($fwp_post['feed'], 'both'); ?></a>>. |
| 513 |
| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/feeds-page.php&link_id=<?php print $link_id; ?>">Configure settings</a>.</p></div> |
| 514 |
<?php else: ?> |
| 515 |
<div class="updated"><p>There was a problem adding the feed. [SQL: <?php echo wp_specialchars(mysql_error(), 'both'); ?>]</p></div> |
| 516 |
<?php endif; |
| 517 |
elseif (isset($fwp_post['save_link_id'])): |
| 518 |
$existingLink = new SyndicatedLink($fwp_post['save_link_id']); |
| 519 |
$changed = $existingLink->set_uri($fwp_post['feed']); |
| 520 |
|
| 521 |
if ($changed): |
| 522 |
$home = $existingLink->homepage(/*from feed=*/ false); |
| 523 |
$name = $existingLink->name(/*from feed=*/ false); |
| 524 |
?> |
| 525 |
<div class="updated"><p>Feed for <a href="<?php echo wp_specialchars($home, 'both'); ?>"><?php echo wp_specialchars($name, 'both'); ?></a> |
| 526 |
updated to <<a href="<?php echo wp_specialchars($fwp_post['feed'], 'both'); ?>"><?php echo wp_specialchars($fwp_post['feed'], 'both'); ?></a>>.</p></div> |
| 527 |
<?php |
| 528 |
endif; |
| 529 |
endif; |
| 530 |
endif; |
| 531 |
|
| 532 |
if (!$changed) : |
| 533 |
?> |
| 534 |
<div class="updated"><p>Nothing was changed.</p></div> |
| 535 |
<?php |
| 536 |
endif; |
| 537 |
return true; // Continue |
| 538 |
} |
| 539 |
|
| 540 |
function fwp_multidelete_page () { |
| 541 |
global $wpdb; |
| 542 |
|
| 543 |
// If this is a POST, validate source and user credentials |
| 544 |
FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_feeds', /*capability=*/ 'manage_links'); |
| 545 |
|
| 546 |
$link_ids = (isset($_REQUEST['link_ids']) ? $_REQUEST['link_ids'] : array()); |
| 547 |
if (isset($_REQUEST['link_id'])) : array_push($link_ids, $_REQUEST['link_id']); endif; |
| 548 |
|
| 549 |
if (isset($GLOBALS['fwp_post']['confirm']) and $GLOBALS['fwp_post']['confirm']=='Delete'): |
| 550 |
if (isset($GLOBALS['fwp_post']['link_action']) and is_array($GLOBALS['fwp_post']['link_action'])) : |
| 551 |
$actions = $GLOBALS['fwp_post']['link_action']; |
| 552 |
else : |
| 553 |
$actions = array(); |
| 554 |
endif; |
| 555 |
|
| 556 |
foreach ($actions as $link_id => $what) : |
| 557 |
$do_it[$what][] = $link_id; |
| 558 |
endforeach; |
| 559 |
|
| 560 |
$alter = array(); |
| 561 |
if (count($do_it['hide']) > 0) : |
| 562 |
$hidem = "(".implode(', ', $do_it['hide']).")"; |
| 563 |
$alter[] = " |
| 564 |
UPDATE $wpdb->links |
| 565 |
SET link_visible = 'N' |
| 566 |
WHERE link_id IN {$hidem} |
| 567 |
"; |
| 568 |
endif; |
| 569 |
|
| 570 |
if (count($do_it['nuke']) > 0) : |
| 571 |
$nukem = "(".implode(', ', $do_it['nuke']).")"; |
| 572 |
|
| 573 |
// Make a list of the items syndicated from this feed... |
| 574 |
$post_ids = $wpdb->get_col(" |
| 575 |
SELECT post_id FROM $wpdb->postmeta |
| 576 |
WHERE meta_key = 'syndication_feed_id' |
| 577 |
AND meta_value IN {$nukem} |
| 578 |
"); |
| 579 |
|
| 580 |
// ... and kill them all |
| 581 |
if (count($post_ids) > 0) : |
| 582 |
foreach ($post_ids as $post_id) : |
| 583 |
wp_delete_post($post_id); |
| 584 |
endforeach; |
| 585 |
endif; |
| 586 |
|
| 587 |
$alter[] = " |
| 588 |
DELETE FROM $wpdb->links |
| 589 |
WHERE link_id IN {$nukem} |
| 590 |
"; |
| 591 |
endif; |
| 592 |
|
| 593 |
if (count($do_it['delete']) > 0) : |
| 594 |
$deletem = "(".implode(', ', $do_it['delete']).")"; |
| 595 |
|
| 596 |
// Make the items syndicated from this feed appear to be locally-authored |
| 597 |
$alter[] = " |
| 598 |
DELETE FROM $wpdb->postmeta |
| 599 |
WHERE meta_key = 'syndication_feed_id' |
| 600 |
AND meta_value IN {$deletem} |
| 601 |
"; |
| 602 |
|
| 603 |
// ... and delete the links themselves. |
| 604 |
$alter[] = " |
| 605 |
DELETE FROM $wpdb->links |
| 606 |
WHERE link_id IN {$deletem} |
| 607 |
"; |
| 608 |
endif; |
| 609 |
|
| 610 |
$errs = array(); $success = array (); |
| 611 |
foreach ($alter as $sql) : |
| 612 |
$result = $wpdb->query($sql); |
| 613 |
if (!$result): |
| 614 |
$errs[] = mysql_error(); |
| 615 |
endif; |
| 616 |
endforeach; |
| 617 |
|
| 618 |
if (count($alter) > 0) : |
| 619 |
echo "<div class=\"updated\">\n"; |
| 620 |
if (count($errs) > 0) : |
| 621 |
echo "There were some problems processing your "; |
| 622 |
echo "unsubscribe request. [SQL: ".implode('; ', $errs)."]"; |
| 623 |
else : |
| 624 |
echo "Your unsubscribe request(s) have been processed."; |
| 625 |
endif; |
| 626 |
echo "</div>\n"; |
| 627 |
endif; |
| 628 |
|
| 629 |
return true; // Continue on to Syndicated Sites listing |
| 630 |
else : |
| 631 |
$targets = $wpdb->get_results(" |
| 632 |
SELECT * FROM $wpdb->links |
| 633 |
WHERE link_id IN (".implode(",",$link_ids).") |
| 634 |
"); |
| 635 |
?> |
| 636 |
<form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post"> |
| 637 |
<div class="wrap"> |
| 638 |
<?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?> |
| 639 |
<input type="hidden" name="action" value="Unsubscribe" /> |
| 640 |
<input type="hidden" name="confirm" value="Delete" /> |
| 641 |
|
| 642 |
<h2>Unsubscribe from Syndicated Links:</h2> |
| 643 |
<?php foreach ($targets as $link) : |
| 644 |
$link_url = wp_specialchars($link->link_url, 1); |
| 645 |
$link_name = wp_specialchars($link->link_name, 1); |
| 646 |
$link_description = wp_specialchars($link->link_description, 'both'); |
| 647 |
$link_rss = wp_specialchars($link->link_rss, 'both'); |
| 648 |
?> |
| 649 |
<fieldset> |
| 650 |
<legend><?php echo $link_name; ?></legend> |
| 651 |
<table class="editform" width="100%" cellspacing="2" cellpadding="5"> |
| 652 |
<tr><th scope="row" width="20%"><?php _e('Feed URI:') ?></th> |
| 653 |
<td width="80%"><a href="<?php echo $link_rss; ?>"><?php echo $link_rss; ?></a></td></tr> |
| 654 |
<tr><th scope="row" width="20%"><?php _e('Short description:') ?></th> |
| 655 |
<td width="80%"><?php echo $link_description; ?></span></td></tr> |
| 656 |
<tr><th width="20%" scope="row"><?php _e('Homepage:') ?></th> |
| 657 |
<td width="80%"><a href="<?php echo $link_url; ?>"><?php echo $link_url; ?></a></td></tr> |
| 658 |
<tr style="vertical-align:top"><th width="20%" scope="row">Subscription <?php _e('Options') ?>:</th> |
| 659 |
<td width="80%"><ul style="margin:0; padding: 0; list-style: none"> |
| 660 |
<li><input type="radio" id="hide-<?php echo $link->link_id; ?>" |
| 661 |
name="link_action[<?php echo $link->link_id; ?>]" value="hide" /> |
| 662 |
<label for="hide-<?php echo $link->link_id; ?>">Turn off the subscription for this |
| 663 |
syndicated link<br/><span style="font-size:smaller">(Keep the feed information |
| 664 |
and all the posts from this feed in the database, but don't syndicate any |
| 665 |
new posts from the feed.)</span></label></li> |
| 666 |
<li><input type="radio" id="nuke-<?php echo $link->link_id; ?>" |
| 667 |
name="link_action[<?php echo $link->link_id; ?>]" value="nuke" /> |
| 668 |
<label for="nuke-<?php echo $link->link_id; ?>">Delete this syndicated link and all the |
| 669 |
posts that were syndicated from it</label></li> |
| 670 |
<li><input type="radio" id="delete-<?php echo $link->link_id; ?>" |
| 671 |
name="link_action[<?php echo $link->link_id; ?>]" value="delete" /> |
| 672 |
<label for="delete-<?php echo $link->link_id; ?>">Delete this syndicated link, but |
| 673 |
<em>keep</em> posts that were syndicated from it (as if they were authored |
| 674 |
locally).</label></li> |
| 675 |
<li><input type="radio" id="nothing-<?php echo $link->link_id; ?>" |
| 676 |
name="link_action[<?php echo $link->link_id; ?>]" value="nothing" /> |
| 677 |
<label for="nothing-<?php echo $link->link_id; ?>">Keep this feed as it is. I changed |
| 678 |
my mind.</label></li> |
| 679 |
</ul> |
| 680 |
</table> |
| 681 |
</fieldset> |
| 682 |
<?php endforeach; ?> |
| 683 |
|
| 684 |
<div class="submit"> |
| 685 |
<input class="delete" type="submit" name="submit" value="<?php _e('Unsubscribe from selected feeds »') ?>" /> |
| 686 |
</div> |
| 687 |
</div> |
| 688 |
<?php |
| 689 |
return false; // Don't continue on to Syndicated Sites listing |
| 690 |
endif; |
| 691 |
} |
| 692 |
|
| 693 |
$syndicationPage = new FeedWordPressSyndicationPage; |
| 694 |
$syndicationPage->display(); |
| 695 |
|
| 696 |
|