'admin/settings/jquery_media', 'title' => t('jQuery Media'), 'callback' => 'drupal_get_form', 'callback arguments' => array('_jquery_media_settings'), ); $items[] = array( 'path' => JQUERY_MEDIA_DEFAULT_JS_FILEPATH, 'type' => MENU_CALLBACK, 'access' => user_access('access content'), 'callback' => '_jquery_media_default_js_file', ); return $items; } } /** * Implements hook_help */ function jquery_media_help($section) { include_once(drupal_get_path('module', 'jquery_media') .'/jquery_media.settings.inc'); return _jquery_media_help($section); } /** * Callback for /admin/settings/jquery_media */ function _jquery_media_settings() { include_once(drupal_get_path('module', 'jquery_media') .'/jquery_media.settings.inc'); if (!module_exists('jq')) { drupal_set_message(t('You may wish to install and enable the !jq for a more centralized administration and development of jQuery plugin User Interface modules such as jQuery Media.', array('!jq' => l(t('jQ Module'), 'http://drupal.org/project/jq', array('target' => '_blank'))))); } else { drupal_set_message(t('You may wish to configure these settings at the !jq.', array('!jq' => l(t('jQ administrative settings page'), 'admin/settings/jq')))); } return system_settings_form(_jquery_media_settings_form()); } /** * Attempt to go through jQ first. Then add our files manually. */ function jquery_media_add($options = array()) { static $installed = FALSE; if (module_exists('jq')) { return module_invoke('jq', 'add', 'jquery_media'); } if (!$installed) { drupal_add_js(drupal_get_path('module', 'jquery_media') .'/js/jquery.media.js'); } include_once(drupal_get_path('module', 'jquery_media') .'/jquery_media.jq.inc'); _jquery_media_add($options); return TRUE; } /** * Print the default js file. */ function _jquery_media_default_js_file() { include_once(drupal_get_path('module', 'jquery_media') .'/jquery_media.jq.inc'); $js = _jquery_media_add(array(), TRUE); header('Content-Length: '. strlen($js)); header('Content-Type: text/javascript'); header('Date: '.date('r')); print $js; } /** * Invoke the plugin if we support it for this node type. */ function jquery_media_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) { if ($op == 'view') { if (in_array($node->type, variable_get('jquery_media_node_types', array()))) { jquery_media_add(); } } } /** * Invoke the plugin on any page listed from the configuration page. * Code swiped from block_list */ function jquery_media_footer() { $path = drupal_get_path_alias($_GET['q']); $regexp = '/^('. preg_replace(array('/(\r\n?|\n)/', '/\\\\\*/', '/(^|\|)\\\\($|\|)/'), array('|', '.*', '\1'. preg_quote(variable_get('site_frontpage', 'node'), '/') .'\2'), preg_quote(variable_get('jquery_media_pages', ''), '/')) .')$/'; // Compare with the internal and path alias (if any). $page_match = preg_match($regexp, $path); if ($path != $_GET['q']) { $page_match = $page_match || preg_match($regexp, $_GET['q']); } if ($page_match) { jquery_media_add(); } }