You are here

function asset_widget_get_tabs_info in Asset 7

Return all possible widget tabs to render.

2 calls to asset_widget_get_tabs_info()
asset_widget_get_tab_by_id in modules/asset_widget/asset_widget.admin.inc
Menu callback to get tab content by ID, or all enabled tabs if ID omitted.
template_preprocess_asset_widget_wrapper in modules/asset_widget/theme/theme.inc
Preprocess variables for asset-widget-wrapper.tpl.php.

File

modules/asset_widget/asset_widget.module, line 444
Code for the Asset widget module.

Code

function asset_widget_get_tabs_info($tab_id = FALSE) {
  $tabs_info =& drupal_static(__FUNCTION__);
  if (!isset($tabs_info)) {
    $tabs_info = array(
      'search' => array(
        'title' => 'Search assets',
        'content_callback' => 'asset_widget_get_search_form',
        'arguments' => array(
          'filter_params',
        ),
        'defaults' => array(
          'filter_params' => array(),
        ),
      ),
      'results' => array(
        'title' => 'Search results',
        'content_callback' => 'asset_widget_get_search_results',
        'arguments' => array(
          'filter_params',
          'dom_id',
        ),
        'defaults' => array(
          'filter_params' => array(),
          'dom_id' => FALSE,
        ),
        // Filter-params special class to show filter params block.
        'classes' => array(
          'filter-params',
        ),
      ),
    );

    // Provide separate tab with form for each type, sorted by Asset weight.
    $types = array();
    foreach (assets_get_types() as $name => $type_info) {
      if (asset_creation_access($name)) {
        $types[$name]['weight'] = intval($type_info->weight);
        $types[$name]['title'] = $type_info->name;
      }
    }
    uasort($types, 'drupal_sort_weight');
    foreach ($types as $name => $type) {
      $tabs_info[$name] = array(
        'title' => $type['title'],
        'content_callback' => 'asset_widget_get_asset_form',
        'arguments' => array(
          'type',
        ),
        'defaults' => array(
          'type' => $name,
        ),
        'classes' => array(
          'async',
          'refresh-content',
        ),
      );
    }

    // Allow to modify set of tabs.
    drupal_alter('asset_widget_tabs_info', $tabs_info);
  }
  return $tab_id && isset($tabs_info[$tab_id]) ? $tabs_info[$tab_id] : $tabs_info;
}