This error only occurs with anonymous users as I found. Hook_init explains the problem http://api.drupal.org/api/function/hook_init/5 .

This patch moves the contents of the hook_init in this module to hook_menu.

Thanks!
DaveA

CommentFileSizeAuthor
jq_maphilight.07292008.patch945 bytesdavea

Comments

WorldFallz’s picture

Status: Active » Fixed

Nice catch-- and thanks so much for the patch. It will be included in the next release (should be this weekend).

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

Mysterious Britain’s picture

Status: Closed (fixed) » Active

Thanks for the patch, davea. I'm trying to patch the file using Cygwin but have not had any success, I either get end-of-line or hunk failed errors.

WorldFallz - please could you release a patched version of the module or, at the very least could someone post up their patched jq_maphilight.module file?

Regards,
Neil.

Mysterious Britain’s picture

Status: Active » Closed (fixed)

I managed to patch the file manually, thanks to some informative threads on patching in the forum.

Here's the fully patched jq_maphilight.module code for anyone who needs it:

<?php
// $Id: jq_maphilight.module,v 1.1.4.1 2008/04/23 16:05:43 worldfallz Exp $

/**
 * @file
 * Configurable javascript based image map hilighting using the jquery map hilight plugin.
 */
 
 /**
 * Implemention of hook_menu().
 */
function jq_maphilight_menu($may_cache) {
  $available = _jq_maphilight_available();
  if (($available !== FALSE)  && (arg(0) != 'admin') && (arg(0) != 'user') && (arg(1) != 'add') && (arg(2) != 'edit')) {

    $script = "\$(document).ready(function() { \$.fn.maphilight.defaults = { "
      ."fill: ". variable_get('jq_maphilight_fill', 'true') .","
      ."fillColor: '". variable_get('jq_maphilight_fillcolor', 'ff0000') ."',"
      ."fillOpacity: ". (variable_get('jq_maphilight_fillopacity', '2') / 10) .","
      ."stroke: ". variable_get('jq_maphilight_stroke', 'true') .","
      ."strokeColor: '". variable_get('jq_maphilight_strokecolor', 'D51910') ."',"
      ."strokeOpacity: ". (variable_get('jq_maphilight_strokeopacity', '10') / 10) .","
      ."strokeWidth: ". variable_get('jq_maphilight_strokewidth', '2') .","
      ."fade: ". variable_get('jq_maphilight_fade', 'true') .","
      ."alwaysOn: false}; "
      ."\$('.jq_maphilight').maphilight();});";

    jquery_plugin_add('metadata');
    jquery_plugin_add('maphilight');
    drupal_add_js($script, 'inline');     
  }

  $items = array();
  if ($may_cache) {
    $items[] = array(
       'path' => 'admin/settings/jq_maphilight',
      'title' => t('JQuery Map Hilight'),
      'description' => t('Javascript image map highlighting using the jquery Map Hilight plugin.'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array('jq_maphilight_admin_settings'),
      'access' => user_access('access administration pages'),
      'type' => MENU_NORMAL_ITEM,
    );
  }
  return $items;
}

/**
 *  jq_maphilight admin/settings page; implements hook_form
 */
function jq_maphilight_admin_settings() {
  $form = array();
  
  $form['jq_maphilight_status'] = array(
    '#type' => 'fieldset',
    '#title' => t('jQuery Map Hilight Plugin Status'),
    '#weight' => -10,
    '#description' => (_jq_maphilight_available() !== false) ? t('The Map Hilight jQuery plugin is available at: /') . _jq_maphilight_available() : '<em><span style="color: #A50000;">'. t('The Map Hilight jQuery plugin is unavailable or not located in the jquery_plugin module directory.') .'</span></em>',
    '#collapsible' => TRUE,
    );

  $form['jq_maphilight_settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('jQuery Map Hilight Plugin Settings'),
    '#description' => 'Be sure to add <strong><em>class="jq_maphilight"</em></strong> to the IMG tag of all image maps you want hilighted.'
  );

  $form['jq_maphilight_settings']['jq_maphilight_fill'] = array(
    '#type' => 'select',
    '#title' => t('Fill'),
    '#default_value' => variable_get('jq_maphilight_fill', 'true'),
    '#options' => array('true' => t('TRUE'), 'false' => t('FALSE')),
    '#description' => 'Specify whether or not the hilighted area should be filled.'
  );

  $form['jq_maphilight_settings']['jq_maphilight_fillcolor'] = array(
    '#type' => 'textfield',
    '#title' => t('Fill Color'),
    '#default_value' => variable_get('jq_maphilight_fillcolor', 'ff0000'),
    '#size' => 8,
    '#description' => 'Specify the color of the fill. Use HTML # notation without the #.'
  );

  $form['jq_maphilight_settings']['jq_maphilight_fillopacity'] = array(
    '#type' => 'select',
    '#title' => t('Fill Opacity'),
    '#default_value' => variable_get('jq_maphilight_fillopacity', 2),
    '#options' => drupal_map_assoc(array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)),
    '#description' => 'Specify the opacity of the fill (0 = lightest, 10 = darkest).'
  );

  $form['jq_maphilight_settings']['jq_maphilight_stroke'] = array(
    '#type' => 'select',
    '#title' => t('Stroke (outline)'),
    '#options' => array('true' => t('TRUE'), 'false' => t('FALSE')),
    '#default_value' => (variable_get('jq_maphilight_stroke', 'true')),
    '#description' => 'Specify whether or not the hilighted area will be outlined.'
  );

  $form['jq_maphilight_settings']['jq_maphilight_strokecolor'] = array(
    '#type' => 'textfield',
    '#title' => t('Stroke Color'),
    '#default_value' => variable_get('jq_maphilight_strokecolor', 'D51910'),
    '#size' => 8,
    '#description' => 'Specify the color of the outline. Use HTML # notation without the #.'
  );

  $form['jq_maphilight_settings']['jq_maphilight_strokewidth'] = array(
    '#type' => 'textfield',
    '#title' => t('Stroke Width'),
    '#default_value' => variable_get('jq_maphilight_strokewidth', 2),
    '#size' => 8,
    '#description' => 'Specify the width of the outline in pixels.'
  );

  $form['jq_maphilight_settings']['jq_maphilight_strokeopacity'] = array(
    '#type' => 'select',
    '#title' => t('Stroke Opacity'),
    '#default_value' => variable_get('jq_maphilight_strokeopacity', 10),
    '#options' => drupal_map_assoc(array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)),
    '#description' => 'Specify the opacity of the outline (0 = lightest, 10 = darkest).'
  );

  $form['jq_maphilight_settings']['jq_maphilight_fade'] = array(
    '#type' => 'select',
    '#title' => t('Fade'),
    '#options' => array('true' => t('TRUE'), 'false' => t('FALSE')),
    '#default_value' => (variable_get('jq_maphilight_fade', 'true')),
    '#description' => 'Specify whether or not the hilighting uses a fade transition.'
  );

  return system_settings_form($form);
}

/**
 * check jquery_plugin directory for the jquery.maphilight.min.js file
 */
function _jq_maphilight_available() {

  $available = drupal_get_path('module', 'jquery_plugin') .'/jquery.maphilight.min.js'; 

  if (!is_file($available)) {
    return FALSE;
  }

  return $available;
}
WorldFallz’s picture

Status: Closed (fixed) » Active

I apologize to all for not getting to this sooner. I've had some pressing issues that have recently sucked up my free time. I've just committed the patch from the op of this issue as well as a couple of other minor items from other issues. The dev snapshot should be updated within 12 hours.

Leaving this active until I confirm the dev snapshot updates.

WorldFallz’s picture

Status: Active » Fixed

Committed-- thanks!

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.