| 1 |
<?php |
<?php |
| 2 |
// $Id: jq.admin.inc,v 1.1 2008/05/01 17:59:45 aaron Exp $ |
// $Id: jq.admin.inc,v 1.2.2.2 2008/05/04 19:06:16 aaron Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* The administration form. Allows an administrator to turn off specific plugins |
* The administration form. Allows an administrator to turn off specific plugins |
| 55 |
return system_settings_form($form); |
return system_settings_form($form); |
| 56 |
} |
} |
| 57 |
|
|
| 58 |
|
/** |
| 59 |
|
* Build the jquery plugin array to be cached. |
| 60 |
|
* Any module that defines hook_jquery_plugins may define new jquery plugins for the system. |
| 61 |
|
* |
| 62 |
|
* For a plugin to be registered with this module, a module needs to invoke hook_jq. |
| 63 |
|
* hook_jq($op = 'info|add', $plugin = NULL) |
| 64 |
|
* If $op is 'add', then it is called with the plugin when invoked on a page. |
| 65 |
|
* If $op is 'info', then it needs to return an associative array of defined plugins: |
| 66 |
|
* 'name' => // ... Name of the plugin. |
| 67 |
|
* 'description' => // ... Description of the plugin. |
| 68 |
|
* 'files' => array( |
| 69 |
|
* 'js' => array( |
| 70 |
|
* // ... An array of js files to be loaded on the page. |
| 71 |
|
* ), |
| 72 |
|
* 'css' => array( |
| 73 |
|
* // ... An array of css files to be loaded on the page. |
| 74 |
|
* ), |
| 75 |
|
* ), |
| 76 |
|
*/ |
| 77 |
function _jq_plugins($display_errors = FALSE, $log_errors = TRUE) { |
function _jq_plugins($display_errors = FALSE, $log_errors = TRUE) { |
| 78 |
$plugins = array(); |
$plugins = array(); |
| 79 |
|
|
| 80 |
|
// Scan the '/plugins' and '/sites/example.com/files/plugins' directories for .js and .css files. |
| 81 |
|
// If there are multiple plugins with the same filename in the directory, the LAST file read will be used. |
| 82 |
|
$files = drupal_system_listing('(\.js$|\.css$)', 'plugins', 'basename', 0); |
| 83 |
|
foreach ($files as $file) { |
| 84 |
|
$plugins[$file->name] = array( |
| 85 |
|
'name' => $file->name, |
| 86 |
|
'plugin' => $file->name, |
| 87 |
|
); |
| 88 |
|
if (substr($filename, -1 * strripos($filename, '.')) == 'js') { |
| 89 |
|
$plugins[$file->name]['files']['js'] = $file->filename; |
| 90 |
|
} |
| 91 |
|
else { |
| 92 |
|
$plugins[$file->name]['files']['css'] = $file->filename; |
| 93 |
|
} |
| 94 |
|
} |
| 95 |
|
|
| 96 |
// any module may put its hook_jq functions in module_name.jq.inc, so that it may be included automatically |
// any module may put its hook_jq functions in module_name.jq.inc, so that it may be included automatically |
| 97 |
module_load_all_includes('jq.inc'); |
module_load_all_includes('jq.inc'); |
| 98 |
foreach (module_implements('jq') as $module) { |
foreach (module_implements('jq') as $module) { |