You are here

function fckeditor_wrapper_img_assist_loader in FCKeditor - WYSIWYG HTML editor 6.2

This function wraps img_assist_loader

1 string reference to 'fckeditor_wrapper_img_assist_loader'
fckeditor_menu in ./fckeditor.module
Implementation of hook_menu().

File

./fckeditor.user.inc, line 180
FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2008 Frederico Caldeira Knabben

Code

function fckeditor_wrapper_img_assist_loader() {
  if (module_exists('img_assist')) {
    $fckpath = drupal_get_path('module', 'fckeditor');
    $fckjs = $fckpath . '/img_assist_fckeditor.js';
    $iapath = drupal_get_path('module', 'img_assist');

    // find the version of img_assist by looking at the CVS Id version
    $cvsversion = -1;
    $iafp = fopen($iapath . '/img_assist.module', 'r');
    $cvsidlines = fread($iafp, 100);

    // the cvs version is probably in the first 100 bytes
    fclose($iafp);
    $matches = array();
    if (preg_match('# \\d+\\.(\\d+)[\\d\\.]* #', $cvsidlines, $matches)) {
      $cvsversion = (int) $matches[1];
    }
    switch ($cvsversion) {
      case 75:

        // this branch is the branch for 6.x-2.x of img_assist
        // add img_assist js files before our own file to
        drupal_add_js($iapath . '/img_assist_popup.js');
        drupal_add_js($iapath . '/img_assist_textarea.js');
        drupal_add_js($fckjs);
        img_assist_loader();
        break;
      case 72:

        // this branch is the branch for 6.x-1.x of img_assist
        ob_start();
        img_assist_loader();
        $text = ob_get_clean();
        $search = '<script type="text/javascript" src="' . base_path() . $iapath . '/img_assist_fckeditor.js"></script>';
        $new = '<script type="text/javascript" src="' . base_path() . $iapath . '/img_assist_textarea.js"></script>' . "\n" . '<script type="text/javascript" src="' . base_path() . $fckjs . '"></script>';
        if (strpos($text, $search) !== FALSE) {
          $text = str_replace($search, $new, $text);
          echo $text;
          break;
        }
        else {
          drupal_set_message(t('Image Assist output was not recognized'), 'error');
          return '';
        }
      default:
        drupal_set_message(t('This Image Assist version is not supported'), 'error');
        return '';
    }
  }
  else {
    drupal_not_found();
  }
}