Working on the recently committed code in the CVS, I'm proposing here many fixes. There was no way to create separated patches for them, as they are all mixed, but I think it is not a big issue. These fixes are more related to detais:

  • All references to the wrongly cased "FCKEditor" were corrected to "FCKeditor".
  • The hook_help has been changed and an important TODO task has been left in the code for the editor help. Sorry for not providing it right now, but it is something important to do.
  • In fckeditor_process_textarea(), the exclusion checks are now made in the beginning of the function and return right away, instead of enclosing the entire function contents. This creates a more clear and readable code.
  • It seams that the "drupal_get_path" function returns a path that starts with slash in some cases, but in other cases it comes without it. So now we ensure that all paths starts with a slash.
  • Introduced a new attribute called "#wysiwyg" so you can mark textarea fields as not WYSIWYG compatible when creating custom forms. Actually this is something that should be part of Drupal's code

I don't see any issue on committing this patch, but let's discuss any point that may not be clear.

Best regards,
Frederico Caldeira Knabben
----
http://www.fckeditor.net
"Support Open Source Software"

CommentFileSizeAuthor
fckeditor.module_1.patch8.12 KBFredCK

Comments

ontwerpwerk’s picture

Assigned: Unassigned » ontwerpwerk
Status: Reviewed & tested by the community » Needs review
  • I fixed the capitalization
  • I moved the path functions around a bit (I used base_path() too), it also made one of the variables obsolete (fckeditor_default_base_path)
  • The Extra help is now http://drupal.org/node/81339. (TODO not in code but in issue tracker is easier and cleaner)
  • The last point, a #wysiwyg attribute is a good idea, but I would wait until that is standardized for all of drupal, it would probably make most of the exclusion stuff obsolete anyway.
havran’s picture

I have tried patch and i have still problem with paths. For example i have set open FCKeditor through link and in opened window i give:


Not Found
The requested URL /sites/www.fem.uniag.sk.havran/modules/fckeditor/fckeditor.popup.html was not found on this server.
Apache/2.0.59 (FreeBSD) PHP/4.4.4 mod_ssl/2.0.59 OpenSSL/0.9.7e-p1 Server at www.fem.uniag.sk Port 80

(i have installed modul in sites/myweb/mypath/modules but i give same error if i installed fckeditor.module in to standard modules directory.)

My site is running on path /havran/ .... i think i need path /havran/sites/www.fem.uniag.sk.havran/modules/fckeditor/fckeditor.popup.html - why not use base_path() function for give real web path?

FredCK’s picture

The #wysiwyg thing could be considered as a FCKeditor extension. It gives some possibility of blocking the WYSIWYG on custom forms. As this is a urging thing today, having this on FCKeditor will at lease give us some possibilities, otherwise we will continue have to hack the FCKeditor module.

Talking about standardizing things... let's give our +1 to the idea:
http://drupal.org/node/81297

FredCK’s picture

The Extra help is now http://drupal.org/node/81339. (TODO not in code but in issue tracker is easier and cleaner)

The specific tracker item is a nice thing. The TODO in the code served as a template for the implementation.

havran’s picture

I find fix. Use Drupal function base_path() before all JS paths solve this issue...

  $element['#suffix'] .= "
<script type=\"text/javascript\">
var ".$js_id." = new FCKeditor( '".$element['#id']."' );
".$js_id.".BasePath	= '".base_path().$base_path."';
".$js_id.".Config['CustomConfigurationsPath'] = '".base_path().$module_path."/fckeditor.config.js';
".$js_id.".ToolbarSet = '".$toolbar."';
</script>\n";

  if (variable_get('fckeditor_popup', '0')) {
    // Add the script file with the popup open function.
    drupal_add_js(preg_replace('/^\//', '', $module_path) . '/fckeditor.popup.js');
    $element['#title'] .= " <span class=\"fckeditor_popuplink\">(<a href=\"#\" onclick=\"FCKeditor_OpenPopup('".base_path().$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'] .= "
<script type=\"text/javascript\">
".$js_id.".ReplaceTextarea();
</script>\n";
  }

But base_path() return path with trailing slash (i give path /havran//path) but editor now working in my config well. In Drupal FCKeditor settings i have set path to recommended default: /sites/www.fem.uniag.sk.havran/modules/fckeditor/fckeditor/ (for me).

FredCK’s picture

to Havran:

Checkout the current CVS version. You will see that the fckeditor_modulepath() function has been fixed using base_path().

havran’s picture

I'm apologize, but there is still some things to do. I make clean instalation (i remove previous settings from Drupal system and variable tables). I still give bad paths (from html code, if i have checked Use FCKeditor in a popup window):

<script type="text/javascript" src="/havran/havran/sites/www.fem.uniag.sk.havran/modules/fckeditor/fckeditor/fckeditor.js"></script>
<script type="text/javascript" src="/havran//havran/sites/www.fem.uniag.sk.havran/modules/fckeditor/fckeditor.popup.js"></script>

There is double base dir of my site.

ontwerpwerk’s picture

no apologies neccesary, lets see if we can help

I have some questions about your setup:
My guess is your site is at http://www.fem.uniag.sk/havran/ .. is that right?
Do you have your drupal site in a subdirectory of the webserver, or is it in a home directory of your useraccount there?
Do you have any other contributed modules installed or changed any core modules?

Your fckeditor base_path should look like: /havran/modules/fckeditor/fckeditor/fckeditor.js and your module path should be /havran/modules/fckeditor/

It looks like your base path also has an extra path for your settings added to it... so somewhere there is someting adding it..

havran’s picture

> I have some questions about your setup:
> My guess is your site is at http://www.fem.uniag.sk/havran/ .. is that right?

Right.

> Do you have your drupal site in a subdirectory of the webserver, or is it in a home
> directory of your useraccount there?

Directly in my home directory (http://www.fem.uniag.sk/havran/ from the web).

> Do you have any other contributed modules installed or changed any core modules?

I have installed only module devel. I have fresh Drupal instalation without any changes in core.

> Your fckeditor base_path should look like: /havran/modules/fckeditor/fckeditor/fckeditor.js
> and your module path should be /havran/modules/fckeditor/

I have installed Drupal modules in /havran/sites/www.fem.uniag.sk.havran/modules/... it's legal way installing modules into Drupal. This is something we should count it.

> It looks like your base path also has an extra path for your settings added to it... so
> somewhere there is someting adding it..

I have look on drupal function drupal_add_js() (http://api.drupal.org/api/4.7/function/drupal_add_js) and there is used function base_path() too. I think drupal_add_js() need path without base_path() part.

fwdrupal@drupalcenter.de’s picture

Same here. The problem with the path and the module in a subdirectory still persists.

I pulled current cvs and installed to my Drupal 4.7.3 with no other modules.

It still gives me errors: http://clubhaus.dyndns.org/fw//fw/modules/fckeditor/fckeditor.popup.js

ontwerpwerk’s picture

@havran.. ah, that is why the path looked so weird to me, I havent tested with that situation yet...
does your error occur only when you use the popup editor?

Does the behaviour change when you use the following function instead of the function in CVS?

function fckeditor_modulepath() {
  $path = drupal_get_path('module', 'fckeditor');
  return $path;
}
havran’s picture

function fckeditor_modulepath() {
  $path = drupal_get_path('module', 'fckeditor');
  return $path;
}

This function return correct path for including .js files. I erase default Base Path settings, default value modules/fckreditor/lib not working - generated autodefault working perfect :).

But for working i must add base_path() function in this code:

  $element['#suffix'] .= "
<script type=\"text/javascript\">
var ".$js_id." = new FCKeditor( '".$element['#id']."' );
".$js_id.".BasePath	= '" . base_path() . $base_path."';
".$js_id.".Config['CustomConfigurationsPath'] = '" . base_path() . $module_path."/fckeditor.config.js';
".$js_id.".ToolbarSet = '".$toolbar."';
</script>\n";

Now seems all working (textarea/editor replace and popup/editor link).

ontwerpwerk’s picture

Status: Needs review » Fixed

should be all fixed now thanks to FredCK
see http://drupal.org/node/82044

Anonymous’s picture

Status: Fixed » Closed (fixed)