/[drupal]/contributions/modules/jquery_media/jquery_media.module
ViewVC logotype

Contents of /contributions/modules/jquery_media/jquery_media.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.6 - (show annotations) (download) (as text)
Mon Jun 30 20:58:53 2008 UTC (16 months, 3 weeks ago) by aaron
Branch: MAIN
CVS Tags: DRUPAL-5--1-3, HEAD
Changes since 1.5: +2 -2 lines
File MIME type: text/x-php
 * Add automatic support for File Field (aaron).
1 <?php
2 // $Id: jquery_media.module,v 1.5 2008/06/16 15:32:07 aaron Exp $
3
4 define('JQUERY_MEDIA_BGCOLOR_DEFAULT', '#ffffff');
5 define('JQUERY_MEDIA_AUTOPLAY_DEFAULT', 0);
6 define('JQUERY_MEDIA_FLVPLAYER_DEFAULT', 'mediaplayer.swf');
7 define('JQUERY_MEDIA_MP3PLAYER_DEFAULT', 'mediaplayer.swf');
8 define('JQUERY_MEDIA_CLASS_MEDIA_DEFAULT', 'a.media, .filefield-item a');
9 define('JQUERY_MEDIA_CLASS_MEDIABOX_DEFAULT', 'a.mediabox');
10 define('JQUERY_MEDIA_CLASS_MEDIA_AUTOINVOKE_DEFAULT', TRUE);
11 define('JQUERY_MEDIA_CLASS_MEDIABOX_AUTOINVOKE_DEFAULT', FALSE);
12 define('JQUERY_MEDIA_MEDIA_WIDTH_DEFAULT', '');
13 define('JQUERY_MEDIA_MEDIA_HEIGHT_DEFAULT', '');
14 define('JQUERY_MEDIA_MEDIABOX_WIDTH_DEFAULT', '');
15 define('JQUERY_MEDIA_MEDIABOX_HEIGHT_DEFAULT', '');
16 define('JQUERY_MEDIA_USE_DEFAULT_JS_FILE', FALSE);
17 define('JQUERY_MEDIA_DEFAULT_JS_FILEPATH', 'jquery_media.defaults.js');
18
19 /**
20 * Implement hook_jq (hook supplied by the jQ module)
21 *
22 * The preferred method to invoke this plugin is to use the jQ module, available at http://drupal.org/project/jq
23 * and then call jq_add('jquery_media'); on the pages requiring this.
24 *
25 * If you don't wish the jQ module installed, then use jquery_media_add() instead.
26 */
27 function jquery_media_jq($op, $plugin = NULL, $options = array()) {
28 include_once(drupal_get_path('module', 'jquery_media') .'/jquery_media.jq.inc');
29 return _jquery_media_jq($op, $plugin, $options);
30 }
31
32 function jquery_media_menu($may_cache) {
33 if ($may_cache) {
34 $items[] = array(
35 'path' => 'admin/settings/jquery_media',
36 'title' => t('jQuery Media'),
37 'callback' => 'drupal_get_form',
38 'callback arguments' => array('_jquery_media_settings'),
39 );
40 $items[] = array(
41 'path' => JQUERY_MEDIA_DEFAULT_JS_FILEPATH,
42 'type' => MENU_CALLBACK,
43 'access' => user_access('access content'),
44 'callback' => '_jquery_media_default_js_file',
45 );
46 return $items;
47 }
48 }
49
50 /**
51 * Implements hook_help
52 */
53 function jquery_media_help($section) {
54 include_once(drupal_get_path('module', 'jquery_media') .'/jquery_media.settings.inc');
55 return _jquery_media_help($section);
56 }
57
58 /**
59 * Callback for /admin/settings/jquery_media
60 */
61 function _jquery_media_settings() {
62 include_once(drupal_get_path('module', 'jquery_media') .'/jquery_media.settings.inc');
63 if (!module_exists('jq')) {
64 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')))));
65 }
66 else {
67 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'))));
68 }
69 return system_settings_form(_jquery_media_settings_form());
70 }
71
72 /**
73 * Attempt to go through jQ first. Then add our files manually.
74 */
75 function jquery_media_add($options = array()) {
76 static $installed = FALSE;
77 if (module_exists('jq')) {
78 return module_invoke('jq', 'add', 'jquery_media');
79 }
80 if (!$installed) {
81 drupal_add_js(drupal_get_path('module', 'jquery_media') .'/js/jquery.media.js');
82 }
83 include_once(drupal_get_path('module', 'jquery_media') .'/jquery_media.jq.inc');
84 _jquery_media_add($options);
85 return TRUE;
86 }
87
88 /**
89 * Print the default js file.
90 */
91 function _jquery_media_default_js_file() {
92 include_once(drupal_get_path('module', 'jquery_media') .'/jquery_media.jq.inc');
93 $js = _jquery_media_add(array(), TRUE);
94 header('Content-Length: '. strlen($js));
95 header('Content-Type: text/javascript');
96 header('Date: '.date('r'));
97 print $js;
98 }
99
100 /**
101 * Invoke the plugin if we support it for this node type.
102 */
103 function jquery_media_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
104 if ($op == 'view') {
105 if (in_array($node->type, variable_get('jquery_media_node_types', array()))) {
106 jquery_media_add();
107 }
108 }
109 }
110
111 /**
112 * Invoke the plugin on any page listed from the configuration page.
113 * Code swiped from block_list
114 */
115 function jquery_media_footer() {
116 $path = drupal_get_path_alias($_GET['q']);
117 $regexp = '/^('. preg_replace(array('/(\r\n?|\n)/', '/\\\\\*/', '/(^|\|)\\\\<front\\\\>($|\|)/'), array('|', '.*', '\1'. preg_quote(variable_get('site_frontpage', 'node'), '/') .'\2'), preg_quote(variable_get('jquery_media_pages', ''), '/')) .')$/';
118 // Compare with the internal and path alias (if any).
119 $page_match = preg_match($regexp, $path);
120 if ($path != $_GET['q']) {
121 $page_match = $page_match || preg_match($regexp, $_GET['q']);
122 }
123 if ($page_match) {
124 jquery_media_add();
125 }
126 }

  ViewVC Help
Powered by ViewVC 1.1.2