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

Drupal example source code file (jwysiwyg.inc)

This example Drupal source code file (jwysiwyg.inc) 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, css, directory, fgets, file, files, function, if, php, return, script, title, url, version

The jwysiwyg.inc Drupal example source code

<?php
// $Id: jwysiwyg.inc,v 1.5 2010/04/02 14:05:36 sun Exp $

/**
 * @file
 * Editor integration functions for jWYSIWYG.
 */

/**
 * Plugin implementation of hook_editor().
 */
function wysiwyg_jwysiwyg_editor() {
  $editor['jwysiwyg'] = array(
    'title' => 'jWYSIWYG',
    'vendor url' => 'http://code.google.com/p/jwysiwyg/',
    'download url' => 'http://code.google.com/p/jwysiwyg/downloads/list',
    'libraries' => array(
      '' => array(
        'title' => 'Source',
        'files' => array('jquery.wysiwyg.js'),
      ),
      'pack' => array(
        'title' => 'Packed',
        'files' => array('jquery.wysiwyg.pack.js'),
      ),
    ),
    'version callback' => 'wysiwyg_jwysiwyg_version',
    // @todo Wrong property; add separate properties for editor requisites.
    'css path' => wysiwyg_get_path('jwysiwyg'),
    'versions' => array(
      '0.5' => array(
        'js files' => array('jwysiwyg.js'),
        'css files' => array('jquery.wysiwyg.css'),
      ),
    ),
  );
  return $editor;
}

/**
 * Detect editor version.
 *
 * @param $editor
 *   An array containing editor properties as returned from hook_editor().
 *
 * @return
 *   The installed editor version.
 */
function wysiwyg_jwysiwyg_version($editor) {
  $script = $editor['library path'] . '/jquery.wysiwyg.js';
  if (!file_exists($script)) {
    return;
  }
  $script = fopen($script, 'r');
  fgets($script);
  $line = fgets($script);
  if (preg_match('@([0-9\.]+)$@', $line, $version)) {
    fclose($script);
    return $version[1];
  }
  fclose($script);
}

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal jwysiwyg.inc 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.