| @@ -1,26 +1,176 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | require_once(dirname(__FILE__) . '/admin-ui.php'); |
| 3 | 3 | |
| 4 | +class FeedWordPressAuthorsPage extends FeedWordPressAdminPage { | |
| 5 | + var $authorlist = NULL; | |
| 6 | + var $rule_count = 0; | |
| 7 | + | |
| 8 | + function FeedWordPressAuthorsPage ($link) { | |
| 9 | + FeedWordPressAdminPage::FeedWordPressAdminPage('feedwordpressauthors', $link); | |
| 10 | + $this->authorlist = fwp_author_list(); | |
| 11 | + $this->dispatch = 'feedwordpress_author_settings'; | |
| 12 | + $this->filename = __FILE__; | |
| 13 | + } | |
| 14 | + | |
| 15 | + /*static*/ function syndicated_authors_box ($page, $box = NULL) { | |
| 16 | + $link = $page->link; | |
| 17 | + $unfamiliar = array ('create' => '','default' => '','filter' => ''); | |
| 18 | + | |
| 19 | + if ($page->for_feed_settings()) : | |
| 20 | + if (is_string($link->settings["unfamiliar author"])) : | |
| 21 | + $key = $link->settings["unfamiliar author"]; | |
| 22 | + else: | |
| 23 | + $key = 'site-default'; | |
| 24 | + endif; | |
| 25 | + else : | |
| 26 | + $key = FeedWordPress::on_unfamiliar('author'); | |
| 27 | + endif; | |
| 28 | + $unfamiliar[$key] = ' selected="selected"'; | |
| 29 | + | |
| 30 | + $match_author_by_email = !('yes' == get_option("feedwordpress_do_not_match_author_by_email")); | |
| 31 | + $null_emails = FeedWordPress::null_email_set(); | |
| 32 | + | |
| 33 | + // Hey ho, let's go... | |
| 34 | + ?> | |
| 35 | +<table class="form-table"> | |
| 36 | +<tbody> | |
| 37 | +<tr> | |
| 38 | + <th>New authors</th> | |
| 39 | + <td><span>Authors who haven't been syndicated before</span> | |
| 40 | + <select style="max-width: 27.0em" id="unfamiliar-author" name="unfamiliar_author" onchange="contextual_appearance('unfamiliar-author', 'unfamiliar-author-newuser', 'unfamiliar-author-default', 'newuser', 'inline');"> | |
| 41 | +<?php if ($page->for_feed_settings()) : ?> | |
| 42 | + <option value="site-default"<?php print $unfamiliar['site-default']; ?>>are handled according to the default for all feeds</option> | |
| 43 | +<?php endif; ?> | |
| 44 | + <option value="create"<?php $unfamiliar['create']; ?>>will have a new author account created for them</option> | |
| 45 | + <?php foreach ($page->authorlist as $author_id => $author_name) : ?> | |
| 46 | + <option value="<?php echo $author_id; ?>"<?php print $unfamiliar[$author_id]; ?>>will have their posts attributed to <?php echo $author_name; ?></option> | |
| 47 | + <?php endforeach; ?> | |
| 48 | + <option value="newuser">will have their posts attributed to a new user...</option> | |
| 49 | + <option value="filter"<?php print $unfamiliar['filter'] ?>>get filtered out</option> | |
| 50 | + </select> | |
| 51 | + | |
| 52 | + <span id="unfamiliar-author-newuser">named <input type="text" name="unfamiliar_author_newuser" value="" /></span></p> | |
| 53 | + </td> | |
| 54 | +</tr> | |
| 55 | + | |
| 56 | +<?php | |
| 57 | +if ($page->for_feed_settings()) : | |
| 58 | +?> | |
| 59 | +<tr><th>Syndicated authors</th> | |
| 60 | +<td>For attributing posts by specific authors. Blank out a name to delete the rule. Fill in a new name at the bottom to create a new rule.</p> | |
| 61 | +<table style="width: 100%"> | |
| 62 | +<?php | |
| 63 | + if (isset($link->settings['map authors'])) : | |
| 64 | +?> | |
| 65 | +<?php | |
| 66 | + $page->rule_count=0; | |
| 67 | + foreach ($link->settings['map authors'] as $author_rules) : | |
| 68 | + foreach ($author_rules as $author_name => $author_action) : | |
| 69 | + $page->rule_count++; | |
| 70 | +?> | |
| 71 | +<tr> | |
| 72 | +<th style="text-align: left; width: 15.0em">Posts by <input type="text" name="author_rules_name[]" value="<?php echo htmlspecialchars($author_name); ?>" size="11" /></th> | |
| 73 | + <td> | |
| 74 | + <select id="author-rules-<?php echo $page->rule_count; ?>" name="author_rules_action[]" onchange="contextual_appearance('author-rules-<?php echo $page->rule_count; ?>', 'author-rules-<?php echo $page->rule_count; ?>-newuser', 'author-rules-<?php echo $page->rule_count; ?>-default', 'newuser', 'inline');"> | |
| 75 | + <?php foreach ($page->authorlist as $local_author_id => $local_author_name) : ?> | |
| 76 | + <option value="<?php echo $local_author_id; ?>"<?php if ($local_author_id==$author_action) : echo ' selected="selected"'; endif; ?>>are assigned to <?php echo $local_author_name; ?></option> | |
| 77 | + <?php endforeach; ?> | |
| 78 | + <option value="newuser">will be assigned to a new user...</option> | |
| 79 | + <option value="filter"<?php if ('filter'==$author_action) : echo ' selected="selected"'; endif; ?>>get filtered out</option> | |
| 80 | + </select> | |
| 81 | + | |
| 82 | + <span id="author-rules-<?php echo $page->rule_count; ?>-newuser">named <input type="text" name="author_rules_newuser[]" value="" /></span> | |
| 83 | + </td> | |
| 84 | +</tr> | |
| 85 | +<?php endforeach; | |
| 86 | + endforeach; | |
| 87 | + endif; | |
| 88 | +?> | |
| 89 | + | |
| 90 | +<tr> | |
| 91 | +<th style="text-align: left; width: 15.0em">Posts by <input type="text" name="add_author_rule_name" size="11" /></th> | |
| 92 | + <td> | |
| 93 | + <select id="add-author-rule" name="add_author_rule_action" onchange="contextual_appearance('add-author-rule', 'add-author-rule-newuser', 'add-author-rule-default', 'newuser', 'inline');"> | |
| 94 | + <?php foreach ($page->authorlist as $author_id => $author_name) : ?> | |
| 95 | + <option value="<?php echo $author_id; ?>">are assigned to <?php echo $author_name; ?></option> | |
| 96 | + <?php endforeach; ?> | |
| 97 | + <option value="newuser">will be assigned to a new user...</option> | |
| 98 | + <option value="filter">get filtered out</option> | |
| 99 | + </select> | |
| 100 | + | |
| 101 | + <span id="add-author-rule-newuser">named <input type="text" name="add_author_rule_newuser" value="" /></span> | |
| 102 | + </td> | |
| 103 | +</tr> | |
| 104 | +</table> | |
| 105 | +</td> | |
| 106 | +</tr> | |
| 107 | +<?php endif; ?> | |
| 108 | + | |
| 109 | +<?php if ($page->for_default_settings()) : ?> | |
| 110 | +<tr> | |
| 111 | +<th scope="row">Matching Authors</th> | |
| 112 | +<td><ul style="list-style: none; margin: 0; padding: 0;"> | |
| 113 | +<li><div><label><input id="match-author-by-email" type="checkbox" name="match_author_by_email" value="yes" <?php if ($match_author_by_email) : ?>checked="checked" <?php endif; ?>onchange="contextual_appearance('match-author-by-email', 'unless-null-email', null, 'yes', 'block', /*checkbox=*/ true);" /> Treat syndicated authors with the same e-mail address as the same author.</label></div> | |
| 114 | +<div id="unless-null-email"> | |
| 115 | +<p>Unless the e-mail address is one of the following anonymous e-mail addresses:</p> | |
| 116 | +<textarea name="null_emails" rows="3" style="width: 100%"> | |
| 117 | +<?php print implode("\n", $null_emails); ?> | |
| 118 | +</textarea> | |
| 119 | +</div></li> | |
| 120 | +</ul></td> | |
| 121 | +</tr> | |
| 122 | +<?php endif; ?> | |
| 123 | +</tbody> | |
| 124 | +</table> | |
| 125 | + <?php | |
| 126 | + } /* FeedWordPressAuthorsPage::syndicated_authors_box () */ | |
| 127 | + | |
| 128 | + /*static*/ function fix_authors_box ($page, $box = NULL) { | |
| 129 | + ?> | |
| 130 | + <table class="form-table"> | |
| 131 | + <tbody> | |
| 132 | + <tr> | |
| 133 | + <th scope="row">Fixing mis-matched authors:</th> | |
| 134 | + <td><p style="margin: 0.5em 0px">Take all the posts from this feed attributed to | |
| 135 | + <select name="fix_mismatch_from"> | |
| 136 | + <?php foreach ($page->authorlist as $author_id => $author_name) : ?> | |
| 137 | + <option value="<?php echo $author_id; ?>"><?php echo $author_name; ?></option> | |
| 138 | + <?php endforeach; ?> | |
| 139 | + </select> | |
| 140 | + and instead | |
| 141 | + <select id="fix-mismatch-to" name="fix_mismatch_to" onchange="contextual_appearance('fix-mismatch-to', 'fix-mismatch-to-newuser', null, 'newuser', 'inline');"> | |
| 142 | + <?php foreach ($page->authorlist as $author_id => $author_name) : ?> | |
| 143 | + <option value="<?php echo $author_id; ?>">re-assign them to <?php echo $author_name; ?></option> | |
| 144 | + <?php endforeach; ?> | |
| 145 | + <option value="newuser">re-assign them to a new user...</option> | |
| 146 | + <option value="filter">delete them</option> | |
| 147 | + </select> | |
| 148 | + | |
| 149 | + <span id="fix-mismatch-to-newuser">named <input type="text" name="fix_mismatch_to_newuser" value="" /></span> | |
| 150 | + <input type="submit" class="button" name="fix_mismatch" value="Fix it!" /> | |
| 151 | + </td> | |
| 152 | + </tr> | |
| 153 | + </tbody> | |
| 154 | + </table> | |
| 155 | + <?php | |
| 156 | + } /* FeedWordPressAuthorsPage::fix_authors_box () */ | |
| 157 | +} /* class FeedWordPressAuthorsPage */ | |
| 158 | + | |
| 4 | 159 | function fwp_authors_page () { |
| 5 | 160 | global $wpdb, $wp_db_version; |
| 6 | 161 | |
| 162 | + if (FeedWordPress::needs_upgrade()) : | |
| 163 | + fwp_upgrade_page(); | |
| 164 | + return; | |
| 165 | + endif; | |
| 166 | + | |
| 7 | 167 | FeedWordPressCompatibility::validate_http_request(/*action=*/ 'feedwordpress_author_settings', /*capability=*/ 'manage_links'); |
| 8 | 168 | |
| 9 | - if (isset($GLOBALS['fwp_post']['save']) or isset($GLOBALS['fwp_post']['fix_mismatch'])) : | |
| 10 | - $link_id = $_REQUEST['save_link_id']; | |
| 11 | - elseif (isset($_REQUEST['link_id'])) : | |
| 12 | - $link_id = $_REQUEST['link_id']; | |
| 13 | - else : | |
| 14 | - $link_id = NULL; | |
| 15 | - endif; | |
| 169 | + $link = FeedWordPressAdminPage::submitted_link(); | |
| 170 | + $link_id = $link->id; | |
| 171 | + $authorsPage = new FeedWordPressAuthorsPage($link); | |
| 16 | 172 | |
| 17 | - if (is_numeric($link_id) and $link_id) : | |
| 18 | - $link =& new SyndicatedLink($link_id); | |
| 19 | - else : | |
| 20 | - $link = NULL; | |
| 21 | - endif; | |
| 22 | - | |
| 23 | 173 | $mesg = null; |
| 24 | 174 | |
| 25 | 175 | if (isset($GLOBALS['fwp_post']['fix_mismatch'])) : |
| 26 | 176 | if ('newuser'==$GLOBALS['fwp_post']['fix_mismatch_to']) : |
| @@ -138,26 +288,16 @@ | ||
| 138 | 288 | $link->settings['map authors']['name'][$name] = $author_action; |
| 139 | 289 | endif; |
| 140 | 290 | endif; |
| 141 | 291 | endif; |
| 142 | - | |
| 143 | - $alter[] = "link_notes = '".$wpdb->escape($link->settings_to_notes())."'"; | |
| 144 | - | |
| 145 | - $alter_set = implode(", ", $alter); | |
| 146 | - | |
| 147 | - // issue update query | |
| 148 | - $result = $wpdb->query(" | |
| 149 | - UPDATE $wpdb->links | |
| 150 | - SET $alter_set | |
| 151 | - WHERE link_id='$link_id' | |
| 152 | - "); | |
| 292 | + | |
| 293 | + // Save settings | |
| 294 | + $link->save_settings(/*reload=*/ true); | |
| 153 | 295 | $updated_link = true; |
| 154 | - | |
| 155 | - // reload link information from DB | |
| 156 | - if (function_exists('clean_bookmark_cache')) : | |
| 157 | - clean_bookmark_cache($link_id); | |
| 158 | - endif; | |
| 159 | - $link =& new SyndicatedLink($link_id); | |
| 296 | + | |
| 297 | + // Reset, reload | |
| 298 | + unset($link); | |
| 299 | + $link = new SyndicatedLink($link_id); | |
| 160 | 300 | else : |
| 161 | 301 | if ('newuser'==$GLOBALS['fwp_post']['unfamiliar_author']) : |
| 162 | 302 | $newuser_name = trim($GLOBALS['fwp_post']['unfamiliar_author_newuser']); |
| 163 | 303 | if (strlen($newuser_name) > 0) : |
| @@ -196,266 +336,81 @@ | ||
| 196 | 336 | endif; |
| 197 | 337 | |
| 198 | 338 | $updated_link = true; |
| 199 | 339 | endif; |
| 340 | + | |
| 341 | + do_action('feedwordpress_admin_page_authors_save', $GLOBALS['fwp_post'], $authorsPage); | |
| 200 | 342 | else : |
| 201 | 343 | $updated_link = false; |
| 202 | 344 | endif; |
| 345 | + | |
| 346 | + //////////////////////////////////////////////// | |
| 347 | + // Prepare settings page /////////////////////// | |
| 348 | + //////////////////////////////////////////////// | |
| 203 | 349 | |
| 204 | - $unfamiliar = array ('create' => '','default' => '','filter' => ''); | |
| 205 | - | |
| 206 | - if (is_object($link) and $link->found()) : | |
| 207 | - if (is_string($link->settings["unfamiliar author"])) : | |
| 208 | - $key = $link->settings["unfamiliar author"]; | |
| 209 | - else: | |
| 210 | - $key = 'site-default'; | |
| 211 | - endif; | |
| 212 | - else : | |
| 213 | - $key = FeedWordPress::on_unfamiliar('author'); | |
| 214 | - endif; | |
| 215 | - | |
| 216 | - $unfamiliar[$key] = ' selected="selected"'; | |
| 217 | - | |
| 218 | - $match_author_by_email = !('yes' == get_option("feedwordpress_do_not_match_author_by_email")); | |
| 219 | - $null_emails = FeedWordPress::null_email_set(); | |
| 350 | + if ($updated_link) : | |
| 220 | 351 | ?> |
| 221 | -<script type="text/javascript"> | |
| 222 | - function contextual_appearance (item, appear, disappear, value, visibleStyle, checkbox) { | |
| 223 | - if (typeof(visibleStyle)=='undefined') visibleStyle = 'block'; | |
| 224 | - | |
| 225 | - var rollup=document.getElementById(item); | |
| 226 | - var newuser=document.getElementById(appear); | |
| 227 | - var sitewide=document.getElementById(disappear); | |
| 228 | - if (rollup) { | |
| 229 | - if ((checkbox && rollup.checked) || (!checkbox && value==rollup.value)) { | |
| 230 | - if (newuser) newuser.style.display=visibleStyle; | |
| 231 | - if (sitewide) sitewide.style.display='none'; | |
| 232 | - } else { | |
| 233 | - if (newuser) newuser.style.display='none'; | |
| 234 | - if (sitewide) sitewide.style.display=visibleStyle; | |
| 235 | - } | |
| 236 | - } | |
| 237 | - } | |
| 238 | -</script> | |
| 239 | - | |
| 240 | -<?php if ($updated_link) : ?> | |
| 241 | 352 | <div class="updated"><p>Syndicated author settings updated.</p></div> |
| 242 | 353 | <?php elseif (!is_null($mesg)) : ?> |
| 243 | -<div class="updated"><p><?php print wp_specialchars($mesg, 1); ?></p></div> | |
| 244 | -<?php endif; ?> | |
| 354 | +<div class="updated"><p><?php print esc_html($mesg); ?></p></div> | |
| 355 | +<?php endif; | |
| 245 | 356 | |
| 246 | -<div class="wrap"> | |
| 247 | -<form style="position: relative" action="admin.php?page=<?php print $GLOBALS['fwp_path'] ?>/<?php echo basename(__FILE__); ?>" method="post"> | |
| 248 | -<div><?php | |
| 249 | - FeedWordPressCompatibility::stamp_nonce('feedwordpress_author_settings'); | |
| 250 | - | |
| 251 | - if (is_numeric($link_id) and $link_id) : | |
| 252 | -?> | |
| 253 | -<input type="hidden" name="save_link_id" value="<?php echo $link_id; ?>" /> | |
| 254 | -<?php | |
| 255 | - else : | |
| 256 | -?> | |
| 257 | -<input type="hidden" name="save_link_id" value="*" /> | |
| 258 | -<?php | |
| 357 | + if (function_exists('add_meta_box')) : | |
| 358 | + add_action( | |
| 359 | + FeedWordPressCompatibility::bottom_script_hook(__FILE__), | |
| 360 | + /*callback=*/ array($authorsPage, 'fix_toggles'), | |
| 361 | + /*priority=*/ 10000 | |
| 362 | + ); | |
| 363 | + FeedWordPressSettingsUI::ajax_nonce_fields(); | |
| 259 | 364 | endif; |
| 260 | -?> | |
| 261 | -</div> | |
| 262 | 365 | |
| 263 | -<?php $links = FeedWordPress::syndicated_links(); ?> | |
| 264 | -<?php if (fwp_test_wp_version(FWP_SCHEMA_27)) : ?> | |
| 265 | - <div class="icon32"><img src="<?php print htmlspecialchars(WP_PLUGIN_URL.'/'.$GLOBALS['fwp_path'].'/feedwordpress.png'); ?>" alt="" /></div> | |
| 266 | -<?php endif; ?> | |
| 267 | -<h2>Syndicated Author Settings<?php if (!is_null($link) and $link->found()) : ?>: <?php echo wp_specialchars($link->link->link_name, 1); ?><?php endif; ?></h2> | |
| 268 | -<?php if (fwp_test_wp_version(FWP_SCHEMA_27)) : ?> | |
| 269 | - <style type="text/css"> | |
| 270 | - #post-search { | |
| 271 | - float: right; | |
| 272 | - margin:11px 12px 0; | |
| 273 | - min-width: 130px; | |
| 274 | - position:relative; | |
| 275 | - } | |
| 276 | - .fwpfs { | |
| 277 | - color: #dddddd; | |
| 278 | - background:#797979 url(<?php bloginfo('home') ?>/wp-admin/images/fav.png) repeat-x scroll left center; | |
| 279 | - border-color:#777777 #777777 #666666 !important; -moz-border-radius-bottomleft:12px; | |
| 280 | - -moz-border-radius-bottomright:12px; | |
| 281 | - -moz-border-radius-topleft:12px; | |
| 282 | - -moz-border-radius-topright:12px; | |
| 283 | - border-style:solid; | |
| 284 | - border-width:1px; | |
| 285 | - line-height:15px; | |
| 286 | - padding:3px 30px 4px 12px; | |
| 287 | - } | |
| 288 | - .fwpfs.slide-down { | |
| 289 | - border-bottom-color: #626262; | |
| 290 | - -moz-border-radius-bottomleft:0; | |
| 291 | - -moz-border-radius-bottomright:0; | |
| 292 | - -moz-border-radius-topleft:12px; | |
| 293 | - -moz-border-radius-topright:12px; | |
| 294 | - background-image:url(<?php bloginfo('home') ?>/wp-admin/images/fav-top.png); | |
| 295 | - background-position:0 top; | |
| 296 | - background-repeat:repeat-x; | |
| 297 | - border-bottom-style:solid; | |
| 298 | - border-bottom-width:1px; | |
| 299 | - } | |
| 300 | - </style> | |
| 301 | - | |
| 302 | - <script type="text/javascript"> | |
| 303 | - jQuery(document).ready(function($){ | |
| 304 | - $('.fwpfs').toggle( | |
| 305 | - function(){$('.fwpfs').removeClass('slideUp').addClass('slideDown'); setTimeout(function(){if ( $('.fwpfs').hasClass('slideDown') ) { $('.fwpfs').addClass('slide-down'); }}, 10) }, | |
| 306 | - function(){$('.fwpfs').removeClass('slideDown').addClass('slideUp'); setTimeout(function(){if ( $('.fwpfs').hasClass('slideUp') ) { $('.fwpfs').removeClass('slide-down'); }}, 10) } | |
| 307 | - ); | |
| 308 | - $('.fwpfs').bind( | |
| 309 | - 'change', | |
| 310 | - function () { this.form.submit(); } | |
| 311 | - ); | |
| 312 | - $('#post-search .button').css( 'display', 'none' ); | |
| 313 | - }); | |
| 314 | - </script> | |
| 315 | -<?php endif; /* else : */?> | |
| 316 | -<p id="post-search"> | |
| 317 | -<select name="link_id" class="fwpfs" style="max-width: 20.0em;"> | |
| 318 | - <option value="*"<?php if (is_null($link) or !$link->found()) : ?> selected="selected"<?php endif; ?>>- defaults for all feeds -</option> | |
| 319 | -<?php if ($links) : foreach ($links as $ddlink) : ?> | |
| 320 | - <option value="<?php print (int) $ddlink->link_id; ?>"<?php if (!is_null($link) and ($link->link->link_id==$ddlink->link_id)) : ?> selected="selected"<?php endif; ?>><?php print wp_specialchars($ddlink->link_name, 1); ?></option> | |
| 321 | -<?php endforeach; endif; ?> | |
| 322 | -</select> | |
| 323 | -<input class="button" type="submit" name="go" value="<?php _e('Go') ?> »" /> | |
| 324 | -</p> | |
| 325 | -<?php /* endif; */ ?> | |
| 366 | + $authorsPage->open_sheet('Syndicated Author'); | |
| 367 | + ?> | |
| 368 | + <div id="post-body"> | |
| 369 | + <?php | |
| 370 | + //////////////////////////////////////////////// | |
| 371 | + // Display settings boxes ////////////////////// | |
| 372 | + //////////////////////////////////////////////// | |
| 326 | 373 | |
| 327 | -<?php if (!is_null($link) and $link->found()) : ?> | |
| 328 | - <p>These settings only affect posts syndicated from | |
| 329 | - <strong><?php echo wp_specialchars($link->link->link_name, 1); ?></strong>.</p> | |
| 330 | -<?php else : ?> | |
| 331 | - <p>These settings affect posts syndicated from any feed unless they are overridden | |
| 332 | - by settings for that specific feed.</p> | |
| 333 | -<?php endif; ?> | |
| 374 | + $boxes_by_methods = array( | |
| 375 | + 'syndicated_authors_box' => __('Syndicated Authors'), | |
| 376 | + 'fix_authors_box' => __('Reassign Authors'), | |
| 377 | + ); | |
| 378 | + if ($authorsPage->for_default_settings()) : | |
| 379 | + unset($boxes_by_methods['fix_authors_box']); | |
| 380 | + endif; | |
| 334 | 381 | |
| 335 | -<?php | |
| 336 | - $authorlist = fwp_author_list(); | |
| 337 | -?> | |
| 338 | -<table class="form-table"> | |
| 339 | -<tbody> | |
| 340 | -<tr> | |
| 341 | - <th>New authors</th> | |
| 342 | - <td><span>Authors who haven't been syndicated before</span> | |
| 343 | - <select style="max-width: 27.0em" id="unfamiliar-author" name="unfamiliar_author" onchange="contextual_appearance('unfamiliar-author', 'unfamiliar-author-newuser', 'unfamiliar-author-default', 'newuser', 'inline');"> | |
| 344 | -<?php if (is_object($link) and $link->found()) : ?> | |
| 345 | - <option value="site-default"<?php print $unfamiliar['site-default']; ?>>are handled according to the default for all feeds</option> | |
| 346 | -<?php endif; ?> | |
| 347 | - <option value="create"<?php $unfamiliar['create']; ?>>will have a new author account created for them</option> | |
| 348 | - <?php foreach ($authorlist as $author_id => $author_name) : ?> | |
| 349 | - <option value="<?php echo $author_id; ?>"<?php print $unfamiliar[$author_id]; ?>>will have their posts attributed to <?php echo $author_name; ?></option> | |
| 350 | - <?php endforeach; ?> | |
| 351 | - <option value="newuser">will have their posts attributed to a new user...</option> | |
| 352 | - <option value="filter"<?php print $unfamiliar['filter'] ?>>get filtered out</option> | |
| 353 | - </select> | |
| 382 | + foreach ($boxes_by_methods as $method => $row) : | |
| 383 | + if (is_array($row)) : | |
| 384 | + $id = $row['id']; | |
| 385 | + $title = $row['title']; | |
| 386 | + else : | |
| 387 | + $id = 'feedwordpress_'.$method; | |
| 388 | + $title = $row; | |
| 389 | + endif; | |
| 354 | 390 | |
| 355 | - <span id="unfamiliar-author-newuser">named <input type="text" name="unfamiliar_author_newuser" value="" /></span></p> | |
| 356 | - </td> | |
| 357 | -</tr> | |
| 358 | - | |
| 359 | -<?php | |
| 360 | -if (is_object($link) and $link->found()) : | |
| 391 | + fwp_add_meta_box( | |
| 392 | + /*id=*/ $id, | |
| 393 | + /*title=*/ $title, | |
| 394 | + /*callback=*/ array('FeedWordPressAuthorsPage', $method), | |
| 395 | + /*page=*/ $authorsPage->meta_box_context(), | |
| 396 | + /*context=*/ $authorsPage->meta_box_context() | |
| 397 | + ); | |
| 398 | + endforeach; | |
| 399 | + do_action('feedwordpress_admin_page_authors_meta_boxes', $authorsPage); | |
| 361 | 400 | ?> |
| 362 | -<tr><th>Syndicated authors</th> | |
| 363 | -<td>For attributing posts by specific authors. Blank out a name to delete the rule. Fill in a new name at the bottom to create a new rule.</p> | |
| 364 | -<table style="width: 100%"> | |
| 401 | + <div class="metabox-holder"> | |
| 365 | 402 | <?php |
| 366 | - if (isset($link->settings['map authors'])) : | |
| 403 | + fwp_do_meta_boxes($authorsPage->meta_box_context(), $authorsPage->meta_box_context(), $authorsPage); | |
| 367 | 404 | ?> |
| 368 | -<?php | |
| 369 | - $i=0; | |
| 370 | - foreach ($link->settings['map authors'] as $author_rules) : | |
| 371 | - foreach ($author_rules as $author_name => $author_action) : | |
| 372 | - $i++; | |
| 373 | -?> | |
| 374 | -<tr> | |
| 375 | -<th style="text-align: left; width: 15.0em">Posts by <input type="text" name="author_rules_name[]" value="<?php echo htmlspecialchars($author_name); ?>" size="11" /></th> | |
| 376 | - <td> | |
| 377 | - <select id="author-rules-<?php echo $i; ?>" name="author_rules_action[]" onchange="contextual_appearance('author-rules-<?php echo $i; ?>', 'author-rules-<?php echo $i; ?>-newuser', 'author-rules-<?php echo $i; ?>-default', 'newuser', 'inline');"> | |
| 378 | - <?php foreach ($authorlist as $local_author_id => $local_author_name) : ?> | |
| 379 | - <option value="<?php echo $local_author_id; ?>"<?php if ($local_author_id==$author_action) : echo ' selected="selected"'; endif; ?>>are assigned to <?php echo $local_author_name; ?></option> | |
| 380 | - <?php endforeach; ?> | |
| 381 | - <option value="newuser">will be assigned to a new user...</option> | |
| 382 | - <option value="filter"<?php if ('filter'==$author_action) : echo ' selected="selected"'; endif; ?>>get filtered out</option> | |
| 383 | - </select> | |
| 384 | - | |
| 385 | - <span id="author-rules-<?php echo $i; ?>-newuser">named <input type="text" name="author_rules_newuser[]" value="" /></span> | |
| 386 | - </td> | |
| 387 | -</tr> | |
| 388 | -<?php endforeach; | |
| 389 | - endforeach; | |
| 390 | - endif; | |
| 391 | -?> | |
| 405 | + </div> <!-- class="metabox-holder" --> | |
| 406 | +</div> <!-- id="post-body" --> | |
| 407 | +<?php $authorsPage->close_sheet(); ?> | |
| 392 | 408 | |
| 393 | -<tr> | |
| 394 | -<th style="text-align: left; width: 15.0em">Posts by <input type="text" name="add_author_rule_name" size="11" /></th> | |
| 395 | - <td> | |
| 396 | - <select id="add-author-rule" name="add_author_rule_action" onchange="contextual_appearance('add-author-rule', 'add-author-rule-newuser', 'add-author-rule-default', 'newuser', 'inline');"> | |
| 397 | - <?php foreach ($authorlist as $author_id => $author_name) : ?> | |
| 398 | - <option value="<?php echo $author_id; ?>">are assigned to <?php echo $author_name; ?></option> | |
| 399 | - <?php endforeach; ?> | |
| 400 | - <option value="newuser">will be assigned to a new user...</option> | |
| 401 | - <option value="filter">get filtered out</option> | |
| 402 | - </select> | |
| 403 | - | |
| 404 | - <span id="add-author-rule-newuser">named <input type="text" name="add_author_rule_newuser" value="" /></span> | |
| 405 | - </td> | |
| 406 | -</tr> | |
| 407 | -</table> | |
| 408 | -</td> | |
| 409 | -</tr> | |
| 410 | -<?php endif; ?> | |
| 411 | - | |
| 412 | -<?php if (!(is_object($link) and $link->found())) : ?> | |
| 413 | -<tr> | |
| 414 | -<th scope="row">Matching Authors</th> | |
| 415 | -<td><ul style="list-style: none; margin: 0; padding: 0;"> | |
| 416 | -<li><div><label><input id="match-author-by-email" type="checkbox" name="match_author_by_email" value="yes" <?php if ($match_author_by_email) : ?>checked="checked" <?php endif; ?>onchange="contextual_appearance('match-author-by-email', 'unless-null-email', null, 'yes', 'block', /*checkbox=*/ true);" /> Treat syndicated authors with the same e-mail address as the same author.</label></div> | |
| 417 | -<div id="unless-null-email"> | |
| 418 | -<p>Unless the e-mail address is one of the following anonymous e-mail addresses:</p> | |
| 419 | -<textarea name="null_emails" rows="3" style="width: 100%"> | |
| 420 | -<?php print implode("\n", $null_emails); ?> | |
| 421 | -</textarea> | |
| 422 | -</div></li> | |
| 423 | -</ul></td> | |
| 424 | -</tr> | |
| 425 | -<?php else : ?> | |
| 426 | -<th scope="row">Fixing mis-matched authors:</th> | |
| 427 | -<td><p style="margin: 0.5em 0px">Take all the posts from this feed attributed to | |
| 428 | -<select name="fix_mismatch_from"> | |
| 429 | -<?php foreach ($authorlist as $author_id => $author_name) : ?> | |
| 430 | - <option value="<?php echo $author_id; ?>"><?php echo $author_name; ?></option> | |
| 431 | -<?php endforeach; ?> | |
| 432 | -</select> | |
| 433 | -and instead | |
| 434 | -<select id="fix-mismatch-to" name="fix_mismatch_to" onchange="contextual_appearance('fix-mismatch-to', 'fix-mismatch-to-newuser', null, 'newuser', 'inline');"> | |
| 435 | -<?php foreach ($authorlist as $author_id => $author_name) : ?> | |
| 436 | - <option value="<?php echo $author_id; ?>">re-assign them to <?php echo $author_name; ?></option> | |
| 437 | -<?php endforeach; ?> | |
| 438 | - <option value="newuser">re-assign them to a new user...</option> | |
| 439 | - <option value="filter">delete them</option> | |
| 440 | -</select> | |
| 441 | - | |
| 442 | - <span id="fix-mismatch-to-newuser">named <input type="text" name="fix_mismatch_to_newuser" value="" /></span> | |
| 443 | - <input type="submit" class="button" name="fix_mismatch" value="Fix it!" /> | |
| 444 | - </td> | |
| 445 | -</td> | |
| 446 | -<?php endif; ?> | |
| 447 | -</tbody> | |
| 448 | -</table> | |
| 449 | - | |
| 450 | -<p class="submit"> | |
| 451 | -<input class="button-primary" type="submit" name="save" value="Save Changes" /> | |
| 452 | -</p> | |
| 453 | - | |
| 454 | 409 | <script type="text/javascript"> |
| 455 | 410 | contextual_appearance('unfamiliar-author', 'unfamiliar-author-newuser', 'unfamiliar-author-default', 'newuser', 'inline'); |
| 456 | 411 | <?php if (is_object($link) and $link->found()) : ?> |
| 457 | -<?php for ($j=1; $j<=$i; $j++) : ?> | |
| 412 | +<?php for ($j=1; $j<=$authorsPage->rule_count; $j++) : ?> | |
| 458 | 413 | contextual_appearance('author-rules-<?php echo $j; ?>', 'author-rules-<?php echo $j; ?>-newuser', 'author-rules-<?php echo $j; ?>-default', 'newuser', 'inline'); |
| 459 | 414 | <?php endfor; ?> |
| 460 | 415 | contextual_appearance('add-author-rule', 'add-author-rule-newuser', 'add-author-rule-default', 'newuser', 'inline'); |
| 461 | 416 | contextual_appearance('fix-mismatch-to', 'fix-mismatch-to-newuser', null, 'newuser', 'inline'); |
| @@ -462,10 +417,8 @@ | ||
| 462 | 417 | <?php else : ?> |
| 463 | 418 | contextual_appearance('match-author-by-email', 'unless-null-email', null, 'yes', 'block', /*checkbox=*/ true); |
| 464 | 419 | <?php endif; ?> |
| 465 | 420 | </script> |
| 466 | -</form> | |
| 467 | -</div> <!-- class="wrap" --> | |
| 468 | 421 | <?php |
| 469 | 422 | } /* function fwp_authors_page () */ |
| 470 | 423 | |
| 471 | 424 | fwp_authors_page(); |