Index: markitup.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/markitup/markitup.module,v
retrieving revision 1.4
diff -u -p -r1.4 markitup.module
--- markitup.module	8 Apr 2008 03:33:29 -0000	1.4
+++ markitup.module	9 May 2008 08:08:51 -0000
@@ -6,9 +6,6 @@
  * Enables the markitup universal content editor jQuery plugin.
  */
 
-// Define the path for the module.
-define("MARKITUP_PATH", drupal_get_path('module', 'markitup'));
-
 /**
  * Implementation of hook_perm().
  */
@@ -19,16 +16,26 @@ function markitup_perm() {
 /**
  * Implementation of hook_menu().
  */
-function markitup_menu() {
-  $items['admin/settings/markitup'] = array(
-    'title' => 'markItUp Editor',
-    'description' => 'Choose the skin and button/tag set for the markItUp! editor.',
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('markitup_admin_settings'),
-    'access arguments' => array('administer markitup'),
-    'type' => MENU_NORMAL_ITEM,
-    'file' => 'markitup.module',
-  );
+function markitup_menu($may_cache) {
+  $items = array();
+
+  if ($may_cache) {
+    $items[] = array(
+      'path' => 'admin/settings/markitup',
+      'title' => 'markItUp Editor',
+      'description' => 'Choose the skin and button/tag set for the markItUp! editor.',
+      'callback' => 'drupal_get_form',
+      'callback arguments' => array('markitup_admin_settings'),
+      'access' => user_access('administer markitup'),
+      'type' => MENU_NORMAL_ITEM,
+    );
+  }
+  else {
+    // Invoke the loading of our js and css if user has permission.
+    if (user_access('use markitup editor')) {
+      markitup();
+    }
+  }
 
   return $items;
 }
@@ -58,7 +65,7 @@ function markitup_admin_settings() {
 function _markitup_dirs($dir) {
   // Use $dir (which will be a plugin directory either skins or sets) to get
   // a listing of sub-directories and feed them to $dirs.
-  $dirs = scandir(MARKITUP_PATH .'/markitup/'. $dir);
+  $dirs = scandir(drupal_get_path('module', 'markitup') .'/markitup/'. $dir);
   $needle = array('.', '..', 'CVS', '.svn');  // others?
   // Iterate through the list of needles, looking for matching directories,
   // and then unset the matches.
@@ -87,12 +94,12 @@ function markitup() {
   $skins =  variable_get('markitup_skins', $default = 'simple');
   $sets =  variable_get('markitup_sets', $default = 'default');
   // load the javascript and css files
-  drupal_add_css(MARKITUP_PATH ."/markitup/skins/$skins/markitup-skin-style.css", $type = 'module', $media = 'all', $preprocess = TRUE);
-  drupal_add_css(MARKITUP_PATH ."/markitup/sets/$sets/markitup-set-style.css", $type = 'module', $media = 'all', $preprocess = TRUE);
-  drupal_add_css(MARKITUP_PATH ."/markitup.css", $type = 'module', $media = 'all', $preprocess = TRUE); // CSS overrides for Drupal integration
+  drupal_add_css(drupal_get_path('module', 'markitup') ."/markitup/skins/$skins/markitup-skin-style.css", $type = 'module', $media = 'all', $preprocess = TRUE);
+  drupal_add_css(drupal_get_path('module', 'markitup') ."/markitup/sets/$sets/markitup-set-style.css", $type = 'module', $media = 'all', $preprocess = TRUE);
+  drupal_add_css(drupal_get_path('module', 'markitup') ."/markitup.css", $type = 'module', $media = 'all', $preprocess = TRUE); // CSS overrides for Drupal integration
 
-  drupal_add_js(MARKITUP_PATH ."/markitup/jquery.markitup.pack.js", 'module');
-  drupal_add_js(MARKITUP_PATH ."/markitup/sets/$sets/set.js", 'module');
+  drupal_add_js(drupal_get_path('module', 'markitup') ."/markitup/jquery.markitup.pack.js", 'module');
+  drupal_add_js(drupal_get_path('module', 'markitup') ."/markitup/sets/$sets/set.js", 'module');
 
   $invoke_markitup = '
     if (Drupal.jsEnabled) {
@@ -107,27 +114,4 @@ function markitup() {
     }
   ';
   drupal_add_js($invoke_markitup, 'inline');
-
-  // Let's avoid the issues that arise if the textarea splitter is on.
-  $turnoff_teaser = ' 	 
-    if (Drupal.jsEnabled) { 	 
-      // Skip out of teaser splitter as defined in teaser.js. 	 
-      Drupal.behaviors.teaser = function(context) { 	 
-        return;
-      }
-    }
-  '; 	 
-  drupal_add_js($turnoff_teaser, 'inline');
 }
-
-
-/**
- * Implmentation of hook_init().
- */
-function markitup_init() {
-  // Invoke the loading of our js and css if user has permission.
-  if (user_access('use markitup editor')) {
-    markitup();
-  }
-}
-
