PluginProbe
FeedWordPress / 2013.0503
FeedWordPress v2013.0503
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 2013.0503, at feeds-page.php

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