function asset_widget_get_tab_by_id in Asset 7
Menu callback to get tab content by ID, or all enabled tabs if ID omitted.
1 string reference to 'asset_widget_get_tab_by_id'
- asset_widget_menu in modules/
asset_widget/ asset_widget.module - Implements hook_menu().
File
- modules/
asset_widget/ asset_widget.admin.inc, line 10 - Assets widget administration pages logic.
Code
function asset_widget_get_tab_by_id($target_tab_id = FALSE) {
// Disable Rel module activation for our widget forms.
if (module_exists('rel')) {
$GLOBALS['conf']['rel_build_form_registration'] = FALSE;
}
$tabs_content = array();
$response = array(
'#type' => 'ajax',
);
// Render specified tab.
if ($target_tab_id) {
$info = asset_widget_get_tabs_info($target_tab_id);
if ($info) {
$output = asset_widget_get_rendered_tab_content($info, $_POST);
if ($output) {
$tabs_content['tabsContent'][$target_tab_id] = $output;
}
}
}
else {
$use_cookie_fallback = variable_get('asset_widget_save_last_search', TRUE);
foreach (asset_widget_get_tabs_info() as $tab_id => $info) {
$output = asset_widget_get_rendered_tab_content($info, $_POST, $use_cookie_fallback);
if ($output) {
$tabs_content['tabsContent'][$tab_id] = $output;
}
}
}
// We let our content callback add own specific commands.
$response['#commands'] = asset_widget_get_current_commands();
if (!empty($tabs_content['tabsContent'])) {
$response['#commands'][] = array(
'command' => 'assetWidgetInsertTabContent',
'data' => $tabs_content['tabsContent'],
);
}
// Set first tab as active on first load, or search results in case of cookie-stored search.
if (!$target_tab_id && variable_get('asset_widget_save_last_search', TRUE) && !empty($_COOKIE['Drupal_asset_widget_filter_params'])) {
$target_tab = 'results';
}
else {
$target_tab = !$target_tab_id ? key($tabs_content['tabsContent']) : $target_tab_id;
}
$response['#commands'][] = array(
'command' => 'assetWidgetGotoTab',
'data' => $target_tab,
);
return $response;
}