PluginProbe
FeedWordPress / 2010.0528
FeedWordPress v2010.0528
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 +306 -672 2009.06182010.0528 View file →
@@ -1,50 +1,7 @@
1 1 <?php
2 2 require_once(dirname(__FILE__) . '/admin-ui.php');
3 -require_once(dirname(__FILE__) . '/magpiemocklink.class.php');
4 -require_once(dirname(__FILE__) . '/feedfinder.class.php');
5 3
6 -$FeedWordPressHTTPStatusMessages = array (
7 - 200 => 'OK. FeedWordPress had no problems retrieving the content at this URL but the content does not seem to be a feed, and does not seem to include links to any feeds.',
8 - 201 => 'Created',
9 - 202 => 'Accepted',
10 - 203 => 'Non-Authoritative information',
11 - 204 => 'No Content',
12 - 205 => 'Reset Content',
13 - 206 => 'Partial Content',
14 - 300 => 'Multiple Choices',
15 - 301 => 'Moved Permanently',
16 - 302 => 'Found',
17 - 303 => 'See Other',
18 - 304 => 'Not Modified',
19 - 305 => 'Use Proxy',
20 - 307 => 'Temporary Redirect',
21 - 400 => 'Bad Request',
22 - 401 => 'Unauthorized. This URL probably needs a username and password for you to access it.',
23 - 402 => 'Payment Required',
24 - 403 => 'Forbidden. The URL is not made available for the machine that FeedWordPress is running on.',
25 - 404 => 'Not Found. There is nothing at this URL. Have you checked the address for typos?',
26 - 405 => 'Method Not Allowed',
27 - 406 => 'Not Acceptable',
28 - 407 => 'Proxy Authentication Required',
29 - 408 => 'Request Timeout',
30 - 409 => 'Conflict',
31 - 410 => 'Gone. This URL is no longer available on this server and no forwarding address is known.',
32 - 411 => 'Length Required',
33 - 412 => 'Precondition Failed',
34 - 413 => 'Request Entity Too Large',
35 - 414 => 'Request URI Too Long',
36 - 415 => 'Unsupported Media Type',
37 - 416 => 'Requested Range Not Satisfiable',
38 - 417 => 'Expectation Failed',
39 - 500 => 'Internal Server Error. Something unexpected went wrong with the configuration of the server that hosts this URL. You might try again later to see if this issue has been resolved.',
40 - 501 => 'Not Implemented',
41 - 502 => 'Bad Gateway',
42 - 503 => 'Service Unavailable. The server is currently unable to handle the request due to a temporary overloading or maintenance of the server that hosts this URL. This is probably a temporary condition and you should try again later to see if the issue has been resolved.',
43 - 504 => 'Gateway Timeout',
44 - 505 => 'HTTP Version Not Supported',
45 -);
46 -
47 4 ################################################################################
48 5 ## ADMIN MENU ADD-ONS: implement Dashboard management pages ####################
49 6 ################################################################################
50 7
@@ -50,15 +7,201 @@
50 7
51 8 if (fwp_test_wp_version(0, FWP_SCHEMA_25)) :
52 9 define('FWP_UPDATE_CHECKED', 'Update Checked Links');
53 10 define('FWP_UNSUB_CHECKED', 'Unsubscribe from Checked Links');
54 - define('FWP_SYNDICATE_NEW', 'Syndicate »');
11 + define('FWP_SYNDICATE_NEW', 'Syndicate ...');
55 12 else :
56 13 define('FWP_UPDATE_CHECKED', 'Update Checked');
57 14 define('FWP_UNSUB_CHECKED', 'Unsubscribe');
58 - define('FWP_SYNDICATE_NEW', 'Syndicate »');
15 + define('FWP_SYNDICATE_NEW', 'Syndicate ...');
59 16 endif;
60 17
18 +class FeedWordPressSyndicationPage extends FeedWordPressAdminPage {
19 + function FeedWordPressSyndicationPage () {
20 + FeedWordPressAdminPage::FeedWordPressAdminPage('feedwordpresssyndication', /*link=*/ NULL);
21 +
22 + // No over-arching form element
23 + $this->dispatch = NULL;
24 + $this->filename = __FILE__;
25 + } /* FeedWordPressSyndicationPage constructor */
26 +
27 + function has_link () { return false; }
28 +
29 + function display () {
30 + global $wpdb;
31 +
32 + if (FeedWordPress::needs_upgrade()) :
33 + fwp_upgrade_page();
34 + return;
35 + endif;
36 +
37 + ?>
38 + <?php $cont = true;
39 + if (isset($_REQUEST['action'])):
40 + if ($_REQUEST['action'] == 'feedfinder' or $_REQUEST['action']==FWP_SYNDICATE_NEW) : $cont = fwp_feedfinder_page();
41 + elseif ($_REQUEST['action'] == 'switchfeed') : $cont = fwp_switchfeed_page();
42 + elseif ($_REQUEST['action'] == FWP_UNSUB_CHECKED or $_REQUEST['action'] == 'Unsubscribe') : $cont = fwp_multidelete_page();
43 + endif;
44 + endif;
45 +
46 + if ($cont):
47 + ?>
48 + <style type="text/css">
49 + .heads-up {
50 + background-color: #d0d0d0;
51 + color: black;
52 + padding: 1.0em;
53 + margin: 0.5em 4.0em !important;
54 + }
55 + .update-form.with-donation {
56 + margin-right: 50%;
57 + min-height: 255px;
58 + }
59 + .donation-form, .donation-thanks {
60 + background-color: #ffffcc;
61 + text-align: left;
62 + padding: 0.5em 0.5em;
63 + border-left: thin dashed #777777;
64 + font-size: 70%;
65 + position: absolute;
66 + top: 0; bottom: 0; right: 0; left: auto;
67 + width: 50%;
68 + }
69 + .donation-thanks {
70 + background-color: #ccffcc;
71 + }
72 + .donation-thanks .signature {
73 + text-align: right;
74 + font-style: italic;
75 + }
76 + .donation-form h4, .donation-thanks h4 {
77 + font-size: 10px;
78 + text-align: center;
79 + border-bottom: 1px solid #777777;
80 + margin: 0px;
81 + }
82 + .donation-form .donate {
83 + text-align: center;
84 + }
85 + .donation-form .sod-off {
86 + padding-top: 0.5em;
87 + margin-top: 0.5em;
88 + border-top: thin solid #777777;
89 + }
90 + </style>
91 + <?php
92 + $links = FeedWordPress::syndicated_links();
93 + $this->open_sheet('Syndicated Sites');
94 + ?>
95 + <div id="post-body">
96 + <?php
97 + if ($links) :
98 + fwp_add_meta_box(
99 + /*id=*/ 'feedwordpress_update_box',
100 + /*title=*/ __('Update feeds now'),
101 + /*callback=*/ 'fwp_syndication_manage_page_update_box',
102 + /*page=*/ $this->meta_box_context(),
103 + /*context =*/ $this->meta_box_context()
104 + );
105 + endif;
106 + fwp_add_meta_box(
107 + /*id=*/ 'feedwordpress_feeds_box',
108 + /*title=*/ __('Syndicated sources'),
109 + /*callback=*/ 'fwp_syndication_manage_page_links_box',
110 + /*page=*/ $this->meta_box_context(),
111 + /*context =*/ $this->meta_box_context()
112 + );
113 + if (FeedWordPressCompatibility::test_version(0, FWP_SCHEMA_25)) :
114 + fwp_add_meta_box(
115 + /*id=*/ 'feedwordpress_add_feed_box',
116 + /*title=*/ 'Add a new syndicated source',
117 + /*callback=*/ 'fwp_syndication_manage_page_add_feed_box',
118 + /*page=*/ $this->meta_box_context(),
119 + /*context=*/ $this->meta_box_context()
120 + );
121 + endif;
122 +
123 + do_action('feedwordpress_admin_page_syndication_meta_boxes', $this);
124 + ?>
125 + <div class="metabox-holder">
126 + <?php
127 + fwp_do_meta_boxes($this->meta_box_context(), $this->meta_box_context(), $this);
128 + ?>
129 + </div> <!-- class="metabox-holder" -->
130 + </div> <!-- id="post-body" -->
131 +
132 + <?php $this->close_sheet(/*dispatch=*/ NULL); ?>
133 +
134 + <div style="display: none">
135 + <div id="tags-input"></div> <!-- avoid JS error from WP 2.5 bug -->
136 + </div>
137 + <?php
138 + endif;
139 + } /* FeedWordPressSyndicationPage::display () */
140 +
141 + function bleg_thanks ($page, $box = NULL) {
142 + ?>
143 + <div class="donation-thanks">
144 + <h4>Thank you!</h4>
145 + <p><strong>Thank you</strong> for your contribution to <a href="http://feedwordpress.radgeek.com/">FeedWordPress</a> development.
146 + Your generous gifts make ongoing support and development for
147 + FeedWordPress possible.</p>
148 + <p>If you have any questions about FeedWordPress, or if there
149 + is anything I can do to help make FeedWordPress more useful for
150 + you, please <a href="http://feedwordpress.radgeek.com/contact">contact me</a>
151 + and let me know what you're thinking about.</p>
152 + <p class="signature">&#8212;<a href="http://radgeek.com/">Charles Johnson</a>, Developer, <a href="http://feedwordpress.radgeek.com/">FeedWordPress</a>.</p>
153 + </div>
154 + <?php
155 + } /* FeedWordPressSyndicationPage::bleg_thanks () */
156 +
157 + function bleg_box ($page, $box = NULL) {
158 + ?>
159 +<div class="donation-form">
160 +<h4>Keep FeedWordPress improving</h4>
161 +<form action="https://www.paypal.com/cgi-bin/webscr" accept-charset="UTF-8" method="post"><div>
162 +<p><a href="http://feedwordpress.radgeek.com/">FeedWordPress</a> makes syndication
163 +simple and empowers you to stream content from all over the web into your
164 +WordPress hub. That's got to be worth a few lattes. If you're finding FWP useful,
165 +<a href="http://feedwordpress.radgeek.com/donation/">a modest gift</a>
166 +is the best way to support steady progress on development, enhancements,
167 +support, and documentation.</p>
168 +<div class="donate">
169 +<input type="hidden" name="business" value="commerce@radgeek.com" />
170 +<input type="hidden" name="cmd" value="_xclick" />
171 +<input type="hidden" name="item_name" value="FeedWordPress donation" />
172 +<input type="hidden" name="no_shipping" value="1" />
173 +<input type="hidden" name="return" value="<?php bloginfo('url'); ?>/wp-admin/admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php print basename(__FILE__); ?>&amp;paid=yes" />
174 +<input type="hidden" name="currency_code" value="USD" />
175 +<input type="hidden" name="notify_url" value="http://feedwordpress.radgeek.com/ipn/donation" />
176 +<input type="hidden" name="custom" value="1" />
177 +<input type="image" name="submit" src="https://www.paypal.com/en_GB/i/btn/btn_donate_SM.gif" alt="Donate through PayPal" />
178 +</div>
179 +</div></form>
180 +
181 +<p>You can make a gift online (or
182 +<a href="http://feedwordpress.radgeek.com/donation">set up an automatic
183 +regular donation</a>) using an existing PayPal account or any major credit card.</p>
184 +
185 +<div class="sod-off">
186 +<form style="text-align: center" action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php print basename(__FILE__); ?>" method="POST"><div>
187 +<input class="button-primary" type="submit" name="maybe_later" value="Maybe Later" />
188 +<input class="button-secondary" type="submit" name="go_away" value="Dismiss" />
189 +</div></form>
190 +</div>
191 +</div> <!-- class="donation-form" -->
192 + <?php
193 + } /* FeedWordPressSyndicationPage::bleg_box () */
194 +
195 + /**
196 + * Override the default display of a save-settings button and replace
197 + * it with nothing.
198 + */
199 + function interstitial () {
200 + /* NOOP */
201 + } /* FeedWordPressSyndicationPage::interstitial() */
202 +} /* class FeedWordPressSyndicationPage */
203 +
61 204 function fwp_dashboard_update_if_requested () {
62 205 global $wpdb;
63 206
64 207 if (isset($_POST['update']) or isset($_POST['action']) or isset($_POST['update_uri'])) :
@@ -85,9 +228,9 @@
85 228 endif;
86 229
87 230 shuffle($update_set); // randomize order for load balancing purposes...
88 231 if ($fwp_update_invoke != 'get' and count($update_set) > 0) : // Only do things with side-effects for HTTP POST or command line
89 - $feedwordpress =& new FeedWordPress;
232 + $feedwordpress = new FeedWordPress;
90 233 add_action('feedwordpress_check_feed', 'update_feeds_mention');
91 234 add_action('feedwordpress_check_feed_complete', 'update_feeds_finish', 10, 3);
92 235
93 236 $crash_dt = (int) get_option('feedwordpress_update_time_limit');
@@ -132,147 +275,80 @@
132 275 echo "<p>Update complete.".implode(' and', $mesg)."</p>";
133 276 echo "\n"; flush();
134 277 endif;
135 278 echo "</div> <!-- class=\"updated\" -->\n";
136 - elseif (fwp_test_wp_version(FWP_SCHEMA_25)) :
137 -?>
138 - <p class="youare">Check currently scheduled feeds for new and updated posts.</p>
139 -<?php
140 279 endif;
141 280 }
142 281
143 -function fwp_syndication_manage_page () {
144 - global $wpdb;
282 +function fwp_syndication_manage_page_add_feed_box ($object = NULL, $box = NULL) {
283 + ?>
284 + <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php print basename(__FILE__); ?>" method="post">
285 + <div>
286 + <?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?>
287 + <label for="add-uri">Website or feed:</label>
288 + <input type="text" name="lookup" id="add-uri" value="URI" size="64" />
289 + <input type="hidden" name="action" value="feedfinder" />
290 + </div>
291 + <div class="submit"><input type="submit" value="<?php print FWP_SYNDICATE_NEW; ?>" /></div>
292 + </form>
293 + <?php
294 +}
145 295
146 - if (FeedWordPress::needs_upgrade()) :
147 - fwp_upgrade_page();
148 - return;
296 +define('FEEDWORDPRESS_BLEG_MAYBE_LATER_OFFSET', (60 /*sec/min*/ * 60 /*min/hour*/ * 24 /*hour/day*/ * 31 /*days*/));
297 +define('FEEDWORDPRESS_BLEG_ALREADY_PAID_OFFSET', (60 /*sec/min*/ * 60 /*min/hour*/ * 24 /*hour/day*/ * 183 /*days*/));
298 +function fwp_syndication_manage_page_update_box ($object = NULL, $box = NULL) {
299 + $bleg_box_hidden = null;
300 + if (isset($_POST['maybe_later'])) :
301 + $bleg_box_hidden = time() + FEEDWORDPRESS_BLEG_MAYBE_LATER_OFFSET;
302 + elseif (isset($_REQUEST['paid']) and $_REQUEST['paid']) :
303 + $bleg_box_hidden = time() + FEEDWORDPRESS_BLEG_ALREADY_PAID_OFFSET;
304 + elseif (isset($_POST['go_away'])) :
305 + $bleg_box_hidden = 'permanent';
149 306 endif;
150 307
151 -?>
152 -<?php $cont = true;
153 -if (isset($_REQUEST['action'])):
154 - if ($_REQUEST['action'] == 'feedfinder' or $_REQUEST['action'] == FWP_SYNDICATE_NEW) : $cont = fwp_feedfinder_page();
155 - elseif ($_REQUEST['action'] == 'switchfeed') : $cont = fwp_switchfeed_page();
156 - elseif ($_REQUEST['action'] == 'linkedit') : $cont = fwp_linkedit_page();
157 - elseif ($_REQUEST['action'] == FWP_UNSUB_CHECKED or $_REQUEST['action'] == 'Unsubscribe') : $cont = fwp_multidelete_page();
308 + if (!is_null($bleg_box_hidden)) :
309 + update_option('feedwordpress_bleg_box_hidden', $bleg_box_hidden);
310 + else :
311 + $bleg_box_hidden = get_option('feedwordpress_bleg_box_hidden');
158 312 endif;
159 -endif;
160 -
161 -if ($cont):
162 313 ?>
163 -<?php
164 - $links = FeedWordPress::syndicated_links();
165 -?>
166 - <div class="wrap">
167 -<?php if (fwp_test_wp_version(FWP_SCHEMA_27)) : ?>
168 - <div class="icon32"><img src="<?php print htmlspecialchars(WP_PLUGIN_URL.'/'.$GLOBALS['fwp_path'].'/feedwordpress.png'); ?>" alt="" /></div>
169 - <h2>Syndicated Sites</h2>
170 -<?php endif;
171 - if (fwp_test_wp_version(0, FWP_SCHEMA_25)) :
172 - fwp_dashboard_update_if_requested();
314 + <?php
315 + $bleg_box_ready = (!$bleg_box_hidden or (is_numeric($bleg_box_hidden) and $bleg_box_hidden < time()));
316 + if (isset($_REQUEST['paid']) and $_REQUEST['paid']) :
317 + $object->bleg_thanks($subject, $box);
318 + elseif ($bleg_box_ready) :
319 + $object->bleg_box($object, $box);
173 320 endif;
321 + ?>
174 322
175 - if (fwp_test_wp_version(FWP_SCHEMA_27)) :
176 -?>
177 - <script type="text/javascript">
178 - jQuery(document).ready( function($) {
179 - // In case someone got here first.
180 - $('.postbox h3, .postbox .handlediv').unbind('click');
181 - $('.hide-postbox-tog').unbind('click');
182 - $('.meta-box-sortables').sortable('destroy');
323 + <form
324 + action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php print basename(__FILE__); ?>"
325 + method="POST"
326 + class="update-form<?php if ($bleg_box_ready) : ?> with-donation<?php endif; ?>"
327 + >
328 + <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div>
329 + <p>Check currently scheduled feeds for new and updated posts.</p>
183 330
184 - postboxes.add_postbox_toggles('feedwordpress_syndication');
185 - } );
186 - </script>
187 -<?php
188 - echo "<form style='display: none' method='get' action=''>\n<p>\n";
189 - wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
190 - wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
191 - echo "</p>\n</form>\n";
192 -
193 - if ($links) :
194 - add_meta_box('feedwordpress_update_box', __('Update feeds now'), 'fwp_syndication_manage_page_update_box', /*page=*/ 'feedwordpress_syndication', /*context =*/ 'normal');
195 - endif;
196 - add_meta_box('feedwordpress_feeds_box', __('Syndicated sources'), 'fwp_syndication_manage_page_links_box', /*page=*/ 'feedwordpress_syndication', /*context =*/ 'normal');
197 -?>
198 - <div class="metabox-holder">
199 - <div id="feedwordpress-sortables" class="meta-box-sortables ui-sortable">
200 -<?php
201 - do_meta_boxes('feedwordpress_syndication', 'normal', NULL);
202 - else :
203 - if ($links): // only display Update panel if there are some links to update....
204 - fwp_syndication_manage_page_update_box();
205 - endif;
206 - fwp_syndication_manage_page_links_box();
207 -?>
208 - </div> <!-- class="wrap" -->
331 + <?php
332 + fwp_dashboard_update_if_requested();
209 333
210 - <?php if (fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?>
211 - <div class="wrap">
212 - <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
213 - <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div>
214 - <h2>Add a new syndicated site:</h2>
215 - <div>
216 - <label for="add-uri">Website or feed:</label>
217 - <input type="text" name="lookup" id="add-uri" value="URI" size="64" />
218 - <input type="hidden" name="action" value="feedfinder" />
219 - </div>
220 - <div class="submit"><input type="submit" value="Syndicate &raquo;" /></div>
221 - </form>
222 - </div> <!-- class="wrap" -->
223 - <?php endif; ?>
224 -
225 - <div style="display: none">
226 - <div id="tags-input"></div> <!-- avoid JS error from WP 2.5 bug -->
227 - </div>
228 -<?php
334 + if (!get_option('feedwordpress_automatic_updates')) :
335 + ?>
336 + <p class="heads-up"><strong>Note:</strong> Automatic updates are currently turned
337 + <strong>off</strong>. New posts from your feeds will not be syndicated
338 + until you manually check for them here. You can turn on automatic
339 + updates under <a href="admin.php?page=<?php print $GLOBALS['fwp_path']; ?>/feeds-page.php">Feed &amp; Update Settings<a></a>.</p>
340 + <?php
229 341 endif;
230 -endif;
231 -} /* function fwp_syndication_manage_page () */
342 + ?>
232 343
233 -function fwp_syndication_manage_page_update_box ($object = NULL, $box = NULL) {
234 - $updateFeedsNow = __('Update feeds now');
235 -?>
236 - <form action="" method="POST">
237 - <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div>
238 - <?php if (fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_27)) : ?>
239 - <div id="rightnow">
240 - <h3 class="reallynow"><span><?php print $updateFeedsNow; ?></span>
241 - <input type="hidden" name="update_uri" value="*" /><input style="float: right; border: none;" class="rbutton" type="submit" name="update" value="Update" />
242 - <br class="clear"/></h3>
243 - <?php elseif (fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?>
244 - <h2><?php print $updateFeedsNow; ?></h2>
245 - <?php endif; ?>
246 -
247 -<?php
248 - if (fwp_test_wp_version(FWP_SCHEMA_25)) :
249 - fwp_dashboard_update_if_requested();
250 - else :
251 -?>
252 -<p>Check currently scheduled feeds for new and updated posts.</p>
253 -<?php endif; ?>
254 -
255 -<?php if (!get_option('feedwordpress_automatic_updates')) : ?>
256 - <p class="youhave"><strong>Note:</strong> Automatic updates are currently turned
257 - <strong>off</strong>. New posts from your feeds will not be syndicated
258 - until you manually check for them here. You can turn on automatic
259 - updates under <a href="admin.php?page=<?php print $GLOBALS['fwp_path']; ?>/syndication-options.php">Syndication
260 - Options</a>.</p>
261 -<?php endif; ?>
262 -
263 - <?php if (!fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_27)) : ?>
264 344 <div class="submit"><input type="hidden" name="update_uri" value="*" /><input class="button-primary" type="submit" name="update" value="Update" /></div>
265 - <?php endif; ?>
266 345
267 346 <?php if (fwp_test_wp_version(FWP_SCHEMA_27)) : ?>
268 347 <br style="clear: both" />
269 - <?php elseif (fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_27)) : ?>
348 + <?php /* elseif (fwp_test_wp_version(FWP_SCHEMA_25, FWP_SCHEMA_27)) :
270 349 </div> <!-- id="rightnow" -->
271 - </div> <!-- class="wrap" -->
272 - <?php elseif (fwp_test_wp_version(0, FWP_SCHEMA_25)) : ?>
273 - </div> <!-- class="wrap" -->
274 - <?php endif; ?>
350 + <?php */ endif; ?>
275 351 </form>
276 352 <?php
277 353 } /* function fwp_syndication_manage_page_update_box () */
278 354
@@ -278,13 +354,8 @@
278 354
279 355 function fwp_syndication_manage_page_links_box ($object = NULL, $box = NULL) {
280 356 $links = FeedWordPress::syndicated_links();
281 357 ?>
282 - <?php if (!fwp_test_wp_version(FWP_SCHEMA_27)) : ?>
283 - <div class="wrap">
284 - <h2>Syndicated Sites</h2>
285 - <?php endif; ?>
286 -
287 358 <form id="syndicated-links" action="admin.php?page=<?php print $GLOBALS['fwp_path']; ?>/<?php echo basename(__FILE__); ?>" method="post">
288 359 <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?></div>
289 360
290 361 <?php $alt_row = true; ?>
@@ -293,25 +364,10 @@
293 364 <div class="tablenav">
294 365 <div class="alignright">
295 366 <label for="add-uri">Add new source:</label>
296 367 <input type="text" name="lookup" id="add-uri" value="Website or feed URI" />
297 -<script type="text/javascript">
298 -jQuery(document).ready( function () {
299 - var addUri = jQuery("#add-uri");
300 - var box = addUri.get(0);
301 - if (box.value==box.defaultValue) { addUri.addClass('form-input-tip'); }
302 - addUri.focus(function() {
303 - if ( this.value == this.defaultValue )
304 - jQuery(this).val( '' ).removeClass( 'form-input-tip' );
305 - });
306 - addUri.blur(function() {
307 - if ( this.value == '' )
308 - jQuery(this).val( this.defaultValue ).addClass( 'form-input-tip' );
309 - });
368 + <?php FeedWordPressSettingsUI::magic_input_tip_js('add-uri'); ?>
310 369
311 -} );
312 -</script>
313 -
314 370 <input type="hidden" name="action" value="feedfinder" />
315 371 <input type="submit" class="button-secondary" name="action" value="<?php print FWP_SYNDICATE_NEW; ?>" /></div>
316 372
317 373 <?php if (count($links) > 0) : ?>
@@ -352,33 +408,22 @@
352 408 $caption=__('Find Feed');
353 409 endif;
354 410 ?>
355 411 <td>
356 -<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>
412 +<strong><a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/feeds-page.php&amp;link_id=<?php echo $link->link_id; ?>"><?php echo esc_html($link->link_name); ?></a></strong>
357 413 <div class="row-actions"><div><strong>Settings &gt;</strong>
358 -<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('Feed'); ?></a>
414 +<a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/feeds-page.php&amp;link_id=<?php echo $link->link_id; ?>"><?php _e('Feed'); ?></a>
359 415 | <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/posts-page.php&amp;link_id=<?php echo $link->link_id; ?>"><?php _e('Posts'); ?></a>
360 416 | <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/authors-page.php&amp;link_id=<?php echo $link->link_id; ?>"><?php _e('Authors'); ?></a>
361 -| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/categories-page.php&amp;link_id=<?php echo $link->link_id; ?>"><?php _e('Categories &amp; Tags'); ?></a></div>
417 +| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/categories-page.php&amp;link_id=<?php echo $link->link_id; ?>"><?php print htmlspecialchars(__('Categories'.FEEDWORDPRESS_AND_TAGS)); ?></a></div>
362 418 <div><strong>Actions &gt;</strong>
363 419 <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>
364 420 | <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>
365 -| <a href="<?php echo wp_specialchars($link->link_url, 'both'); ?>"><?php _e('View')?></a></div>
421 +| <a href="<?php echo esc_html($link->link_url); ?>"><?php _e('View')?></a></div>
366 422 </div>
367 423 </td>
368 -<?php
369 - if (strlen($link->link_rss) > 0):
370 - $uri_bits = parse_url($link->link_rss);
371 - $uri_bits['host'] = preg_replace('/^www\./i', '', $uri_bits['host']);
372 - $display_uri =
373 - (isset($uri_bits['user'])?$uri_bits['user'].'@':'')
374 - .(isset($uri_bits['host'])?$uri_bits['host']:'')
375 - .(isset($uri_bits['port'])?':'.$uri_bits['port']:'')
376 - .(isset($uri_bits['path'])?$uri_bits['path']:'')
377 - .(isset($uri_bits['query'])?'?'.$uri_bits['query']:'');
378 - if (strlen($display_uri) > 32) : $display_uri = substr($display_uri, 0, 32).'&#8230;'; endif;
379 -?>
380 - <td><a href="<?php echo wp_specialchars($link->link_rss, 'both'); ?>"><?php echo wp_specialchars($display_uri, 'both'); ?></a></td>
424 + <?php if (strlen($link->link_rss) > 0): ?>
425 + <td><a href="<?php echo esc_html($link->link_rss); ?>"><?php echo esc_html(feedwordpress_display_url($link->link_rss, 32)); ?></a></td>
381 426 <?php else: ?>
382 427 <td style="background-color:#FFFFD0"><p><strong>no
383 428 feed assigned</strong></p></td>
384 429 <?php endif; ?>
@@ -383,9 +428,9 @@
383 428 feed assigned</strong></p></td>
384 429 <?php endif; ?>
385 430
386 431 <td><?php
387 - $sLink =& new SyndicatedLink($link->link_id);
432 + $sLink = new SyndicatedLink($link->link_id);
388 433 if (isset($sLink->settings['update/last'])) :
389 434 print fwp_time_elapsed($sLink->settings['update/last']);
390 435 else :
391 436 _e('None yet');
@@ -395,8 +440,9 @@
395 440 if (isset($sLink->settings['update/ttl']) and is_numeric($sLink->settings['update/ttl'])) :
396 441 if (isset($sLink->settings['update/timed']) and $sLink->settings['update/timed']=='automatically') :
397 442 $next = $sLink->settings['update/last'] + ((int) $sLink->settings['update/ttl'] * 60);
398 443 print fwp_time_elapsed($next);
444 + if (FEEDWORDPRESS_DEBUG) : print " [".(($next-time())/60)." minutes]"; endif;
399 445 else :
400 446 echo "every ".$sLink->settings['update/ttl']." minute".(($sLink->settings['update/ttl']!=1)?"s":"");
401 447 endif;
402 448 else:
@@ -401,8 +447,9 @@
401 447 endif;
402 448 else:
403 449 echo "as soon as possible";
404 450 endif;
451 + unset($sLink);
405 452 print "</div>";
406 453 ?>
407 454 </td>
408 455 </tr>
@@ -427,484 +474,64 @@
427 474 <?php
428 475 } /* function fwp_syndication_manage_page_links_box() */
429 476
430 477 function fwp_feedfinder_page () {
431 - global $wpdb;
432 - global $FeedWordPressHTTPStatusMessages;
478 + global $post_source;
479 +
480 + $post_source = 'feedwordpress_feeds';
481 +
482 + // With action=feedfinder, this goes directly to the feedfinder page
483 + include_once(dirname(__FILE__) . '/feeds-page.php');
484 + return false;
485 +} /* function fwp_feedfinder_page () */
433 486
434 - $lookup = (isset($_REQUEST['lookup'])?$_REQUEST['lookup']:NULL);
435 -
436 - if (isset($_REQUEST['link_id']) and ($_REQUEST['link_id']!=0)):
437 - $link_id = $_REQUEST['link_id'];
438 - if (!is_numeric($link_id)) : FeedWordPress::critical_bug('fwp_feedfinder_page::link_id', $link_id, __LINE__); endif;
439 -
440 - $link = $wpdb->get_row("SELECT * FROM $wpdb->links WHERE link_id='".$wpdb->escape($link_id)."'");
441 - if (is_object($link)):
442 - if (is_null($lookup)) $lookup = $link->link_url;
443 - $name = wp_specialchars($link->link_name, 'both');
444 - else:
445 - die (__("Cheatin' uh ?"));
446 - endif;
447 - else:
448 - $name = "<code>".htmlspecialchars($lookup)."</code>";
449 - $link_id = 0;
450 - endif;
451 -?>
452 - <div class="wrap">
453 - <h2>Feed Finder: <?php echo $name; ?></h2>
454 -<?php
455 - $f =& new FeedFinder($lookup);
456 - $feeds = $f->find();
457 - if (count($feeds) > 0):
458 - foreach ($feeds as $key => $f):
459 - $rss = fetch_rss($f);
460 - if ($rss):
461 - $feed_title = isset($rss->channel['title'])?$rss->channel['title']:$rss->channel['link'];
462 - $feed_link = isset($rss->channel['link'])?$rss->channel['link']:'';
463 - else :
464 - // Give us some sucky defaults
465 - $uri_bits = parse_url($lookup);
466 - $uri_bits['host'] = preg_replace('/^www\./i', '', $uri_bits['host']);
467 - $display_uri =
468 - (isset($uri_bits['user'])?$uri_bits['user'].'@':'')
469 - .(isset($uri_bits['host'])?$uri_bits['host']:'')
470 - .(isset($uri_bits['port'])?':'.$uri_bits['port']:'')
471 - .(isset($uri_bits['path'])?$uri_bits['path']:'')
472 - .(isset($uri_bits['query'])?'?'.$uri_bits['query']:'');
473 - if (strlen($display_uri) > 32) : $display_uri = substr($display_uri, 0, 32).'&#8230;'; endif;
474 -
475 - $feed_title = $display_uri;
476 - $feed_link = $lookup;
477 - endif;
478 -?>
479 - <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
480 - <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_switchfeed'); ?></div>
481 - <fieldset style="clear: both">
482 - <legend><?php echo $rss->feed_type; ?> <?php echo $rss->feed_version; ?> feed</legend>
483 -
484 - <?php if ($link_id===0): ?>
485 - <input type="hidden" name="feed_title" value="<?php echo wp_specialchars($feed_title, 'both'); ?>" />
486 - <input type="hidden" name="feed_link" value="<?php echo wp_specialchars($feed_link, 'both'); ?>" />
487 - <?php endif; ?>
488 -
489 - <input type="hidden" name="link_id" value="<?php echo $link_id; ?>" />
490 - <input type="hidden" name="feed" value="<?php echo wp_specialchars($f, 'both'); ?>" />
491 - <input type="hidden" name="action" value="switchfeed" />
492 -
493 - <div>
494 - <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">
495 -<?php if (count($rss->items) > 0): ?>
496 - <?php
497 - // Prepare to display Sample Item
498 - $link =& new MagpieMockLink($rss, $f);
499 - $post =& new SyndicatedPost($rss->items[0], $link);
500 - ?>
501 - <h3>Sample Item</h3>
502 - <ul>
503 - <li><strong>Title:</strong> <a href="<?php echo $post->post['meta']['syndication_permalink']; ?>"><?php echo $post->post['post_title']; ?></a></li>
504 - <li><strong>Date:</strong> <?php print date('d-M-y g:i:s a', $post->published()); ?></li>
505 - </ul>
506 - <div class="entry">
507 - <?php print $post->post['post_content']; ?>
508 - </div>
509 -<?php else: ?>
510 - <h3>No Items</h3>
511 - <p>FeedWordPress found no posts on this feed.</p>
512 -<?php endif; ?>
513 - </div>
514 -
515 - <div>
516 - <h3>Feed Information</h3>
517 - <ul>
518 - <li><strong>Website:</strong> <a href="<?php echo $feed_link; ?>"><?php echo is_null($feed_title)?'<em>Unknown</em>':$feed_title; ?></a></li>
519 - <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>
520 - <li><strong>Encoding:</strong> <?php echo isset($rss->encoding)?wp_specialchars($rss->encoding, 'both'):"<em>Unknown</em>"; ?></li>
521 - <li><strong>Description:</strong> <?php echo isset($rss->channel['description'])?wp_specialchars($rss->channel['description'], 'both'):"<em>Unknown</em>"; ?></li>
522 - </ul>
523 - <div class="submit"><input type="submit" name="Use" value="&laquo; Use this feed" /></div>
524 - <div class="submit"><input type="submit" name="Cancel" value="&laquo; Cancel" /></div>
525 - </div>
526 - </div>
527 - </fieldset>
528 - </form>
529 -<?php
530 - endforeach;
531 - else:
532 - print "<p><strong>".__('Error').":</strong> ".__("FeedWordPress couldn't find any feeds at").' <code><a href="'.htmlspecialchars($lookup).'">'.htmlspecialchars($lookup).'</a></code>';
533 - print ". ".__('Try another URL').".</p>";
534 -
535 - // Diagnostics
536 - $httpObject = _wp_http_get_object();
537 - $transports = $httpObject->_getTransport();
538 - print "<div class=\"updated\" style=\"margin-left: 3.0em; margin-right: 3.0em;\">\n";
539 - print "<h3>".__('Diagnostic information')."</h3>\n";
540 - if (!is_null($f->error())) :
541 - print "<h4>".__('HTTP request failure')."</h4>\n";
542 - print "<p>".$f->error()."</p>\n";
543 - else :
544 - print "<h4>".__('HTTP request completed')."</h4>\n";
545 - print "<p><strong>Status ".$f->status().":</strong> ".$FeedWordPressHTTPStatusMessages[$f->status()]."</p>\n";
546 - endif;
547 - print "<h4>".__('HTTP Transports available').":</h4>\n";
548 - print "<ol>\n";
549 - print "<li>".implode("</li>\n<li>", array_map('get_class', $transports))."</li>\n";
550 - print "</ol>\n";
551 - print "</div>\n";
552 - endif;
553 -?>
554 - </div>
555 -
556 - <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
557 - <div><?php
558 - FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds');
559 - ?></div>
560 - <div class="wrap">
561 - <h2>Use another feed</h2>
562 - <div><label>Feed:</label>
563 - <input type="text" name="lookup" value="URI" />
564 - <input type="hidden" name="link_id" value="<?php echo $link_id; ?>" />
565 - <input type="hidden" name="action" value="feedfinder" /></div>
566 - <div class="submit"><input type="submit" value="Use this feed &raquo;" /></div>
567 - </div>
568 - </form>
569 -<?php
570 - return false; // Don't continue
571 -}
572 -
573 487 function fwp_switchfeed_page () {
574 488 global $wpdb, $wp_db_version;
489 + global $fwp_post;
575 490
576 491 // If this is a POST, validate source and user credentials
577 492 FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_switchfeed', /*capability=*/ 'manage_links');
578 493
579 - if (!isset($_REQUEST['Cancel'])):
580 - if (isset($_POST['link_id']) and ($_POST['link_id']==0)):
581 - $link_id = FeedWordPress::syndicate_link($_REQUEST['feed_title'], $_REQUEST['feed_link'], $_REQUEST['feed']);
582 - if ($link_id): ?>
583 -<div class="updated"><p><a href="<?php echo stripslashes($_REQUEST['feed_link']); ?>"><?php echo wp_specialchars(stripslashes($_REQUEST['feed_title']), 'both'); ?></a>
584 -has been added as a contributing site, using the feed at &lt;<a href="<?php echo stripslashes($_REQUEST['feed']); ?>"><?php echo wp_specialchars(stripslashes($_REQUEST['feed']), 'both'); ?></a>&gt;.
585 -| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>&amp;link_id=<?php echo $link_id; ?>&amp;action=linkedit">Configure settings</a>.</div>
494 + $changed = false;
495 + if (!isset($fwp_post['Cancel'])):
496 + if (isset($fwp_post['save_link_id']) and ($fwp_post['save_link_id']=='*')) :
497 + $changed = true;
498 + $link_id = FeedWordPress::syndicate_link($fwp_post['feed_title'], $fwp_post['feed_link'], $fwp_post['feed']);
499 + if ($link_id):
500 + $existingLink = new SyndicatedLink($link_id);
501 + ?>
502 +<div class="updated"><p><a href="<?php print $fwp_post['feed_link']; ?>"><?php print esc_html($fwp_post['feed_title']); ?></a>
503 +has been added as a contributing site, using the feed at
504 +&lt;<a href="<?php print $fwp_post['feed']; ?>"><?php print esc_html($fwp_post['feed']); ?></a>&gt;.
505 +| <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/feeds-page.php&amp;link_id=<?php print $link_id; ?>">Configure settings</a>.</p></div>
586 506 <?php else: ?>
587 -<div class="updated"><p>There was a problem adding the feed. [SQL: <?php echo wp_specialchars(mysql_error(), 'both'); ?>]</p></div>
507 +<div class="updated"><p>There was a problem adding the feed. [SQL: <?php echo esc_html(mysql_error()); ?>]</p></div>
588 508 <?php endif;
589 - elseif (isset($_POST['link_id'])):
590 - // Update link_rss
591 - $result = $wpdb->query("
592 - UPDATE $wpdb->links
593 - SET
594 - link_rss = '".$wpdb->escape($_REQUEST['feed'])."'
595 - WHERE link_id = '".$wpdb->escape($_REQUEST['link_id'])."'
596 - ");
597 -
598 - if ($result):
599 - $result = $wpdb->get_row("
600 - SELECT link_name, link_url FROM $wpdb->links
601 - WHERE link_id = '".$wpdb->escape($_REQUEST['link_id'])."'
602 - ");
603 - ?>
604 -<div class="updated"><p>Feed for <a href="<?php echo $result->link_url; ?>"><?php echo wp_specialchars($result->link_name, 'both'); ?></a>
605 -updated to &lt;<a href="<?php echo $_REQUEST['feed']; ?>"><?php echo wp_specialchars($_REQUEST['feed'], 'both'); ?></a>&gt;.</p></div>
606 - <?php else: ?>
607 -<div class="updated"><p>Nothing was changed.</p></div>
608 - <?php endif;
609 - endif;
610 - endif;
611 - return true; // Continue
612 -}
509 + elseif (isset($fwp_post['save_link_id'])):
510 + $existingLink = new SyndicatedLink($fwp_post['save_link_id']);
511 + $changed = $existingLink->set_uri($fwp_post['feed']);
613 512
614 -function fwp_linkedit_page () {
615 - global $wpdb, $wp_db_version;
616 -
617 - // If this is a POST, validate source and user credentials
618 - FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_linkedit', /*capability=*/ 'manage_links');
619 -
620 - $special_settings = array ( /* Regular expression syntax is OK here */
621 - 'cats',
622 - 'cat_split',
623 - 'hardcode name',
624 - 'hardcode url',
625 - 'hardcode description',
626 - 'hardcode categories', /* Deprecated */
627 - 'post status',
628 - 'comment status',
629 - 'ping status',
630 - 'unfamiliar author',
631 - 'unfamliar categories', /* Deprecated */
632 - 'unfamiliar category',
633 - 'map authors',
634 - 'tags',
635 - 'update/.*',
636 - 'feed/.*',
637 - 'link/.*',
638 - );
639 -
640 - if (isset($_REQUEST['feedfinder'])) :
641 - return fwp_feedfinder_page(); // re-route to Feed Finder page
642 - else :
643 - $link_id = (int) $_REQUEST['link_id'];
644 - $link =& new SyndicatedLink($link_id);
645 -
646 - if ($link->found()) :
647 - if (isset($GLOBALS['fwp_post']['save'])) :
648 - $alter = array ();
649 -
650 - // custom feed settings first
651 - foreach ($GLOBALS['fwp_post']['notes'] as $mn) :
652 - $mn['key0'] = trim($mn['key0']);
653 - $mn['key1'] = trim($mn['key1']);
654 - if (preg_match("\007^(("
655 - .implode(')|(',$special_settings)
656 - ."))$\007i",
657 - $mn['key1'])) :
658 - $mn['key1'] = 'user/'.$mn['key1'];
659 - endif;
660 -
661 - if (strlen($mn['key0']) > 0) :
662 - unset($link->settings[$mn['key0']]); // out with the old
663 - endif;
664 -
665 - if (($mn['action']=='update') and (strlen($mn['key1']) > 0)) :
666 - $link->settings[$mn['key1']] = $mn['value']; // in with the new
667 - endif;
668 - endforeach;
669 -
670 - // now stuff through the web form
671 - // hardcoded feed info
672 - if (isset($GLOBALS['fwp_post']['hardcode_name'])) :
673 - $link->settings['hardcode name'] = $GLOBALS['fwp_post']['hardcode_name'];
674 - if (FeedWordPress::affirmative($link->settings, 'hardcode name')) :
675 - $alter[] = "link_name = '".$wpdb->escape($GLOBALS['fwp_post']['name'])."'";
676 - endif;
677 - endif;
678 - if (isset($GLOBALS['fwp_post']['hardcode_description'])) :
679 - $link->settings['hardcode description'] = $GLOBALS['fwp_post']['hardcode_description'];
680 - if (FeedWordPress::affirmative($link->settings, 'hardcode description')) :
681 - $alter[] = "link_description = '".$wpdb->escape($GLOBALS['fwp_post']['description'])."'";
682 - endif;
683 - endif;
684 - if (isset($GLOBALS['fwp_post']['hardcode_url'])) :
685 - $link->settings['hardcode url'] = $GLOBALS['fwp_post']['hardcode_url'];
686 - if (FeedWordPress::affirmative($link->settings, 'hardcode url')) :
687 - $alter[] = "link_url = '".$wpdb->escape($GLOBALS['fwp_post']['linkurl'])."'";
688 - endif;
689 - endif;
690 -
691 - // Update scheduling
692 - if (isset($GLOBALS['fwp_post']['update_schedule'])) :
693 - $link->settings['update/hold'] = $GLOBALS['fwp_post']['update_schedule'];
694 - endif;
695 -
696 - $alter[] = "link_notes = '".$wpdb->escape($link->settings_to_notes())."'";
697 -
698 - $alter_set = implode(", ", $alter);
699 -
700 - // issue update query
701 - $result = $wpdb->query("
702 - UPDATE $wpdb->links
703 - SET $alter_set
704 - WHERE link_id='$link_id'
705 - ");
706 - $updated_link = true;
707 -
708 - // reload link information from DB
709 - if (function_exists('clean_bookmark_cache')) :
710 - clean_bookmark_cache($link_id);
711 - endif;
712 - $link =& new SyndicatedLink($link_id);
713 - else :
714 - $updated_link = false;
513 + if ($changed):
514 + $home = $existingLink->homepage(/*from feed=*/ false);
515 + $name = $existingLink->name(/*from feed=*/ false);
516 + ?>
517 +<div class="updated"><p>Feed for <a href="<?php echo esc_html($home); ?>"><?php echo esc_html($name); ?></a>
518 +updated to &lt;<a href="<?php echo esc_html($fwp_post['feed']); ?>"><?php echo esc_html($fwp_post['feed']); ?></a>&gt;.</p></div>
519 + <?php
715 520 endif;
716 -
717 - $db_link = $link->link;
718 - $link_url = wp_specialchars($db_link->link_url, 1);
719 - $link_name = wp_specialchars($db_link->link_name, 1);
720 - $link_description = wp_specialchars($db_link->link_description, 'both');
721 - $link_rss_uri = wp_specialchars($db_link->link_rss, 'both');
722 - else :
723 - die( __('Link not found.') );
724 521 endif;
522 + endif;
725 523
726 - ?>
727 -<script type="text/javascript">
728 - function flip_hardcode (item) {
729 - ed=document.getElementById('basics-'+item+'-edit');
730 - view=document.getElementById('basics-'+item+'-view');
731 -
732 - o = document.getElementById('basics-hardcode-'+item);
733 - if (o.value=='yes') { ed.style.display='inline'; view.style.display='none'; }
734 - else { ed.style.display='none'; view.style.display='inline'; }
735 - }
736 -</script>
737 -
738 -<?php if ($updated_link) : ?>
739 -<div class="updated"><p>Syndicated feed settings updated.</p></div>
740 -<?php endif; ?>
741 -
742 -<form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post">
743 -<div class="wrap">
744 -<?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_linkedit'); ?>
745 -<input type="hidden" name="link_id" value="<?php echo $link_id; ?>" />
746 -<input type="hidden" name="action" value="linkedit" />
747 -<input type="hidden" name="save" value="link" />
748 -
749 -<?php if (fwp_test_wp_version(FWP_SCHEMA_27)) : ?>
750 - <div class="icon32"><img src="<?php print htmlspecialchars(WP_PLUGIN_URL.'/'.$GLOBALS['fwp_path'].'/feedwordpress.png'); ?>" alt="" /></div>
751 -<?php endif; ?>
752 -
753 -<h2><?php _e('Feed settings'); ?><?php if (!is_null($link) and $link->found()) : ?>: <?php echo wp_specialchars($link->link->link_name, 1); ?><?php endif; ?></h2>
754 -
755 -<div id="poststuff">
756 -<?php fwp_linkedit_single_submit($status); ?>
757 -
758 -<div id="post-body">
759 -<?php fwp_option_box_opener('Feed Information', 'feedinformationdiv'); ?>
760 - <table class="editform" width="100%" cellspacing="2" cellpadding="5">
761 - <tr>
762 - <th scope="row" width="20%"><?php _e('Feed URI:') ?></th>
763 - <td width="60%"><a href="<?php echo wp_specialchars($link_rss_uri, 'both'); ?>"><?php echo $link_rss_uri; ?></a>
764 - (<a href="<?php echo FEEDVALIDATOR_URI; ?>?url=<?php echo urlencode($link_rss_uri); ?>"
765 - title="Check feed &lt;<?php echo wp_specialchars($link_rss_uri, 'both'); ?>&gt; for validity">validate</a>)
766 - </td>
767 - <td width="20%"><input type="submit" name="feedfinder" value="switch &rarr;" style="font-size:smaller" /></td>
768 - </tr>
769 - <tr>
770 - <th scope="row" width="20%"><?php _e('Link Name:') ?></th>
771 - <td width="60%"><input type="text" id="basics-name-edit" name="name"
772 - value="<?php echo $link_name; ?>" style="width: 95%" />
773 - <span id="basics-name-view"><strong><?php echo $link_name; ?></strong></span>
774 - </td>
775 - <td>
776 - <select id="basics-hardcode-name" onchange="flip_hardcode('name')" name="hardcode_name">
777 - <option value="no" <?php echo $link->hardcode('name')?'':'selected="selected"'; ?>>update automatically</option>
778 - <option value="yes" <?php echo $link->hardcode('name')?'selected="selected"':''; ?>>edit manually</option>
779 - </select>
780 - </td>
781 - </tr>
782 - <tr>
783 - <th scope="row" width="20%"><?php _e('Short description:') ?></th>
784 - <td width="60%">
785 - <input id="basics-description-edit" type="text" name="description" value="<?php echo $link_description; ?>" style="width: 95%" />
786 - <span id="basics-description-view"><strong><?php echo $link_description; ?></strong></span>
787 - </td>
788 - <td>
789 - <select id="basics-hardcode-description" onchange="flip_hardcode('description')"
790 - name="hardcode_description">
791 - <option value="no" <?php echo $link->hardcode('description')?'':'selected="selected"'; ?>>update automatically</option>
792 - <option value="yes" <?php echo $link->hardcode('description')?'selected="selected"':''; ?>>edit manually</option>
793 - </select></td>
794 - </tr>
795 - <tr>
796 - <th width="20%" scope="row"><?php _e('Homepage:') ?></th>
797 - <td width="60%">
798 - <input id="basics-url-edit" type="text" name="linkurl" value="<?php echo $link_url; ?>" style="width: 95%;" />
799 - <a id="basics-url-view" href="<?php echo $link_url; ?>"><?php echo $link_url; ?></a></td>
800 - <td>
801 - <select id="basics-hardcode-url" onchange="flip_hardcode('url')" name="hardcode_url">
802 - <option value="no"<?php echo $link->hardcode('url')?'':' selected="selected"'; ?>>update automatically</option>
803 - <option value="yes"<?php echo $link->hardcode('url')?' selected="selected"':''; ?>>edit manually</option>
804 - </select></td></tr>
524 + if (isset($existingLink)) :
525 + do_action('feedwordpress_admin_switchfeed', $fwp_post['feed'], $existingLink);
526 + endif;
805 527
806 - <tr>
807 - <th width="20%"><?php _e('Last update') ?>:</th>
808 - <td colspan="2"><?php
809 - if (isset($link->settings['update/last'])) :
810 - echo fwp_time_elapsed($link->settings['update/last'])." ";
811 - else :
812 - echo " none yet";
813 - endif;
814 - ?></td></tr>
815 - <tr><th width="20%">Next update:</th>
816 - <td colspan="2"><?php
817 - $holdem = (isset($link->settings['update/hold']) ? $link->settings['update/hold'] : 'scheduled');
818 - ?>
819 - <select name="update_schedule">
820 - <option value="scheduled"<?php echo ($holdem=='scheduled')?' selected="selected"':''; ?>>update on schedule <?php
821 - echo " (";
822 - if (isset($link->settings['update/ttl']) and is_numeric($link->settings['update/ttl'])) :
823 - if (isset($link->settings['update/timed']) and $link->settings['update/timed']=='automatically') :
824 - echo 'next: ';
825 - $next = $link->settings['update/last'] + ((int) $link->settings['update/ttl'] * 60);
826 - if (strftime('%x', time()) != strftime('%x', $next)) :
827 - echo strftime('%x', $next)." ";
828 - endif;
829 - echo strftime('%X', $link->settings['update/last']+((int) $link->settings['update/ttl']*60));
830 - else :
831 - echo "every ".$link->settings['update/ttl']." minute".(($link->settings['update/ttl']!=1)?"s":"");
832 - endif;
833 - else:
834 - echo "next scheduled update";
835 - endif;
836 - echo ")";
837 - ?></option>
838 - <option value="next"<?php echo ($holdem=='next')?' selected="selected"':''; ?>>update ASAP</option>
839 - <option value="ping"<?php echo ($holdem=='ping')?' selected="selected"':''; ?>>update only when pinged</option>
840 - </select></tr>
841 - </table>
842 -<?php fwp_option_box_closer(); ?>
843 -
844 -<script type="text/javascript">
845 -flip_hardcode('name');
846 -flip_hardcode('description');
847 -flip_hardcode('url');
848 -</script>
849 -
850 -<?php fwp_linkedit_periodic_submit(); ?>
851 -
852 -<?php
853 - FeedWordPressSettingsUI::instead_of_posts_box($link_id);
854 - FeedWordPressSettingsUI::instead_of_authors_box($link_id);
855 - FeedWordPressSettingsUI::instead_of_categories_box($link_id);
856 -
857 - fwp_option_box_opener('Custom Feed Settings (for use in templates)', 'postcustom', 'postbox');
858 -?>
859 -<p class="setting-description">These custom settings are special fields for the <strong>feed</strong> you are
860 -syndicating, to be retrieved in templates using the <code>get_feed_meta()</code> function. They do not create
861 -custom fields on syndicated <strong>posts</strong>. If you want to create custom fields that are applied to each
862 -individual post from this feed, set up the settings in <a href="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/posts-page.php&amp;link_id=<?php print $link_id; ?>">Syndicated Posts</a>.</p>
863 -
864 -<div id="postcustomstuff">
865 -<table id="meta-list" cellpadding="3">
866 - <tr>
867 - <th>Key</th>
868 - <th>Value</th>
869 - <th>Action</th>
870 - </tr>
871 -
872 -<?php
873 - $i = 0;
874 - foreach ($link->settings as $key => $value) :
875 - if (!preg_match("\007^((".implode(')|(', $special_settings)."))$\007i", $key)) :
876 -?>
877 - <tr style="vertical-align:top">
878 - <th width="30%" scope="row"><input type="hidden" name="notes[<?php echo $i; ?>][key0]" value="<?php echo wp_specialchars($key, 'both'); ?>" />
879 - <input id="notes-<?php echo $i; ?>-key" name="notes[<?php echo $i; ?>][key1]" value="<?php echo wp_specialchars($key, 'both'); ?>" /></th>
880 - <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>
881 - <td width="10%"><select name="notes[<?php echo $i; ?>][action]">
882 - <option value="update">save changes</option>
883 - <option value="delete">delete this setting</option>
884 - </select></td>
885 - </tr>
886 -<?php
887 - $i++;
888 - endif;
889 - endforeach;
890 -?>
891 - <tr>
892 - <th scope="row"><input type="text" size="10" name="notes[<?php echo $i; ?>][key1]" value="" /></th>
893 - <td><textarea name="notes[<?php echo $i; ?>][value]" rows="2" cols="40"></textarea></td>
894 - <td><em>add new setting...</em><input type="hidden" name="notes[<?php echo $i; ?>][action]" value="update" /></td>
895 - </tr>
896 -</table>
897 -<?php fwp_option_box_closer(); ?>
898 -
899 -<?php fwp_linkedit_periodic_submit(); ?>
900 -<?php fwp_linkedit_single_submit_closer(); ?>
901 -</div> <!-- id="post-body" -->
902 -</div> <!-- id="poststuff" -->
903 -</div>
904 - <?php
528 + if (!$changed) :
529 + ?>
530 +<div class="updated"><p>Nothing was changed.</p></div>
531 + <?php
905 532 endif;
906 - return false; // Don't continue
533 + return true; // Continue
907 534 }
908 535
909 536 function fwp_multidelete_page () {
910 537 global $wpdb;
@@ -915,9 +542,15 @@
915 542 $link_ids = (isset($_REQUEST['link_ids']) ? $_REQUEST['link_ids'] : array());
916 543 if (isset($_REQUEST['link_id'])) : array_push($link_ids, $_REQUEST['link_id']); endif;
917 544
918 545 if (isset($GLOBALS['fwp_post']['confirm']) and $GLOBALS['fwp_post']['confirm']=='Delete'):
919 - foreach ($GLOBALS['fwp_post']['link_action'] as $link_id => $what) :
546 + if (isset($GLOBALS['fwp_post']['link_action']) and is_array($GLOBALS['fwp_post']['link_action'])) :
547 + $actions = $GLOBALS['fwp_post']['link_action'];
548 + else :
549 + $actions = array();
550 + endif;
551 +
552 + foreach ($actions as $link_id => $what) :
920 553 $do_it[$what][] = $link_id;
921 554 endforeach;
922 555
923 556 $alter = array();
@@ -1003,12 +636,12 @@
1003 636 <input type="hidden" name="confirm" value="Delete" />
1004 637
1005 638 <h2>Unsubscribe from Syndicated Links:</h2>
1006 639 <?php foreach ($targets as $link) :
1007 - $link_url = wp_specialchars($link->link_url, 1);
1008 - $link_name = wp_specialchars($link->link_name, 1);
1009 - $link_description = wp_specialchars($link->link_description, 'both');
1010 - $link_rss = wp_specialchars($link->link_rss, 'both');
640 + $link_url = esc_html($link->link_url);
641 + $link_name = esc_html($link->link_name);
642 + $link_description = esc_html($link->link_description);
643 + $link_rss = esc_html($link->link_rss);
1011 644 ?>
1012 645 <fieldset>
1013 646 <legend><?php echo $link_name; ?></legend>
1014 647 <table class="editform" width="100%" cellspacing="2" cellpadding="5">
@@ -1052,6 +685,7 @@
1052 685 return false; // Don't continue on to Syndicated Sites listing
1053 686 endif;
1054 687 }
1055 688
1056 - fwp_syndication_manage_page();
689 + $syndicationPage = new FeedWordPressSyndicationPage;
690 + $syndicationPage->display();
1057 691