function og_admin_menu_overview_form in Organic Groups Menu (OG Menu) 7.3
Callback for admin/structure/og_menu.
Just duplicates the standard menu list, but only displays those created through og_menu.
1 string reference to 'og_admin_menu_overview_form'
- og_menu_menu in ./
og_menu.module - Implements hook_menu().
File
- ./
og_menu.pages.inc, line 356 - Contains page callbacks for og_menu
Code
function og_admin_menu_overview_form($form, $form_state) {
$session = isset($_SESSION['og_menu_filter']) ? $_SESSION['og_menu_filter'] : array();
// Get filter value from $_SESSION variable.
foreach ($session as $filter) {
list($type, $value) = $filter;
}
$form['filters'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => isset($type) ? FALSE : TRUE,
'#title' => 'Filter',
'#description' => 'Filter on the title of the OG menu.',
);
$form['filters']['og_menu_filter'] = array(
'#type' => 'textfield',
'#title' => t('Filter this out'),
'#required' => FALSE,
'#size' => 20,
'#default_value' => isset($type) ? $value : '',
);
$form['filters']['og_menu_actions'] = array(
'#type' => 'actions',
'#attributes' => array(
'class' => array(
'container-inline',
),
),
);
$form['filters']['og_menu_actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Filter'),
);
if (count($session)) {
$form['filters']['og_menu_actions']['reset'] = array(
'#type' => 'submit',
'#value' => t('Reset'),
);
}
$header = array(
'title' => array(
'data' => 'Title',
'field' => 'title',
'sort' => 'asc',
),
'type' => array(
'data' => 'Group Type',
'field' => 'group_type',
),
'list' => array(
'data' => 'Operations',
),
'edit' => array(
'data' => '',
),
'add' => array(
'data' => '',
),
'view' => array(
'data' => '',
),
);
// Build Query (extend for paging and sorting).
$query = db_select('menu_custom', 'mc')
->extend('PagerDefault')
->limit(20);
// Pager Extender.
$query
->join('og_menu', 'om', 'mc.menu_name = om.menu_name');
$query
->fields('mc')
->fields('om')
->orderBy('title')
->extend('TableSort')
->orderByHeader($header);
// Add conditional filter if enter by user.
if (isset($type)) {
$query
->condition('title', '%' . $value . '%', 'LIKE');
}
$result = $query
->execute();
// Build table.
$options = array();
foreach ($result as $menu) {
$options[$menu->menu_name] = array(
'title' => array(
'data' => theme('menu_admin_overview', array(
'title' => $menu->title,
'name' => $menu->menu_name,
'description' => $menu->description,
)),
),
'type' => array(
'data' => $menu->group_type,
),
'list' => array(
'data' => array(
'#type' => 'link',
'#title' => t('list links'),
'#href' => 'admin/structure/menu/manage/' . $menu->menu_name,
),
),
'edit' => array(
'data' => array(
'#type' => 'link',
'#title' => t('edit menu'),
'#href' => 'admin/structure/menu/manage/' . $menu->menu_name . '/edit',
),
),
'add' => array(
'data' => array(
'#type' => 'link',
'#title' => t('add link'),
'#href' => 'admin/structure/menu/manage/' . $menu->menu_name . '/add',
),
),
'view' => array(
'data' => array(
'#type' => 'link',
'#title' => t('view group'),
'#href' => 'node/' . $menu->gid,
),
),
);
}
$tableselect = array_sum(module_invoke_all('og_menu_admin_menu_overview_form_tableselect'));
if ($tableselect) {
$form['og_menu_menu_list'] = array(
'#type' => 'tableselect',
'#title' => t('Results'),
'#header' => $header,
'#options' => $options,
'#empty' => 'Nothing to see',
'#suffix' => theme('pager'),
);
}
else {
$output = theme('table', array(
'header' => $header,
'rows' => $options,
)) . theme('pager');
$form['og_menu_menu_list'] = array(
'#type' => 'markup',
'#title' => t('Results'),
'#markup' => $output,
);
}
return $form;
}