| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @file 5 * Provides the jQuery UI plug-in to other Drupal modules. 6 * 7 * This module doesn't do too much, but it is a central location for any other 8 * modules that implement the JQuery UI library. It ensures that multiple 9 * modules will all include the same library script just once on any given page. 10 */ 11 12 /** 13 * Add the specified jQuery UI library files to this page. 14 * 15 * The ui.core file is always included automatically, as well as the 16 * effects.core file if any of the effects libraries are used. 17 * 18 * @param $files 19 * An array of what additional files (other than UI core) should be loaded 20 * on the page, or a string with a single file name. 21 */ 22 function jquery_ui_add($files = array()) { 23 static $loaded_files, $ui_core, $effects_core; 24 25 $jquery_ui_path = jquery_ui_get_path(); 26 if ($jquery_ui_path === FALSE) { 27 return FALSE; 28 } 29 $jquery_ui_path .= '/ui'; 30 $compression = variable_get('jquery_update_compression_type', 'mini'); 31 32 // Convert file to an array if it's not one already, to compensate for 33 // lazy developers. ;) 34 if (!is_array($files)) { 35 $files = array($files); 36 } 37 38 // If core hasn't been added yet, add it. 39 if (!isset($ui_core)) { 40 $ui_core = TRUE; 41 jquery_ui_add(array('ui.core')); 42 } 43 44 // Loop through list of files to include and add them to the page. 45 foreach ($files as $file) { 46 // Any effects files require the effects core file. 47 if (!isset($effects_core) && strpos($file, 'effects.') === 0) { 48 $effects_core = TRUE; 49 jquery_ui_add(array('effects.core')); 50 } 51 52 // Load other files. 53 if (!isset($loaded_files[$file])) { 54 switch ($compression) { 55 case 'none': 56 $file_path = "$file.js"; 57 break; 58 59 case 'pack': 60 $file_path = "packed/$file.packed.js"; 61 break; 62 63 case 'mini': 64 default: 65 $file_path = "minified/$file.min.js"; 66 break; 67 } 68 $js_path = $jquery_ui_path . '/' . $file_path; 69 drupal_add_js($js_path); 70 $loaded_files[$file] = $js_path; 71 } 72 } 73 } 74 75 /** 76 * Returns the path to the jQuery UI library or FALSE if not found. 77 */ 78 function jquery_ui_get_path() { 79 static $path; 80 81 if (isset($path)) { 82 return $path; 83 } 84 $path = FALSE; 85 86 // Libraries API integration. 87 if (function_exists('libraries_get_path')) { 88 $path = libraries_get_path('jquery.ui'); 89 // Libraries API 1.x returns a default path; 2.x returns FALSE. 90 if ($path !== FALSE && !file_exists($path)) { 91 $path = FALSE; 92 } 93 } 94 // Manually check sites/all/libraries in case Libraries API is not available. 95 elseif (file_exists('./sites/all/libraries/jquery.ui')) { 96 $path = 'sites/all/libraries/jquery.ui'; 97 } 98 99 // Check the module directory for backwards compatibility if other methods 100 // failed. 101 if (!$path) { 102 // drupal_get_path() is not available during Drupal installation. 103 if (defined('MAINTENANCE_MODE') && MAINTENANCE_MODE == 'install') { 104 $path = drupal_substr(dirname(__FILE__), drupal_strlen(getcwd()) + 1); 105 $path = strtr($path, '\\', '/'); 106 $path .= '/jquery.ui'; 107 } 108 else { 109 $path = drupal_get_path('module', 'jquery_ui') . '/jquery.ui'; 110 } 111 if (!file_exists($path)) { 112 $path = FALSE; 113 } 114 } 115 116 return $path; 117 } 118 119 /** 120 * Return the version of jQuery UI installed. 121 */ 122 function jquery_ui_get_version() { 123 $version = 0; 124 125 $path = jquery_ui_get_path(); 126 if ($path === FALSE) { 127 return $version; 128 } 129 $file = $path . '/version.txt'; 130 if (file_exists($file)) { 131 $version = file_get_contents($file); 132 } 133 134 return $version; 135 } 136
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Jul 9 18:01:44 2012 | Cross-referenced by PHPXref 0.7 |