/** * AJAX entry point for to add a visibility rule. */ function ajax_access_add_test($pid = NULL) { if (empty($this->display->content[$pid])) { ctools_modal_render(t('Error'), t('Invalid pane id.')); } $pane =& $this->display->content[$pid]; $subtype = ctools_content_get_subtype($pane->type, $pane->subtype); $form_state = array('display' => &$this->display, 'pane' => &$pane, 'ajax' => TRUE, 'title' => t('Add visibility rule for !subtype_title', array('!subtype_title' => $subtype['title']))); $output = ctools_modal_form_wrapper('panels_edit_add_access_test_form', $form_state); if (empty($output)) { // Set up the plugin in cache $plugin = ctools_get_access_plugin($form_state['values']['type']); $this->cache->new_plugin = ctools_access_new_test($plugin); panels_edit_cache_set($this->cache); // go to the next step. return $this->ajax_access_configure_test($pid, 'add'); } ctools_ajax_render($output); }
/** * 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. */ 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) { return 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); $help_area = $this->help_area($form_state); ctools_include('form'); $form = ctools_build_form('ctools_export_ui_list_form', $form_state); $output = $this->list_header($form_state) . $this->list_render($form_state) . $this->list_footer($form_state); if (!$js) { $this->list_css(); return $help_area . $form . $output; } ctools_include('ajax'); $commands = array(); $commands[] = ctools_ajax_command_replace('#ctools-export-ui-list-items', $output); if (!empty($replace_form)) { $commands[] = ctools_ajax_command_replace('#ctools-export-ui-list-form', $form); } ctools_ajax_render($commands); }
public function getFormDialog($js, $q) { $this->useJS = $js; $this->questionId = $q; if (!$this->useJS()) { return drupal_get_form('chgk_db_edit_question_form'); } $modal_style = array('chgkdb_modal' => array('modalOptions' => array('opacity' => 0.5, 'background-color' => '#000'), 'animation' => 'fadeIn', 'modalTheme' => 'CToolsChgkDbModal')); drupal_add_js($modal_style, 'setting'); $form_state = array('title' => 'Редактирование вопроса', 'ajax' => $js, 'question_id' => $this->getQuestionId(), 'question' => &$q); $commands = ctools_modal_form_wrapper('chgk_db_edit_question_form', $form_state); if (!empty($form_state['executed'])) { $commands = array(); $commands[] = ctools_modal_command_display(t("Sending form"), "Сохраняем..."); $commands[] = ctools_ajax_command_reload(); } print ctools_ajax_render($commands); exit; }