function farm_dashboard_page_callback in farmOS 7
Farm dashboard page callback.
1 string reference to 'farm_dashboard_page_callback'
- farm_dashboard_menu in modules/
farm/ farm_dashboard/ farm_dashboard.module - Implements hook_menu().
File
- modules/
farm/ farm_dashboard/ farm_dashboard.module, line 75 - Farm dashboard module.
Code
function farm_dashboard_page_callback() {
// Set the page title.
drupal_set_title('Dashboard');
// Start a build array.
$build = array();
// Ask modules for dashboard panes.
$panes = module_invoke_all('farm_dashboard_panes');
// Iterate through the panes and add them to the dashboard.
foreach ($panes as $pane) {
// Set defaults for title, output, group, and weight.
$output = '';
$title = '';
$group = 'general';
$weight = 0;
// Use the provided title, if available.
if (!empty($pane['title'])) {
$title = $pane['title'];
}
// If a 'view' and 'view_display_id' are provided, load the view, generate
// the preview, and set the title automatically.
if (!empty($pane['view']) && !empty($pane['view_display_id'])) {
$view = views_get_view($pane['view']);
$preview = $view
->preview($pane['view_display_id']);
$title = $view
->get_title();
$output = $preview;
}
elseif (!empty($pane['callback']) && function_exists($pane['callback'])) {
$output = call_user_func($pane['callback']);
}
// If a group is not provided, assign it to a general default group.
if (!empty($pane['group'])) {
$group = $pane['group'];
}
// If a weight is not provided, default to 0.
if (!empty($pane['weight'])) {
$weight = $pane['weight'];
}
// Create a container for the pane.
$container = array(
'#type' => 'container',
'#weight' => $weight,
);
// If a title is set, make it a fieldset.
if (!empty($title)) {
$container['#type'] = 'fieldset';
$container['#title'] = check_plain($title);
}
// Assemble a content markup item inside the container.
$container['content'] = array(
'#type' => 'markup',
'#markup' => $output,
);
// Add the container to the build array.
$build[$group][] = $container;
}
// Return the build array.
return $build;
}