function noderelationships_noderef_page in Node Relationships 6
Menu callback; Search or Create and reference.
1 string reference to 'noderelationships_noderef_page'
- _noderelationships_menu in ./
noderelationships.system.inc - Implementation of hook_menu().
File
- ./
noderelationships.pages.inc, line 303 - Implementation of user land pages.
Code
function noderelationships_noderef_page($mode, $referrer_type = NULL, $field_name = NULL, $arg = NULL) {
// Enable the Modal Frame API for the child window.
modalframe_child_js();
// Try to load information about the requested nodereference field.
$referrer_field = isset($field_name) && isset($referrer_type) ? content_fields($field_name, $referrer_type) : NULL;
if (empty($referrer_field)) {
drupal_not_found();
return;
}
$module_path = drupal_get_path('module', 'noderelationships');
drupal_add_css($module_path . '/css/noderelationships.noderef_dialog.css');
drupal_add_js($module_path . '/js/noderef_dialog.js');
// Include common module functions.
module_load_include('inc', 'noderelationships');
// Obtain settings for nodereference extras for this type.
$noderef_settings = noderelationships_settings_load($referrer_type, 'noderef');
$create_or_translate_enabled = isset($noderef_settings['create_and_reference'][$field_name]) || isset($noderef_settings['translate_and_reference'][$field_name]) && noderelationships_translation_supported_type($referrer_type);
if ($mode == 'create' && $create_or_translate_enabled) {
$content = noderelationships_noderef_page_create($referrer_type, $field_name, $arg);
if (!empty($content)) {
$output = '';
if (isset($noderef_settings['search_and_reference_view'][$field_name]) && !noderelationships_noderef_get_translation_page_title()) {
$output .= theme('noderelationships_noderef_page_tabs', $mode, $referrer_type, $field_name);
}
$output .= theme('noderelationships_noderef_page_content', $content);
}
}
elseif ($mode == 'search' && isset($noderef_settings['search_and_reference_view'][$field_name])) {
list($view_name, $display_id) = explode(':', $noderef_settings['search_and_reference_view'][$field_name]);
$field_multiple = isset($arg) && $arg == 'multiselect' ? (int) $referrer_field['multiple'] : 0;
$content = noderelationships_noderef_page_search($referrer_type, $field_name, $referrer_field, $view_name, $display_id, $field_multiple);
if (!empty($content)) {
$output = '';
if ($create_or_translate_enabled && !$field_multiple) {
$output .= theme('noderelationships_noderef_page_tabs', $mode, $referrer_type, $field_name);
}
$output .= theme('noderelationships_noderef_page_content', $content);
}
}
if (isset($output)) {
return $output;
}
// Determine if an HTTP error has already been sent.
if (preg_match('`^HTTP/1.1\\s*[45][0-9][0-9]\\s*`m', drupal_get_headers())) {
return;
}
// Default to a 404 error page.
drupal_not_found();
}