Same name in other branches
  1. 7.x-3.x quicktabs.admin.inc \quicktabs_list()

Page callback to list quicktabs in the system.

1 string reference to 'quicktabs_list'
quicktabs_menu in ./quicktabs.module
Implements hook_menu().

File

includes/admin.inc, line 11

Code

function quicktabs_list() {
    $colspan = module_exists('ctools') ? 4 : 3;
    $header = array(
        array(
            'data' => t('Quicktab'),
        ),
        array(
            'data' => t('Storage'),
        ),
        array(
            'data' => t('Operations'),
            'colspan' => $colspan,
        ),
    );
    $rows = array();
    foreach (quicktabs_get_all_quicktabs() as $quicktab) {
        if (module_exists('ctools')) {
            // Determine storage
            switch ($quicktab->export_type) {
                case EXPORT_IN_DATABASE | EXPORT_IN_CODE:
                    $storage = t('Overridden');
                    $delete = l(t('Revert'), 'admin/structure/quicktabs/manage/' . $quicktab->machine_name . '/delete');
                    break;
                case EXPORT_IN_DATABASE:
                    $storage = t('Normal');
                    $delete = l(t('Delete'), 'admin/structure/quicktabs/manage/' . $quicktab->machine_name . '/delete');
                    break;
                case EXPORT_IN_CODE:
                    $storage = t('Default');
                    $delete = '';
                    break;
            }
            $tablerow = array(
                array(
                    'data' => $quicktab->title,
                ),
                array(
                    'data' => $storage,
                ),
                array(
                    'data' => l(t('Edit'), 'admin/structure/quicktabs/manage/' . $quicktab->machine_name . '/edit'),
                ),
                array(
                    'data' => l(t('Export'), 'admin/structure/quicktabs/manage/' . $quicktab->machine_name . '/export'),
                ),
                array(
                    'data' => l(t('Clone'), 'admin/structure/quicktabs/manage/' . $quicktab->machine_name . '/clone'),
                ),
                array(
                    'data' => $delete,
                ),
            );
        }
        else {
            $tablerow = array(
                array(
                    'data' => $quicktab->title,
                ),
                array(
                    'data' => t('Normal'),
                ),
                array(
                    'data' => l(t('Edit'), 'admin/structure/quicktabs/manage/' . $quicktab->machine_name . '/edit'),
                ),
                array(
                    'data' => l(t('Clone'), 'admin/structure/quicktabs/manage/' . $quicktab->machine_name . '/clone'),
                ),
                array(
                    'data' => l(t('Delete'), 'admin/structure/quicktabs/manage/' . $quicktab->machine_name . '/delete'),
                ),
            );
        }
        $rows[] = $tablerow;
    }
    if (empty($rows)) {
        $rows[] = array(
            array(
                'data' => t('No quicktabs available.'),
                'colspan' => $colspan,
            ),
        );
    }
    $build = array(
        '#theme' => 'table',
        '#header' => $header,
        '#rows' => $rows,
        '#attributes' => array(
            'id' => 'quicktabs',
        ),
    );
    return $build;
}