function categories_box ($page, $box = NULL) {
$link = $page->link;
if ($this->for_feed_settings()) :
$post_type = $link->setting('syndicated post type', 'syndicated_post_type', 'post');
else :
$post_type = get_option('feedwordpress_syndicated_post_type', 'post');
endif;
$taxonomies = get_object_taxonomies(array('object_type' => $post_type), 'names');
$option_map = $this->term_option_map();
$setting_map = $this->term_setting_map();
$globalTax = get_option('feedwordpress_syndication_terms', array());
if ($page->for_feed_settings()) :
$terms = $link->setting('terms', NULL, array());
endif;
?>
<table class="edit-form narrow">
<tbody>
<?php
foreach ($taxonomies as $tax) :
$taxonomy = get_taxonomy($tax);
?>
<tr><th><?php print $taxonomy->labels->name; ?></th>
<td><?php
if (isset($option_map[$tax])) :
$option = $option_map[$tax];
$globalCats = preg_split(FEEDWORDPRESS_CAT_SEPARATOR_PATTERN, get_option($option));
elseif (isset($globalTax[$tax])) :
$globalCats = $globalTax[$tax];
else :
$globalCats = array();
endif;
$globalCats = array_map('trim', $globalCats);
if ($page->for_feed_settings()) :
$add_global_categories = $link->setting("add/$tax", NULL, 'yes');
$checked = array('yes' => '', 'no' => '');
$checked[$add_global_categories] = ' checked="checked"';
if (isset($setting_map[$tax])) :
$setting = $setting_map[$tax];
$cats = $link->setting($setting, NULL, NULL);
if (is_null($cats)) : $cats = array(); endif;
elseif (isset($terms[$tax])) :
$cats = $terms[$tax];
else :
$cats = array();
endif;
else :
$cats = $globalCats;
endif;
if ($page->for_feed_settings()) :
?>
<table class="twofer">
<tbody>
<tr>
<td class="primary">
<?php
endif;
$dogs = SyndicatedPost::category_ids($cats, /*unfamiliar=*/ NULL, /*taxonomies=*/ array($tax));
if ($taxonomy->hierarchical) : // Use a category-style checkbox
fwp_category_box($dogs, 'all '.$page->these_posts_phrase(), /*tags=*/ array(), /*params=*/ array('taxonomy' => $tax));
else : // Use a tag-style edit box
fwp_tags_box($cats, 'all '.$page->these_posts_phrase(), /*params=*/ array('taxonomy' => $tax));
endif;
$globalDogs = SyndicatedPost::category_ids($globalCats, /*unfamiliar=*/ 'create:'.$tax, /*taxonomies=*/ array($tax));
$siteWideHref = 'admin.php?page='.$GLOBALS['fwp_path'].'/'.basename(__FILE__);
if ($page->for_feed_settings()) :
?>
</td>
<td class="secondary">
<h4>Site-wide <?php print $taxonomy->labels->name; ?></h4>
<?php if (count($globalCats) > 0) : ?>
<ul class="current-setting">
<?php foreach ($globalDogs as $dog) : ?>
<li><?php $cat = get_term($dog, $tax); print $cat->name; ?></li>
<?php endforeach; ?>
</ul>
</div>
<p>
<?php else : ?>
<p>Site-wide settings may also assign categories to syndicated
posts.
<?php endif; ?>
Should <?php print $page->these_posts_phrase(); ?> be assigned
these <?php print $taxonomy->labels->name; ?> from the <a href="<?php print esc_html($siteWideHref); ?>">site-wide settings</a>, in
addition to the feed-specific <?php print $taxonomy->labels->name; ?> you set up here?</p>
<ul class="settings">
<li><p><label><input type="radio" name="add_global[<?php print $tax; ?>]" value="yes" <?php print $checked['yes']; ?> /> Yes. Place <?php print $page->these_posts_phrase(); ?> under all these categories.</label></p></li>
<li><p><label><input type="radio" name="add_global[<?php print $tax; ?>]" value="no" <?php print $checked['no']; ?> /> No. Only use the categories I set up on the left. Do not use the global defaults for <?php print $page->these_posts_phrase(); ?></label></p></li>
</ul>
</td>
</tr>
</tbody>
</table>
<?php
endif;
?>
</td>
</tr>
<?php
endforeach;
?>
</tbody>
</table>
<?php
} /* FeedWordPressCategoriesPage::categories_box () */