home | career | drupal | java | mac | mysql | perl | php | scala | uml | unix

Drupal example source code file (imce_wysiwyg.module)

This example Drupal source code file (imce_wysiwyg.module) is included in the DevDaily.com "Drupal Source Code Warehouse" project. The intent of this project is to help you "Learn Drupal by Example".

PHP - Drupal tags/keywords

array, drupal_add_js, editor, false, if, imce, imcepath, integrated, load, php, return, true, url

The imce_wysiwyg.module Drupal example source code

<?php

/**
 * @file
 * Makes IMCE available as plugin for client-side editors integrated via
 * Wysiwyg API.
 */

/**
 * Implementation of hook_wysiwyg_plugin().
 */
function imce_wysiwyg_plugin($editor, $version) {
  static $integrated = array();

  if (!module_invoke('imce', 'access')) {
    return;
  }
  // Load our invocation scripts.
  if (empty($integrated)) {
    $imcepath = drupal_get_path('module', 'imce');
    $path = drupal_get_path('module', 'imce_wysiwyg');
    drupal_add_js($imcepath . '/js/imce.js');
    drupal_add_js($imcepath . '/js/imce_set_app.js');
    drupal_add_js($path . '/js/imce_wysiwyg.js');
  }

  switch ($editor) {
    case 'tinymce':
      if (!isset($integrated[$editor])) {
        $integrated[$editor] = TRUE;
        // @todo If some other editor also needs the URL to be passed via
        //   Drupal.settings.imce, then we need another sub-key '$editor'.
        $settings = array(
          'imce' => array('url' => url('imce', array('query' => array('app' => $editor . '|url@')))),
        );
        drupal_add_js($settings, 'setting');
      }
      return array(
        'imce' => array(
          'extensions' => array('imce' => t('IMCE')),
          'url' => 'http://drupal.org/project/imce',
          'options' => array(
            'file_browser_callback' => 'imceImageBrowser',
            'inline_styles' => TRUE,
          ),
          'load' => FALSE,
        ),
      );

   case 'ckeditor':
      $integrated[$editor] = TRUE;
      return array(
        'imce' => array(
          'extensions' => array('imce' => t('IMCE')),
          'url' => 'http://drupal.org/project/imce',
          'options' => array(
            'filebrowserBrowseUrl' => url('imce', array('query' => array('app' => $editor . '|sendto@imceCkeditSendTo|params@'))),
          ),
          'load' => FALSE,
        ),
      );

    case 'fckeditor':
      $integrated[$editor] = TRUE;
      return array(
        'imce' => array(
          'extensions' => array('imce' => t('IMCE')),
          'url' => 'http://drupal.org/project/imce',
          'options' => array(
            'LinkBrowser' => TRUE,
            'LinkBrowserURL' => url('imce', array('query' => array('app' => $editor . '|url@txtUrl'))),
            'ImageBrowser' => TRUE,
            'ImageBrowserURL' => url('imce', array('query' => array('app' => $editor . '|url@txtUrl|width@txtWidth|height@txtHeight'))),
            'FlashBrowser' => TRUE,
            'FlashBrowserURL' => url('imce', array('query' => array('app' => $editor . '|url@txtUrl'))),
          ),
          'load' => FALSE,
        ),
      );
  }
}

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal imce_wysiwyg.module source code file:

new blog posts

"Drupal" is a registered trademark of Dries Buytaert.

my drupal tutorials and examples  

Copyright 1998-2016 Alvin Alexander, alvinalexander.com
All Rights Reserved.

Beginning in 2016, a portion of the proceeds from pages under the '/drupal-code-examples/' URI will be donated to charity.