PluginProbe
FeedWordPress / 2011.0721
FeedWordPress v2011.0721
trunk 0.8 0.9 0.91 0.95 0.96 0.97 0.98 0.981 0.99 0.991 0.992 0.993 2008.1030 2008.1101 2008.1105 2008.1214 2009.0612 2009.0613 2009.0618 2009.0707 2009.1111 2009.1112 2010.0127 2010.0528 All 65 releases
← All changes | syndication.php +3 -1332 2008.12142011.0721 View file →
@@ -1,1335 +1,6 @@
1 1 <?php
2 -require_once(dirname(__FILE__) . '/admin-ui.php');
2 + require_once(dirname(__FILE__).'/feedwordpresssyndicationpage.class.php');
3 3
4 -################################################################################
5 -## ADMIN MENU ADD-ONS: implement Dashboard management pages ####################
6 -################################################################################
7 -
8 -if (fwp_test_wp_version(0, FWP_SCHEMA_25)) :
9 - define('FWP_UPDATE_CHECKED', 'Update Checked Links');
10 - define('FWP_UNSUB_CHECKED', 'Unsubscribe from Checked Links');
11 - define('FWP_SYNDICATE_NEW', 'Syndicate »');
12 -else :
13 - define('FWP_UPDATE_CHECKED', 'Update Checked');
14 - define('FWP_UNSUB_CHECKED', 'Unsubscribe');
15 - define('FWP_SYNDICATE_NEW', 'Syndicate »');
16 -endif;
17 -
18 -function fwp_dashboard_update_if_requested () {
19 - global $wpdb;
20 -
21 - if (isset($_POST['update']) or isset($_POST['action']) or isset($_POST['update_uri'])) :
22 - $fwp_update_invoke = 'post';
23 - else :
24 - $fwp_update_invoke = 'get';
25 - endif;
26 -
27 - $update_set = array();
28 - if (isset($_POST['link_ids']) and is_array($_POST['link_ids']) and ($_POST['action']==FWP_UPDATE_CHECKED)) :
29 - $targets = $wpdb->get_results("
30 - SELECT * FROM $wpdb->links
31 - WHERE link_id IN (".implode(",",$_POST['link_ids']).")
32 - ");
33 - if (is_array($targets)) :
34 - foreach ($targets as $target) :
35 - $update_set[] = $target->link_rss;
36 - endforeach;
37 - else : // This should never happen
38 - FeedWordPress::critical_bug('fwp_syndication_manage_page::targets', $targets, __LINE__);
39 - endif;
40 - elseif (isset($_POST['update_uri'])) :
41 - $update_set[] = $_POST['update_uri'];
42 - endif;
43 -
44 - shuffle($update_set); // randomize order for load balancing purposes...
45 - if ($fwp_update_invoke != 'get' and count($update_set) > 0) : // Only do things with side-effects for HTTP POST or command line
46 - $feedwordpress =& new FeedWordPress;
47 - add_action('feedwordpress_check_feed', 'update_feeds_mention');
48 - add_action('feedwordpress_check_feed_complete', 'update_feeds_finish', 10, 3);
49 -
50 - $crash_dt = (int) get_option('feedwordpress_update_time_limit');
51 - if ($crash_dt > 0) :
52 - $crash_ts = time() + $crash_dt;
53 - else :
54 - $crash_ts = NULL;
55 - endif;
56 -
57 - if (fwp_test_wp_version(FWP_SCHEMA_25)) :
58 - echo "<div class=\"youare\">\n";
59 - else :
60 - echo "<div class=\"updated\">\n";
61 - endif;
62 - echo "<ul>\n";
63 - $tdelta = NULL;
64 - foreach ($update_set as $uri) :
65 - if (!is_null($crash_ts) and (time() > $crash_ts)) :
66 - echo "<li><p><strong>Further updates postponed:</strong> update time limit of ".$crash_dt." second".(($crash_dt==1)?"":"s")." exceeded.</p></li>";
67 - break;
68 - endif;
69 -
70 - if ($uri == '*') : $uri = NULL; endif;
71 - $delta = $feedwordpress->update($uri, $crash_ts);
72 - if (!is_null($delta)) :
73 - if (is_null($tdelta)) :
74 - $tdelta = $delta;
75 - else :
76 - $tdelta['new'] += $delta['new'];
77 - $tdelta['updated'] += $delta['updated'];
78 - endif;
79 - else :
80 - echo "<li><p><strong>Error:</strong> There was a problem updating <a href=\"$uri\">$uri</a></p></li>\n";
81 - endif;
82 - endforeach;
83 - echo "</ul>\n";
84 -
85 - if (!is_null($tdelta)) :
86 - $mesg = array();
87 - if (isset($delta['new'])) : $mesg[] = ' '.$tdelta['new'].' new posts were syndicated'; endif;
88 - if (isset($delta['updated'])) : $mesg[] = ' '.$tdelta['updated'].' existing posts were updated'; endif;
89 - echo "<p>Update complete.".implode(' and', $mesg)."</p>";
90 - echo "\n"; flush();
91 - endif;
92 - echo "</div> <!-- class=\"updated\" -->\n";
93 - elseif (fwp_test_wp_version(FWP_SCHEMA_25)) :
94 -?>
95 - <p class="youare">Check currently scheduled feeds for new and updated posts.</p>
96 -<?php
97 - endif;
98 -}
99 -
100 -function fwp_syndication_manage_page () {
101 - global $wpdb;
102 -
103 - if (FeedWordPress::needs_upgrade()) :
104 - fwp_upgrade_page();
105 - return;
106 - endif;
107 -
108 -?>
109 -<?php $cont = true;
110 -if (isset($_REQUEST['action'])):
111 - if ($_REQUEST['action'] == 'feedfinder' or $_REQUEST['action'] == FWP_SYNDICATE_NEW) : $cont = fwp_feedfinder_page();
112 - elseif ($_REQUEST['action'] == 'switchfeed') : $cont = fwp_switchfeed_page();
113 - elseif ($_REQUEST['action'] == 'linkedit') : $cont = fwp_linkedit_page();
114 - elseif ($_REQUEST['action'] == FWP_UNSUB_CHECKED or $_REQUEST['action'] == 'Unsubscribe') : $cont = fwp_multidelete_page();
115 - endif;
116 -endif;
117 -
118 -if ($cont):
119 -?>
120 -<?php
121 - $links = FeedWordPress::syndicated_links();
122 -?>
123 - <div class="wrap">
124 -<?php if (fwp_test_wp_version(FWP_SCHEMA_27)) : ?>
125 - <div class="icon32"><img src="<?php print htmlspecialchars(WP_PLUGIN_URL.'/'.$GLOBALS['fwp_path'].'/feedwordpress.png'); ?>" alt="" /></div>
126 - <h2>Syndicated Sites</h2>
127 -<?php endif;
128 - if (fwp_test_wp_version(0, FWP_SCHEMA_25)) :
129 - fwp_dashboard_update_if_requested();
130 - endif;
131 -
132 - if (fwp_test_wp_version(FWP_SCHEMA_27)) :
133 -?>
134 - <script type="text/javascript">
135 - jQuery(document).ready( function($) {
136 - // In case someone got here first.
137 - $('.postbox h3, .postbox .handlediv').unbind('click');
138 - $('.hide-postbox-tog').unbind('click');
139 - $('.meta-box-sortables').sortable('destroy');
140 -
141 - postboxes.add_postbox_toggles('feedwordpress_syndication');
142 - } );
143 - </script>
144 -<?php
145 - echo "<form style='display: none' method='get' action=''>\n<p>\n";
146 - wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
147 - wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
148 - echo "</p>\n</form>\n";
149 -
150 - if ($links) :
151 - add_meta_box('feedwordpress_update_box', __('Update feeds now'), 'fwp_syndication_manage_page_update_box', /*page=*/ 'feedwordpress_syndication', /*context =*/ 'normal');
152 - endif;
153 - add_meta_box('feedwordpress_feeds_box', __('Syndicated sources'), 'fwp_syndication_manage_page_links_box', /*page=*/ 'feedwordpress_syndication', /*context =*/ 'normal');
154 -?>
155 - <div class="metabox-holder">
156 - <div id="feedwordpress-sortables" class="meta-box-sortables ui-sortable">
157 -<?php
158 - do_meta_boxes('feedwordpress_syndication', 'normal', NULL);
159 - else :
160 - if ($links): // only display Update panel if there are some links to update....
161 - fwp_syndication_manage_page_update_box();
162 - endif;
163 - fwp_syndication_manage_page_links_box();
164 -?>
165 - </div> <!-- class="wrap" -->
166 -
167 - <?php if (fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?>
168 - <div class="wrap">
169 - <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
170 - <h2>Add a new syndicated site:</h2>
171 - <div>
172 - <label for="add-uri">Website or newsfeed:</label>
173 - <input type="text" name="lookup" id="add-uri" value="URI" size="64" />
174 - <input type="hidden" name="action" value="feedfinder" />
175 - </div>
176 - <div class="submit"><input type="submit" value="Syndicate &raquo;" /></div>
177 - </form>
178 - </div> <!-- class="wrap" -->
179 - <?php endif; ?>
180 -
181 - <div style="display: none">
182 - <div id="tags-input"></div> <!-- avoid JS error from WP 2.5 bug -->
183 - </div>
184 -<?php
185 - endif;
186 -endif;
187 -} /* function fwp_syndication_manage_page () */
188 -
189 -function fwp_syndication_manage_page_update_box ($object = NULL, $box = NULL) {
190 - $updateFeedsNow = __('Update feeds now');
191 -?>
192 - <form action="" method="POST">
193 - <?php if (fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_27)) : ?>
194 - <div id="rightnow">
195 - <h3 class="reallynow"><span><?php print $updateFeedsNow; ?></span>
196 - <input type="hidden" name="update_uri" value="*" /><input style="float: right; border: none;" class="rbutton" type="submit" name="update" value="Update" />
197 - <br class="clear"/></h3>
198 - <?php elseif (fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?>
199 - <h2><?php print $updateFeedsNow; ?></h2>
200 - <?php endif; ?>
201 -
202 -<?php
203 - if (fwp_test_wp_version(FWP_SCHEMA_25)) :
204 - fwp_dashboard_update_if_requested();
205 - else :
206 -?>
207 -<p>Check currently scheduled feeds for new and updated posts.</p>
208 -<?php endif; ?>
209 -
210 -<?php if (!get_option('feedwordpress_automatic_updates')) : ?>
211 - <p class="youhave"><strong>Note:</strong> Automatic updates are currently turned
212 - <strong>off</strong>. New posts from your feeds will not be syndicated
213 - until you manually check for them here. You can turn on automatic
214 - updates under <a href="admin.php?page=<?php print $GLOBALS['fwp_path']; ?>/syndication-options.php">Syndication
215 - Options</a>.</p>
216 -<?php endif; ?>
217 -
218 - <?php if (!fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_27)) : ?>
219 - <div class="submit"><input type="hidden" name="update_uri" value="*" /><input class="button-primary" type="submit" name="update" value="Update" /></div>
220 - <?php endif; ?>
221 -
222 - <?php if (fwp_test_wp_version(FWP_SCHEMA_27)) : ?>
223 - <br style="clear: both" />
224 - <?php elseif (fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_27)) : ?>
225 - </div> <!-- id="rightnow" -->
226 - </div> <!-- class="wrap" -->
227 - <?php elseif (fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?>
228 - </div> <!-- class="wrap" -->
229 - <?php endif; ?>
230 - </form>
231 -<?php
232 -} /* function fwp_syndication_manage_page_update_box () */
233 -
234 -function fwp_syndication_manage_page_links_box ($object = NULL, $box = NULL) {
235 - $links = FeedWordPress::syndicated_links();
236 -?>
237 - <?php if (!fwp_test_wp_version(FWP_SCHEMA_27)) : ?>
238 - <div class="wrap">
239 - <h2>Syndicated Sites</h2>
240 - <?php endif; ?>
241 -
242 - <form id="syndicated-links" action="admin.php?page=<?php print $GLOBALS['fwp_path']; ?>/<?php echo basename(__FILE__); ?>" method="post">
243 -<?php $alt_row = true; ?>
244 -
245 - <?php if (fwp_test_wp_version(FWP_SCHEMA_25)) : ?>
246 - <div class="tablenav">
247 - <div class="alignright">
248 - <label for="add-uri">Add new source:</label>
249 - <input type="text" name="lookup" id="add-uri" value="Website or feed URI" />
250 -<script type="text/javascript">
251 -jQuery(document).ready( function () {
252 - var addUri = jQuery("#add-uri");
253 - var box = addUri.get(0);
254 - if (box.value==box.defaultValue) { addUri.addClass('form-input-tip'); }
255 - addUri.focus(function() {
256 - if ( this.value == this.defaultValue )
257 - jQuery(this).val( '' ).removeClass( 'form-input-tip' );
258 - });
259 - addUri.blur(function() {
260 - if ( this.value == '' )
261 - jQuery(this).val( this.defaultValue ).addClass( 'form-input-tip' );
262 - });
263 -
264 -} );
265 -</script>
266 -
267 - <input type="hidden" name="action" value="feedfinder" />
268 - <input type="submit" class="button-secondary" name="action" value="<?php print FWP_SYNDICATE_NEW; ?>" /></div>
269 -
270 -<?php if (count($links) > 0) : ?>
271 - <div class="alignleft">
272 - <input class="button-secondary" type="submit" name="action" value="<?php print FWP_UPDATE_CHECKED; ?>" />
273 - <input class="button-secondary delete" type="submit" class="delete" name="action" value="<?php print FWP_UNSUB_CHECKED; ?>" />
274 - </div>
275 -<?php endif; ?>
276 -
277 - <br class="clear" />
278 - </div>
279 - <br class="clear" />
280 -
281 - <table class="widefat">
282 - <?php else : ?>
283 - <table width="100%" cellpadding="3" cellspacing="3">
284 - <?php endif; ?>
285 -<thead>
286 -<tr>
287 -<th class="check-column" scope="col"><?php if (fwp_test_wp_version(FWP_SCHEMA_25)) : ?>
288 -<input type="checkbox" <?php if (fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_26)) : ?>onclick="checkAll(document.getElementById('syndicated-links'));"<?php endif; ?> />
289 -<?php endif; ?></th>
290 -<th scope="col"><?php _e('Name'); ?></th>
291 -<th scope="col"><?php _e('Feed'); ?></th>
292 -<th scope="col"><?php _e('Updated'); ?></th>
293 -</tr>
294 -</thead>
295 -
296 -<tbody>
297 -<?php if (count($links) > 0): foreach ($links as $link):
298 - $alt_row = !$alt_row; ?>
299 -<tr<?php echo ($alt_row?' class="alternate"':''); ?>>
300 -<th class="check-column" scope="row"><input type="checkbox" name="link_ids[]" value="<?php echo $link->link_id; ?>" /></th>
301 -<?php
302 - if (strlen($link->link_rss) > 0):
303 - $caption=__('Switch Feed');
304 - else :
305 - $caption=__('Find Feed');
306 - endif;
307 -?>
308 -<td>
309 -<strong><a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&amp;link_id=<?php echo $link->link_id; ?>&amp;action=linkedit"><?php echo wp_specialchars($link->link_name, 'both'); ?></a></strong>
310 -<div class="row-actions"><a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&amp;link_id=<?php echo $link->link_id; ?>&amp;action=linkedit"><?php _e('Edit'); ?></a>
311 -| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&amp;link_id=<?php echo $link->link_id; ?>&amp;action=feedfinder"><?php echo $caption; ?></a>
312 -| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&amp;link_id=<?php echo $link->link_id; ?>&amp;action=Unsubscribe"><?php _e('Unsubscribe'); ?></a>
313 -| <a href="<?php echo wp_specialchars($link->link_url, 'both'); ?>"><?php _e('View')?></a>
314 -</div>
315 -</td>
316 -<?php
317 - if (strlen($link->link_rss) > 0):
318 - $uri_bits = parse_url($link->link_rss);
319 - $uri_bits['host'] = preg_replace('/^www\./i', '', $uri_bits['host']);
320 - $display_uri =
321 - (isset($uri_bits['user'])?$uri_bits['user'].'@':'')
322 - .(isset($uri_bits['host'])?$uri_bits['host']:'')
323 - .(isset($uri_bits['port'])?':'.$uri_bits['port']:'')
324 - .(isset($uri_bits['path'])?$uri_bits['path']:'')
325 - .(isset($uri_bits['query'])?'?'.$uri_bits['query']:'');
326 - if (strlen($display_uri) > 32) : $display_uri = substr($display_uri, 0, 32).'&#8230;'; endif;
327 -?>
328 - <td><a href="<?php echo wp_specialchars($link->link_rss, 'both'); ?>"><?php echo wp_specialchars($display_uri, 'both'); ?></a></td>
329 - <?php else: ?>
330 - <td style="background-color:#FFFFD0"><p><strong>no
331 - feed assigned</strong></p></td>
332 - <?php endif; ?>
333 -
334 - <td><?php
335 - $sLink =& new SyndicatedLink($link->link_id);
336 - if (isset($sLink->settings['update/last'])) :
337 - print fwp_time_elapsed($sLink->settings['update/last']);
338 - else :
339 - _e('None yet');
340 - endif;
341 -
342 - print "<div style='font-style:italic;size:0.9em'>Ready for next update ";
343 - if (isset($sLink->settings['update/ttl']) and is_numeric($sLink->settings['update/ttl'])) :
344 - if (isset($sLink->settings['update/timed']) and $sLink->settings['update/timed']=='automatically') :
345 - $next = $sLink->settings['update/last'] + ((int) $sLink->settings['update/ttl'] * 60);
346 - print fwp_time_elapsed($next);
347 - else :
348 - echo "every ".$sLink->settings['update/ttl']." minute".(($sLink->settings['update/ttl']!=1)?"s":"");
349 - endif;
350 - else:
351 - echo "as soon as possible";
352 - endif;
353 - print "</div>";
354 -?>
355 - </td>
356 - </tr>
357 -<?php
358 - endforeach;
359 - else :
360 -?>
361 -<tr><td colspan="<?php print $span+2; ?>"><p>There are no websites currently listed for syndication.</p></td></tr>
362 -<?php
363 - endif;
364 -?>
365 -</tbody>
366 -</table>
367 -
368 -<?php if (count($links) > 0 and fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?>
369 -<br/><hr/>
370 -<div class="submit"><input type="submit" class="delete" name="action" value="<?php print FWP_UNSUB_CHECKED; ?>" />
371 -<input type="submit" name="action" value="<?php print FWP_UPDATE_CHECKED; ?>" /></div>
372 -<?php endif; ?>
373 -
374 - </form>
375 -<?php
376 -} /* function fwp_syndication_manage_page_links_box() */
377 -
378 -function fwp_feedfinder_page () {
379 - global $wpdb;
380 -
381 - $lookup = (isset($_REQUEST['lookup'])?$_REQUEST['lookup']:NULL);
382 -
383 - if (isset($_REQUEST['link_id']) and ($_REQUEST['link_id']!=0)):
384 - $link_id = $_REQUEST['link_id'];
385 - if (!is_numeric($link_id)) : FeedWordPress::critical_bug('fwp_feedfinder_page::link_id', $link_id, __LINE__); endif;
386 -
387 - $link = $wpdb->get_row("SELECT * FROM $wpdb->links WHERE link_id='".$wpdb->escape($link_id)."'");
388 - if (is_object($link)):
389 - if (is_null($lookup)) $lookup = $link->link_url;
390 - $name = wp_specialchars($link->link_name, 'both');
391 - else:
392 - die (__("Cheatin' uh ?"));
393 - endif;
394 - else:
395 - $name = "<code>".htmlspecialchars($lookup)."</code>";
396 - $link_id = 0;
397 - endif;
398 -?>
399 - <div class="wrap">
400 - <h2>Feed Finder: <?php echo $name; ?></h2>
401 -<?php
402 - $f =& new FeedFinder($lookup);
403 - $feeds = $f->find();
404 - if (count($feeds) > 0):
405 - foreach ($feeds as $key => $f):
406 - $rss = fetch_rss($f);
407 - if ($rss):
408 - $feed_title = isset($rss->channel['title'])?$rss->channel['title']:$rss->channel['link'];
409 - $feed_link = isset($rss->channel['link'])?$rss->channel['link']:'';
410 - else :
411 - // Give us some sucky defaults
412 - $uri_bits = parse_url($lookup);
413 - $uri_bits['host'] = preg_replace('/^www\./i', '', $uri_bits['host']);
414 - $display_uri =
415 - (isset($uri_bits['user'])?$uri_bits['user'].'@':'')
416 - .(isset($uri_bits['host'])?$uri_bits['host']:'')
417 - .(isset($uri_bits['port'])?':'.$uri_bits['port']:'')
418 - .(isset($uri_bits['path'])?$uri_bits['path']:'')
419 - .(isset($uri_bits['query'])?'?'.$uri_bits['query']:'');
420 - if (strlen($display_uri) > 32) : $display_uri = substr($display_uri, 0, 32).'&#8230;'; endif;
421 -
422 - $feed_title = $display_uri;
423 - $feed_link = $lookup;
424 - endif;
425 -?>
426 - <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
427 - <fieldset style="clear: both">
428 - <legend><?php echo $rss->feed_type; ?> <?php echo $rss->feed_version; ?> feed</legend>
429 -
430 - <?php if ($link_id===0): ?>
431 - <input type="hidden" name="feed_title" value="<?php echo wp_specialchars($feed_title, 'both'); ?>" />
432 - <input type="hidden" name="feed_link" value="<?php echo wp_specialchars($feed_link, 'both'); ?>" />
433 - <?php endif; ?>
434 -
435 - <input type="hidden" name="link_id" value="<?php echo $link_id; ?>" />
436 - <input type="hidden" name="feed" value="<?php echo wp_specialchars($f, 'both'); ?>" />
437 - <input type="hidden" name="action" value="switchfeed" />
438 -
439 - <div>
440 - <div style="float:right; background-color:#D0D0D0; color: black; width:45%; font-size:70%; border-left: 1px dotted #A0A0A0; padding-left: 0.5em; margin-left: 1.0em">
441 -<?php if (count($rss->items) > 0): ?>
442 - <?php $item = $rss->items[0]; ?>
443 - <h3>Sample Item</h3>
444 - <ul>
445 - <li><strong>Title:</strong> <a href="<?php echo $item['link']; ?>"><?php echo $item['title']; ?></a></li>
446 - <li><strong>Date:</strong> <?php echo isset($item['date_timestamp']) ? date('d-M-y g:i:s a', $item['date_timestamp']) : 'unknown'; ?></li>
447 - </ul>
448 - <div class="entry">
449 - <?php echo (isset($item['content']['encoded'])?$item['content']['encoded']:$item['description']); ?>
450 - </div>
451 -<?php else: ?>
452 - <h3>No Items</h3>
453 - <p>FeedWordPress found no posts on this feed.</p>
454 -<?php endif; ?>
455 - </div>
456 -
457 - <div>
458 - <h3>Feed Information</h3>
459 - <ul>
460 - <li><strong>Website:</strong> <a href="<?php echo $feed_link; ?>"><?php echo is_null($feed_title)?'<em>Unknown</em>':$feed_title; ?></a></li>
461 - <li><strong>Feed URI:</strong> <a href="<?php echo wp_specialchars($f, 'both'); ?>"><?php echo wp_specialchars($f, 'both'); ?></a> (<a title="Check feed &lt;<?php echo wp_specialchars($f, 'both'); ?>&gt; for validity" href="http://feedvalidator.org/check.cgi?url=<?php echo urlencode($f); ?>">validate</a>)</li>
462 - <li><strong>Encoding:</strong> <?php echo isset($rss->encoding)?wp_specialchars($rss->encoding, 'both'):"<em>Unknown</em>"; ?></li>
463 - <li><strong>Description:</strong> <?php echo isset($rss->channel['description'])?wp_specialchars($rss->channel['description'], 'both'):"<em>Unknown</em>"; ?></li>
464 - </ul>
465 - <div class="submit"><input type="submit" name="Use" value="&laquo; Use this feed" /></div>
466 - <div class="submit"><input type="submit" name="Cancel" value="&laquo; Cancel" /></div>
467 - </div>
468 - </div>
469 - </fieldset>
470 - </form>
471 -<?php
472 - endforeach;
473 - else:
474 - print "<p><strong>".__('Error').":</strong> ".__("I couldn't find any feeds at").' <code><a href="'.htmlspecialchars($lookup).'">'.htmlspecialchars($lookup).'</a></code>';
475 - if (!is_null($f->error())) :
476 - print " [".__('HTTP request error').": ".htmlspecialchars(trim($f->error()))."]";
477 - endif;
478 - print ". ".__('Try another URL')."</p>";
479 - endif;
480 -?>
481 - </div>
482 -
483 - <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
484 - <div class="wrap">
485 - <h2>Use another feed</h2>
486 - <div><label>Feed:</label>
487 - <input type="text" name="lookup" value="URI" />
488 - <input type="hidden" name="link_id" value="<?php echo $link_id; ?>" />
489 - <input type="hidden" name="action" value="feedfinder" /></div>
490 - <div class="submit"><input type="submit" value="Use this feed &raquo;" /></div>
491 - </div>
492 - </form>
493 -<?php
494 - return false; // Don't continue
495 -}
496 -
497 -function fwp_switchfeed_page () {
498 - global $wpdb, $wp_db_version;
499 -
500 - check_admin_referer();
501 - if (!isset($_REQUEST['Cancel'])):
502 - if (!current_user_can('manage_links')):
503 - die (__("Cheatin' uh ?"));
504 - elseif (isset($_REQUEST['link_id']) and ($_REQUEST['link_id']==0)):
505 - $link_id = FeedWordPress::syndicate_link($_REQUEST['feed_title'], $_REQUEST['feed_link'], $_REQUEST['feed']);
506 - if ($link_id): ?>
507 -<div class="updated"><p><a href="<?php echo $_REQUEST['feed_link']; ?>"><?php echo wp_specialchars($_REQUEST['feed_title'], 'both'); ?></a>
508 -has been added as a contributing site, using the newsfeed at &lt;<a href="<?php echo $_REQUEST['feed']; ?>"><?php echo wp_specialchars($_REQUEST['feed'], 'both'); ?></a>&gt;.</p></div>
509 -<?php else: ?>
510 -<div class="updated"><p>There was a problem adding the newsfeed. [SQL: <?php echo wp_specialchars(mysql_error(), 'both'); ?>]</p></div>
511 -<?php endif;
512 - elseif (isset($_REQUEST['link_id'])):
513 - // Update link_rss
514 - $result = $wpdb->query("
515 - UPDATE $wpdb->links
516 - SET
517 - link_rss = '".$wpdb->escape($_REQUEST['feed'])."'
518 - WHERE link_id = '".$wpdb->escape($_REQUEST['link_id'])."'
519 - ");
520 -
521 - if ($result):
522 - $result = $wpdb->get_row("
523 - SELECT link_name, link_url FROM $wpdb->links
524 - WHERE link_id = '".$wpdb->escape($_REQUEST['link_id'])."'
525 - ");
526 - ?>
527 -<div class="updated"><p>Feed for <a href="<?php echo $result->link_url; ?>"><?php echo wp_specialchars($result->link_name, 'both'); ?></a>
528 -updated to &lt;<a href="<?php echo $_REQUEST['feed']; ?>"><?php echo wp_specialchars($_REQUEST['feed'], 'both'); ?></a>&gt;.</p></div>
529 - <?php else: ?>
530 -<div class="updated"><p>Nothing was changed.</p></div>
531 - <?php endif;
532 - endif;
533 - endif;
534 - return true; // Continue
535 -}
536 -
537 -function fwp_linkedit_page () {
538 - global $wpdb, $wp_db_version;
539 -
540 - check_admin_referer(); // Make sure we arrived here from the Dashboard
541 -
542 - $special_settings = array ( /* Regular expression syntax is OK here */
543 - 'cats',
544 - 'cat_split',
545 - 'hardcode name',
546 - 'hardcode url',
547 - 'hardcode description',
548 - 'hardcode categories', /* Deprecated */
549 - 'post status',
550 - 'comment status',
551 - 'ping status',
552 - 'unfamiliar author',
553 - 'unfamliar categories', /* Deprecated */
554 - 'unfamiliar category',
555 - 'map authors',
556 - 'tags',
557 - 'update/.*',
558 - 'feed/.*',
559 - 'link/.*',
560 - );
561 -
562 - if (!current_user_can('manage_links')) :
563 - die (__("Cheatin' uh ?"));
564 - elseif (isset($_REQUEST['feedfinder'])) :
565 - return fwp_feedfinder_page(); // re-route to Feed Finder page
566 - else :
567 - $link_id = (int) $_REQUEST['link_id'];
568 - $link =& new SyndicatedLink($link_id);
569 -
570 - if ($link->found()) :
571 - if (isset($GLOBALS['fwp_post']['save'])) :
572 - $alter = array ();
573 -
574 - // custom feed settings first
575 - foreach ($GLOBALS['fwp_post']['notes'] as $mn) :
576 - $mn['key0'] = trim($mn['key0']);
577 - $mn['key1'] = trim($mn['key1']);
578 - if (preg_match("\007^(("
579 - .implode(')|(',$special_settings)
580 - ."))$\007i",
581 - $mn['key1'])) :
582 - $mn['key1'] = 'user/'.$mn['key1'];
583 - endif;
584 -
585 - if (strlen($mn['key0']) > 0) :
586 - unset($link->settings[$mn['key0']]); // out with the old
587 - endif;
588 -
589 - if (($mn['action']=='update') and (strlen($mn['key1']) > 0)) :
590 - $link->settings[$mn['key1']] = $mn['value']; // in with the new
591 - endif;
592 - endforeach;
593 -
594 - // now stuff through the web form
595 - // hardcoded feed info
596 - if (isset($GLOBALS['fwp_post']['hardcode_name'])) :
597 - $link->settings['hardcode name'] = $GLOBALS['fwp_post']['hardcode_name'];
598 - if (FeedWordPress::affirmative($link->settings, 'hardcode name')) :
599 - $alter[] = "link_name = '".$wpdb->escape($GLOBALS['fwp_post']['name'])."'";
600 - endif;
601 - endif;
602 - if (isset($GLOBALS['fwp_post']['hardcode_description'])) :
603 - $link->settings['hardcode description'] = $GLOBALS['fwp_post']['hardcode_description'];
604 - if (FeedWordPress::affirmative($link->settings, 'hardcode description')) :
605 - $alter[] = "link_description = '".$wpdb->escape($GLOBALS['fwp_post']['description'])."'";
606 - endif;
607 - endif;
608 - if (isset($GLOBALS['fwp_post']['hardcode_url'])) :
609 - $link->settings['hardcode url'] = $GLOBALS['fwp_post']['hardcode_url'];
610 - if (FeedWordPress::affirmative($link->settings, 'hardcode url')) :
611 - $alter[] = "link_url = '".$wpdb->escape($GLOBALS['fwp_post']['linkurl'])."'";
612 - endif;
613 - endif;
614 -
615 - // Update scheduling
616 - if (isset($GLOBALS['fwp_post']['update_schedule'])) :
617 - $link->settings['update/hold'] = $GLOBALS['fwp_post']['update_schedule'];
618 - endif;
619 -
620 - // Categories
621 - if (isset($GLOBALS['fwp_post']['post_category'])) :
622 - $link->settings['cats'] = array();
623 - foreach ($GLOBALS['fwp_post']['post_category'] as $cat_id) :
624 - $link->settings['cats'][] = '{#'.$cat_id.'}';
625 - endforeach;
626 - else :
627 - unset($link->settings['cats']);
628 - endif;
629 -
630 - // Tags
631 - if (isset($GLOBALS['fwp_post']['tags_input'])) :
632 - $link->settings['tags'] = array();
633 - foreach (explode(',', $GLOBALS['fwp_post']['tags_input']) as $tag) :
634 - $link->settings['tags'][] = trim($tag);
635 - endforeach;
636 - endif;
637 -
638 - // Post status, comment status, ping status
639 - foreach (array('post', 'comment', 'ping') as $what) :
640 - $sfield = "feed_{$what}_status";
641 - if (isset($GLOBALS['fwp_post'][$sfield])) :
642 - if ($GLOBALS['fwp_post'][$sfield]=='site-default') :
643 - unset($link->settings["{$what} status"]);
644 - else :
645 - $link->settings["{$what} status"] = $GLOBALS['fwp_post'][$sfield];
646 - endif;
647 - endif;
648 - endforeach;
649 -
650 - // Unfamiliar author, unfamiliar categories
651 - foreach (array("author", "category") as $what) :
652 - $sfield = "unfamiliar_{$what}";
653 - if (isset($GLOBALS['fwp_post'][$sfield])) :
654 - if ('site-default'==$GLOBALS['fwp_post'][$sfield]) :
655 - unset($link->settings["unfamiliar {$what}"]);
656 - elseif ('newuser'==$GLOBALS['fwp_post'][$sfield]) :
657 - $newuser_name = trim($GLOBALS['fwp_post']["{$sfield}_newuser"]);
658 - if (strlen($newuser_name) > 0) :
659 - $userdata = array();
660 - $userdata['ID'] = NULL;
661 -
662 - $userdata['user_login'] = sanitize_user($newuser_name);
663 - $userdata['user_login'] = apply_filters('pre_user_login', $userdata['user_login']);
664 -
665 - $userdata['user_nicename'] = sanitize_title($newuser_name);
666 - $userdata['user_nicename'] = apply_filters('pre_user_nicename', $userdata['user_nicename']);
667 -
668 - $userdata['display_name'] = $wpdb->escape($newuser_name);
669 -
670 - $newuser_id = wp_insert_user($userdata);
671 - if (is_numeric($newuser_id)) :
672 - $link->settings["unfamiliar {$what}"] = $newuser_id;
673 - else :
674 - // TODO: Add some error detection and reporting
675 - endif;
676 - else :
677 - // TODO: Add some error reporting
678 - endif;
679 - else :
680 - $link->settings["unfamiliar {$what}"] = $GLOBALS['fwp_post'][$sfield];
681 - endif;
682 - endif;
683 - endforeach;
684 -
685 - // Handle author mapping rules
686 - if (isset($GLOBALS['fwp_post']['author_rules_name']) and isset($GLOBALS['fwp_post']['author_rules_action'])) :
687 - unset($link->settings['map authors']);
688 - foreach ($GLOBALS['fwp_post']['author_rules_name'] as $key => $name) :
689 - // Normalize for case and whitespace
690 - $name = strtolower(trim($name));
691 - $author_action = strtolower(trim($GLOBALS['fwp_post']['author_rules_action'][$key]));
692 -
693 - if (strlen($name) > 0) :
694 - if ('newuser' == $author_action) :
695 - $newuser_name = trim($GLOBALS['fwp_post']['author_rules_newuser'][$key]);
696 - if (strlen($newuser_name) > 0) :
697 - $userdata = array();
698 - $userdata['ID'] = NULL;
699 -
700 - $userdata['user_login'] = sanitize_user($newuser_name);
701 - $userdata['user_login'] = apply_filters('pre_user_login', $userdata['user_login']);
702 -
703 - $userdata['user_nicename'] = sanitize_title($newuser_name);
704 - $userdata['user_nicename'] = apply_filters('pre_user_nicename', $userdata['user_nicename']);
705 -
706 - $userdata['display_name'] = $wpdb->escape($newuser_name);
707 -
708 - $newuser_id = wp_insert_user($userdata);
709 - if (is_numeric($newuser_id)) :
710 - $link->settings['map authors']['name'][$name] = $newuser_id;
711 - else :
712 - // TODO: Add some error detection and reporting
713 - endif;
714 - else :
715 - // TODO: Add some error reporting
716 - endif;
717 - else :
718 - $link->settings['map authors']['name'][$name] = $author_action;
719 - endif;
720 - endif;
721 - endforeach;
722 - endif;
723 -
724 - if (isset($GLOBALS['fwp_post']['add_author_rule_name']) and isset($GLOBALS['fwp_post']['add_author_rule_action'])) :
725 - $name = strtolower(trim($GLOBALS['fwp_post']['add_author_rule_name']));
726 - $author_action = strtolower(trim($GLOBALS['fwp_post']['add_author_rule_action']));
727 - if (strlen($name) > 0) :
728 - if ('newuser' == $author_action) :
729 - $newuser_name = trim($GLOBALS['fwp_post']['add_author_rule_newuser']);
730 - if (strlen($newuser_name) > 0) :
731 - $userdata = array();
732 - $userdata['ID'] = NULL;
733 -
734 - $userdata['user_login'] = sanitize_user($newuser_name);
735 - $userdata['user_login'] = apply_filters('pre_user_login', $userdata['user_login']);
736 -
737 - $userdata['user_nicename'] = sanitize_title($newuser_name);
738 - $userdata['user_nicename'] = apply_filters('pre_user_nicename', $userdata['user_nicename']);
739 -
740 - $userdata['display_name'] = $wpdb->escape($newuser_name);
741 -
742 - $newuser_id = wp_insert_user($userdata);
743 - if (is_numeric($newuser_id)) :
744 - $link->settings['map authors']['name'][$name] = $newuser_id;
745 - else :
746 - // TODO: Add some error detection and reporting
747 - endif;
748 - else :
749 - // TODO: Add some error reporting
750 - endif;
751 - else :
752 - $link->settings['map authors']['name'][$name] = $author_action;
753 - endif;
754 - endif;
755 - endif;
756 -
757 - if (isset($GLOBALS['fwp_post']['cat_split'])) :
758 - if (strlen(trim($GLOBALS['fwp_post']['cat_split'])) > 0) :
759 - $link->settings['cat_split'] = trim($GLOBALS['fwp_post']['cat_split']);
760 - else :
761 - unset($link->settings['cat_split']);
762 - endif;
763 - endif;
764 -
765 - $alter[] = "link_notes = '".$wpdb->escape($link->settings_to_notes())."'";
766 -
767 - $alter_set = implode(", ", $alter);
768 -
769 - // issue update query
770 - $result = $wpdb->query("
771 - UPDATE $wpdb->links
772 - SET $alter_set
773 - WHERE link_id='$link_id'
774 - ");
775 - $updated_link = true;
776 -
777 - // reload link information from DB
778 - if (function_exists('clean_bookmark_cache')) :
779 - clean_bookmark_cache($link_id);
780 - endif;
781 - $link =& new SyndicatedLink($link_id);
782 - else :
783 - $updated_link = false;
784 - endif;
785 -
786 - $db_link = $link->link;
787 - $link_url = wp_specialchars($db_link->link_url, 1);
788 - $link_name = wp_specialchars($db_link->link_name, 1);
789 - $link_description = wp_specialchars($db_link->link_description, 'both');
790 - $link_rss_uri = wp_specialchars($db_link->link_rss, 'both');
791 -
792 - $post_status_global = get_option('feedwordpress_syndicated_post_status');
793 - $comment_status_global = get_option('feedwordpress_syndicated_comment_status');
794 - $ping_status_global = get_option('feedwordpress_syndicated_ping_status');
795 -
796 - $status['post'] = array('publish' => '', 'private' => '', 'draft' => '', 'site-default' => '');
797 - if (SyndicatedPost::use_api('post_status_pending')) :
798 - $status['post']['pending'] = '';
799 - endif;
800 -
801 - $status['comment'] = array('open' => '', 'closed' => '', 'site-default' => '');
802 - $status['ping'] = array('open' => '', 'closed' => '', 'site-default' => '');
803 -
804 - foreach (array('post', 'comment', 'ping') as $what) :
805 - if (isset($link->settings["{$what} status"])) :
806 - $status[$what][$link->settings["{$what} status"]] = ' checked="checked"';
807 - else :
808 - $status[$what]['site-default'] = ' checked="checked"';
809 - endif;
810 - endforeach;
811 -
812 - $unfamiliar['author'] = array ('create' => '','default' => '','filter' => '');
813 - $unfamiliar['category'] = array ('create'=>'','tag' => '','default'=>'','filter'=>'');
814 -
815 - foreach (array('author', 'category') as $what) :
816 - if (is_string($link->settings["unfamiliar {$what}"]) and
817 - array_key_exists($link->settings["unfamiliar {$what}"], $unfamiliar[$what])) :
818 - $key = $link->settings["unfamiliar {$what}"];
819 - else:
820 - $key = 'site-default';
821 - endif;
822 - $unfamiliar[$what][$key] = ' checked="checked"';
823 - endforeach;
824 -
825 - if (is_array($link->settings['cats'])) : $cats = $link->settings['cats'];
826 - else : $cats = array();
827 - endif;
828 -
829 - $dogs = SyndicatedPost::category_ids($cats, /*unfamiliar=*/ NULL);
830 - else :
831 - die( __('Link not found.') );
832 - endif;
833 -
834 - ?>
835 -<script type="text/javascript">
836 - function flip_hardcode (item) {
837 - ed=document.getElementById('basics-'+item+'-edit');
838 - view=document.getElementById('basics-'+item+'-view');
839 -
840 - o = document.getElementById('basics-hardcode-'+item);
841 - if (o.value=='yes') { ed.style.display='inline'; view.style.display='none'; }
842 - else { ed.style.display='none'; view.style.display='inline'; }
843 - }
844 - function flip_newuser (item) {
845 - rollup=document.getElementById(item);
846 - newuser=document.getElementById(item+'-newuser');
847 - sitewide=document.getElementById(item+'-default');
848 - if (rollup) {
849 - if ('newuser'==rollup.value) {
850 - if (newuser) newuser.style.display='block';
851 - if (sitewide) sitewide.style.display='none';
852 - } else if ('site-default'==rollup.value) {
853 - if (newuser) newuser.style.display='none';
854 - if (sitewide) sitewide.style.display='block';
855 - } else {
856 - if (newuser) newuser.style.display='none';
857 - if (sitewide) sitewide.style.display='none';
858 - }
859 - }
860 - }
861 -</script>
862 -
863 -<?php if ($updated_link) : ?>
864 -<div class="updated"><p>Syndicated feed settings updated.</p></div>
865 -<?php endif; ?>
866 -
867 -<form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
868 -<div class="wrap">
869 -<input type="hidden" name="link_id" value="<?php echo $link_id; ?>" />
870 -<input type="hidden" name="action" value="linkedit" />
871 -<input type="hidden" name="save" value="link" />
872 -
873 -<h2>Edit a syndicated feed:</h2>
874 -<div id="poststuff">
875 -<?php fwp_linkedit_single_submit($status); ?>
876 -
877 -<div id="post-body">
878 -<?php fwp_option_box_opener('Feed Information', 'feedinformationdiv'); ?>
879 - <table class="editform" width="100%" cellspacing="2" cellpadding="5">
880 - <tr>
881 - <th scope="row" width="20%"><?php _e('Feed URI:') ?></th>
882 - <td width="60%"><a href="<?php echo wp_specialchars($link_rss_uri, 'both'); ?>"><?php echo $link_rss_uri; ?></a>
883 - (<a href="<?php echo FEEDVALIDATOR_URI; ?>?url=<?php echo urlencode($link_rss_uri); ?>"
884 - title="Check feed &lt;<?php echo wp_specialchars($link_rss_uri, 'both'); ?>&gt; for validity">validate</a>)
885 - </td>
886 - <td width="20%"><input type="submit" name="feedfinder" value="switch &rarr;" style="font-size:smaller" /></td>
887 - </tr>
888 - <tr>
889 - <th scope="row" width="20%"><?php _e('Link Name:') ?></th>
890 - <td width="60%"><input type="text" id="basics-name-edit" name="name"
891 - value="<?php echo $link_name; ?>" style="width: 95%" />
892 - <span id="basics-name-view"><strong><?php echo $link_name; ?></strong></span>
893 - </td>
894 - <td>
895 - <select id="basics-hardcode-name" onchange="flip_hardcode('name')" name="hardcode_name">
896 - <option value="no" <?php echo $link->hardcode('name')?'':'selected="selected"'; ?>>update automatically</option>
897 - <option value="yes" <?php echo $link->hardcode('name')?'selected="selected"':''; ?>>edit manually</option>
898 - </select>
899 - </td>
900 - </tr>
901 - <tr>
902 - <th scope="row" width="20%"><?php _e('Short description:') ?></th>
903 - <td width="60%">
904 - <input id="basics-description-edit" type="text" name="description" value="<?php echo $link_description; ?>" style="width: 95%" />
905 - <span id="basics-description-view"><strong><?php echo $link_description; ?></strong></span>
906 - </td>
907 - <td>
908 - <select id="basics-hardcode-description" onchange="flip_hardcode('description')"
909 - name="hardcode_description">
910 - <option value="no" <?php echo $link->hardcode('description')?'':'selected="selected"'; ?>>update automatically</option>
911 - <option value="yes" <?php echo $link->hardcode('description')?'selected="selected"':''; ?>>edit manually</option>
912 - </select></td>
913 - </tr>
914 - <tr>
915 - <th width="20%" scope="row"><?php _e('Homepage:') ?></th>
916 - <td width="60%">
917 - <input id="basics-url-edit" type="text" name="linkurl" value="<?php echo $link_url; ?>" style="width: 95%;" />
918 - <a id="basics-url-view" href="<?php echo $link_url; ?>"><?php echo $link_url; ?></a></td>
919 - <td>
920 - <select id="basics-hardcode-url" onchange="flip_hardcode('url')" name="hardcode_url">
921 - <option value="no"<?php echo $link->hardcode('url')?'':' selected="selected"'; ?>>update automatically</option>
922 - <option value="yes"<?php echo $link->hardcode('url')?' selected="selected"':''; ?>>edit manually</option>
923 - </select></td></tr>
924 -
925 - <tr>
926 - <th width="20%"><?php _e('Last update') ?>:</th>
927 - <td colspan="2"><?php
928 - if (isset($link->settings['update/last'])) :
929 - echo fwp_time_elapsed($link->settings['update/last'])." ";
930 - else :
931 - echo " none yet";
932 - endif;
933 - ?></td></tr>
934 - <tr><th width="20%">Next update:</th>
935 - <td colspan="2"><?php
936 - $holdem = (isset($link->settings['update/hold']) ? $link->settings['update/hold'] : 'scheduled');
937 - ?>
938 - <select name="update_schedule">
939 - <option value="scheduled"<?php echo ($holdem=='scheduled')?' selected="selected"':''; ?>>update on schedule <?php
940 - echo " (";
941 - if (isset($link->settings['update/ttl']) and is_numeric($link->settings['update/ttl'])) :
942 - if (isset($link->settings['update/timed']) and $link->settings['update/timed']=='automatically') :
943 - echo 'next: ';
944 - $next = $link->settings['update/last'] + ((int) $link->settings['update/ttl'] * 60);
945 - if (strftime('%x', time()) != strftime('%x', $next)) :
946 - echo strftime('%x', $next)." ";
947 - endif;
948 - echo strftime('%X', $link->settings['update/last']+((int) $link->settings['update/ttl']*60));
949 - else :
950 - echo "every ".$link->settings['update/ttl']." minute".(($link->settings['update/ttl']!=1)?"s":"");
951 - endif;
952 - else:
953 - echo "next scheduled update";
954 - endif;
955 - echo ")";
956 - ?></option>
957 - <option value="next"<?php echo ($holdem=='next')?' selected="selected"':''; ?>>update ASAP</option>
958 - <option value="ping"<?php echo ($holdem=='ping')?' selected="selected"':''; ?>>update only when pinged</option>
959 - </select></tr>
960 - </table>
961 -<?php fwp_option_box_closer(); ?>
962 -
963 -<script type="text/javascript">
964 -flip_hardcode('name');
965 -flip_hardcode('description');
966 -flip_hardcode('url');
967 -</script>
968 -
969 -<?php fwp_linkedit_periodic_submit(); ?>
970 -
971 -<?php
972 -if (!(isset($wp_db_version) and $wp_db_version >= FWP_SCHEMA_25)) :
973 - fwp_option_box_opener('Syndicated Posts', 'syndicatedpostsdiv', 'postbox');
974 -?>
975 -<table class="editform" width="75%" cellspacing="2" cellpadding="5">
976 -<tr><th width="27%" scope="row" style="vertical-align:top">Publication:</th>
977 -<td width="73%" style="vertical-align:top"><ul style="margin:0; list-style:none">
978 -<li><label><input type="radio" name="feed_post_status" value="site-default"
979 -<?php echo $status['post']['site-default']; ?> /> Use site-wide setting from <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/syndication-options.php">Syndication Options</a>
980 -(currently: <strong><?php echo ($post_status_global ? $post_status_global : 'publish'); ?></strong>)</label></li>
981 -<li><label><input type="radio" name="feed_post_status" value="publish"
982 -<?php echo $status['post']['publish']; ?> /> Publish posts from this feed immediately</label></li>
983 -
984 -<?php if (SyndicatedPost::use_api('post_status_pending')) : ?>
985 -<li><label><input type="radio" name="feed_post_status" value="pending"
986 -<?php echo $status['post']['pending']; ?>/> Hold posts from this feed for review; mark as Pending</label></li>
987 -<?php endif; ?>
988 -
989 -<li><label><input type="radio" name="feed_post_status" value="draft"
990 -<?php echo $status['post']['draft']; ?> /> Save posts from this feed as drafts</label></li>
991 -<li><label><input type="radio" name="feed_post_status" value="private"
992 -<?php echo $status['post']['private']; ?> /> Save posts from this feed as private posts</label></li>
993 -</ul></td>
994 -</tr>
995 -</table>
996 -<?php
997 - fwp_option_box_closer();
998 - fwp_linkedit_periodic_submit();
999 -endif;
1000 -
1001 - fwp_option_box_opener(__('Categories'), 'categorydiv', 'postbox');
1002 - fwp_category_box($dogs, 'all syndicated posts from this feed');
1003 -?>
1004 -<table>
1005 -<tr>
1006 -<th width="20%" scope="row" style="vertical-align:top">Unfamiliar categories:</th>
1007 -<td width="80%"><p>When one of the categories on a syndicated post is a category that FeedWordPress has not encountered before ...</p>
1008 -
1009 -<ul style="margin: 0; list-style:none">
1010 -<li><label><input type="radio" name="unfamiliar_category" value="site-default"<?php echo $unfamiliar['category']['site-default']; ?> /> use the site-wide setting from <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/syndication-options.php">Syndication Options</a>
1011 -(currently <strong><?php echo FeedWordPress::on_unfamiliar('category'); ?></strong>)</label></li>
1012 -<li><label><input type="radio" name="unfamiliar_category" value="create"<?php echo $unfamiliar['category']['create']; ?> /> create a new category</label></li>
1013 -<?php if (fwp_test_wp_version(FWP_SCHEMA_23)) : ?>
1014 -<li><label><input type="radio" name="unfamiliar_category" value="tag"<?php echo $unfamiliar['category']['tag']; ?>/> create a new tag</label></li>
1015 -<?php endif; ?>
1016 -<li><label><input type="radio" name="unfamiliar_category" value="default"<?php echo $unfamiliar['category']['default']; ?> /> don't create new categories<?php if (fwp_test_wp_version(FWP_SCHEMA_23)) : ?> or tags<?php endif; ?></label></li>
1017 -<li><label><input type="radio" name="unfamiliar_category" value="filter"<?php echo $unfamiliar['category']['filter']; ?> /> don't create new categories<?php if (fwp_test_wp_version(FWP_SCHEMA_23)) : ?> or tags<?php endif; ?> and don't syndicate posts unless they match at least one familiar category</label></li>
1018 -</ul></td>
1019 -</tr>
1020 -
1021 -<tr>
1022 -<th width="20%" scope="row" style="vertical-align:top">Multiple categories:</th>
1023 -<td width="80%">
1024 -<input type="text" size="20" id="cat_split" name="cat_split" value="<?php if (isset($link->settings['cat_split'])) : echo htmlspecialchars($link->settings['cat_split']); endif; ?>" /><br/>
1025 -Enter a <a href="http://us.php.net/manual/en/reference.pcre.pattern.syntax.php">Perl-compatible regular expression</a> here if the feed provides multiple
1026 -categories in a single category element. The regular expression should match
1027 -the characters used to separate one category from the next. If the feed uses
1028 -spaces (like <a href="http://del.icio.us/">del.icio.us</a>), use the pattern "\s".
1029 -If the feed does not provide multiple categories in a single element, leave this
1030 -blank.</td>
1031 -</tr>
1032 -</table>
1033 -<?php
1034 - fwp_option_box_closer();
1035 - fwp_linkedit_periodic_submit();
1036 -
1037 -if (isset($wp_db_version) and $wp_db_version >= FWP_SCHEMA_25) :
1038 - fwp_tags_box($link->settings['tags']);
1039 - fwp_linkedit_periodic_submit();
1040 -endif; ?>
1041 -
1042 -<?php fwp_option_box_opener('Syndicated Authors', 'authordiv', 'postbox'); ?>
1043 -<?php $authorlist = fwp_author_list(); ?>
1044 -<table>
1045 -<tr><th colspan="3" style="text-align: left; padding-top: 1.0em; border-bottom: 1px dotted black;">For posts by authors that haven't been syndicated before:</th></tr>
1046 -<tr>
1047 - <th style="text-align: left">Posts by new authors</th>
1048 - <td>
1049 - <select id="unfamiliar-author" name="unfamiliar_author" onchange="flip_newuser('unfamiliar-author');">
1050 - <option value="site-default"<?php if (!isset($link->settings['unfamiliar author'])) : ?>selected="selected"<?php endif; ?>>are handled using site-wide settings</option>
1051 - <option value="create"<?php if ('create'==$link->settings['unfamiliar author']) : ?>selected="selected"<?php endif; ?>>create a new author account</option>
1052 - <?php foreach ($authorlist as $author_id => $author_name) : ?>
1053 - <option value="<?php echo $author_id; ?>"<?php if ($author_id==$link->settings['unfamiliar author']) : ?>selected="selected"<?php endif; ?>>are assigned to <?php echo $author_name; ?></option>
1054 - <?php endforeach; ?>
1055 - <option value="newuser">will be assigned to a new user...</option>
1056 - <option value="filter"<?php if ('filter'==$link->settings['unfamiliar author']) : ?>selected="selected"<?php endif; ?>>get filtered out</option>
1057 - </select>
1058 - </td>
1059 - <td>
1060 - <div id="unfamiliar-author-default">Site-wide settings can be set in <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/syndication-options.php">Syndication Options</a></div>
1061 - <div id="unfamiliar-author-newuser">named <input type="text" name="unfamiliar_author_newuser" value="" /></div>
1062 - </td>
1063 -</tr>
1064 -
1065 -<tr><th colspan="3" style="text-align: left; padding-top: 1.0em; border-bottom: 1px dotted black;">For posts by specific authors. Blank out a name to delete the rule.</th></tr>
1066 -
1067 -<?php if (isset($link->settings['map authors'])) : $i=0; foreach ($link->settings['map authors'] as $author_rules) : foreach ($author_rules as $author_name => $author_action) : $i++; ?>
1068 -<tr>
1069 - <th style="text-align: left">Posts by <input type="text" name="author_rules_name[]" value="<?php echo htmlspecialchars($author_name); ?>" /></th>
1070 - <td>
1071 - <select id="author-rules-<?php echo $i; ?>" name="author_rules_action[]" onchange="flip_newuser('author-rules-<?php echo $i; ?>');">
1072 - <?php foreach ($authorlist as $local_author_id => $local_author_name) : ?>
1073 - <option value="<?php echo $local_author_id; ?>"<?php if ($local_author_id==$author_action) : echo ' selected="selected"'; endif; ?>>are assigned to <?php echo $local_author_name; ?></option>
1074 - <?php endforeach; ?>
1075 - <option value="newuser">will be assigned to a new user...</option>
1076 - <option value="filter"<?php if ('filter'==$author_action) : echo ' selected="selected"'; endif; ?>>get filtered out</option>
1077 - </select>
1078 - </td>
1079 - <td><div id="author-rules-<?php echo $i; ?>-newuser">named <input type="text" name="author_rules_newuser[]" value="" /></div></td>
1080 -</tr>
1081 -<?php endforeach; endforeach; endif; ?>
1082 -
1083 -<tr><th colspan="3" style="text-align: left; padding-top: 1.0em; border-bottom: 1px dotted black;">Fill in to set up a new rule:</th></tr>
1084 -
1085 -<tr>
1086 - <th style="text-align: left">Posts by <input type="text" name="add_author_rule_name" /></th>
1087 - <td>
1088 - <select id="add-author-rule" name="add_author_rule_action" onchange="flip_newuser('add-author-rule');">
1089 - <?php foreach ($authorlist as $author_id => $author_name) : ?>
1090 - <option value="<?php echo $author_id; ?>">are assigned to <?php echo $author_name; ?></option>
1091 - <?php endforeach; ?>
1092 - <option value="newuser">will be assigned to a new user...</option>
1093 - <option value="filter">get filtered out</option>
1094 - </select>
1095 - </td>
1096 - <td><div id="add-author-rule-newuser">named <input type="text" name="add_author_rule_newuser" value="" /></div></td>
1097 -</tr>
1098 -
1099 -</table>
1100 -<?php fwp_option_box_closer(); ?>
1101 -
1102 -<script>
1103 - flip_newuser('unfamiliar-author');
1104 -<?php for ($j=1; $j<=$i; $j++) : ?>
1105 - flip_newuser('author-rules-<?php echo $j; ?>');
1106 -<?php endfor; ?>
1107 - flip_newuser('add-author-rule');
1108 -</script>
1109 -
1110 -<?php
1111 - fwp_linkedit_periodic_submit();
1112 - fwp_option_box_opener('Comments & Pings', 'commentstatusdiv', 'postbox');
1113 -?>
1114 -<table class="editform" width="75%" cellspacing="2" cellpadding="5">
1115 -<tr><th width="27%" scope="row" style="vertical-align:top"><?php print __('Comments'); ?>:</th>
1116 -<td width="73%"><ul style="margin:0; list-style:none">
1117 -<li><label><input type="radio" name="feed_comment_status" value="site-default"
1118 -<?php echo $status['comment']['site-default']; ?> /> Use site-wide setting from <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/syndication-options.php">Syndication Options</a>
1119 -(currently: <strong><?php echo ($comment_status_global ? $comment_status_global : 'closed'); ?>)</strong></label></li>
1120 -<li><label><input type="radio" name="feed_comment_status" value="open"
1121 -<?php echo $status['comment']['open']; ?> /> Allow comments on syndicated posts from this feed</label></li>
1122 -<li><label><input type="radio" name="feed_comment_status" value="closed"
1123 -<?php echo $status['comment']['closed']; ?> /> Don't allow comments on syndicated posts from this feed</label></li>
1124 -</ul></td></tr>
1125 -
1126 -<tr><th width="27%" scope="row" style="vertical-align:top"><?php print __('Pings'); ?>:</th>
1127 -<td width="73%"><ul style="margin:0; list-style:none">
1128 -<li><label><input type="radio" name="feed_ping_status" value="site-default"
1129 -<?php echo $status['ping']['site-default']; ?> /> Use site-wide setting from <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/syndication-options.php">Syndication Options</a>
1130 -(currently: <strong><?php echo ($ping_status_global ? $ping_status_global : 'closed'); ?>)</strong></label></li>
1131 -<li><label><input type="radio" name="feed_ping_status" value="open"
1132 -<?php echo $status['ping']['open']; ?> /> Accept pings on syndicated posts from this feed</label></li>
1133 -<li><label><input type="radio" name="feed_ping_status" value="closed"
1134 -<?php echo $status['ping']['closed']; ?> /> Don't accept pings on syndicated posts from this feed</label></li>
1135 -</ul></td></tr>
1136 -
1137 -</table>
1138 -<?php fwp_option_box_closer(); ?>
1139 -<?php fwp_linkedit_periodic_submit(); ?>
1140 -
1141 -<?php fwp_option_box_opener('Custom Settings (for use in templates)', 'postcustom', 'postbox'); ?>
1142 -<div id="postcustomstuff">
1143 -<table id="meta-list" cellpadding="3">
1144 - <tr>
1145 - <th>Key</th>
1146 - <th>Value</th>
1147 - <th>Action</th>
1148 - </tr>
1149 -
1150 -<?php
1151 - $i = 0;
1152 - foreach ($link->settings as $key => $value) :
1153 - if (!preg_match("\007^((".implode(')|(', $special_settings)."))$\007i", $key)) :
1154 -?>
1155 - <tr style="vertical-align:top">
1156 - <th width="30%" scope="row"><input type="hidden" name="notes[<?php echo $i; ?>][key0]" value="<?php echo wp_specialchars($key, 'both'); ?>" />
1157 - <input id="notes-<?php echo $i; ?>-key" name="notes[<?php echo $i; ?>][key1]" value="<?php echo wp_specialchars($key, 'both'); ?>" /></th>
1158 - <td width="60%"><textarea rows="2" cols="40" id="notes-<?php echo $i; ?>-value" name="notes[<?php echo $i; ?>][value]"><?php echo wp_specialchars($value, 'both'); ?></textarea></td>
1159 - <td width="10%"><select name="notes[<?php echo $i; ?>][action]">
1160 - <option value="update">save changes</option>
1161 - <option value="delete">delete this setting</option>
1162 - </select></td>
1163 - </tr>
1164 -<?php
1165 - $i++;
1166 - endif;
1167 - endforeach;
1168 -?>
1169 - <tr>
1170 - <th scope="row"><input type="text" size="10" name="notes[<?php echo $i; ?>][key1]" value="" /></th>
1171 - <td><textarea name="notes[<?php echo $i; ?>][value]" rows="2" cols="40"></textarea></td>
1172 - <td><em>add new setting...</em><input type="hidden" name="notes[<?php echo $i; ?>][action]" value="update" /></td>
1173 - </tr>
1174 -</table>
1175 -<?php fwp_option_box_closer(); ?>
1176 -
1177 -<?php fwp_linkedit_periodic_submit(); ?>
1178 -<?php fwp_linkedit_single_submit_closer(); ?>
1179 -</div> <!-- id="post-body" -->
1180 -</div> <!-- id="poststuff" -->
1181 -</div>
1182 - <?php
1183 - endif;
1184 - return false; // Don't continue
1185 -}
1186 -
1187 -function fwp_multidelete_page () {
1188 - global $wpdb;
1189 -
1190 - check_admin_referer(); // Make sure the referers are kosher
1191 -
1192 - $link_ids = (isset($_REQUEST['link_ids']) ? $_REQUEST['link_ids'] : array());
1193 - if (isset($_REQUEST['link_id'])) : array_push($link_ids, $_REQUEST['link_id']); endif;
1194 -
1195 - if (!current_user_can('manage_links')):
1196 - die (__("Cheatin' uh ?"));
1197 - elseif (isset($GLOBALS['fwp_post']['confirm']) and $GLOBALS['fwp_post']['confirm']=='Delete'):
1198 - foreach ($GLOBALS['fwp_post']['link_action'] as $link_id => $what) :
1199 - $do_it[$what][] = $link_id;
1200 - endforeach;
1201 -
1202 - $alter = array();
1203 - if (count($do_it['hide']) > 0) :
1204 - $hidem = "(".implode(', ', $do_it['hide']).")";
1205 - $alter[] = "
1206 - UPDATE $wpdb->links
1207 - SET link_visible = 'N'
1208 - WHERE link_id IN {$hidem}
1209 - ";
1210 - endif;
1211 -
1212 - if (count($do_it['nuke']) > 0) :
1213 - $nukem = "(".implode(', ', $do_it['nuke']).")";
1214 -
1215 - // Make a list of the items syndicated from this feed...
1216 - $post_ids = $wpdb->get_col("
1217 - SELECT post_id FROM $wpdb->postmeta
1218 - WHERE meta_key = 'syndication_feed_id'
1219 - AND meta_value IN {$nukem}
1220 - ");
1221 -
1222 - // ... and kill them all
1223 - if (count($post_ids) > 0) :
1224 - foreach ($post_ids as $post_id) :
1225 - wp_delete_post($post_id);
1226 - endforeach;
1227 - endif;
1228 -
1229 - $alter[] = "
1230 - DELETE FROM $wpdb->links
1231 - WHERE link_id IN {$nukem}
1232 - ";
1233 - endif;
1234 -
1235 - if (count($do_it['delete']) > 0) :
1236 - $deletem = "(".implode(', ', $do_it['delete']).")";
1237 -
1238 - // Make the items syndicated from this feed appear to be locally-authored
1239 - $alter[] = "
1240 - DELETE FROM $wpdb->postmeta
1241 - WHERE meta_key = 'syndication_feed_id'
1242 - AND meta_value IN {$deletem}
1243 - ";
1244 -
1245 - // ... and delete the links themselves.
1246 - $alter[] = "
1247 - DELETE FROM $wpdb->links
1248 - WHERE link_id IN {$deletem}
1249 - ";
1250 - endif;
1251 -
1252 - $errs = array(); $success = array ();
1253 - foreach ($alter as $sql) :
1254 - $result = $wpdb->query($sql);
1255 - if (!$result):
1256 - $errs[] = mysql_error();
1257 - endif;
1258 - endforeach;
1259 -
1260 - if (count($alter) > 0) :
1261 - echo "<div class=\"updated\">\n";
1262 - if (count($errs) > 0) :
1263 - echo "There were some problems processing your ";
1264 - echo "unsubscribe request. [SQL: ".implode('; ', $errs)."]";
1265 - else :
1266 - echo "Your unsubscribe request(s) have been processed.";
1267 - endif;
1268 - echo "</div>\n";
1269 - endif;
1270 -
1271 - return true; // Continue on to Syndicated Sites listing
1272 - else :
1273 - $targets = $wpdb->get_results("
1274 - SELECT * FROM $wpdb->links
1275 - WHERE link_id IN (".implode(",",$link_ids).")
1276 - ");
1277 -?>
1278 -<form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
1279 -<div class="wrap">
1280 -<input type="hidden" name="action" value="Unsubscribe" />
1281 -<input type="hidden" name="confirm" value="Delete" />
1282 -
1283 -<h2>Unsubscribe from Syndicated Links:</h2>
1284 -<?php foreach ($targets as $link) :
1285 - $link_url = wp_specialchars($link->link_url, 1);
1286 - $link_name = wp_specialchars($link->link_name, 1);
1287 - $link_description = wp_specialchars($link->link_description, 'both');
1288 - $link_rss = wp_specialchars($link->link_rss, 'both');
1289 -?>
1290 -<fieldset>
1291 -<legend><?php echo $link_name; ?></legend>
1292 -<table class="editform" width="100%" cellspacing="2" cellpadding="5">
1293 -<tr><th scope="row" width="20%"><?php _e('Feed URI:') ?></th>
1294 -<td width="80%"><a href="<?php echo $link_rss; ?>"><?php echo $link_rss; ?></a></td></tr>
1295 -<tr><th scope="row" width="20%"><?php _e('Short description:') ?></th>
1296 -<td width="80%"><?php echo $link_description; ?></span></td></tr>
1297 -<tr><th width="20%" scope="row"><?php _e('Homepage:') ?></th>
1298 -<td width="80%"><a href="<?php echo $link_url; ?>"><?php echo $link_url; ?></a></td></tr>
1299 -<tr style="vertical-align:top"><th width="20%" scope="row">Subscription <?php _e('Options') ?>:</th>
1300 -<td width="80%"><ul style="margin:0; padding: 0; list-style: none">
1301 -<li><input type="radio" id="hide-<?php echo $link->link_id; ?>"
1302 -name="link_action[<?php echo $link->link_id; ?>]" value="hide" />
1303 -<label for="hide-<?php echo $link->link_id; ?>">Turn off the subscription for this
1304 -syndicated link<br/><span style="font-size:smaller">(Keep the feed information
1305 -and all the posts from this feed in the database, but don't syndicate any
1306 -new posts from the feed.)</span></label></li>
1307 -<li><input type="radio" id="nuke-<?php echo $link->link_id; ?>"
1308 -name="link_action[<?php echo $link->link_id; ?>]" value="nuke" />
1309 -<label for="nuke-<?php echo $link->link_id; ?>">Delete this syndicated link and all the
1310 -posts that were syndicated from it</label></li>
1311 -<li><input type="radio" id="delete-<?php echo $link->link_id; ?>"
1312 -name="link_action[<?php echo $link->link_id; ?>]" value="delete" />
1313 -<label for="delete-<?php echo $link->link_id; ?>">Delete this syndicated link, but
1314 -<em>keep</em> posts that were syndicated from it (as if they were authored
1315 -locally).</label></li>
1316 -<li><input type="radio" id="nothing-<?php echo $link->link_id; ?>"
1317 -name="link_action[<?php echo $link->link_id; ?>]" value="nothing" />
1318 -<label for="nothing-<?php echo $link->link_id; ?>">Keep this feed as it is. I changed
1319 -my mind.</label></li>
1320 -</ul>
1321 -</table>
1322 -</fieldset>
1323 -<?php endforeach; ?>
1324 -
1325 -<div class="submit">
1326 -<input class="delete" type="submit" name="submit" value="<?php _e('Unsubscribe from selected feeds &raquo;') ?>" />
1327 -</div>
1328 -</div>
1329 -<?php
1330 - return false; // Don't continue on to Syndicated Sites listing
1331 - endif;
1332 -}
1333 -
1334 - fwp_syndication_manage_page();
4 + $syndicationPage = new FeedWordPressSyndicationPage(__FILE__);
5 + $syndicationPage->display();
1335 6