'colorbox_node_output', 'page arguments' => array(1), 'access arguments' => array('access content'), 'load arguments' => array('%map'), 'delivery callback' => 'ajax_deliver', 'theme callback' => 'ajax_base_page_theme', 'type' => MENU_CALLBACK, ); return $items; } /* * Displays a node view without the page template. * Takes the path as our argument and from that we * will determine the internal path and node id. */ function colorbox_node_output($path) { // @TODO, we should be able to use this for users too, // Lets beef this up and make it more intelligent around // the system path. //$_GET['destination'] = $path; // Lets determine if this is a webform and add the // nid to dynamically add ajax support. $args = explode('/', $path); if ($args[0] == 'node' && is_numeric($args[1])) { $GLOBALS['colorbox_node_webform'] = $args[1]; } // Fetch our callback based on our path. $page_callback_result = menu_execute_active_handler($path, FALSE); // If the callback is an integer, we have an error, lets // render that out as a command. if (is_int($page_callback_result)) { $commands = ajax_prepare_response($page_callback_result); } else { $commands = array(); // Is we have an array, lets assume we need to render it out. if (is_array($page_callback_result)) { $html = drupal_render($page_callback_result); $commands[] = ajax_command_html('#cboxNode', $html); } else { $commands[] = ajax_command_html('#cboxNode', $page_callback_result); } // Setup our parameters to pass along to our colorbox. $params = array(); $params['inline'] = TRUE; $params['href'] = '#cboxNode'; $params['onClosed'] = 'close'; if (isset($_GET['width'])) $params['innerWidth'] = (int) $_GET['width']; if (isset($_GET['height'])) $params['innerHeight'] = (int) $_GET['height']; $params = json_encode($params); $javascript = ' '; $commands[] = ajax_command_html('#cboxNodeJS', $javascript); } // Render our commands out to the browser. return array('#type' => 'ajax', '#commands' => $commands); } /* * Takes a path as an array of all our arguments from the * url structure. We then put that structure back together, * find our system path and then return it. */ function colorbox_node_url_load($arg, $path = array()) { // First lets remove colorbox array_shift($path); // Lets determine if we have a prefix from our languages. if (module_exists('locale') && function_exists('language_url_split_prefix')) { // Get our language list to pass into our url splitter. $languages = language_list(); // Turn the path into a string so we can then remove our prefix. $path_string = implode('/', $path); $language_path = language_url_split_prefix($path_string, $languages); // Separate out the returned path and language. We should always // have two indexes, the first is the language, second is the path. $language = $language_path[0] ? $language_path[0]->language : ''; $final_path = $language_path[1]; // Lets find our path based on the current translation. return drupal_get_normal_path($final_path, $language); } // Now lets buld our path to return our system path, return drupal_get_normal_path(implode('/', $path)); } /* * Implements hook_form_alter(). */ function colorbox_node_form_alter(&$form, &$form_state, $form_id) { // Determine if our webform as been set for display inside a // colorbox modal window. if (isset($GLOBALS['colorbox_node_webform']) && $GLOBALS['colorbox_node_webform']) { // $make_form_ajax = false; // $webform_id = 'webform_client_form_'. $GLOBALS['colorbox_node_webform']; if ($form_id == $webform_id) { $make_form_ajax = true; } elseif (is_numeric($GLOBALS['colorbox_node_webform'])) { $tmp_node = node_load($GLOBALS['colorbox_node_webform']); if ($tmp_node !== FALSE) { $webform_id = $tmp_node->type . '_node_form'; if ($form_id == $webform_id) { $make_form_ajax = true; array_unshift($form['#validate'], "colorbox_js_node_form_validate"); } } } // If we are altering our current webform to be displayed // inside a modal box, lets add ajax support. if ($make_form_ajax == true) { // Add our ajax support for this webform dynamically. $form['#prefix'] = '