Index: contributions/modules/jqp/jqp.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/jqp/jqp.info,v
retrieving revision 1.1
diff -u -p -r1.1 jqp.info
--- contributions/modules/jqp/jqp.info	30 Sep 2008 20:17:12 -0000	1.1
+++ contributions/modules/jqp/jqp.info	16 Dec 2008 13:26:24 -0000
@@ -1,4 +1,4 @@
 ; $Id: jqp.info,v 1.1 2008/09/30 20:17:12 jjeff Exp $
 name = "jQuery Plugin Handler"
 description = "Creates a central location from which modules can include jQuery plugins"
-core = "6.x"
\ No newline at end of file
+package = Javascript Utilities
\ No newline at end of file
Index: contributions/modules/jqp/jqp.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/jqp/jqp.module,v
retrieving revision 1.2
diff -u -p -r1.2 jqp.module
--- contributions/modules/jqp/jqp.module	1 Oct 2008 01:19:20 -0000	1.2
+++ contributions/modules/jqp/jqp.module	16 Dec 2008 13:26:24 -0000
@@ -4,23 +4,34 @@
 /**
  * Add a shared Javascript file from the plugins directory
  *
- * @param $file_name
+ * @param $file_name string required
  *   the name of the file to add
  * 
- * @param ...additional arguments to pass to drupal_add_js
- *
+ * @param $required boolean optional
+ *   Whether or not the plugin is required. 
+ *   If TRUE, a message will displayed if the plugin doesn't exist
+ * 
+ * @param $message_elements array optional
+ *   info which can be used in the message displayed if a plugin doesn't exist.
+ * @see jqp_display_message().
+ * 
+ * @param $js_args array optional
+ *   arguments to pass to drupal_add_js
+ * 
+ * @return boolean
+ *   TRUE/FALSE representing whether the file was found
+ * 
  */
-function jqp_add_js(){
-  $args = func_get_args();
-  $file_name = array_shift($args);
-
-  $files = jqp_scan_dir();
-  
-  if ($files[$file_name]) {
-    array_unshift($args, $files[$file_name]->filename);
-    call_user_func_array('drupal_add_js', $args);
+function jqp_add_js($file_name, $required = FALSE, $message_elements = array(), $js_args = array()) {
+  if ($file = jqp_plugin_exists($file_name)) {
+    array_unshift($js_args, $file->filename);
+    call_user_func_array('drupal_add_js', $js_args);
+    return TRUE;
   }
   else {
+    if ($required) {
+      jqp_display_message($file_name, $message_elements['module'], $message_elements['plugin_page']);
+    }
     return FALSE;
   }
 }
@@ -34,7 +45,7 @@ function jqp_add_js(){
  * @param ...additional arguments to pass to drupal_add_css
  *
  */
-function jqp_add_css(){
+function jqp_add_css() {
   $args = func_get_args();
   $file_name = array_shift($args);
 
@@ -54,12 +65,12 @@ function jqp_add_css(){
  * @param $file_name
  *   The name of the .js or .css file to check in the plugins directory
  *
- * @return boolean
- *   TRUE/FALSE representing whether the file was found
+ * @return
+ *   If the file was found, the file will be returned, otherwise FALSE will be returned
  */
-function jqp_plugin_exists($file_name){
+function jqp_plugin_exists($file_name) {
   $files = jqp_scan_dir();
-  return $files[$file_name] ? TRUE : FALSE;
+  return $files[$file_name] ? $files[$file_name] : FALSE;
 }
 
 
@@ -82,12 +93,49 @@ function jqp_scan_dir() {
   static $files;
   if (!isset($files)) {
     if ($cache = cache_get('jqp_plugins')) {
-      $files = $cache->data;
+      $files = unserialize($cache->data);
     }
     else {
       $files = drupal_system_listing('(\.js$|\.css$)', 'plugins', 'basename', 0);
-      cache_set('jqp_plugins', $files);
+      cache_set('jqp_plugins', 'cache', serialize($files));
     }
   }
   return $files;
+}
+
+/**
+ * Displays a notification message if a a required plugin isn't found.
+ * 
+ * @param $file_name string required
+ *   The name of the missing file
+ * 
+ * @param $module string optional
+ *   The module name which depends on the plugin
+ * 
+ * @param $plugin_page string optional
+ *   The url to the page where the plugin can be downloaded
+ * 
+ */
+function jqp_display_message($file_name, $module = NULL, $plugin_page = NULL) {
+  $message  = 'The jQuery plugin %file_name !module could not be found! ';
+  $message .= 'Please make sure the jQuery Plugin Handler module is correctly !installed ';
+  $message .= 'and the plugin is present in the plugins folder. !plugin_page';
+
+  $replacements = array(
+    '%file_name' => $file_name,
+    '!installed' => l(t('installed'), 'help'),
+    '!module' => '',
+    '!plugin_page' => '',
+  );
+
+  if ($plugin_page) {
+    $replacements['!plugin_page'] = t('The required plugin can be downloaded !here.', array(
+      '!here' => l(t('here'), $plugin_page)
+    ));
+  }
+
+  if ($module) {
+    $replacements['!module'] = t(', required by %module, ', array('%module' => $module));
+  }
+  drupal_set_message(t($message, $replacements), 'error');
 }
\ No newline at end of file
