function simplenews_admin_categories in Simplenews 7
Same name and namespace in other branches
- 7.2 includes/simplenews.admin.inc \simplenews_admin_categories()
Menu callback: list admin form with list of available list categories.
See also
simplenews_admin_newsletter_categories_submit()
theme_simplenews_admin_newsletter_categories()
1 string reference to 'simplenews_admin_categories'
- simplenews_menu in ./
simplenews.module - Implements hook_menu().
File
- includes/
simplenews.admin.inc, line 316 - Newsletter admin, subscription admin, simplenews settings
Code
function simplenews_admin_categories() {
$form['#tree'] = TRUE;
if ($categories = simplenews_categories_load_multiple(array(), array(
'show_all' => TRUE,
))) {
foreach ($categories as $category) {
$form[$category->tid]['#category'] = $category;
$form[$category->tid]['name'] = array(
'#markup' => check_plain(_simplenews_newsletter_name($category)),
);
$form[$category->tid]['count'] = array(
'#markup' => simplenews_count_subscriptions($category->tid),
);
$form[$category->tid]['weight'] = array(
'#type' => 'weight',
'#delta' => 10,
'#default_value' => $category->weight,
);
$form[$category->tid]['edit'] = array(
'#type' => 'link',
'#title' => t('edit newsletter category'),
'#href' => "admin/config/services/simplenews/categories/{$category->tid}/edit",
);
}
}
// Only make this form include a submit button and weight if more than one
// category exists.
if (count($categories) > 1) {
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
}
elseif (!empty($categories)) {
$form[$category->tid]['weight'] = array(
'#type' => 'value',
'#value' => 0,
);
}
return $form;
}