PluginProbe
FeedWordPress / 2017.1020
FeedWordPress v2017.1020
trunk 0.8 0.9 0.91 0.95 0.96 0.97 0.98 0.981 0.99 0.991 0.992 0.993 2008.1030 2008.1101 2008.1105 2008.1214 2009.0612 2009.0613 2009.0618 2009.0707 2009.1111 2009.1112 2010.0127 2010.0528 All 65 releases
feedwordpress / feeds-page.php

feeds-page.php in FeedWordPress 2017.1020, at feeds-page.php

1,283 lines 46.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 require_once(dirname(__FILE__) . '/admin-ui.php');
3 require_once(dirname(__FILE__) . '/magpiemocklink.class.php');
4 require_once(dirname(__FILE__) . '/feedfinder.class.php');
5 require_once(dirname(__FILE__) . '/updatedpostscontrol.class.php');
6
7 class FeedWordPressFeedsPage extends FeedWordPressAdminPage {
8 var $HTTPStatusMessages = array (
9 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.',
10 201 => 'Created',
11 202 => 'Accepted',
12 203 => 'Non-Authoritative information',
13 204 => 'No Content',
14 205 => 'Reset Content',
15 206 => 'Partial Content',
16 300 => 'Multiple Choices',
17 301 => 'Moved Permanently',
18 302 => 'Found',
19 303 => 'See Other',
20 304 => 'Not Modified',
21 305 => 'Use Proxy',
22 307 => 'Temporary Redirect',
23 400 => 'Bad Request',
24 401 => 'Unauthorized. This URL probably needs a username and password for you to access it.',
25 402 => 'Payment Required',
26 403 => 'Forbidden. The URL is not made available for the machine that FeedWordPress is running on.',
27 404 => 'Not Found. There is nothing at this URL. Have you checked the address for typos?',
28 405 => 'Method Not Allowed',
29 406 => 'Not Acceptable',
30 407 => 'Proxy Authentication Required',
31 408 => 'Request Timeout',
32 409 => 'Conflict',
33 410 => 'Gone. This URL is no longer available on this server and no forwarding address is known.',
34 411 => 'Length Required',
35 412 => 'Precondition Failed',
36 413 => 'Request Entity Too Large',
37 414 => 'Request URI Too Long',
38 415 => 'Unsupported Media Type',
39 416 => 'Requested Range Not Satisfiable',
40 417 => 'Expectation Failed',
41 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.',
42 501 => 'Not Implemented',
43 502 => 'Bad Gateway',
44 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.',
45 504 => 'Gateway Timeout',
46 505 => 'HTTP Version Not Supported',
47 );
48 var $updatedPosts = NULL;
49
50 var $special_settings = array ( /* Regular expression syntax is OK here */
51 'cats',
52 'cat_split',
53 'fetch timeout',
54 'freeze updates',
55 'hardcode name',
56 'hardcode url',
57 'hardcode description',
58 'hardcode categories', /* Deprecated */
59 'comment status',
60 'terms',
61 'map authors',
62 'munge permalink',
63 'ping status',
64 'post status',
65 'postmeta',
66 'query parameters',
67 'resolve relative',
68 'syndicated post type',
69 'tags',
70 'unfamiliar author',
71 'unfamliar categories', /* Deprecated */
72 'unfamiliar category',
73 'unfamiliar post_tag',
74 'add/.*',
75 'update/.*',
76 'feed/.*',
77 'link/.*',
78 'match/.*',
79 );
80
81 /**
82 * Constructs the Feeds page object
83 *
84 * @param mixed $link An object of class {@link SyndicatedLink} if created for one feed's settings, NULL if created for global default settings
85 */
86 public function __construct( $link = -1 ) {
87 if (is_numeric($link) and -1 == $link) :
88 $link = $this->submitted_link();
89 endif;
90
91 parent::__construct('feedwordpressfeeds', $link);
92
93 $this->dispatch = 'feedwordpress_admin_page_feeds';
94 $this->pagenames = array(
95 'default' => 'Feeds',
96 'settings-update' => 'Syndicated feed',
97 'open-sheet' => 'Feed and Update',
98 );
99 $this->filename = __FILE__;
100 $this->updatedPosts = new UpdatedPostsControl($this);
101
102 $this->special_settings = apply_filters('syndicated_feed_special_settings', $this->special_settings, $this);
103 } /* FeedWordPressFeedsPage constructor */
104
105 function display () {
106 global $fwp_post;
107 global $post_source;
108
109 $this->boxes_by_methods = array(
110 'feed_information_box' => __('Feed Information'),
111 'global_feeds_box' => __('Update Scheduling'),
112 'updated_posts_box' => __('Updated Posts'),
113 'custom_settings_box' => __('Custom Feed Settings (for use in templates)'),
114 'advanced_settings_box' => __('Advanced Settings'),
115 );
116 if ($this->for_default_settings()) :
117 unset($this->boxes_by_methods['custom_settings_box']);
118 endif;
119
120 // Allow overriding of normal source for FeedFinder, which may
121 // be called from multiple points.
122 if (isset($post_source) and !is_null($post_source)) :
123 $source = $post_source;
124 else :
125 $source = $this->dispatch;
126 endif;
127
128 if (isset($_REQUEST['feedfinder'])
129 or (isset($_REQUEST['action']) and $_REQUEST['action']=='feedfinder')
130 or (isset($_REQUEST['action']) and $_REQUEST['action']==FWP_SYNDICATE_NEW)) :
131 // If this is a POST, validate source and user credentials
132 FeedWordPressCompatibility::validate_http_request(/*action=*/ $source, /*capability=*/ 'manage_links');
133
134 return $this->display_feedfinder(); // re-route to Feed Finder page
135 endif;
136
137 parent::display();
138 return false; // Don't continue
139 } /* FeedWordPressFeedsPage::display() */
140
141 function ajax_interface_js () {
142 parent::ajax_interface_js();
143 ?>
144
145 jQuery(document).ready( function () {
146 contextual_appearance('automatic-updates-selector', 'cron-job-explanation', null, 'no');
147 contextual_appearance('time-limit', 'time-limit-box', null, 'yes');
148 contextual_appearance('use-default-update-window-no', 'update-scheduling-note', null, null, 'block', true);
149 jQuery('#use-default-update-window-yes, #use-default-update-window-no').click( function () {
150 contextual_appearance('use-default-update-window-no', 'update-scheduling-note', null, null, 'block', true);
151 } );
152
153 var els = ['name', 'description', 'url'];
154 for (var i = 0; i < els.length; i++) {
155 contextual_appearance(
156 /*item=*/ 'basics-hardcode-'+els[i],
157 /*appear=*/ 'basics-'+els[i]+'-view',
158 /*disappear=*/ 'basics-'+els[i]+'-edit',
159 /*value=*/ 'no',
160 /*visibleStyle=*/ 'block',
161 /*checkbox=*/ true
162 );
163 } /* for */
164 } );
165
166 <?php
167 }
168
169 /*static*/ function updated_posts_box ($page, $box = NULL) {
170 ?>
171 <table class="edit-form">
172 <?php $page->updatedPosts->display(); ?>
173 </table>
174 <?php
175 } /* FeedWordPressFeedsPage::updated_posts_box() */
176
177 /*static*/ function global_feeds_box ($page, $box = NULL) {
178 global $feedwordpress;
179 $automatic_updates = $feedwordpress->automatic_update_hook(array('setting only' => true));
180 $update_time_limit = (int) get_option('feedwordpress_update_time_limit');
181
182 // Hey, ho, let's go...
183 ?>
184
185 <table class="edit-form">
186 <?php if ($page->for_default_settings()) : ?>
187
188 <tr>
189 <th scope="row">Updates:</th>
190 <td><select id="automatic-updates-selector" name="automatic_updates" size="1" onchange="contextual_appearance('automatic-updates-selector', 'cron-job-explanation', null, 'no');">
191 <option value="shutdown"<?php echo ($automatic_updates=='shutdown')?' selected="selected"':''; ?>>automatically check for updates after pages load</option>
192 <option value="init"<?php echo ($automatic_updates=='init')?' selected="selected"':''; ?>>automatically check for updates before pages load</option>
193 <option value="no"<?php echo (!$automatic_updates)?' selected="selected"':''; ?>>cron job or manual updates</option>
194 </select>
195 <div id="cron-job-explanation" class="setting-description">
196 <p><?php
197 // Do we have shell_exec() available from here, or is it disabled for security reasons?
198 // If it's available, use it to execute `which` to try to get a realistic path to curl,
199 // or to wget. If everything fails or shell_exec() isn't available, then just make
200 // up something for the sake of example.
201 $shellExecAvailable = (is_callable('shell_exec') && false === stripos(ini_get('disable_functions'), 'shell_exec'));
202
203 if ($shellExecAvailable) :
204 $path = `which curl`; $opts = '--silent %s';
205 endif;
206
207 if ($shellExecAvailable and (is_null($path) or strlen(trim($path))==0)) :
208 $path = `which wget`; $opts = '-q -O - %s';
209 endif;
210
211 if (is_null($path) or strlen(trim($path))==0) :
212 $path = '/usr/bin/curl'; $opts = '--silent %s';
213 endif;
214
215 $path = preg_replace('/\n+$/', '', $path);
216
217 $cmdline = $path . ' ' . sprintf($opts, get_bloginfo('url').'?update_feedwordpress=1');
218
219 ?>If you want to use a cron job,
220 you can perform scheduled updates by sending regularly-scheduled
221 requests to <a href="<?php bloginfo('url'); ?>?update_feedwordpress=1"><code><?php bloginfo('url') ?>?update_feedwordpress=1</code></a>
222 For example, inserting the following line in your crontab:</p>
223 <pre style="font-size: 0.80em"><code>*/10 * * * * <?php print esc_html($cmdline); ?></code></pre>
224 <p class="setting-description">will check in every 10 minutes
225 and check for updates on any feeds that are ready to be polled for updates.</p>
226 </div>
227 </td>
228 </tr>
229
230 <?php else : /* Feed-specific settings */ ?>
231
232 <tr>
233 <th scope="row"><?php _e('Last update') ?>:</th>
234 <td><?php
235 if (isset($page->link->settings['update/last'])) :
236 echo fwp_time_elapsed($page->link->settings['update/last'])." ";
237 else :
238 echo " none yet";
239 endif;
240 ?></td></tr>
241
242 <tr><th><?php _e('Next update') ?>:</th>
243 <td><?php
244 $holdem = (isset($page->link->settings['update/hold']) ? $page->link->settings['update/hold'] : 'scheduled');
245 ?>
246 <select name="update_schedule">
247 <option value="scheduled"<?php echo ($holdem=='scheduled')?' selected="selected"':''; ?>>update on schedule <?php
248 echo " (";
249 if (isset($page->link->settings['update/ttl']) and is_numeric($page->link->settings['update/ttl'])) :
250 if (isset($page->link->settings['update/timed']) and $page->link->settings['update/timed']=='automatically') :
251 echo 'next: ';
252 $next = $page->link->settings['update/last'] + ((int) $page->link->settings['update/ttl'] * 60);
253 if (strftime('%x', time()) != strftime('%x', $next)) :
254 echo strftime('%x', $next)." ";
255 endif;
256 echo strftime('%X', $page->link->settings['update/last']+((int) $page->link->settings['update/ttl']*60));
257 else :
258 echo "every ".$page->link->settings['update/ttl']." minute".(($page->link->settings['update/ttl']!=1)?"s":"");
259 endif;
260 else:
261 echo "next scheduled update";
262 endif;
263 echo ")";
264 ?></option>
265 <option value="next"<?php echo ($holdem=='next')?' selected="selected"':''; ?>>update ASAP</option>
266 <option value="ping"<?php echo ($holdem=='ping')?' selected="selected"':''; ?>>update only when pinged</option>
267 </select></td></tr>
268
269 <?php endif; ?>
270
271 <tr>
272 <th scope="row"><?php print __('Update scheduling:') ?></th>
273 <td><p style="margin-top:0px">How long should FeedWordPress wait between updates before it considers this feed ready to be polled for updates again?</p>
274 <?php
275
276 $this->setting_radio_control(
277 'update/window', 'update_window',
278 array($this, 'update_window_edit_box'),
279 array(
280 'global-setting-default' => DEFAULT_UPDATE_PERIOD,
281 'default-input-name' => 'use_default_update_window',
282 'default-input-id' => 'use-default-update-window-yes',
283 'default-input-id-no' => 'use-default-update-window-no',
284 'labels' => array($this, 'update_window_currently'),
285 )
286 );
287 ?></td>
288 </tr>
289
290 <tr>
291 <th scope="row"><?php print __('Minimum Interval:'); ?></th>
292 <td><p style="margin-top:0px">Some feeds include standard elements that
293 request a specific update schedule. If the interval requested by the
294 feed provider is <em>longer</em> than FeedWordPress's normal scheduling,
295 FeedWordPress will always respect their request to slow down. But what
296 should it do if the update interval is <em>shorter</em> than the schedule set above?</p>
297 <?php
298 $this->setting_radio_control(
299 'update/minimum', 'update_minimum',
300 /*options=*/ array(
301 'no' => 'Speed up and accept the interval from the feed provider',
302 'yes' => 'Keep pace and use the longer scheduling from FeedWordPress',
303 ),
304 /*params=*/ array(
305 'setting-default' => NULL,
306 'global-setting-default' => 'no',
307 'default-input-value' => 'default',
308 )
309 );
310 ?>
311 </td>
312 </tr>
313
314 <?php if ($this->for_default_settings()) : ?>
315
316 <tr>
317 <th scope="row"><?php print __('Time limit on updates'); ?>:</th>
318 <td><select id="time-limit" name="update_time_limit" size="1" onchange="contextual_appearance('time-limit', 'time-limit-box', null, 'yes');">
319 <option value="no"<?php echo ($update_time_limit>0)?'':' selected="selected"'; ?>>no time limit on updates</option>
320 <option value="yes"<?php echo ($update_time_limit>0)?' selected="selected"':''; ?>>limit updates to no more than...</option>
321 </select>
322 <span id="time-limit-box"><label><input type="text" name="time_limit_seconds" value="<?php print $update_time_limit; ?>" size="5" /> seconds</label></span>
323 </tr>
324
325 <?php endif; ?>
326
327 </table>
328
329 <?php
330 } /* FeedWordPressFeedsPage::global_feeds_box() */
331
332 function update_window_edit_box ($updateWindow, $defaulted, $params) {
333 if (!is_numeric($updateWindow)) :
334 $updateWindow = DEFAULT_UPDATE_PERIOD;
335 endif;
336 ?>
337 <p>Wait <input type="text" name="update_window" value="<?php print $updateWindow; ?>" size="4" /> minutes between polling.</p>
338 <div class="setting-description" id="update-scheduling-note">
339 <p<?php if ($updateWindow<50) : ?> style="color: white; background-color: #703030; padding: 1.0em;"<?php endif; ?>><strong>Recommendation.</strong> Unless you are positive that you have the webmaster's permission, you generally should not set FeedWordPress to poll feeds more frequently than once every 60 minutes. Many webmasters consider more frequent automated polling to be abusive, and may complain to your web host, or ban your IP address, as retaliation for hammering their servers too hard.</p>
340 <p><strong>Note.</strong> This is a default setting that FeedWordPress uses to schedule updates when the feed does not provide any scheduling requests. If this feed does provide update scheduling information (through elements such as <code>&lt;rss:ttl&gt;</code> or <code>&lt;sy:updateFrequency&gt;</code>), FeedWordPress will respect the feed's request.</p>
341 </div>
342 <?php
343 } /* FeedWordPressFeedsPage::update_window_edit_box () */
344
345 function update_window_currently ($updateWindow, $defaulted, $params) {
346 $updateWindow = (int) $updateWindow;
347 if (1==$updateWindow) :
348 $caption = 'wait %d minute between polling';
349 else :
350 $caption = 'wait %d minutes between polling';
351 endif;
352 return sprintf(__($caption), $updateWindow);
353 } /* FeedWordPressFeedsPage::update_window_currently () */
354
355 function fetch_timeout_setting ($setting, $defaulted, $params) {
356 $timeout = intval($this->setting('fetch timeout', FEEDWORDPRESS_FETCH_TIMEOUT_DEFAULT));
357
358 if ($this->for_feed_settings()) :
359 $article = 'this';
360 else :
361 $article = 'a';
362 endif;
363 ?>
364 <p>Wait no more than
365 than <input name="fetch_timeout" type="number" min="0" size="3" value="<?php print $timeout; ?>" />
366 second(s) when trying to fetch <?php print $article; ?> feed to check for updates.</p>
367 <p>If <?php print $article; ?> source's web server does not respond before time runs
368 out, FeedWordPress will skip over the source and try again during
369 the next update cycle.</p>
370 <?php
371 }
372 function fetch_timeout_setting_value ($setting, $defaulted, $params) {
373 print number_format(intval($setting)) . " " . (($setting==1) ? "second" : "seconds");
374 }
375
376 function advanced_settings_box ($page, $box = NULL) {
377 ?>
378 <table class="edit-form">
379 <tr>
380 <th>Fetch Timeout:</th>
381 <td>
382 <?php
383 $this->setting_radio_control(
384 'fetch timeout', 'fetch_timeout',
385 array($this, 'fetch_timeout_setting'),
386 array(
387 'global-setting-default' => FEEDWORDPRESS_FETCH_TIMEOUT_DEFAULT,
388 'input-name' => 'fetch_timeout',
389 'default-input-name' => 'fetch_timeout_default',
390 'labels' => array($this, 'fetch_timeout_setting_value'),
391 )
392 );
393 ?>
394 </td>
395 </tr>
396 <tr>
397 <th>Feed Update Type:</th>
398 <td><?php
399 $this->setting_radio_control('update_incremental', 'update_incremental',
400 /*options=*/ array(
401 'incremental' => '<strong>Incremental.</strong> When items no longer appear on the feed, keep them in the WordPress posts table.',
402 'complete' => '<strong>Complete.</strong> When items no longer appear on the feed, they are obsolete; retire them from the WordPress posts table.',
403 ),
404 /*params=*/ array(
405 'setting-default' => NULL,
406 'global-setting-default' => 'incremental',
407 'default-input-value' => 'default',
408 )
409 ); ?></td>
410 </tr>
411 <tr>
412 <th>Allow Feeds to Delete Posts:</th>
413 <td><?php
414 $this->setting_radio_control('tombstones', 'tombstones',
415 /*options=*/ array(
416 'yes' => 'Yes. If a feed indicates that one of its posts has been deleted, delete the local copy syndicated to this website.',
417 'no' => 'No. Even if a feed indicates that one of its posts has been deleted, retain the local copy on this website.',
418 ),
419 /*params=*/ array(
420 'setting-default' => NULL,
421 'global-setting-default' => 'yes',
422 'default-input-value' => 'default',
423 )
424 ); ?></td>
425 </tr>
426 </table>
427 <?php
428 } /* FeedWordPressFeedsPage::advanced_settings_box () */
429
430 function display_authentication_credentials_box ($params = array()) {
431 static $count = 0;
432
433 $params = wp_parse_args($params, array(
434 'username' => NULL,
435 'password' => NULL,
436 'method' => '-',
437 ));
438
439 // Equivalents
440 if (is_null($params['method'])) : $params['method'] = '-'; endif;
441
442 $count++;
443 $slug = ($count > 1 ? '-'.$count : '');
444
445 global $feedwordpress;
446 $authMethods = apply_filters(
447 'feedwordpress_http_auth_methods',
448 $feedwordpress->httpauth->methods_available()
449 );
450
451 if (count($authMethods) > 1) : /* More than '-' */
452 ?>
453 <div class="link-rss-authentication" id="link-rss-authentication<?php print $slug; ?>">
454 <table>
455 <tbody>
456 <tr class="link-rss-authentication-credentials" id="link-rss-authentication-credentials<?php print $slug; ?>">
457 <td><label>user: <input type="text" name="link_rss_username"
458 value="<?php print esc_attr($params['username']); ?>" size="16"
459 placeholder="username to access this feed" /></label></td>
460 <td><label>pass: <input type="text" name="link_rss_password"
461 value="<?php print esc_attr($params['password']); ?>" size="16"
462 placeholder="password to access this feed" /></label></td>
463 <td class="link-rss-authentication-method" id="link-rss-authentication-method<?php print $slug; ?>"><label>method: <select class="link-rss-auth-method" id="link-rss-auth-method" name="link_rss_auth_method" size="1">
464 <?php foreach ($authMethods as $value => $label) : ?>
465 <option value="<?php print esc_attr($value); ?>"<?php
466 if ($value == $params['method']) : ?> selected="selected"<?php
467 endif; ?>><?php print esc_html($label); ?></option>
468 <?php endforeach; ?>
469 </select></label></td>
470 </tr>
471 </tbody>
472 </table>
473 </div>
474
475 <script type="text/javascript">
476 jQuery('<td><a class="add-remove remove-it" id="link-rss-userpass-remove<?php print $slug; ?>" href="#"><span class="x">(X)</span> Remove</a></td>')
477 .appendTo('#link-rss-authentication-credentials<?php print $slug; ?>')
478 .click( feedAuthenticationMethodUnPress );
479 jQuery('#link-rss-auth-method<?php print $slug; ?>').change( feedAuthenticationMethod );
480 feedAuthenticationMethod({
481 init: true,
482 node: jQuery('#link-rss-authentication<?php print $slug; ?>') });
483 </script>
484
485 <?php
486 endif;
487 }
488
489 function feed_information_box ($page, $box = NULL) {
490 global $wpdb;
491 $link_rss_params = maybe_unserialize($page->setting('query parameters', ''));
492 if (!is_array($link_rss_params)) :
493 $link_rss_params = array();
494 endif;
495
496 if ($page->for_feed_settings()) :
497 $info['name'] = esc_html($page->link->link->link_name);
498 $info['description'] = esc_html($page->link->link->link_description);
499 $info['url'] = esc_html($page->link->link->link_url);
500 $rss_url = $page->link->link->link_rss;
501
502 $hardcode['name'] = $page->link->hardcode('name');
503 $hardcode['description'] = $page->link->hardcode('description');
504 $hardcode['url'] = $page->link->hardcode('url');
505 else :
506 $cat_id = FeedWordPress::link_category_id();
507
508 $params = array();
509 if (FeedWordPressCompatibility::test_version(FWP_SCHEMA_USES_ARGS_TAXONOMY)) :
510 $params['taxonomy'] = 'link_category';
511 else :
512 $params['type'] = 'link';
513 endif;
514 $params['hide_empty'] = false;
515 $results = get_categories($params);
516
517 // Guarantee that the Contributors category will be in the drop-down chooser, even if it is empty.
518 $found_link_category_id = false;
519 foreach ($results as $row) :
520 // Normalize case
521 if (!isset($row->cat_id)) : $row->cat_id = $row->cat_ID; endif;
522
523 if ($row->cat_id == $cat_id) : $found_link_category_id = true; endif;
524 endforeach;
525
526 if (!$found_link_category_id) :
527 $results[] = get_category($cat_id);
528 endif;
529
530 $info = array();
531 $rss_url = null;
532
533 $hardcode['name'] = get_option('feedwordpress_hardcode_name');
534 $hardcode['description'] = get_option('feedwordpress_hardcode_description');
535 $hardcode['url'] = get_option('feedwordpress_hardcode_url');
536 endif;
537
538 $hideAuth = false;
539
540 $username = $this->setting('http username', NULL);
541
542 if (is_null($username)) :
543 $username = '';
544 $hideAuth = true;
545 endif;
546
547 $password = $this->setting('http password', NULL);
548 if (is_null($password)) :
549 $password = '';
550 endif;
551
552 $auth = $this->setting('http auth method', NULL);
553
554 global $feedwordpress;
555
556 if (is_null($auth) or (strlen($auth)==0)) :
557 $auth = '-';
558 $hideAuth = true;
559 endif;
560
561 // Hey ho, let's go
562
563 ?>
564 <table class="edit-form">
565
566 <?php if ($page->for_feed_settings()) : ?>
567
568 <tr>
569 <th scope="row"><?php _e('Feed URL:') ?></th>
570 <td><a href="<?php echo esc_html($rss_url); ?>"><?php echo esc_html($rss_url); ?></a>
571 (<a href="<?php echo FEEDVALIDATOR_URI; ?>?url=<?php echo urlencode($rss_url); ?>"
572 title="Check feed &lt;<?php echo esc_html($rss_url); ?>&gt; for validity">validate</a>)
573 <input type="submit" name="feedfinder" value="switch &rarr;" style="font-size:smaller" />
574
575 <?php $this->display_authentication_credentials_box(array(
576 'username' => $username,
577 'password' => $password,
578 'method' => $auth,
579 )); ?>
580
581 <table id="link-rss-params">
582 <tbody>
583 <?php
584 $link_rss_params['new'] = array('', '');
585 $i = 0;
586 foreach ($link_rss_params as $index => $pair) :
587 ?>
588 <tr class="link-rss-params-row" id="link-rss-params-<?php print $index; ?>">
589 <td><label>Parameter: <input type="text" class="link_params_key"
590 name="link_rss_params_key[<?php print $index; ?>]" value="<?php print esc_html($pair[0]); ?>"
591 size="5" style="width: 5em" placeholder="name" /></label></td>
592 <td class="link-rss-params-value-cell"><label class="link_params_value_label">= <input type="text" class="link_params_value"
593 name="link_rss_params_value[<?php print $index; ?>]" value="<?php print esc_html($pair[1]); ?>"
594 size="8" placeholder="value" /></label></td>
595 </tr>
596 <?php
597 $i++;
598 endforeach;
599 ?>
600 </tbody>
601 </table>
602
603 <div><input type="hidden" id="link-rss-params-num" name="link_rss_params_num" value="<?php print $i; ?>" /></div>
604
605 <script type="text/javascript">
606 function linkParamsRowRemove (element) {
607 jQuery(element).closest('tr').fadeOut('slow', function () {
608 jQuery(this).remove();
609 } );
610 }
611
612 jQuery('<td><a href="#" class="add-remove link-rss-params-remove"><span class="x">(X)</span> Remove</a></td>').insertAfter('.link-rss-params-value-cell');
613
614 jQuery('#link-rss-params-new').hide();
615 jQuery('<a class="add-remove" id="link-rss-params-add" href="#">+ Add a query parameter</a>').insertAfter('#link-rss-params');
616 jQuery('#link-rss-params-add').click( function () {
617 var next = jQuery('#link-rss-params-num').val();
618 var newRow = jQuery('#link-rss-params-new').clone().attr('id', 'link-rss-params-'+next);
619 newRow.find('.link_params_key').attr('name', 'link_rss_params_key['+next+']');
620 newRow.find('.link_params_value').attr('name', 'link_rss_params_value['+next+']');
621
622 newRow.find('.link-rss-params-remove').click( function () {
623 linkParamsRowRemove(this);
624 return false;
625 } );
626
627 newRow.appendTo('#link-rss-params');
628 newRow.show();
629
630 // Update counter for next row.
631 next++;
632 jQuery('#link-rss-params-num').val(next);
633
634 return false;
635 } );
636 jQuery('.link-rss-params-remove').click( function () {
637 linkParamsRowRemove(this);
638 return false;
639 } );
640 </script>
641 </td>
642 </tr>
643
644 <?php
645 $rows = array(
646 "name" => __('Link Name'),
647 "description" => __('Short Description'),
648 "url" => __('Homepage'),
649 );
650 foreach ($rows as $what => $label) :
651 ?>
652 <tr>
653 <th scope="row"><?php print $label ?></th>
654 <td>
655 <div id="basics-<?php print $what; ?>-edit"><input type="text" name="link<?php print $what; ?>"
656 value="<?php echo $info[$what]; ?>" style="width: 95%" /></div>
657 <div id="basics-<?php print $what; ?>-view">
658 <?php if ($what=='url') : ?><a href="<?php print $info[$what]; ?>"><?php else : ?><strong><?php endif; ?>
659 <?php print (strlen(trim($info[$what])) > 0) ? $info[$what] : '(none provided)'; ?>
660 <?php if ($what=='url') : ?></a><?php else : ?></strong><?php endif; ?></div>
661
662 <div>
663 <label><input id="basics-hardcode-<?php print $what; ?>"
664 type="radio" name="hardcode_<?php print $what; ?>" value="no"
665 <?php echo (($hardcode[$what]=='yes')?'':' checked="checked"');?>
666 onchange="contextual_appearance('basics-hardcode-<?php print $what; ?>', 'basics-<?php print $what; ?>-view', 'basics-<?php print $what; ?>-edit', 'no', 'block', /*checkbox=*/ true)"
667 /> Update automatically from feed</label>
668 <label><input type="radio" name="hardcode_<?php print $what; ?>" value="yes"
669 <?php echo (($hardcode[$what]!='yes')?'':' checked="checked"');?>
670 onchange="contextual_appearance('basics-hardcode-<?php print $what; ?>', 'basics-<?php print $what; ?>-view', 'basics-<?php print $what; ?>-edit', 'no', 'block', /*checkbox=*/ true)"
671 /> Edit manually</label>
672 </div>
673 </td>
674 </tr>
675 <?php
676 endforeach;
677 ?>
678
679 <?php else : ?>
680
681 <tr>
682 <th scope="row">Syndicated Link category:</th>
683 <td><p><select name="syndication_category" size="1">
684 <?php
685 foreach ($results as $row) :
686 // Normalize case
687 if (!isset($row->cat_id)) : $row->cat_id = $row->cat_ID; endif;
688
689 echo "\n\t<option value=\"$row->cat_id\"";
690 if ($row->cat_id == $cat_id) :
691 echo " selected='selected'";
692 endif;
693 echo ">$row->cat_id: ".esc_html($row->cat_name);
694 echo "</option>\n";
695 endforeach;
696 ?></select></p>
697 <p class="setting-description">FeedWordPress will syndicate the
698 links placed under this link category.</p>
699 </td>
700 </tr>
701
702 <tr>
703 <th scope="row">Link Names:</th>
704 <td><label><input type="checkbox" name="hardcode_name" value="no"<?php echo (($hardcode['name']=='yes')?'':' checked="checked"');?>/> Update contributor titles automatically when the feed title changes</label></td>
705 </tr>
706
707 <tr>
708 <th scope="row">Short descriptions:</th>
709 <td><label><input type="checkbox" name="hardcode_description" value="no"<?php echo (($hardcode['description']=='yes')?'':' checked="checked"');?>/> Update contributor descriptions automatically when the feed tagline changes</label></td>
710 </tr>
711
712 <tr>
713 <th scope="row">Homepages:</th>
714 <td><label><input type="checkbox" name="hardcode_url" value="no"<?php echo (($hardcode['url']=='yes')?'':' checked="checked"');?>/> Update contributor homepages automatically when the feed link changes</label></td>
715 </tr>
716
717 <?php endif; ?>
718
719 </table>
720 <?php
721 } /* FeedWordPressFeedsPage::feed_information_box() */
722
723 function custom_settings_box ($page, $box = NULL) {
724 $postsSettings = $this->admin_page_href('posts-page.php', array(), $page->link);
725 ?>
726 <p class="setting-description">These custom settings are special fields for the <strong>feed</strong> you are
727 syndicating, to be retrieved in templates using the <code>get_feed_meta()</code> function. They do not create
728 custom fields on syndicated <strong>posts</strong>. If you want to create custom fields that are applied to each
729 individual post from this feed, set up the settings in <a href="<?php print $postsSettings; ?>">Syndicated Posts</a>.</p>
730
731 <div id="postcustomstuff">
732 <table id="meta-list" cellpadding="3">
733 <tr>
734 <th>Key</th>
735 <th>Value</th>
736 <th>Action</th>
737 </tr>
738
739 <?php
740 $i = 0;
741 foreach ($page->link->settings as $key => $value) :
742 if (!preg_match("\007^((".implode(')|(', $page->special_settings)."))$\007i", $key)) :
743 ?>
744 <tr style="vertical-align:top">
745 <th width="30%" scope="row"><input type="hidden" name="notes[<?php echo $i; ?>][key0]" value="<?php echo esc_html($key); ?>" />
746 <input id="notes-<?php echo $i; ?>-key" name="notes[<?php echo $i; ?>][key1]" value="<?php echo esc_html($key); ?>" /></th>
747 <td width="60%"><textarea rows="2" cols="40" id="notes-<?php echo $i; ?>-value" name="notes[<?php echo $i; ?>][value]"><?php echo esc_html($value); ?></textarea></td>
748 <td width="10%"><select name="notes[<?php echo $i; ?>][action]">
749 <option value="update">save changes</option>
750 <option value="delete">delete this setting</option>
751 </select></td>
752 </tr>
753 <?php
754 $i++;
755 endif;
756 endforeach;
757 ?>
758 <tr>
759 <th scope="row"><input type="text" size="10" name="notes[<?php echo $i; ?>][key1]" value="" /></th>
760 <td><textarea name="notes[<?php echo $i; ?>][value]" rows="2" cols="40"></textarea></td>
761 <td><em>add new setting...</em><input type="hidden" name="notes[<?php echo $i; ?>][action]" value="update" /></td>
762 </tr>
763 </table>
764 </div> <!-- id="postcustomstuff" -->
765 <?php
766 }
767
768 function url_for_401 ($err) {
769 $ret = NULL;
770 if (is_wp_error($err)) :
771 if ($err->get_error_code()=='http_request_failed') :
772 $data = $err->get_error_data('http_request_failed');
773
774 if (is_array($data) and isset($data['status'])) :
775 if (401==$data['status']) :
776 $ret = $data['uri'];
777 endif;
778 endif;
779 endif;
780 endif;
781 return $ret;
782 }
783
784 function display_feedfinder () {
785 global $wpdb;
786
787 $lookup = (isset($_REQUEST['lookup']) ? $_REQUEST['lookup'] : NULL);
788
789 $auth = MyPHP::request('link_rss_auth_method');
790 $username = MyPHP::request('link_rss_username');
791 $password = MyPHP::request('link_rss_password');
792 $credentials = array(
793 "authentication" => $auth,
794 "username" => $username,
795 "password" => $password,
796 );
797
798 $feeds = array(); $feedSwitch = false; $current = null;
799 if ($this->for_feed_settings()) : // Existing feed?
800 $feedSwitch = true;
801 if (is_null($lookup)) :
802 // Switch Feed without a specific feed yet suggested
803 // Go to the human-readable homepage to look for
804 // auto-detection links
805
806 $lookup = $this->link->link->link_url;
807 $auth = $this->link->setting('http auth method');
808 $username = $this->link->setting('http username');
809 $password = $this->link->setting('http password');
810
811 // Guarantee that you at least have the option to
812 // stick with what works.
813 $current = $this->link->link->link_rss;
814 $feeds[] = $current;
815 endif;
816 $name = esc_html($this->link->link->link_name);
817 else: // Or a new subscription to add?
818 $name = "Subscribe to <code>".esc_html(feedwordpress_display_url($lookup))."</code>";
819 endif;
820 ?>
821 <div class="wrap" id="feed-finder">
822 <h2>Feed Finder: <?php echo $name; ?></h2>
823
824 <?php
825 if ($feedSwitch) :
826 $this->display_alt_feed_box($lookup);
827 endif;
828
829 $finder = array();
830 if (!is_null($current)) :
831 $finder[$current] = new FeedFinder($current);
832 endif;
833 $finder[$lookup] = new FeedFinder($lookup);
834
835 foreach ($finder as $url => $ff) :
836 $feeds = array_merge($feeds, $ff->find(
837 /*url=*/ NULL,
838 /*params=*/ $credentials));
839 endforeach;
840
841 $feeds = array_values( // Renumber from 0..(N-1)
842 $feeds
843 );
844
845 // Allow for some simple FeedFinder results filtering
846 $feeds = apply_filters(
847 'feedwordpress_feedfinder_results',
848 $feeds,
849 array(
850 "url" => $lookup,
851 "auth" => $auth,
852 "username" => $username,
853 "password" => $password,
854 "finder" => $finder,
855 ),
856 $this
857 );
858
859 if (count($feeds) > 0):
860 if ($feedSwitch) :
861 ?>
862 <h3>Feeds Found</h3>
863 <?php
864 endif;
865
866 if (count($feeds) > 1) :
867 $option_template = 'Option %d: ';
868 $form_class = ' class="multi"';
869 ?>
870 <p><strong>This web page provides at least <?php print count($feeds); ?> different feeds.</strong> These feeds may provide the same information
871 in different formats, or may track different items. (You can check the Feed Information and the
872 Sample Item for each feed to get an idea of what the feed provides.) Please select the feed that you'd like to subscribe to.</p>
873 <?php
874 else :
875 $option_template = '';
876 $form_class = '';
877 endif;
878
879 global $fwp_credentials;
880
881 foreach ($feeds as $key => $f):
882 $ofc = $fwp_credentials;
883 $fwp_credentials = $credentials; // Set
884 $pie = FeedWordPress::fetch($f, array("cache" => false));
885 $fwp_credentials = $ofc; // Re-Set
886
887 $rss = (is_wp_error($pie) ? $pie : new MagpieFromSimplePie($pie));
888
889 if ($this->url_for_401($pie)) :
890 $this->display_alt_feed_box($lookup, array(
891 "err" => $pie,
892 "auth" => $auth,
893 "username" => $username,
894 "password" => $password
895 ));
896 continue;
897 endif;
898
899 if ($rss and !is_wp_error($rss)):
900 $feed_link = (isset($rss->channel['link'])?$rss->channel['link']:'');
901 $feed_title = (isset($rss->channel['title'])?$rss->channel['title']:$feed_link);
902 $feed_type = ($rss->feed_type ? $rss->feed_type : 'Unknown');
903 $feed_version_template = '%.1f';
904 $feed_version = $rss->feed_version;
905 else :
906 // Give us some sucky defaults
907 $feed_title = feedwordpress_display_url($lookup);
908 $feed_link = $lookup;
909 $feed_type = 'Unknown';
910 $feed_version_template = '';
911 $feed_version = '';
912 endif;
913 ?>
914 <form<?php print $form_class; ?> action="<?php print $this->form_action('syndication.php'); ?>" method="post">
915 <div class="inside"><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_switchfeed'); ?>
916
917 <?php
918 $classes = array('feed-found'); $currentFeed = '';
919 if (!is_null($current) and $current==$f) :
920 $classes[] = 'current';
921 $currentFeed = ' (currently subscribed)';
922 endif;
923 if ($key%2) :
924 $classes[] = 'alt';
925 endif;
926 ?>
927 <fieldset class="<?php print implode(" ", $classes); ?>">
928 <legend><?php printf($option_template, ($key+1)); print $feed_type." "; printf($feed_version_template, $feed_version); ?> feed<?php print $currentFeed; ?></legend>
929
930 <?php
931 $this->stamp_link_id();
932
933 // No feed specified = add new feed; we
934 // need to pass along a starting title
935 // and homepage URL for the new Link.
936 if (!$this->for_feed_settings()):
937 ?>
938 <input type="hidden" name="feed_title" value="<?php echo esc_html($feed_title); ?>" />
939 <input type="hidden" name="feed_link" value="<?php echo esc_html($feed_link); ?>" />
940 <?php
941 endif;
942 ?>
943
944 <input type="hidden" name="feed" value="<?php echo esc_html($f); ?>" />
945 <input type="hidden" name="action" value="switchfeed" />
946
947 <div>
948 <div class="feed-sample">
949 <?php
950 $link = NULL;
951 $post = NULL;
952 if (!is_wp_error($rss) and count($rss->items) > 0):
953 // Prepare to display Sample Item
954 $link = new MagpieMockLink(array('simplepie' => $pie, 'magpie' => $rss), $f);
955 $post = new SyndicatedPost(array('simplepie' => $rss->originals[0], 'magpie' => $rss->items[0]), $link);
956 ?>
957 <h3>Sample Item</h3>
958 <ul>
959 <li><strong>Title:</strong> <a href="<?php echo $post->post['meta']['syndication_permalink']; ?>"><?php echo $post->post['post_title']; ?></a></li>
960 <li><strong>Date:</strong> <?php print date('d-M-y g:i:s a', $post->published()); ?></li>
961 </ul>
962 <div class="entry">
963 <?php print $post->post['post_content']; ?>
964 </div>
965 <?php
966 do_action('feedwordpress_feed_finder_sample_item', $f, $post, $link);
967 else:
968 if (is_wp_error($rss)) :
969 print '<div class="feed-problem">';
970 print "<h3>Problem:</h3>\n";
971 print "<p>FeedWordPress encountered the following error
972 when trying to retrieve this feed:</p>";
973 print '<p style="margin: 1.0em 3.0em"><code>'.$rss->get_error_message().'</code></p>';
974 print "<p>If you think this is a temporary problem, you can still force FeedWordPress to add the subscription. FeedWordPress will not be able to find any syndicated posts until this problem is resolved.</p>";
975 print "</div>";
976 endif;
977 ?>
978 <h3>No Items</h3>
979 <p>FeedWordPress found no posts on this feed.</p>
980 <?php
981 endif;
982 ?>
983 </div>
984
985 <div>
986 <h3>Feed Information</h3>
987 <ul>
988 <li><strong>Homepage:</strong> <a href="<?php echo $feed_link; ?>"><?php echo is_null($feed_title)?'<em>Unknown</em>':$feed_title; ?></a></li>
989 <li><strong>Feed URL:</strong> <a title="<?php echo esc_html($f); ?>" href="<?php echo esc_html($f); ?>"><?php echo esc_html(feedwordpress_display_url($f, 40, 10)); ?></a> (<a title="Check feed &lt;<?php echo esc_html($f); ?>&gt; for validity" href="http://feedvalidator.org/check.cgi?url=<?php echo urlencode($f); ?>">validate</a>)</li>
990 <li><strong>Encoding:</strong> <?php echo isset($rss->encoding)?esc_html($rss->encoding):"<em>Unknown</em>"; ?></li>
991 <li><strong>Description:</strong> <?php echo isset($rss->channel['description'])?esc_html($rss->channel['description']):"<em>Unknown</em>"; ?></li>
992 </ul>
993 <?php $this->display_authentication_credentials_box(array(
994 'username' => $username,
995 'password' => $password,
996 'method' => $auth,
997 )); ?>
998 <?php do_action('feedwordpress_feedfinder_form', $f, $post, $link, $this->for_feed_settings()); ?>
999 <div class="submit"><input type="submit" class="button-primary" name="Use" value="&laquo; Use this feed" />
1000 <input type="submit" class="button" name="Cancel" value="× Cancel" /></div>
1001 </div>
1002 </div>
1003 </fieldset>
1004 </div> <!-- class="inside" -->
1005 </form>
1006 <?php
1007 unset($link);
1008 unset($post);
1009 endforeach;
1010 else:
1011 foreach ($finder as $url => $ff) :
1012 $url = esc_html($url);
1013 print "<h3>Searched for feeds at ${url}</h3>\n";
1014 print "<p><strong>".__('Error').":</strong> ".__("FeedWordPress couldn't find any feeds at").' <code><a href="'.htmlspecialchars($lookup).'">'.htmlspecialchars($lookup).'</a></code>';
1015 print ". ".__('Try another URL').".</p>";
1016
1017 // Diagnostics
1018 print "<div class=\"updated\" style=\"margin-left: 3.0em; margin-right: 3.0em;\">\n";
1019 print "<h3>".__('Diagnostic information')."</h3>\n";
1020 if (!is_null($ff->error()) and strlen($ff->error()) > 0) :
1021 print "<h4>".__('HTTP request failure')."</h4>\n";
1022 print "<p>".$ff->error()."</p>\n";
1023 else :
1024 print "<h4>".__('HTTP request completed')."</h4>\n";
1025 print "<p><strong>Status ".$ff->status().":</strong> ".$this->HTTPStatusMessages[(int) $ff->status()]."</p>\n";
1026 endif;
1027
1028 // Do some more diagnostics if the API for it is available.
1029 if (function_exists('_wp_http_get_object')) :
1030 $httpObject = _wp_http_get_object();
1031
1032 if (is_callable(array($httpObject, '_getTransport'))) :
1033 $transports = $httpObject->_getTransport();
1034
1035 print "<h4>".__('HTTP Transports available').":</h4>\n";
1036 print "<ol>\n";
1037 print "<li>".implode("</li>\n<li>", array_map('get_class', $transports))."</li>\n";
1038 print "</ol>\n";
1039 elseif (is_callable(array($httpObject, '_get_first_available_transport'))) :
1040 $transport = $httpObject->_get_first_available_transport(
1041 array(),
1042 $url
1043 );
1044
1045 print "<h4>".__("HTTP Transport").":</h4>\n";
1046 print "<ol>\n";
1047 print "<li>".MyPHP::val($transport)."</li>\n";
1048 print "</ol>\n";
1049 endif;
1050
1051 print "</div>\n";
1052 endif;
1053 endforeach;
1054 endif;
1055
1056 if (!$feedSwitch) :
1057 $this->display_alt_feed_box($lookup, /*alt=*/ true);
1058 endif;
1059 ?>
1060 </div> <!-- class="wrap" -->
1061 <?php
1062 return false; // Don't continue
1063 } /* FeedWordPressFeedsPage::display_feedfinder() */
1064
1065 function display_alt_feed_box ($lookup, $params = false) {
1066 global $fwp_post;
1067
1068 if (is_bool($params)) :
1069 $params = array("alt" => $params);
1070 endif;
1071
1072 $params = wp_parse_args($params, array( // Defaults
1073 "alt" => false,
1074 "err" => NULL,
1075 "auth" => NULL,
1076 "password" => NULL,
1077 "username" => NULL,
1078 ));
1079 $alt = $params['alt'];
1080
1081 ?>
1082 <form action="<?php print $this->form_action('syndication.php'); ?>" method="post">
1083 <div class="inside"><?php
1084 FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds');
1085 ?>
1086 <fieldset class="alt"
1087 <?php if (!$alt): ?>style="margin: 1.0em 3.0em; font-size: smaller;"<?php endif; ?>>
1088 <legend><?php if ($alt) : ?>Alternative feeds<?php else: ?>Find feeds<?php endif; ?></legend>
1089 <?php if ($alt) : ?><h3>Use a different feed</h3><?php endif; ?>
1090 <?php if (is_wp_error($params['err'])) :
1091 ?>
1092 <p><em><strong>401 Not Authorized.</strong> This URL may require
1093 a username and password to access it.</em> You may want to add login
1094 credentials below and check it again.</p>
1095 <?php
1096 endif;
1097 ?>
1098 <div><label>Address:
1099 <input type="text" name="lookup" id="use-another-feed"
1100 placeholder="URL"
1101 <?php if (is_null($lookup)) : ?>
1102 value="URL"
1103 <?php else : ?>
1104 value="<?php print esc_html($lookup); ?>"
1105 <?php endif; ?>
1106 size="64" style="max-width: 80%" /></label>
1107 <?php if (is_null($lookup)) : ?>
1108 <?php FeedWordPressSettingsUI::magic_input_tip_js('use-another-feed'); ?>
1109 <?php endif; ?>
1110
1111 <?php $this->stamp_link_id('link_id'); ?>
1112 <input type="hidden" name="action" value="feedfinder" />
1113 <input type="submit" class="button<?php if ($alt): ?>-primary<?php endif; ?>" value="Check &raquo;" /></div>
1114
1115 <?php $this->display_authentication_credentials_box(array(
1116 'username' => $params['username'],
1117 'password' => $params['password'],
1118 'method' => $params['auth'],
1119 )); ?>
1120
1121 <p>This can be the address of a feed, or of a website. FeedWordPress
1122 will try to automatically detect any feeds associated with a
1123 website.</p>
1124 </div> <!-- class="inside" -->
1125 </fieldset></form>
1126
1127 <?php
1128 } /* FeedWordPressFeedsPage::display_alt_feed_box() */
1129
1130 function save_settings ($post) {
1131 if ($this->for_feed_settings()) :
1132
1133 if (isset($post['link_rss_params_key'])) :
1134 $qp = array();
1135 foreach ($post['link_rss_params_key'] as $index => $key) :
1136 if (strlen($key) > 0) :
1137 if (isset($post['link_rss_params_value'][$index])
1138 and strlen($post['link_rss_params_value'][$index])) :
1139 $value = $post['link_rss_params_value'][$index];
1140 $qp[] = array($key, $value);
1141 endif;
1142 endif;
1143 endforeach;
1144 $this->update_setting('query parameters', serialize($qp));
1145 endif;
1146
1147 // custom feed settings first
1148 foreach ($post['notes'] as $mn) :
1149 $mn['key0'] = (isset($mn['key0']) ? trim($mn['key0']) : NULL);
1150 $mn['key1'] = trim($mn['key1']);
1151 if (preg_match("\007^(("
1152 .implode(')|(',$this->special_settings)
1153 ."))$\007i",
1154 $mn['key1'])) :
1155 $mn['key1'] = 'user/'.$mn['key1'];
1156 endif;
1157
1158 if (strlen($mn['key0']) > 0) :
1159 unset($this->link->settings[$mn['key0']]); // out with the old
1160 endif;
1161
1162 if (($mn['action']=='update') and (strlen($mn['key1']) > 0)) :
1163 $this->link->settings[$mn['key1']] = $mn['value']; // in with the new
1164 endif;
1165 endforeach;
1166
1167 // now stuff through the web form
1168 // hardcoded feed info
1169
1170 foreach (array('name', 'description', 'url') as $what) :
1171 // We have a checkbox for "No," so if it's unchecked, mark as "Yes."
1172 $this->link->settings["hardcode {$what}"] = (isset($post["hardcode_{$what}"]) ? $post["hardcode_{$what}"] : 'yes');
1173 if (FeedWordPress::affirmative($this->link->settings, "hardcode {$what}")) :
1174 $this->link->link->{'link_'.$what} = $post['link'.$what];
1175 endif;
1176 endforeach;
1177
1178 // Update scheduling
1179 if (isset($post['update_schedule'])) :
1180 $this->link->settings['update/hold'] = $post['update_schedule'];
1181 endif;
1182
1183 if (isset($post['use_default_update_window']) and strtolower($post['use_default_update_window'])=='yes') :
1184 unset($this->link->settings['update/window']);
1185 elseif (isset($post['update_window'])):
1186 if ((int) $post['update_window'] > 0) :
1187 $this->link->settings['update/window'] = (int) $post['update_window'];
1188 endif;
1189 endif;
1190
1191 else :
1192 // Global
1193 update_option('feedwordpress_cat_id', $post['syndication_category']);
1194
1195 if (!isset($post['automatic_updates']) or !in_array($post['automatic_updates'], array('init', 'shutdown'))) :
1196 $automatic_updates = NULL;
1197 else :
1198 $automatic_updates = $post['automatic_updates'];
1199 endif;
1200 update_option('feedwordpress_automatic_updates', $automatic_updates);
1201
1202 if (isset($post['update_window'])):
1203 if ((int) $post['update_window'] > 0) :
1204 update_option('feedwordpress_update_window', (int) $post['update_window']);
1205 endif;
1206 endif;
1207
1208 update_option('feedwordpress_update_time_limit', ($post['update_time_limit']=='yes')?(int) $post['time_limit_seconds']:0);
1209
1210 foreach (array('name', 'description', 'url') as $what) :
1211 // We have a checkbox for "No," so if it's unchecked, mark as "Yes."
1212 $hardcode = (isset($post["hardcode_{$what}"]) ? $post["hardcode_{$what}"] : 'yes');
1213 update_option("feedwordpress_hardcode_{$what}", $hardcode);
1214 endforeach;
1215
1216 endif;
1217
1218 if (isset($post['fetch_timeout'])) :
1219 if (isset($post['fetch_timeout_default']) and $post['fetch_timeout_default']=='yes') :
1220 $timeout = NULL;
1221 else :
1222 $timeout = $post['fetch_timeout'];
1223 endif;
1224
1225 if (is_int($timeout)) :
1226 $timeout = intval($timeout);
1227 endif;
1228 $this->update_setting('fetch timeout', $timeout);
1229 endif;
1230
1231 if (isset($post['update_incremental'])) :
1232 $this->update_setting('update_incremental', $post['update_incremental']);
1233 endif;
1234
1235 if (isset($post['tombstones'])) :
1236 $this->update_setting('tombstones', $post['tombstones']);
1237 endif;
1238
1239 if (isset($post['update_minimum'])) :
1240 $this->update_setting('update/minimum', $post['update_minimum']);
1241 endif;
1242
1243 if (
1244 isset($post['link_rss_auth_method'])
1245 and $post['link_rss_auth_method']
1246 and ('-' != $post['link_rss_auth_method'])
1247 ) :
1248 $this->update_setting('http auth method', $post['link_rss_auth_method']);
1249 else :
1250 $this->update_setting('http auth method', NULL);
1251 endif;
1252
1253 if (
1254 isset($post['link_rss_username'])
1255 and (strlen($post['link_rss_username']) > 0)
1256 and ('-' != $post['link_rss_auth_method'])
1257 ) :
1258 $this->update_setting('http username', $post['link_rss_username']);
1259 else :
1260 $this->update_setting('http username', NULL);
1261 endif;
1262
1263 if (
1264 isset($post['link_rss_password'])
1265 and (strlen($post['link_rss_password']) > 0)
1266 and ('-' != $post['link_rss_auth_method'])
1267 ) :
1268 $this->update_setting('http password', $post['link_rss_password']);
1269 else :
1270 $this->update_setting('http password', NULL);
1271 endif;
1272
1273 $this->updatedPosts->accept_POST($post);
1274
1275 parent::save_settings($post);
1276 } /* FeedWordPressFeedsPage::save_settings() */
1277
1278 } /* class FeedWordPressFeedsPage */
1279
1280 $feedsPage = new FeedWordPressFeedsPage;
1281 $feedsPage->display();
1282
1283