Ejemplo n.º 1
0
 /**
  * Create a command array to add a new pane.
  */
 function command_add_pane($pid)
 {
     if (is_object($pid)) {
         $pane = $pid;
     } else {
         $pane = $this->display->content[$pid];
     }
     $this->commands[] = ajax_command_prepend("#panels-ipe-regionid-{$pane->panel} div.panels-ipe-sort-container", $this->render_pane($pane));
     $this->commands[] = ajax_command_changed("#panels-ipe-display-{$this->clean_key}");
 }
Ejemplo n.º 2
0
function dguk_ajax_render_alter(&$commands)
{
    $commands[] = ajax_command_remove('#messages');
    $commands[] = ajax_command_prepend('.drupal-messages', '<div id="messages">' . theme('status_messages') . '</div>');
}
Ejemplo n.º 3
0
/**
 * Alter the commands that are sent to the user through the Ajax framework.
 *
 * @param $commands
 *   An array of all commands that will be sent to the user.
 *
 * @see ajax_render()
 */
function hook_ajax_render_alter(&$commands)
{
    // Inject any new status messages into the content area.
    $commands[] = ajax_command_prepend('#block-system-main .content', theme('status_messages'));
}
 /**
  * AJAX Callback for the path table.
  *
  * @param $form
  * @param $form_state
  * @param $offset_to_root
  * @param $clear
  *
  * @throws \Exception
  * @return array
  */
 public static function ajaxCallbackBase($form, $form_state, $offset_to_root, $clear = false)
 {
     if (!array_key_exists('triggering_element', $form_state)) {
         throw new \Exception('The trigger could not be found.');
     }
     $trigger = $form_state['triggering_element'];
     $parents = array_slice($trigger['#array_parents'], 0, count($trigger['#array_parents']) - $offset_to_root);
     $parents[] = 'paths';
     $parents_form = drupal_array_get_nested_value($form, $parents);
     $commands = array();
     $commands[] = ajax_command_replace(null, theme('publisher_purge_configure_content_type_table', array('paths_form' => $parents_form)));
     $commands[] = ajax_command_prepend(null, theme('status_messages'));
     if ($clear) {
         // Get the "Add Path" textbox.
         $add_path_parents = array_slice($parents, 0, count($parents) - 1);
         $add_path_parents[] = 'add_path';
         $add_path_parents[] = 'path';
         $add_path = drupal_array_get_nested_value($form, $add_path_parents);
         // TODO: Actually find out why the form API is adding numbers to the IDs.
         $add_path_id = str_replace('--2', '', $add_path['#id']);
         $commands[] = ajax_command_invoke('#' . $add_path_id, 'val', array(''));
     }
     return array('#type' => 'ajax', '#commands' => $commands);
 }