| @@ -46,152 +46,127 @@ | ||
| 46 | 46 | 505 => 'HTTP Version Not Supported', |
| 47 | 47 | ); |
| 48 | 48 | var $updatedPosts = NULL; |
| 49 | 49 | |
| 50 | - /** | |
| 51 | - * Constructs the Feeds page object | |
| 52 | - * | |
| 53 | - * @param mixed $link An object of class {@link SyndicatedLink} if created for one feed's settings, NULL if created for global default settings | |
| 54 | - */ | |
| 55 | - function FeedWordPressFeedsPage ($link = -1) { | |
| 56 | - if (is_numeric($link) and -1 == $link) : | |
| 57 | - $link = FeedWordPressAdminPage::submitted_link(); | |
| 58 | - endif; | |
| 59 | - | |
| 60 | - FeedWordPressAdminPage::FeedWordPressAdminPage('feedwordpressfeeds', $link); | |
| 61 | - | |
| 62 | - $this->dispatch = get_class($this); | |
| 63 | - $this->filename = __FILE__; | |
| 64 | - $this->updatedPosts = new UpdatedPostsControl($this); | |
| 65 | - } /* FeedWordPressFeedsPage constructor */ | |
| 66 | - | |
| 67 | 50 | var $special_settings = array ( /* Regular expression syntax is OK here */ |
| 68 | 51 | 'cats', |
| 69 | 52 | 'cat_split', |
| 53 | + 'fetch timeout', | |
| 54 | + 'freeze updates', | |
| 70 | 55 | 'hardcode name', |
| 71 | 56 | 'hardcode url', |
| 72 | 57 | 'hardcode description', |
| 73 | 58 | 'hardcode categories', /* Deprecated */ |
| 74 | - 'post status', | |
| 75 | 59 | 'comment status', |
| 60 | + 'terms', | |
| 61 | + 'map authors', | |
| 62 | + 'munge permalink', | |
| 76 | 63 | 'ping status', |
| 64 | + 'post status', | |
| 65 | + 'postmeta', | |
| 66 | + 'query parameters', | |
| 67 | + 'resolve relative', | |
| 68 | + 'syndicated post type', | |
| 69 | + 'tags', | |
| 77 | 70 | 'unfamiliar author', |
| 78 | 71 | 'unfamliar categories', /* Deprecated */ |
| 79 | 72 | 'unfamiliar category', |
| 80 | - 'map authors', | |
| 81 | - 'tags', | |
| 82 | - 'postmeta', | |
| 83 | - 'resolve relative', | |
| 84 | - 'freeze updates', | |
| 85 | - 'munge permalink', | |
| 73 | + 'unfamiliar post_tag', | |
| 74 | + 'add/.*', | |
| 86 | 75 | 'update/.*', |
| 87 | 76 | 'feed/.*', |
| 88 | 77 | 'link/.*', |
| 78 | + 'match/.*', | |
| 89 | 79 | ); |
| 90 | 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 | + | |
| 91 | 105 | function display () { |
| 92 | - global $wpdb; | |
| 93 | 106 | global $fwp_post; |
| 94 | 107 | global $post_source; |
| 95 | - | |
| 96 | - if (FeedWordPress::needs_upgrade()) : | |
| 97 | - fwp_upgrade_page(); | |
| 98 | - return; | |
| 99 | - endif; | |
| 100 | 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 | + 'fetch_settings_box' => __('Settings for Fetching Feeds (Advanced)'), | |
| 115 | + ); | |
| 116 | + if ($this->for_default_settings()) : | |
| 117 | + unset($this->boxes_by_methods['custom_settings_box']); | |
| 118 | + endif; | |
| 119 | + | |
| 101 | 120 | // Allow overriding of normal source for FeedFinder, which may |
| 102 | 121 | // be called from multiple points. |
| 103 | 122 | if (isset($post_source) and !is_null($post_source)) : |
| 104 | 123 | $source = $post_source; |
| 105 | 124 | else : |
| 106 | - $source = get_class($this); | |
| 125 | + $source = $this->dispatch; | |
| 107 | 126 | endif; |
| 108 | 127 | |
| 109 | - // If this is a POST, validate source and user credentials | |
| 110 | - FeedWordPressCompatibility::validate_http_request(/*action=*/ $source, /*capability=*/ 'manage_links'); | |
| 111 | - | |
| 112 | 128 | if (isset($_REQUEST['feedfinder']) |
| 113 | 129 | or (isset($_REQUEST['action']) and $_REQUEST['action']=='feedfinder') |
| 114 | 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 | + | |
| 115 | 134 | return $this->display_feedfinder(); // re-route to Feed Finder page |
| 116 | - else : | |
| 117 | - if (strtoupper($_SERVER['REQUEST_METHOD'])=='POST') : | |
| 118 | - $this->accept_POST($fwp_post); | |
| 119 | - do_action('feedwordpress_admin_page_feeds_save', $GLOBALS['fwp_post'], $this); | |
| 120 | - endif; | |
| 121 | - | |
| 122 | - //////////////////////////////////////////////// | |
| 123 | - // Prepare settings page /////////////////////// | |
| 124 | - //////////////////////////////////////////////// | |
| 125 | - | |
| 126 | - $this->ajax_interface_js(); | |
| 127 | - $this->display_update_notice_if_updated('Syndicated feed'); | |
| 128 | - $this->open_sheet('Feed and Update'); | |
| 129 | - ?> | |
| 130 | - <div id="post-body"> | |
| 131 | - <?php | |
| 132 | - //////////////////////////////////////////////// | |
| 133 | - // Display settings boxes ////////////////////// | |
| 134 | - //////////////////////////////////////////////// | |
| 135 | - | |
| 136 | - $boxes_by_methods = array( | |
| 137 | - 'feed_information_box' => __('Feed Information'), | |
| 138 | - 'global_feeds_box' => __('Update Scheduling'), | |
| 139 | - 'updated_posts_box' => __('Updated Posts'), | |
| 140 | - 'posts_box' => __('Syndicated Posts, Links, Comments & Pings'), | |
| 141 | - 'authors_box' => __('Syndicated Authors'), | |
| 142 | - 'categories_box' => __('Categories'.FEEDWORDPRESS_AND_TAGS), | |
| 143 | - 'custom_settings_box' => __('Custom Feed Settings (for use in templates)'), | |
| 144 | - ); | |
| 145 | - if ($this->for_default_settings()) : | |
| 146 | - unset($boxes_by_methods['custom_settings_box']); | |
| 147 | - endif; | |
| 148 | - | |
| 149 | - foreach ($boxes_by_methods as $method => $row) : | |
| 150 | - if (is_array($row)) : | |
| 151 | - $id = $row['id']; | |
| 152 | - $title = $row['title']; | |
| 153 | - else : | |
| 154 | - $id = 'feedwordpress_'.$method; | |
| 155 | - $title = $row; | |
| 156 | - endif; | |
| 157 | - | |
| 158 | - fwp_add_meta_box( | |
| 159 | - /*id=*/ $id, | |
| 160 | - /*title=*/ $title, | |
| 161 | - /*callback=*/ array(get_class($this), $method), | |
| 162 | - /*page=*/ $this->meta_box_context(), | |
| 163 | - /*context=*/ $this->meta_box_context() | |
| 164 | - ); | |
| 165 | - endforeach; | |
| 166 | - do_action('feedwordpress_admin_page_feeds_meta_boxes', $this); | |
| 167 | - ?> | |
| 168 | - <div class="metabox-holder"> | |
| 169 | - <?php | |
| 170 | - fwp_do_meta_boxes($this->meta_box_context(), $this->meta_box_context(), $this); | |
| 171 | - ?> | |
| 172 | - </div> <!-- class="metabox-holder" --> | |
| 173 | - </div> <!-- id="post-body" --> | |
| 174 | - <?php $this->close_sheet(); ?> | |
| 135 | + endif; | |
| 175 | 136 | |
| 176 | - <script type="text/javascript"> | |
| 177 | - var els = ['name', 'description', 'url']; | |
| 178 | - for (var i = 0; i < els.length; i++) { | |
| 179 | - contextual_appearance( | |
| 180 | - /*item=*/ 'basics-hardcode-'+els[i], | |
| 181 | - /*appear=*/ 'basics-'+els[i]+'-view', | |
| 182 | - /*disappear=*/ 'basics-'+els[i]+'-edit', | |
| 183 | - /*value=*/ 'no', | |
| 184 | - /*visibleStyle=*/ 'block', | |
| 185 | - /*checkbox=*/ true | |
| 186 | - ); | |
| 187 | - } /* for */ | |
| 188 | - </script> | |
| 189 | - <?php | |
| 190 | - endif; | |
| 137 | + parent::display(); | |
| 191 | 138 | return false; // Don't continue |
| 192 | 139 | } /* FeedWordPressFeedsPage::display() */ |
| 193 | 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 | + | |
| 194 | 169 | /*static*/ function updated_posts_box ($page, $box = NULL) { |
| 195 | 170 | ?> |
| 196 | 171 | <table class="edit-form"> |
| 197 | 172 | <?php $page->updatedPosts->display(); ?> |
| @@ -199,24 +174,16 @@ | ||
| 199 | 174 | <?php |
| 200 | 175 | } /* FeedWordPressFeedsPage::updated_posts_box() */ |
| 201 | 176 | |
| 202 | 177 | /*static*/ function global_feeds_box ($page, $box = NULL) { |
| 203 | - global $wpdb; | |
| 178 | + $automatic_updates = get_option('feedwordpress_automatic_updates'); | |
| 179 | + $update_time_limit = (int) get_option('feedwordpress_update_time_limit'); | |
| 204 | 180 | |
| 205 | - $defaultUpdateWindow = get_option('feedwordpress_update_window'); | |
| 206 | - if (!is_numeric($defaultUpdateWindow)) : | |
| 207 | - $defaultUpdateWindow = DEFAULT_UPDATE_PERIOD; | |
| 208 | - else : | |
| 209 | - $defaultUpdateWindow = (int) $defaultUpdateWindow; | |
| 210 | - endif; | |
| 181 | + // Hey, ho, let's go... | |
| 211 | 182 | ?> |
| 212 | - | |
| 183 | + | |
| 213 | 184 | <table class="edit-form"> |
| 214 | - <?php | |
| 215 | - if ($page->for_default_settings()) : | |
| 216 | - $automatic_updates = get_option('feedwordpress_automatic_updates'); | |
| 217 | - $update_time_limit = (int) get_option('feedwordpress_update_time_limit'); | |
| 218 | - ?> | |
| 185 | + <?php if ($page->for_default_settings()) : ?> | |
| 219 | 186 | |
| 220 | 187 | <tr> |
| 221 | 188 | <th scope="row">Updates:</th> |
| 222 | 189 | <td><select id="automatic-updates-selector" name="automatic_updates" size="1" onchange="contextual_appearance('automatic-updates-selector', 'cron-job-explanation', null, 'no');"> |
| @@ -226,11 +193,11 @@ | ||
| 226 | 193 | </select> |
| 227 | 194 | <div id="cron-job-explanation" class="setting-description"> |
| 228 | 195 | <p>If you want to use a cron job, |
| 229 | 196 | you can perform scheduled updates by sending regularly-scheduled |
| 230 | - requests to <a href="<?php bloginfo('home'); ?>?update_feedwordpress=1"><code><?php bloginfo('home') ?>?update_feedwordpress=1</code></a> | |
| 197 | + requests to <a href="<?php bloginfo('home'); ?>?update_feedwordpress=1"><code><?php bloginfo('url') ?>?update_feedwordpress=1</code></a> | |
| 231 | 198 | For example, inserting the following line in your crontab:</p> |
| 232 | - <pre style="font-size: 0.80em"><code>*/10 * * * * /usr/bin/curl --silent <?php bloginfo('home'); ?>?update_feedwordpress=1</code></pre> | |
| 199 | + <pre style="font-size: 0.80em"><code>*/10 * * * * /usr/bin/curl --silent <?php bloginfo('url'); ?>?update_feedwordpress=1</code></pre> | |
| 233 | 200 | <p class="setting-description">will check in every 10 minutes |
| 234 | 201 | and check for updates on any feeds that are ready to be polled for updates.</p> |
| 235 | 202 | </div> |
| 236 | 203 | </td> |
| @@ -235,39 +202,10 @@ | ||
| 235 | 202 | </div> |
| 236 | 203 | </td> |
| 237 | 204 | </tr> |
| 238 | 205 | |
| 239 | - <tr> | |
| 240 | - <th scope="row"><?php print __('Update scheduling:') ?></th> | |
| 241 | - <td><p style="margin-top:0px">How long should FeedWordPress wait between updates before it considers a feed ready to be polled for updates again?</p> | |
| 242 | - <p style="font-style: italic; margin-left: 2.0em"><label>Wait <input type="text" name="update_window" value="<?php print $defaultUpdateWindow; ?>" size="4" /> minutes between polling.</label></p> | |
| 243 | - <div class="setting-description"> | |
| 244 | - <p<?php if ($defaultUpdateWindow<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> | |
| 245 | - <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 a feed does provide update scheduling information (through elements such as <code><rss:ttl></code> or <code><sy:updateFrequency></code>), FeedWordPress will respect the feed's request.</p> | |
| 246 | - </div></td> | |
| 247 | - </tr> | |
| 248 | - | |
| 249 | - <tr> | |
| 250 | - <th scope="row"><?php print __('Time limit on updates'); ?>:</th> | |
| 251 | - <td><select id="time-limit" name="update_time_limit" size="1" onchange="contextual_appearance('time-limit', 'time-limit-box', null, 'yes');"> | |
| 252 | - <option value="no"<?php echo ($update_time_limit>0)?'':' selected="selected"'; ?>>no time limit on updates</option> | |
| 253 | - <option value="yes"<?php echo ($update_time_limit>0)?' selected="selected"':''; ?>>limit updates to no more than...</option> | |
| 254 | - </select> | |
| 255 | - <span id="time-limit-box"><label><input type="text" name="time_limit_seconds" value="<?php print $update_time_limit; ?>" size="5" /> seconds</label></span> | |
| 256 | - </tr> | |
| 206 | + <?php else : /* Feed-specific settings */ ?> | |
| 257 | 207 | |
| 258 | - <?php else : | |
| 259 | - $useDefaultUpdateWindow = !(isset($page->link->settings['update/window'])); | |
| 260 | - | |
| 261 | - $updateWindow = (isset($page->link->settings['update/window']) ? $page->link->settings['update/window'] : null); | |
| 262 | - if (!is_numeric($updateWindow)) : | |
| 263 | - $updateWindow = 60; | |
| 264 | - else : | |
| 265 | - $updateWindow = (int) $updateWindow; | |
| 266 | - endif; | |
| 267 | - | |
| 268 | - ?> | |
| 269 | - | |
| 270 | 208 | <tr> |
| 271 | 209 | <th scope="row"><?php _e('Last update') ?>:</th> |
| 272 | 210 | <td><?php |
| 273 | 211 | if (isset($page->link->settings['update/last'])) : |
| @@ -302,35 +240,112 @@ | ||
| 302 | 240 | ?></option> |
| 303 | 241 | <option value="next"<?php echo ($holdem=='next')?' selected="selected"':''; ?>>update ASAP</option> |
| 304 | 242 | <option value="ping"<?php echo ($holdem=='ping')?' selected="selected"':''; ?>>update only when pinged</option> |
| 305 | 243 | </select></td></tr> |
| 306 | - | |
| 244 | + | |
| 245 | + <?php endif; ?> | |
| 246 | + | |
| 307 | 247 | <tr> |
| 308 | 248 | <th scope="row"><?php print __('Update scheduling:') ?></th> |
| 309 | 249 | <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> |
| 310 | - <ul> | |
| 311 | - <li><label><input type="radio" name="use_default_update_window" value="Yes" <?php if ($useDefaultUpdateWindow) : ?>checked="checked"<?php endif; ?> /> Use site-wide setting (currently <?php print $defaultUpdateWindow; ?> minutes)</li> | |
| 312 | - <li><label><input type="radio" name="use_default_update_window" value="No" <?php if (!$useDefaultUpdateWindow) : ?>checked="checked"<?php endif; ?> /> Wait <input type="text" name="update_window" value="<?php print $updateWindow; ?>" size="4" /> minutes between polling.</label></li> | |
| 313 | - </ul> | |
| 250 | + <?php | |
| 251 | + | |
| 252 | + $this->setting_radio_control( | |
| 253 | + 'update/window', 'update_window', | |
| 254 | + array(&$this, 'update_window_edit_box'), | |
| 255 | + array( | |
| 256 | + 'global-setting-default' => DEFAULT_UPDATE_PERIOD, | |
| 257 | + 'default-input-name' => 'use_default_update_window', | |
| 258 | + 'default-input-id' => 'use-default-update-window-yes', | |
| 259 | + 'default-input-id-no' => 'use-default-update-window-no', | |
| 260 | + 'labels' => array(&$this, 'update_window_currently'), | |
| 261 | + ) | |
| 262 | + ); | |
| 263 | + ?></td> | |
| 264 | + </tr> | |
| 265 | + | |
| 266 | + <?php if ($this->for_default_settings()) : ?> | |
| 314 | 267 | |
| 315 | - <div class="setting-description"> | |
| 316 | - <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> | |
| 317 | - <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><rss:ttl></code> or <code><sy:updateFrequency></code>), FeedWordPress will respect the feed's request.</p> | |
| 318 | - </div></td> | |
| 268 | + <tr> | |
| 269 | + <th scope="row"><?php print __('Time limit on updates'); ?>:</th> | |
| 270 | + <td><select id="time-limit" name="update_time_limit" size="1" onchange="contextual_appearance('time-limit', 'time-limit-box', null, 'yes');"> | |
| 271 | + <option value="no"<?php echo ($update_time_limit>0)?'':' selected="selected"'; ?>>no time limit on updates</option> | |
| 272 | + <option value="yes"<?php echo ($update_time_limit>0)?' selected="selected"':''; ?>>limit updates to no more than...</option> | |
| 273 | + </select> | |
| 274 | + <span id="time-limit-box"><label><input type="text" name="time_limit_seconds" value="<?php print $update_time_limit; ?>" size="5" /> seconds</label></span> | |
| 319 | 275 | </tr> |
| 276 | + | |
| 320 | 277 | <?php endif; ?> |
| 278 | + | |
| 279 | + </table> | |
| 280 | + | |
| 281 | + <?php | |
| 282 | + } /* FeedWordPressFeedsPage::global_feeds_box() */ | |
| 321 | 283 | |
| 284 | + function update_window_edit_box ($updateWindow, $defaulted, $params) { | |
| 285 | + if (!is_numeric($updateWindow)) : | |
| 286 | + $updateWindow = DEFAULT_UPDATE_PERIOD; | |
| 287 | + endif; | |
| 288 | + ?> | |
| 289 | + <p>Wait <input type="text" name="update_window" value="<?php print $updateWindow; ?>" size="4" /> minutes between polling.</p> | |
| 290 | + <div class="setting-description" id="update-scheduling-note"> | |
| 291 | + <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> | |
| 292 | + <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><rss:ttl></code> or <code><sy:updateFrequency></code>), FeedWordPress will respect the feed's request.</p> | |
| 293 | + </div> | |
| 294 | + <?php | |
| 295 | + } /* FeedWordPressFeedsPage::update_window_edit_box () */ | |
| 296 | + | |
| 297 | + function update_window_currently ($updateWindow, $defaulted, $params) { | |
| 298 | + $updateWindow = (int) $updateWindow; | |
| 299 | + if (1==$updateWindow) : | |
| 300 | + $caption = 'wait %d minute between polling'; | |
| 301 | + else : | |
| 302 | + $caption = 'wait %d minutes between polling'; | |
| 303 | + endif; | |
| 304 | + return sprintf(__($caption), $updateWindow); | |
| 305 | + } /* FeedWordPressFeedsPage::update_window_currently () */ | |
| 306 | + | |
| 307 | + function fetch_timeout_setting ($setting, $defaulted, $params) { | |
| 308 | + $timeout = intval($this->setting('fetch timeout', FEEDWORDPRESS_FETCH_TIMEOUT_DEFAULT)); | |
| 322 | 309 | |
| 323 | -</table> | |
| 324 | -<script type="text/javascript"> | |
| 325 | -contextual_appearance('automatic-updates-selector', 'cron-job-explanation', null, 'no'); | |
| 326 | -contextual_appearance('time-limit', 'time-limit-box', null, 'yes'); | |
| 327 | -</script> | |
| 328 | -<?php | |
| 329 | - } /* FeedWordPressFeedsPage::global_feeds_box() */ | |
| 330 | - | |
| 310 | + if ($this->for_feed_settings()) : | |
| 311 | + $article = 'this'; | |
| 312 | + else : | |
| 313 | + $article = 'a'; | |
| 314 | + endif; | |
| 315 | + ?> | |
| 316 | + <p>Wait no more than | |
| 317 | + than <input name="fetch_timeout" type="number" min="0" size="3" value="<?php print $timeout; ?>" /> | |
| 318 | + second(s) when trying to fetch <?php print $article; ?> feed to check for updates.</p> | |
| 319 | + <p>If <?php print $article; ?> source's web server does not respond before time runs | |
| 320 | + out, FeedWordPress will skip over the source and try again during | |
| 321 | + the next update cycle.</p> | |
| 322 | + <?php | |
| 323 | + } | |
| 324 | + function fetch_timeout_setting_value ($setting, $defaulted, $params) { | |
| 325 | + print number_format(intval($setting)) . " " . (($setting==1) ? "second" : "seconds"); | |
| 326 | + } | |
| 327 | + | |
| 328 | + function fetch_settings_box ($page, $box = NULL) { | |
| 329 | + $this->setting_radio_control( | |
| 330 | + 'fetch timeout', 'fetch_timeout', | |
| 331 | + array(&$this, 'fetch_timeout_setting'), | |
| 332 | + array( | |
| 333 | + 'global-setting-default' => FEEDWORDPRESS_FETCH_TIMEOUT_DEFAULT, | |
| 334 | + 'input-name' => 'fetch_timeout', | |
| 335 | + 'default-input-name' => 'fetch_timeout_default', | |
| 336 | + 'labels' => array(&$this, 'fetch_timeout_setting_value'), | |
| 337 | + ) | |
| 338 | + ); | |
| 339 | + } /* FeedWordPressFeedsPage::fetch_settings_box () */ | |
| 340 | + | |
| 331 | 341 | function feed_information_box ($page, $box = NULL) { |
| 332 | 342 | global $wpdb; |
| 343 | + $link_rss_params = maybe_unserialize($page->setting('query parameters', '')); | |
| 344 | + if (!is_array($link_rss_params)) : | |
| 345 | + $link_rss_params = array(); | |
| 346 | + endif; | |
| 347 | + | |
| 333 | 348 | if ($page->for_feed_settings()) : |
| 334 | 349 | $info['name'] = esc_html($page->link->link->link_name); |
| 335 | 350 | $info['description'] = esc_html($page->link->link->link_description); |
| 336 | 351 | $info['url'] = esc_html($page->link->link->link_url); |
| @@ -340,26 +355,29 @@ | ||
| 340 | 355 | $hardcode['description'] = $page->link->hardcode('description'); |
| 341 | 356 | $hardcode['url'] = $page->link->hardcode('url'); |
| 342 | 357 | else : |
| 343 | 358 | $cat_id = FeedWordPress::link_category_id(); |
| 344 | - if (FeedWordPressCompatibility::test_version(FWP_SCHEMA_21)) : | |
| 345 | - $results = get_categories(array( | |
| 346 | - "type" => 'link', | |
| 347 | - "hide_empty" => false, | |
| 348 | - )); | |
| 359 | + | |
| 360 | + $params = array(); | |
| 361 | + if (FeedWordPressCompatibility::test_version(FWP_SCHEMA_USES_ARGS_TAXONOMY)) : | |
| 362 | + $params['taxonomy'] = 'link_category'; | |
| 363 | + else : | |
| 364 | + $params['type'] = 'link'; | |
| 365 | + endif; | |
| 366 | + $params['hide_empty'] = false; | |
| 367 | + $results = get_categories($params); | |
| 349 | 368 | |
| 350 | - // Guarantee that the Contributors category will be in the drop-down chooser, even if it is empty. | |
| 351 | - $found_link_category_id = false; | |
| 352 | - foreach ($results as $row) : | |
| 353 | - // Normalize case | |
| 354 | - if (!isset($row->cat_id)) : $row->cat_id = $row->cat_ID; endif; | |
| 369 | + // Guarantee that the Contributors category will be in the drop-down chooser, even if it is empty. | |
| 370 | + $found_link_category_id = false; | |
| 371 | + foreach ($results as $row) : | |
| 372 | + // Normalize case | |
| 373 | + if (!isset($row->cat_id)) : $row->cat_id = $row->cat_ID; endif; | |
| 355 | 374 | |
| 356 | - if ($row->cat_id == $cat_id) : $found_link_category_id = true; endif; | |
| 357 | - endforeach; | |
| 358 | - | |
| 359 | - if (!$found_link_category_id) : $results[] = get_category($cat_id); endif; | |
| 360 | - else : | |
| 361 | - $results = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $wpdb->linkcategories ORDER BY cat_id"); | |
| 375 | + if ($row->cat_id == $cat_id) : $found_link_category_id = true; endif; | |
| 376 | + endforeach; | |
| 377 | + | |
| 378 | + if (!$found_link_category_id) : | |
| 379 | + $results[] = get_category($cat_id); | |
| 362 | 380 | endif; |
| 363 | 381 | |
| 364 | 382 | $info = array(); |
| 365 | 383 | $rss_url = null; |
| @@ -370,15 +388,8 @@ | ||
| 370 | 388 | endif; |
| 371 | 389 | |
| 372 | 390 | // Hey ho, let's go |
| 373 | 391 | ?> |
| 374 | - <style type="text/css"> | |
| 375 | - table.edit-form { width: 100%; } | |
| 376 | - table.edit-form th { width: 25%; vertical-align: top; text-align: right; padding: 0.5em; } | |
| 377 | - table.edit-form td { width: 75%; vertical-align: top; padding: 0.5em; } | |
| 378 | - table.edit-form td ul.options { margin: 0; padding: 0; list-style: none; } | |
| 379 | - </style> | |
| 380 | - | |
| 381 | 392 | <table class="edit-form"> |
| 382 | 393 | |
| 383 | 394 | <?php if ($page->for_feed_settings()) : ?> |
| 384 | 395 | |
| @@ -386,11 +397,73 @@ | ||
| 386 | 397 | <th scope="row"><?php _e('Feed URL:') ?></th> |
| 387 | 398 | <td><a href="<?php echo esc_html($rss_url); ?>"><?php echo esc_html($rss_url); ?></a> |
| 388 | 399 | (<a href="<?php echo FEEDVALIDATOR_URI; ?>?url=<?php echo urlencode($rss_url); ?>" |
| 389 | 400 | title="Check feed <<?php echo esc_html($rss_url); ?>> for validity">validate</a>) |
| 390 | - <input type="submit" name="feedfinder" value="switch →" style="font-size:smaller" /></td> | |
| 401 | + <input type="submit" name="feedfinder" value="switch →" style="font-size:smaller" /> | |
| 402 | + | |
| 403 | + <table id="link-rss-params"> | |
| 404 | + <tbody> | |
| 405 | + <?php | |
| 406 | + $link_rss_params['new'] = array('', ''); | |
| 407 | + $i = 0; | |
| 408 | + foreach ($link_rss_params as $index => $pair) : | |
| 409 | + ?> | |
| 410 | + <tr class="link-rss-params-row" id="link-rss-params-<?php print $index; ?>"> | |
| 411 | + <td><label>Parameter: <input type="text" class="link_params_key" | |
| 412 | + name="link_rss_params_key[<?php print $index; ?>]" value="<?php print esc_html($pair[0]); ?>" | |
| 413 | + size="5" style="width: 5em" placeholder="name" /></label></td> | |
| 414 | + <td class="link-rss-params-value-cell"><label class="link_params_value_label">= <input type="text" class="link_params_value" | |
| 415 | + name="link_rss_params_value[<?php print $index; ?>]" value="<?php print esc_html($pair[1]); ?>" | |
| 416 | + size="8" placeholder="value" /></label></td> | |
| 391 | 417 | </tr> |
| 418 | + <?php | |
| 419 | + $i++; | |
| 420 | + endforeach; | |
| 421 | + ?> | |
| 422 | + </tbody> | |
| 423 | + </table> | |
| 424 | + | |
| 425 | + <div><input type="hidden" id="link-rss-params-num" name="link_rss_params_num" value="<?php print $i; ?>" /></div> | |
| 426 | + | |
| 427 | + <script type="text/javascript"> | |
| 428 | + function linkParamsRowRemove (element) { | |
| 429 | + jQuery(element).closest('tr').fadeOut('slow', function () { | |
| 430 | + jQuery(this).remove(); | |
| 431 | + } ); | |
| 432 | + } | |
| 392 | 433 | |
| 434 | + 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'); | |
| 435 | + | |
| 436 | + jQuery('#link-rss-params-new').hide(); | |
| 437 | + jQuery('<a class="add-remove" id="link-rss-params-add" href="#">+ Add a query parameter</a>').insertAfter('#link-rss-params'); | |
| 438 | + jQuery('#link-rss-params-add').click( function () { | |
| 439 | + var next = jQuery('#link-rss-params-num').val(); | |
| 440 | + var newRow = jQuery('#link-rss-params-new').clone().attr('id', 'link-rss-params-'+next); | |
| 441 | + newRow.find('.link_params_key').attr('name', 'link_rss_params_key['+next+']'); | |
| 442 | + newRow.find('.link_params_value').attr('name', 'link_rss_params_value['+next+']'); | |
| 443 | + | |
| 444 | + newRow.find('.link-rss-params-remove').click( function () { | |
| 445 | + linkParamsRowRemove(this); | |
| 446 | + return false; | |
| 447 | + } ); | |
| 448 | + | |
| 449 | + newRow.appendTo('#link-rss-params'); | |
| 450 | + newRow.show(); | |
| 451 | + | |
| 452 | + // Update counter for next row. | |
| 453 | + next++; | |
| 454 | + jQuery('#link-rss-params-num').val(next); | |
| 455 | + | |
| 456 | + return false; | |
| 457 | + } ); | |
| 458 | + jQuery('.link-rss-params-remove').click( function () { | |
| 459 | + linkParamsRowRemove(this); | |
| 460 | + return false; | |
| 461 | + } ); | |
| 462 | + </script> | |
| 463 | + </td> | |
| 464 | + </tr> | |
| 465 | + | |
| 393 | 466 | <?php |
| 394 | 467 | $rows = array( |
| 395 | 468 | "name" => __('Link Name'), |
| 396 | 469 | "description" => __('Short Description'), |
| @@ -468,20 +541,8 @@ | ||
| 468 | 541 | </table> |
| 469 | 542 | <?php |
| 470 | 543 | } /* FeedWordPressFeedsPage::feed_information_box() */ |
| 471 | 544 | |
| 472 | - function posts_box ($page, $box = NULL) { | |
| 473 | - FeedWordPressSettingsUI::instead_of_posts_box($page->link->id); | |
| 474 | - } /* FeedWordPressFeedsPage::posts_box() */ | |
| 475 | - | |
| 476 | - function authors_box ($page, $box = NULL) { | |
| 477 | - FeedWordPressSettingsUI::instead_of_authors_box($page->link->id); | |
| 478 | - } /* FeedWordPressFeedsPage::authors_box() */ | |
| 479 | - | |
| 480 | - function categories_box ($page, $box = NULL) { | |
| 481 | - FeedWordPressSettingsUI::instead_of_categories_box($page->link->id); | |
| 482 | - } /* FeedWordPressFeedsPage::categories_box() */ | |
| 483 | - | |
| 484 | 545 | function custom_settings_box ($page, $box = NULL) { |
| 485 | 546 | ?> |
| 486 | 547 | <p class="setting-description">These custom settings are special fields for the <strong>feed</strong> you are |
| 487 | 548 | syndicating, to be retrieved in templates using the <code>get_feed_meta()</code> function. They do not create |
| @@ -529,68 +590,107 @@ | ||
| 529 | 590 | global $wpdb; |
| 530 | 591 | |
| 531 | 592 | $lookup = (isset($_REQUEST['lookup']) ? $_REQUEST['lookup'] : NULL); |
| 532 | 593 | |
| 594 | + $feeds = array(); $feedSwitch = false; $current = null; | |
| 533 | 595 | if ($this->for_feed_settings()) : // Existing feed? |
| 534 | - if (is_null($lookup)) : $lookup = $this->link->link->link_url; endif; | |
| 596 | + $feedSwitch = true; | |
| 597 | + if (is_null($lookup)) : | |
| 598 | + // Switch Feed without a specific feed yet suggested | |
| 599 | + // Go to the human-readable homepage to look for | |
| 600 | + // auto-detection links | |
| 601 | + $lookup = $this->link->link->link_url; | |
| 602 | + | |
| 603 | + // Guarantee that you at least have the option to | |
| 604 | + // stick with what works. | |
| 605 | + $current = $this->link->link->link_rss; | |
| 606 | + $feeds[] = $current; | |
| 607 | + endif; | |
| 535 | 608 | $name = esc_html($this->link->link->link_name); |
| 536 | 609 | else: // Or a new subscription to add? |
| 537 | 610 | $name = "Subscribe to <code>".esc_html(feedwordpress_display_url($lookup))."</code>"; |
| 538 | 611 | endif; |
| 539 | 612 | ?> |
| 540 | - <style type="text/css"> | |
| 541 | - form.fieldset { | |
| 542 | - clear: both; | |
| 543 | - } | |
| 544 | - .feed-sample { | |
| 545 | - float: right; | |
| 546 | - background-color: #D0D0D0; | |
| 547 | - color: black; | |
| 548 | - width: 45%; | |
| 549 | - font-size: 70%; | |
| 550 | - border-left: 1px dotted #A0A0A0; | |
| 551 | - margin-left: 1.0em; | |
| 552 | - } | |
| 553 | - .feed-sample p, .feed-sample h3 { | |
| 554 | - padding-left: 0.5em; | |
| 555 | - padding-right: 0.5em; | |
| 556 | - } | |
| 557 | - .feed-sample .feed-problem { | |
| 558 | - background-color: #ffd0d0; | |
| 559 | - border-bottom: 1px dotted black; | |
| 560 | - padding-bottom: 0.5em; | |
| 561 | - margin-bottom: 0.5em; | |
| 562 | - } | |
| 563 | - </style> | |
| 564 | - | |
| 565 | - <div class="wrap"> | |
| 613 | + <div class="wrap" id="feed-finder"> | |
| 566 | 614 | <h2>Feed Finder: <?php echo $name; ?></h2> |
| 567 | 615 | |
| 568 | 616 | <?php |
| 569 | - $f = new FeedFinder($lookup); | |
| 570 | - $feeds = $f->find(); | |
| 617 | + if ($feedSwitch) : | |
| 618 | + $this->display_alt_feed_box($lookup); | |
| 619 | + endif; | |
| 620 | + | |
| 621 | + $finder = array(); | |
| 622 | + if (!is_null($current)) : | |
| 623 | + $finder[$current] = new FeedFinder($current); | |
| 624 | + endif; | |
| 625 | + $finder[$lookup] = new FeedFinder($lookup); | |
| 626 | + | |
| 627 | + foreach ($finder as $url => $ff) : | |
| 628 | + $feeds = array_merge($feeds, $ff->find()); | |
| 629 | + endforeach; | |
| 630 | + | |
| 631 | + $feeds = array_values( // Renumber from 0..(N-1) | |
| 632 | + array_unique( // Eliminate duplicates | |
| 633 | + $feeds | |
| 634 | + ) | |
| 635 | + ); | |
| 636 | + | |
| 571 | 637 | if (count($feeds) > 0): |
| 638 | + if ($feedSwitch) : | |
| 639 | + ?> | |
| 640 | + <h3>Feeds Found</h3> | |
| 641 | + <?php | |
| 642 | + endif; | |
| 643 | + | |
| 644 | + if (count($feeds) > 1) : | |
| 645 | + $option_template = 'Option %d: '; | |
| 646 | + $form_class = ' class="multi"'; | |
| 647 | + ?> | |
| 648 | + <p><strong>This web page provides at least <?php print count($feeds); ?> different feeds.</strong> These feeds may provide the same information | |
| 649 | + in different formats, or may track different items. (You can check the Feed Information and the | |
| 650 | + 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> | |
| 651 | + <?php | |
| 652 | + else : | |
| 653 | + $option_template = ''; | |
| 654 | + $form_class = ''; | |
| 655 | + endif; | |
| 656 | + | |
| 572 | 657 | foreach ($feeds as $key => $f): |
| 573 | 658 | $pie = FeedWordPress::fetch($f); |
| 574 | 659 | $rss = (is_wp_error($pie) ? $pie : new MagpieFromSimplePie($pie)); |
| 575 | 660 | |
| 576 | 661 | if ($rss and !is_wp_error($rss)): |
| 577 | - $feed_title = isset($rss->channel['title'])?$rss->channel['title']:$rss->channel['link']; | |
| 578 | - $feed_link = isset($rss->channel['link'])?$rss->channel['link']:''; | |
| 662 | + $feed_link = (isset($rss->channel['link'])?$rss->channel['link']:''); | |
| 663 | + $feed_title = (isset($rss->channel['title'])?$rss->channel['title']:$feed_link); | |
| 579 | 664 | $feed_type = ($rss->feed_type ? $rss->feed_type : 'Unknown'); |
| 665 | + $feed_version_template = '%.1f'; | |
| 666 | + $feed_version = $rss->feed_version; | |
| 580 | 667 | else : |
| 581 | 668 | // Give us some sucky defaults |
| 582 | 669 | $feed_title = feedwordpress_display_url($lookup); |
| 583 | 670 | $feed_link = $lookup; |
| 584 | 671 | $feed_type = 'Unknown'; |
| 672 | + $feed_version_template = ''; | |
| 673 | + $feed_version = ''; | |
| 585 | 674 | endif; |
| 586 | 675 | ?> |
| 587 | - <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/syndication.php" method="post"> | |
| 588 | - <div><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_switchfeed'); ?></div> | |
| 589 | - <fieldset> | |
| 590 | - <legend><?php echo $feed_type; ?> <?php echo $rss->feed_version; ?> feed</legend> | |
| 676 | + <form<?php print $form_class; ?> action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/syndication.php" method="post"> | |
| 677 | + <div class="inside"><?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_switchfeed'); ?> | |
| 591 | 678 | |
| 592 | 679 | <?php |
| 680 | + $classes = array('feed-found'); $currentFeed = ''; | |
| 681 | + if (!is_null($current) and $current==$f) : | |
| 682 | + $classes[] = 'current'; | |
| 683 | + $currentFeed = ' (currently subscribed)'; | |
| 684 | + endif; | |
| 685 | + if ($key%2) : | |
| 686 | + $classes[] = 'alt'; | |
| 687 | + endif; | |
| 688 | + ?> | |
| 689 | + <fieldset class="<?php print implode(" ", $classes); ?>"> | |
| 690 | + <legend><?php printf($option_template, ($key+1)); print $feed_type." "; printf($feed_version_template, $feed_version); ?> feed<?php print $currentFeed; ?></legend> | |
| 691 | + | |
| 692 | + <?php | |
| 593 | 693 | $this->stamp_link_id(); |
| 594 | 694 | |
| 595 | 695 | // No feed specified = add new feed; we |
| 596 | 696 | // need to pass along a starting title |
| @@ -647,18 +747,19 @@ | ||
| 647 | 747 | <div> |
| 648 | 748 | <h3>Feed Information</h3> |
| 649 | 749 | <ul> |
| 650 | 750 | <li><strong>Homepage:</strong> <a href="<?php echo $feed_link; ?>"><?php echo is_null($feed_title)?'<em>Unknown</em>':$feed_title; ?></a></li> |
| 651 | - <li><strong>Feed URL:</strong> <a href="<?php echo esc_html($f); ?>"><?php echo esc_html($f); ?></a> (<a title="Check feed <<?php echo esc_html($f); ?>> for validity" href="http://feedvalidator.org/check.cgi?url=<?php echo urlencode($f); ?>">validate</a>)</li> | |
| 751 | + <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 <<?php echo esc_html($f); ?>> for validity" href="http://feedvalidator.org/check.cgi?url=<?php echo urlencode($f); ?>">validate</a>)</li> | |
| 652 | 752 | <li><strong>Encoding:</strong> <?php echo isset($rss->encoding)?esc_html($rss->encoding):"<em>Unknown</em>"; ?></li> |
| 653 | 753 | <li><strong>Description:</strong> <?php echo isset($rss->channel['description'])?esc_html($rss->channel['description']):"<em>Unknown</em>"; ?></li> |
| 654 | 754 | </ul> |
| 655 | 755 | <?php do_action('feedwordpress_feedfinder_form', $f, $post, $link, $this->for_feed_settings()); ?> |
| 656 | - <div class="submit"><input type="submit" name="Use" value="« Use this feed" /></div> | |
| 657 | - <div class="submit"><input type="submit" name="Cancel" value="« Cancel" /></div> | |
| 756 | + <div class="submit"><input type="submit" class="button-primary" name="Use" value="« Use this feed" /> | |
| 757 | + <input type="submit" class="button" name="Cancel" value="× Cancel" /></div> | |
| 658 | 758 | </div> |
| 659 | 759 | </div> |
| 660 | 760 | </fieldset> |
| 761 | + </div> <!-- class="inside" --> | |
| 661 | 762 | </form> |
| 662 | 763 | <?php |
| 663 | 764 | unset($link); |
| 664 | 765 | unset($post); |
| @@ -663,164 +764,186 @@ | ||
| 663 | 764 | unset($link); |
| 664 | 765 | unset($post); |
| 665 | 766 | endforeach; |
| 666 | 767 | else: |
| 667 | - print "<p><strong>".__('Error').":</strong> ".__("FeedWordPress couldn't find any feeds at").' <code><a href="'.htmlspecialchars($lookup).'">'.htmlspecialchars($lookup).'</a></code>'; | |
| 668 | - print ". ".__('Try another URL').".</p>"; | |
| 768 | + foreach ($finder as $url => $ff) : | |
| 769 | + $url = esc_html($url); | |
| 770 | + print "<h3>Searched for feeds at ${url}</h3>\n"; | |
| 771 | + print "<p><strong>".__('Error').":</strong> ".__("FeedWordPress couldn't find any feeds at").' <code><a href="'.htmlspecialchars($lookup).'">'.htmlspecialchars($lookup).'</a></code>'; | |
| 772 | + print ". ".__('Try another URL').".</p>"; | |
| 669 | 773 | |
| 670 | - // Diagnostics | |
| 671 | - print "<div class=\"updated\" style=\"margin-left: 3.0em; margin-right: 3.0em;\">\n"; | |
| 672 | - print "<h3>".__('Diagnostic information')."</h3>\n"; | |
| 673 | - if (!is_null($f->error()) and strlen($f->error()) > 0) : | |
| 674 | - print "<h4>".__('HTTP request failure')."</h4>\n"; | |
| 675 | - print "<p>".$f->error()."</p>\n"; | |
| 676 | - else : | |
| 677 | - print "<h4>".__('HTTP request completed')."</h4>\n"; | |
| 678 | - print "<p><strong>Status ".$f->status().":</strong> ".$this->HTTPStatusMessages[(int) $f->status()]."</p>\n"; | |
| 679 | - endif; | |
| 774 | + // Diagnostics | |
| 775 | + print "<div class=\"updated\" style=\"margin-left: 3.0em; margin-right: 3.0em;\">\n"; | |
| 776 | + print "<h3>".__('Diagnostic information')."</h3>\n"; | |
| 777 | + if (!is_null($ff->error()) and strlen($ff->error()) > 0) : | |
| 778 | + print "<h4>".__('HTTP request failure')."</h4>\n"; | |
| 779 | + print "<p>".$ff->error()."</p>\n"; | |
| 780 | + else : | |
| 781 | + print "<h4>".__('HTTP request completed')."</h4>\n"; | |
| 782 | + print "<p><strong>Status ".$ff->status().":</strong> ".$this->HTTPStatusMessages[(int) $ff->status()]."</p>\n"; | |
| 783 | + endif; | |
| 680 | 784 | |
| 681 | - // Do some more diagnostics if the API for it is available. | |
| 682 | - if (function_exists('_wp_http_get_object')) : | |
| 683 | - $httpObject = _wp_http_get_object(); | |
| 684 | - $transports = $httpObject->_getTransport(); | |
| 785 | + // Do some more diagnostics if the API for it is available. | |
| 786 | + if (function_exists('_wp_http_get_object')) : | |
| 787 | + $httpObject = _wp_http_get_object(); | |
| 788 | + $transports = $httpObject->_getTransport(); | |
| 789 | + | |
| 790 | + print "<h4>".__('HTTP Transports available').":</h4>\n"; | |
| 791 | + print "<ol>\n"; | |
| 792 | + print "<li>".implode("</li>\n<li>", array_map('get_class', $transports))."</li>\n"; | |
| 793 | + print "</ol>\n"; | |
| 794 | + print "</div>\n"; | |
| 795 | + endif; | |
| 796 | + endforeach; | |
| 797 | + endif; | |
| 798 | + | |
| 799 | + if (!$feedSwitch) : | |
| 800 | + $this->display_alt_feed_box($lookup, /*alt=*/ true); | |
| 801 | + endif; | |
| 802 | + ?> | |
| 803 | + </div> <!-- class="wrap" --> | |
| 804 | + <?php | |
| 805 | + return false; // Don't continue | |
| 806 | + } /* FeedWordPressFeedsPage::display_feedfinder() */ | |
| 685 | 807 | |
| 686 | - print "<h4>".__('HTTP Transports available').":</h4>\n"; | |
| 687 | - print "<ol>\n"; | |
| 688 | - print "<li>".implode("</li>\n<li>", array_map('get_class', $transports))."</li>\n"; | |
| 689 | - print "</ol>\n"; | |
| 690 | - print "</div>\n"; | |
| 691 | - endif; | |
| 692 | - | |
| 693 | - endif; | |
| 694 | - ?> | |
| 695 | - </div> | |
| 696 | - | |
| 808 | + function display_alt_feed_box ($lookup, $alt = false) { | |
| 809 | + global $fwp_post; | |
| 810 | + ?> | |
| 697 | 811 | <form action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post"> |
| 698 | - <div><?php | |
| 699 | - FeedWordPressCompatibility::stamp_nonce(get_class($this)); | |
| 700 | - ?></div> | |
| 701 | - <div class="wrap"> | |
| 702 | - <h2>Use another feed</h2> | |
| 703 | - <div><label>Feed:</label> | |
| 704 | - <input type="text" name="lookup" id="use-another-feed" value="URI" /> | |
| 812 | + <div class="inside"><?php | |
| 813 | + FeedWordPressCompatibility::stamp_nonce($this->dispatch); | |
| 814 | + ?> | |
| 815 | + <fieldset class="alt" | |
| 816 | + <?php if (!$alt): ?>style="margin: 1.0em 3.0em; font-size: smaller;"<?php endif; ?>> | |
| 817 | + <legend><?php if ($alt) : ?>Alternative feeds<?php else: ?>Find feeds<?php endif; ?></legend> | |
| 818 | + <?php if ($alt) : ?><h3>Use a different feed</h3><?php endif; ?> | |
| 819 | + <div><label>Address: | |
| 820 | + <input type="text" name="lookup" id="use-another-feed" | |
| 821 | + placeholder="URL" | |
| 822 | + <?php if (is_null($lookup)) : ?> | |
| 823 | + value="URL" | |
| 824 | + <?php else : ?> | |
| 825 | + value="<?php print esc_html($lookup); ?>" | |
| 826 | + <?php endif; ?> | |
| 827 | + size="64" style="max-width: 80%" /></label> | |
| 828 | + <?php if (is_null($lookup)) : ?> | |
| 705 | 829 | <?php FeedWordPressSettingsUI::magic_input_tip_js('use-another-feed'); ?> |
| 830 | + <?php endif; ?> | |
| 706 | 831 | <?php $this->stamp_link_id('link_id'); ?> |
| 707 | - <input type="hidden" name="action" value="feedfinder" /></div> | |
| 708 | - <div class="submit"><input type="submit" value="Use this feed »" /></div> | |
| 709 | - </div> | |
| 710 | - </form> | |
| 832 | + <input type="hidden" name="action" value="feedfinder" /> | |
| 833 | + <input type="submit" class="button<?php if ($alt): ?>-primary<?php endif; ?>" value="Check »" /></div> | |
| 834 | + <p>This can be the address of a feed, or of a website. FeedWordPress | |
| 835 | + will try to automatically detect any feeds associated with a | |
| 836 | + website.</p> | |
| 837 | + </div> <!-- class="inside" --> | |
| 838 | + </fieldset></form> | |
| 839 | + | |
| 711 | 840 | <?php |
| 712 | - return false; // Don't continue | |
| 713 | - } /* WordPressFeedsPage::display_feedfinder() */ | |
| 714 | - | |
| 715 | - function accept_POST ($post) { | |
| 716 | - global $wpdb; | |
| 717 | - | |
| 718 | - // User mashed a Save Changes button | |
| 719 | - if (isset($post['save']) or isset($post['submit'])) : | |
| 720 | - | |
| 721 | - if ($this->for_feed_settings()) : | |
| 722 | - $alter = array (); | |
| 723 | - | |
| 724 | - // custom feed settings first | |
| 725 | - foreach ($post['notes'] as $mn) : | |
| 726 | - $mn['key0'] = trim($mn['key0']); | |
| 727 | - $mn['key1'] = trim($mn['key1']); | |
| 728 | - if (preg_match("\007^((" | |
| 729 | - .implode(')|(',$this->special_settings) | |
| 730 | - ."))$\007i", | |
| 731 | - $mn['key1'])) : | |
| 732 | - $mn['key1'] = 'user/'.$mn['key1']; | |
| 841 | + } /* FeedWordPressFeedsPage::display_alt_feed_box() */ | |
| 842 | + | |
| 843 | + function save_settings ($post) { | |
| 844 | + if ($this->for_feed_settings()) : | |
| 845 | + if (isset($post['link_rss_params_key'])) : | |
| 846 | + $qp = array(); | |
| 847 | + foreach ($post['link_rss_params_key'] as $index => $key) : | |
| 848 | + if (strlen($key) > 0) : | |
| 849 | + if (isset($post['link_rss_params_value'][$index]) | |
| 850 | + and strlen($post['link_rss_params_value'][$index])) : | |
| 851 | + $value = $post['link_rss_params_value'][$index]; | |
| 852 | + $qp[] = array($key, $value); | |
| 853 | + endif; | |
| 733 | 854 | endif; |
| 734 | - | |
| 735 | - if (strlen($mn['key0']) > 0) : | |
| 736 | - unset($this->link->settings[$mn['key0']]); // out with the old | |
| 737 | - endif; | |
| 738 | - | |
| 739 | - if (($mn['action']=='update') and (strlen($mn['key1']) > 0)) : | |
| 740 | - $this->link->settings[$mn['key1']] = $mn['value']; // in with the new | |
| 741 | - endif; | |
| 742 | 855 | endforeach; |
| 743 | - | |
| 744 | - // now stuff through the web form | |
| 745 | - // hardcoded feed info | |
| 746 | - | |
| 747 | - foreach (array('name', 'description', 'url') as $what) : | |
| 748 | - // We have a checkbox for "No," so if it's unchecked, mark as "Yes." | |
| 749 | - $this->link->settings["hardcode {$what}"] = (isset($post["hardcode_{$what}"]) ? $post["hardcode_{$what}"] : 'yes'); | |
| 750 | - if (FeedWordPress::affirmative($this->link->settings, "hardcode {$what}")) : | |
| 751 | - $this->link->link->{'link_'.$what} = $post['link'.$what]; | |
| 752 | - endif; | |
| 753 | - endforeach; | |
| 754 | - | |
| 755 | - // Update scheduling | |
| 756 | - if (isset($post['update_schedule'])) : | |
| 757 | - $this->link->settings['update/hold'] = $post['update_schedule']; | |
| 856 | + $this->update_setting('query parameters', serialize($qp)); | |
| 857 | + endif; | |
| 858 | + | |
| 859 | + // custom feed settings first | |
| 860 | + foreach ($post['notes'] as $mn) : | |
| 861 | + $mn['key0'] = (isset($mn['key0']) ? trim($mn['key0']) : NULL); | |
| 862 | + $mn['key1'] = trim($mn['key1']); | |
| 863 | + if (preg_match("\007^((" | |
| 864 | + .implode(')|(',$this->special_settings) | |
| 865 | + ."))$\007i", | |
| 866 | + $mn['key1'])) : | |
| 867 | + $mn['key1'] = 'user/'.$mn['key1']; | |
| 758 | 868 | endif; |
| 759 | 869 | |
| 760 | - if (isset($post['use_default_update_window']) and strtolower($post['use_default_update_window'])=='yes') : | |
| 761 | - unset($this->link->settings['update/window']); | |
| 762 | - elseif (isset($post['update_window'])): | |
| 763 | - if ((int) $post['update_window'] > 0) : | |
| 764 | - $this->link->settings['update/window'] = (int) $post['update_window']; | |
| 765 | - endif; | |
| 870 | + if (strlen($mn['key0']) > 0) : | |
| 871 | + unset($this->link->settings[$mn['key0']]); // out with the old | |
| 766 | 872 | endif; |
| 767 | 873 | |
| 768 | - else : | |
| 769 | - // Global | |
| 770 | - update_option('feedwordpress_cat_id', $post['syndication_category']); | |
| 771 | - | |
| 772 | - if (!isset($post['automatic_updates']) or !in_array($post['automatic_updates'], array('init', 'shutdown'))) : | |
| 773 | - $automatic_updates = false; | |
| 774 | - else : | |
| 775 | - $automatic_updates = $post['automatic_updates']; | |
| 874 | + if (($mn['action']=='update') and (strlen($mn['key1']) > 0)) : | |
| 875 | + $this->link->settings[$mn['key1']] = $mn['value']; // in with the new | |
| 776 | 876 | endif; |
| 777 | - update_option('feedwordpress_automatic_updates', $automatic_updates); | |
| 877 | + endforeach; | |
| 878 | + | |
| 879 | + // now stuff through the web form | |
| 880 | + // hardcoded feed info | |
| 881 | + | |
| 882 | + foreach (array('name', 'description', 'url') as $what) : | |
| 883 | + // We have a checkbox for "No," so if it's unchecked, mark as "Yes." | |
| 884 | + $this->link->settings["hardcode {$what}"] = (isset($post["hardcode_{$what}"]) ? $post["hardcode_{$what}"] : 'yes'); | |
| 885 | + if (FeedWordPress::affirmative($this->link->settings, "hardcode {$what}")) : | |
| 886 | + $this->link->link->{'link_'.$what} = $post['link'.$what]; | |
| 887 | + endif; | |
| 888 | + endforeach; | |
| 889 | + | |
| 890 | + // Update scheduling | |
| 891 | + if (isset($post['update_schedule'])) : | |
| 892 | + $this->link->settings['update/hold'] = $post['update_schedule']; | |
| 893 | + endif; | |
| 778 | 894 | |
| 779 | - if (isset($post['update_window'])): | |
| 780 | - if ((int) $post['update_window'] > 0) : | |
| 781 | - update_option('feedwordpress_update_window', (int) $post['update_window']); | |
| 782 | - endif; | |
| 895 | + if (isset($post['use_default_update_window']) and strtolower($post['use_default_update_window'])=='yes') : | |
| 896 | + unset($this->link->settings['update/window']); | |
| 897 | + elseif (isset($post['update_window'])): | |
| 898 | + if ((int) $post['update_window'] > 0) : | |
| 899 | + $this->link->settings['update/window'] = (int) $post['update_window']; | |
| 783 | 900 | endif; |
| 901 | + endif; | |
| 902 | + | |
| 903 | + else : | |
| 904 | + // Global | |
| 905 | + update_option('feedwordpress_cat_id', $post['syndication_category']); | |
| 906 | + | |
| 907 | + if (!isset($post['automatic_updates']) or !in_array($post['automatic_updates'], array('init', 'shutdown'))) : | |
| 908 | + $automatic_updates = false; | |
| 909 | + else : | |
| 910 | + $automatic_updates = $post['automatic_updates']; | |
| 911 | + endif; | |
| 912 | + update_option('feedwordpress_automatic_updates', $automatic_updates); | |
| 784 | 913 | |
| 785 | - update_option('feedwordpress_update_time_limit', ($post['update_time_limit']=='yes')?(int) $post['time_limit_seconds']:0); | |
| 786 | - | |
| 787 | - foreach (array('name', 'description', 'url') as $what) : | |
| 788 | - // We have a checkbox for "No," so if it's unchecked, mark as "Yes." | |
| 789 | - $hardcode = (isset($post["hardcode_{$what}"]) ? $post["hardcode_{$what}"] : 'yes'); | |
| 790 | - update_option("feedwordpress_hardcode_{$what}", $hardcode); | |
| 791 | - endforeach; | |
| 792 | - | |
| 793 | - $this->updated = true; | |
| 914 | + if (isset($post['update_window'])): | |
| 915 | + if ((int) $post['update_window'] > 0) : | |
| 916 | + update_option('feedwordpress_update_window', (int) $post['update_window']); | |
| 917 | + endif; | |
| 794 | 918 | endif; |
| 795 | - $this->updatedPosts->accept_POST($post); | |
| 796 | 919 | |
| 797 | - if ($this->for_feed_settings()) : | |
| 798 | - // Save changes to channel-level meta-data | |
| 799 | - //$alter_set = implode(", ", $alter); | |
| 920 | + update_option('feedwordpress_update_time_limit', ($post['update_time_limit']=='yes')?(int) $post['time_limit_seconds']:0); | |
| 800 | 921 | |
| 801 | - // issue update query | |
| 802 | - //$result = $wpdb->query(" | |
| 803 | - //UPDATE $wpdb->links | |
| 804 | - //SET $alter_set | |
| 805 | - //WHERE link_id='{$this->link->id}' | |
| 806 | - //"); | |
| 807 | - | |
| 808 | - // Save settings | |
| 809 | - $this->link->save_settings(/*reload=*/ true); | |
| 922 | + foreach (array('name', 'description', 'url') as $what) : | |
| 923 | + // We have a checkbox for "No," so if it's unchecked, mark as "Yes." | |
| 924 | + $hardcode = (isset($post["hardcode_{$what}"]) ? $post["hardcode_{$what}"] : 'yes'); | |
| 925 | + update_option("feedwordpress_hardcode_{$what}", $hardcode); | |
| 926 | + endforeach; | |
| 927 | + | |
| 928 | + endif; | |
| 929 | + | |
| 930 | + if (isset($post['fetch_timeout'])) : | |
| 931 | + if (isset($post['fetch_timeout_default']) and $post['fetch_timeout_default']=='yes') : | |
| 932 | + $timeout = NULL; | |
| 933 | + else : | |
| 934 | + $timeout = $post['fetch_timeout']; | |
| 935 | + endif; | |
| 810 | 936 | |
| 811 | - $this->updated = true; | |
| 812 | - | |
| 813 | - // Reset, reload | |
| 814 | - $link_id = $this->link->id; unset($this->link); | |
| 815 | - $this->link = new SyndicatedLink($link_id); | |
| 937 | + if (is_int($timeout)) : | |
| 938 | + $timeout = intval($timeout); | |
| 816 | 939 | endif; |
| 817 | - | |
| 818 | - // Probably a "Go" button for the drop-down | |
| 819 | - else : | |
| 820 | - $this->updated = false; | |
| 940 | + $this->update_setting('fetch timeout', $timeout); | |
| 821 | 941 | endif; |
| 822 | - } /* WordPressFeedsPage::accept_POST() */ | |
| 942 | + | |
| 943 | + $this->updatedPosts->accept_POST($post); | |
| 944 | + parent::save_settings($post); | |
| 945 | + } /* FeedWordPressFeedsPage::save_settings() */ | |
| 823 | 946 | |
| 824 | 947 | } /* class FeedWordPressFeedsPage */ |
| 825 | 948 | |
| 826 | 949 | $feedsPage = new FeedWordPressFeedsPage; |