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