function set_item_state($state, $js, $input, $item) { ctools_export_set_object_status($item, $state); menu_rebuild(); if (!$js) { drupal_goto(ctools_export_ui_plugin_base_path($this->plugin)); } else { return $this->list_page($js, $input); } }
/** * Add some additional operations for handling entities. */ function build_operations($item) { $base_path = ctools_export_ui_plugin_base_path($this->plugin); $name = $item->{$this->plugin['export']['key']}; $operations['list'] = array('title' => t('List'), 'href' => $base_path . '/' . $name . '/list'); $operations['add_entity'] = array('title' => t('Add Entity'), 'href' => $base_path . '/' . $name . '/add'); $operations += parent::build_operations($item); $operations['field'] = array('title' => t('Manage Fields'), 'href' => $base_path . '/' . $name . '/fields'); $operations['display'] = array('title' => t('Manage Display'), 'href' => $base_path . '/' . $name . '/display'); return $operations; }
/** * Add some additional operations for handling entities. */ function build_operations($item) { $base_path = ctools_export_ui_plugin_base_path($this->plugin); $name = $item->{$this->plugin['export']['key']}; if (user_access('administer fieldable panels panes') || user_access('access fieldable panels panes master list')) { $operations['list'] = array( 'title' => t('List'), 'href' => $base_path . '/' . $name . '/list', ); } if (user_access('administer fieldable panels panes') || user_access('create fieldable ' . $name)) { $operations['add_entity'] = array( 'title' => t('Add Entity'), 'href' => $base_path . '/' . $name . '/add', ); } if (user_access('administer fieldable panels panes')) { $operations['edit_entity'] = array( 'title' => t('Edit'), 'href' => $base_path . '/' . $name . '/edit', ); $operations['delete_entity'] = array( 'title' => t('Delete'), 'href' => $base_path . '/' . $name . '/delete', ); $operations['export_entity'] = array( 'title' => t('Export'), 'href' => $base_path . '/' . $name . '/export', ); if (module_exists('field_ui')) { $operations['field'] = array( 'title' => t('Manage Fields'), 'href' => $base_path . '/' . $name . '/fields', ); $operations['display'] = array( 'title' => t('Manage Display'), 'href' => $base_path . '/' . $name . '/display', ); } } return $operations; }
/** * Callback to test a mailbox connection. */ function test_page($js, $input, $mailbox) { $input['test_result'] = _mailhandler_mailbox_test_output($mailbox); if (!$js) { drupal_goto(ctools_export_ui_plugin_base_path($this->plugin)); } else { return $this->list_page($js, $input); } }
function delete_page($js, $input, $item) { $clone = clone $item; // Change the name into the title so the form shows the right value. // @todo file a bug against CTools to use admin title if available. $clone->name = $clone->title; $form_state = array('plugin' => $this->plugin, 'object' => &$this, 'ajax' => $js, 'item' => $clone, 'op' => $item->export_type & EXPORT_IN_CODE ? 'revert' : 'delete', 'rerender' => TRUE, 'no_redirect' => TRUE); $output = drupal_build_form('ctools_export_ui_delete_confirm_form', $form_state); if (!empty($form_state['executed'])) { ctools_export_crud_delete($this->plugin['schema'], $item); $export_key = $this->plugin['export']['key']; drupal_set_message(t($this->plugin['strings']['confirmation'][$form_state['op']]['success'], array('%title' => $item->title))); drupal_goto(ctools_export_ui_plugin_base_path($this->plugin)); } return $output; }
/** * Set an item's state to enabled or disabled and output to user. * * If javascript is in use, this will rebuild the list and send that back * as though the filter form had been executed. */ function set_item_state($state, $js, $input, $item) { ctools_export_crud_set_status($this->plugin['schema'], $item, $state); if (!$js) { drupal_goto(ctools_export_ui_plugin_base_path($this->plugin)); } else { return $this->list_page($js, $input); } }
/** * Page callback to delete an exportable item. */ function delete_page($js, $input, $item) { $form_state = array('plugin' => $this->plugin, 'object' => &$this, 'ajax' => $js, 'item' => $item, 'op' => $item->export_type & EXPORT_IN_CODE ? 'revert' : 'delete', 'rerender' => TRUE, 'no_redirect' => TRUE); ctools_include('form'); $output = ctools_build_form('ctools_export_ui_delete_confirm_form', $form_state); if (!empty($form_state['executed'])) { ctools_export_crud_delete($this->plugin['schema'], $item); $export_key = $this->plugin['export']['key']; $message = str_replace('%title', check_plain($item->{$export_key}), $this->plugin['strings']['confirmation'][$form_state['op']]['success']); drupal_set_message($message); drupal_goto(ctools_export_ui_plugin_base_path($this->plugin)); } return $output; }
/** * Page callback to delete an exportable item. */ function delete_page($js, $input, $item) { $form_state = array('plugin' => $this->plugin, 'object' => &$this, 'ajax' => $js, 'item' => $item, 'op' => $item->export_type & EXPORT_IN_CODE ? 'revert' : 'delete', 'rerender' => TRUE, 'no_redirect' => TRUE); $output = drupal_build_form('ctools_export_ui_delete_confirm_form', $form_state); if (!empty($form_state['executed'])) { // Cleanup the stream config and stream from static caches. heartbeat_stream_config_reset($item); ctools_export_crud_delete($this->plugin['schema'], $item); $message = str_replace('%title', check_plain($item->{$this->plugin['export']['key']}), $this->plugin['strings']['confirmation'][$form_state['op']]['success']); drupal_set_message($message); // Cleanup the blocks that might be in use. db_delete('block')->condition('module', 'heartbeat')->condition('delta', $item->class)->execute(); drupal_goto(ctools_export_ui_plugin_base_path($this->plugin)); } return $output; }
/** * Perform a drupal_goto() to the location provided by the plugin for the * operation. * * @param $op * The operation to use. A string must exist in $this->plugin['redirect'] * for this operation. * @param $item * The item in use; this may be necessary as item IDs are often embedded in * redirects. */ function redirect($op, $item = NULL) { drupal_goto(ctools_export_ui_plugin_base_path($this->plugin) . '/' . $item->bundle); }
/** * Submit callback for the subqueue edit form. */ function entityqueue_subqueue_edit_form_submit($form, &$form_state) { $queue = $form_state['entityqueue_queue']; $subqueue = $form_state['entityqueue_subqueue']; entity_form_submit_build_entity('entityqueue_subqueue', $subqueue, $form, $form_state); $subqueue->save(); $entityqueue_export_ui_plugin = ctools_get_plugins('ctools', 'export_ui', 'entityqueue_export_ui'); $plugin_base_path = ctools_export_ui_plugin_base_path($entityqueue_export_ui_plugin); $handlers = ctools_get_plugins('entityqueue', 'handler'); if ($handlers[$queue->handler]['queue type'] == 'single') { $form_state['redirect'] = $plugin_base_path; } else { $form_state['redirect'] = $plugin_base_path . '/list/' . $queue->name . '/subqueues'; } }
/** * Submit the filter/sort form. * * This submit handler is actually responsible for building up all of the * rows that will later be rendered, since it is doing the filtering and * sorting. * * For the most part, you should not need to override this method, as the * fiddly bits call through to other functions. */ public function list_form_submit(&$form, &$form_state) { // Filter and re-sort the pages. $plugin = $this->plugin; $prefix = ctools_export_ui_plugin_base_path($plugin); $this->jobs_behind = 0; foreach ($this->items as $name => $item) { // Call through to the filter and see if we're going to render this // row. If it returns TRUE, then this row is filtered out. if ($this->list_filter($form_state, $item)) { continue; } $operations = $this->build_operations($item); $this->list_build_row($item, $form_state, $operations); } if ($this->jobs_behind) { drupal_set_message(format_plural($this->jobs_behind, '@count job is behind schedule.', '@count jobs are behind schedule.'), 'warning'); } // Now actually sort. uasort($this->rows, '_ultimate_cron_multi_column_sort'); if ($form_state['values']['sort'] == 'desc') { $this->rows = array_reverse($this->rows); } foreach ($this->rows as &$row) { unset($row['sort']); } }
/** * Set an item's state to enabled or disabled and output to user. * * If javascript is in use, this will rebuild the list and send that back * as though the filter form had been executed. */ function set_item_state($state, $js, $input, $item) { ctools_export_crud_set_status($this->plugin['schema'], $item, $state); // Rebuild index and flush caches. form_builder_crud_index_save(); drupal_flush_all_caches(); if (!$js) { drupal_goto(ctools_export_ui_plugin_base_path($this->plugin)); } else { return $this->list_page($js, $input); } }
/** * Submit the filter/sort form. * * This submit handler is actually responsible for building up all of the * rows that will later be rendered, since it is doing the filtering and * sorting. * * For the most part, you should not need to override this method, as the * fiddly bits call through to other functions. */ function list_form_submit(&$form, &$form_state) { // Filter and re-sort the pages. $plugin = $this->plugin; $schema = ctools_export_get_schema($this->plugin['schema']); $prefix = ctools_export_ui_plugin_base_path($plugin); foreach ($this->items as $name => $item) { // Call through to the filter and see if we're going to render this // row. If it returns TRUE, then this row is filtered out. if ($this->list_filter($form_state, $item)) { continue; } // Note: Creating this list seems a little clumsy, but can't think of // better ways to do this. $allowed_operations = drupal_map_assoc(array_keys($plugin['allowed operations'])); //Cannot find the code that returns the list of possible operations, so I'm going to add extras here, which is not neat. //$allowed_operations['edit terms'] = 'edit terms'; $not_allowed_operations = array('import'); if ($item->{$schema['export']['export type string']} == t('Normal')) { $not_allowed_operations[] = 'revert'; } elseif ($item->{$schema['export']['export type string']} == t('Overridden')) { $not_allowed_operations[] = 'delete'; } else { $not_allowed_operations[] = 'revert'; $not_allowed_operations[] = 'delete'; } //$not_allowed_operations[] = empty($item->disabled) ? 'enable' : 'disable'; //Forcing 'disable' and 'enable' to be disabled always. This should be done in the install schema with 'can disable' => FALSE, but that would //mean reinstalling the module and I don't think it works properly. $not_allowed_operations[] = 'disable'; $not_allowed_operations[] = 'enable'; foreach ($not_allowed_operations as $op) { // Remove the operations that are not allowed for the specific // exportable. unset($allowed_operations[$op]); } $operations = array(); foreach ($allowed_operations as $op) { $operations[$op] = array('title' => $plugin['allowed operations'][$op]['title'], 'href' => ctools_export_ui_plugin_menu_path($plugin, $op, $name)); if (!empty($plugin['allowed operations'][$op]['ajax'])) { $operations[$op]['attributes'] = array('class' => array('use-ajax')); } if (!empty($plugin['allowed operations'][$op]['token'])) { $operations[$op]['query'] = array('token' => drupal_get_token($op)); } } $this->list_build_row($item, $form_state, $operations); } // Now actually sort if ($form_state['values']['sort'] == 'desc') { arsort($this->sorts); } else { asort($this->sorts); } // Nuke the original. $rows = $this->rows; $this->rows = array(); // And restore. foreach ($this->sorts as $name => $title) { $this->rows[$name] = $rows[$name]; } }
function hook_menu(&$items) { if (empty($this->plugin['schema'])) { return; } parent::hook_menu($items); $prefix = ctools_export_ui_plugin_base_path($this->plugin); }