summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fckeditor.module54
-rw-r--r--lib/fckpopup.php77
2 files changed, 31 insertions, 100 deletions
diff --git a/fckeditor.module b/fckeditor.module
index 8464ed9..737f649 100644
--- a/fckeditor.module
+++ b/fckeditor.module
@@ -2,7 +2,7 @@
/*
* FCKeditor Module for Drupal 4.7
*
- * This module allows Drupal to replace textarea fields with FCKEditor.
+ * This module allows Drupal to replace textarea fields with FCKeditor.
*
* This HTML text editor brings to the web many of the powerful functionalities
* of known desktop editors like Word. It's really lightweight and doesn't
@@ -72,7 +72,6 @@ function fckeditor_elements() {
*/
function fckeditor_settings() {
// Settings form
- variable_set('fckeditor_default_base_path', fckeditor_basepath());
$toolbar_options = array('Default' => 'Default', 'DrupalFull' => 'Drupal Full', 'DrupalBasic' => 'Drupal Basic', 'Basic' => 'Basic');
// Generate the form - settings applying to all patterns first
@@ -83,12 +82,6 @@ function fckeditor_settings() {
'#collapsible' => TRUE,
'#collapsed' => FALSE
);
- $form['fckeditor_settings']['fckeditor_base_path'] = array(
- '#type' => 'textfield',
- '#title' => t('Base Path'),
- '#default_value' => variable_get("fckeditor_base_path", 'modules/fckeditor/lib/'),
- '#description' => t('The directory which contains FCKEditor scripts (recommended default: %default).', array('%default'=>variable_get('fckeditor_default_base_path',''))),
- );
$form['fckeditor_settings']['fckeditor_default_toolbar'] = array(
'#type' => 'select',
'#title' => t('Default Toolbar'),
@@ -140,7 +133,7 @@ function fckeditor_settings() {
);
$form['fckeditor_special_settings']['fckeditor_popup'] = array(
'#type' => 'checkbox',
- '#title' => t('Use FCKEditor in a popup window'),
+ '#title' => t('Use FCKeditor in a popup window'),
'#default_value' => variable_get('fckeditor_popup', '0'),
'#description' => t('Popup window or Textarea replace.'),
);
@@ -154,7 +147,7 @@ function fckeditor_settings() {
'#type' => 'textfield',
'#title' => t('Width'),
'#default_value' => variable_get("fckeditor_width", "100%"),
- '#description' => t("width (pixels/percent)"),
+ '#description' => t("Width in pixels or percent. Ex: 400 or 100%"),
);
$form['fckeditor_skin'] = array('#type' => 'value', '#value' => variable_get('fckeditor_skin', 'default'));
@@ -164,7 +157,7 @@ function fckeditor_settings() {
/**
- * This function create the HTML objects required for the FCKEditor
+ * This function create the HTML objects required for the FCKeditor
*/
function fckeditor_process_textarea($element) {
$exclude = preg_split("/[\s,]+/", strip_tags(variable_get("fckeditor_exclude", '')));
@@ -174,8 +167,8 @@ function fckeditor_process_textarea($element) {
// only when a textarea has enough rows and is not in the exclusion list
// setting some variables
- $module_path = drupal_get_path('module', 'fckeditor');
- $base_path = variable_get("fckeditor_base_path", fckeditor_basepath());
+ $module_path = fckeditor_modulepath();
+ $base_path = fckeditor_basepath();
$js_id = 'oFCKeditor_' . str_replace('-', '_', $element['#id']);
// configured in settings
@@ -200,14 +193,15 @@ function fckeditor_process_textarea($element) {
<script type=\"text/javascript\">
var ".$js_id." = new FCKeditor( '".$element['#id']."' );
".$js_id.".BasePath = '".$base_path."';
-".$js_id.".Config['CustomConfigurationsPath'] = '/".$module_path."/fckeditor.config.js';
+".$js_id.".Config['CustomConfigurationsPath'] = '".$module_path."/fckeditor.config.js';
".$js_id.".ToolbarSet = '".$toolbar."';
+".$js_id.".Height = '".$height."';
</script>\n";
if (variable_get('fckeditor_popup', '0')) {
// Add the script file with the popup open function.
drupal_add_js($module_path . '/fckeditor.popup.js');
- $element['#title'] .= " <span class=\"fckeditor_popuplink\">(<a href=\"#\" onclick=\"FCKeditor_OpenPopup('/".$module_path."/fckeditor.popup.html?var=".$js_id."&el=".$element['#id']."');return false;\">" . t('Open rich editor') . "</a>)</span>" ;
+ $element['#title'] .= " <span class=\"fckeditor_popuplink\">(<a href=\"#\" onclick=\"FCKeditor_OpenPopup('".$module_path."/fckeditor.popup.html?var=".$js_id."&el=".$element['#id']."');return false;\">" . t('Open rich editor') . "</a>)</span>" ;
} else {
// if no popup mode, add the editor
$element['#suffix'] .="
@@ -232,7 +226,7 @@ if (!function_exists('array_pregsearch')) {
}
/**
- * Test if client supports the FCKEditor
+ * Test if client supports the FCKeditor
*/
function fckeditor_is_compatible_client() {
$sAgent = $_SERVER['HTTP_USER_AGENT'] ;
@@ -253,11 +247,25 @@ function fckeditor_is_compatible_client() {
* Gets the Base Path of the FCKeditor installation.
*/
function fckeditor_basepath() {
- $path = variable_get( 'fckeditor_base_path', false );
-
- if ( !$path ) {
- return '/' . drupal_get_path('module', 'fckeditor') . '/fckeditor/';
- }
-
- return $path;
+ $path = variable_get( 'fckeditor_base_path', false );
+
+ if ( !$path ) {
+ $path = fckeditor_modulepath() . '/fckeditor/';
+ }
+
+ return $path;
+}
+
+/**
+ * Get the path for the fckeditor module. Ensures that the path starts with a
+ * slash.
+ */
+function fckeditor_modulepath() {
+ $path = drupal_get_path('module', 'fckeditor');
+
+ if ( substr($path, 0, 1) != '/' ) {
+ $path = base_path() . $path;
+ }
+
+ return $path;
} \ No newline at end of file
diff --git a/lib/fckpopup.php b/lib/fckpopup.php
deleted file mode 100644
index 15e1bf5..0000000
--- a/lib/fckpopup.php
+++ /dev/null
@@ -1,77 +0,0 @@
-<?php
-/*
- * FCKeditor - The text editor for internet
- * Copyright (C) 2003-2005 Frederico Caldeira Knabben
- *
- * Licensed under the terms of the GNU Lesser General Public License:
- * http://www.opensource.org/licenses/lgpl-license.php
- *
- * For further information visit:
- * http://www.fckeditor.net/
- *
- * "Support Open Source software. What about a donation today?"
- *
- * File Name: fckpopup.php
- * full size FCKeditor window that gets and save text from parent window.
- * Taylored for use by Drupal,but could be customised for anything else.
- * Accepts the following inputs:
- * fckpopup.php?name=$name&SkinPath=$SkinPath&Toolbar=$Toolbar
- * where:
- * $name = name of window, not important to functionality
- * $SkinPath = point to chosed FCKeditor skin
- * $Toolbar = sets which toolbar to use
- *
- *
- * File Authors:
- * Davide (davide@skeda.com.au)
- */
-$FCKname = ($HTTP_GET_VARS["name"])
- ? " - (" . $HTTP_GET_VARS["name"] . ")"
- : null;
-$FCKSkinPath = ($HTTP_GET_VARS["SkinPath"])
- ? "oFCKeditor.Config['SkinPath'] = '" . $HTTP_GET_VARS["SkinPath"] . "' ;"
- : null;
-$FCKToolbar = ($HTTP_GET_VARS["Toolbar"])
- ? "oFCKeditor.ToolbarSet = '" . $HTTP_GET_VARS["Toolbar"] . "' ;"
- : null;
-?>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-<html>
- <head>
- <title>FCKeditor <?php echo $FCKname; ?></title>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <meta name="robots" content="noindex, nofollow">
- <script type="text/javascript" src="fckeditor.js"></script>
- <script type="text/javascript" language="JavaScript">
- <!--
- function sendEditor()
- {
- // Get the editor instance that we want to interact with.
- var oEditor = FCKeditorAPI.GetInstance('FCKeditor1') ;
-
- // Get the editor contents in XHTML.
- window.opener.oFCKta.value = oEditor.GetXHTML( true );
- parent.window.close();
- }
- -->
- </script>
- </head>
- <body style="margin:0px; padding:0px;">
- <form method="post" onSubmit="sendEditor();">
- <script type="text/javascript">
- <!--
- var oFCKeditor = new FCKeditor( 'FCKeditor1' ) ;
- oFCKeditor.BasePath = '' ;
- oFCKeditor.Height = '98%' ;
- <?php echo $FCKSkinPath ?>
- oFCKeditor.Config['ShowBorders'] = false ;
- oFCKeditor.Config['ToolbarCanCollapse'] = false ;
-
- <?php echo $FCKToolbar; ?>
- oFCKeditor.Value = window.opener.oFCKta.value ;
- oFCKeditor.Create() ;
- //-->
- </script>
- </form>
- </body>
-</html> \ No newline at end of file