function ctools_export_ui::list_page

Master entry point for handling a list.

It is unlikely that a child object will need to override this method, unless the listing mechanism is going to be highly specialized.

1 call to ctools_export_ui::list_page()
ctools_export_ui::set_item_state in plugins/export_ui/ctools_export_ui.class.php
Set an item's state to enabled or disabled and output to user.

File

plugins/export_ui/ctools_export_ui.class.php, line 153

Class

ctools_export_ui
Base class for export UI.

Code

public function list_page($js, $input) {
    $this->items = ctools_export_crud_load_all($this->plugin['schema'], $js);
    // Respond to a reset command by clearing session and doing a drupal goto
    // back to the base URL.
    if (isset($input['op']) && $input['op'] == t('Reset')) {
        unset($_SESSION['ctools_export_ui'][$this->plugin['name']]);
        if (!$js) {
            drupal_goto($_GET['q']);
        }
        // Clear everything but form id, form build id and form token.
        $keys = array_keys($input);
        foreach ($keys as $id) {
            if (!in_array($id, array(
                'form_id',
                'form_build_id',
                'form_token',
            ))) {
                unset($input[$id]);
            }
        }
        $replace_form = TRUE;
    }
    // If there is no input, check to see if we have stored input in the
    // session.
    if (!isset($input['form_id'])) {
        if (isset($_SESSION['ctools_export_ui'][$this->plugin['name']]) && is_array($_SESSION['ctools_export_ui'][$this->plugin['name']])) {
            $input = $_SESSION['ctools_export_ui'][$this->plugin['name']];
        }
    }
    else {
        $_SESSION['ctools_export_ui'][$this->plugin['name']] = $input;
        unset($_SESSION['ctools_export_ui'][$this->plugin['name']]['q']);
    }
    // This is where the form will put the output.
    $this->rows = array();
    $this->sorts = array();
    $form_state = array(
        'plugin' => $this->plugin,
        'input' => $input,
        'rerender' => TRUE,
        'no_redirect' => TRUE,
        'object' => &$this,
    );
    if (!isset($form_state['input']['form_id'])) {
        $form_state['input']['form_id'] = 'ctools_export_ui_list_form';
    }
    // If we do any form rendering, it's to completely replace a form on the
    // page, so don't let it force our ids to change.
    if ($js && isset($_POST['ajax_html_ids'])) {
        unset($_POST['ajax_html_ids']);
    }
    $form = drupal_build_form('ctools_export_ui_list_form', $form_state);
    $form = drupal_render($form);
    $output = $this->list_header($form_state) . $this->list_render($form_state) . $this->list_footer($form_state);
    if (!$js) {
        $this->list_css();
        return $form . $output;
    }
    $commands = array();
    $commands[] = ajax_command_replace('#ctools-export-ui-list-items', $output);
    if (!empty($replace_form)) {
        $commands[] = ajax_command_replace('#ctools-export-ui-list-form', $form);
    }
    print ajax_render($commands);
    ajax_footer();
}