Related: #2155465: Changed plugin/moduls moved, info doesn't change because it's stored in the settings array

(Technically it's not a bug, but it is a huge oversight IMO.)

Features are meant to be reusable, that's why they're features. But CKEDITOR features contain plugin meta data like this:

          'webform_answers' => array(
            'name' => 'webform_answers',
            'desc' => 'Webform Answers',
            'path' => '/sites/virenze/modules/ezhealth/client/custom/webform_answers/editors/ckeditor/',
            'buttons' => array(
              'webform_answers' => array(
                'label' => 'Insert Webform Answer',
                'icon' => 'webform_answers.png',
              ),
            ),
          ),

So the path is fixed, not just the module location, but the site too. Even the base path, but you can manually change that to %base_path%. It would be awesome if the plugin's module directory was a placeholder too, so wherever the module lives, CKEDITOR can find the plugin files. Sometimes just the site location is enough, so you can reuse the feature (or entire site code base) for another site.

I propose to add:

  • %conf_path% for site's location, and
  • %plugin_module_path% for the relevant plugin's module's location

Patch coming.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rudiedirkx’s picture

Issue summary: View changes
rudiedirkx’s picture

Issue summary: View changes
rudiedirkx’s picture

Issue summary: View changes
rudiedirkx’s picture

Title: Add %conf_path% to plugin path render placeholders/replacements to make features reusable » Add %conf_path% and %plugin_module_path% to plugin path render placeholders/replacements to make features reusable
rudiedirkx’s picture

Status: Active » Needs review
FileSize
2.11 KB

This is a way. But it only supports %plugin_module_path% for plugins provided by hook_ckeditor_plugin().

Another (better) way would be if CKEDITOR saved the module path for every plugin, when it collects plugins, but that's more work. Maybe later.

rudiedirkx’s picture

FileSize
7.87 KB

Alright, this is the right method. It's really weird CKEDITOR collects plugins like this...

rudiedirkx’s picture

FileSize
564 bytes

The way simpler method that applies to 1.13 and dev is to only add %conf_path%, which is enough in my case.

rudiedirkx’s picture

The one in #6 is the best way. That should get in.

discipolo’s picture

so i review the one from #6 and not #7 then?

rudiedirkx’s picture

Yes, do #6. It's the only one not hidden, but that's not very obvious.

#5 is weird. #7 is only for people with 1.13 (like me).

othermachines’s picture

Title: Add %conf_path% and %plugin_module_path% to plugin path render placeholders/replacements to make features reusable » Save module path for every plugin to make features reusable
FileSize
5.98 KB

@rudiedirkx - Is the issue name OK? Looks like you went through at least a couple of iterations in your approach since you first posted.

There were some major changes committed today so I gave this a reroll. I'm not sure if it's what you intended, but this resolved my problem of errors that arise when two modules try to add the same plugin via hook_ckeditor_plugin(). I would like others to confirm this though.

If I'm right, this might qualify as a bug fix?

Thanks!

rudiedirkx’s picture

The issue really was about those placeholders in the plugin path. Not just about adding the relevant module for every plugin info. That was a necessary side effect.

I really need those placeholders, because my make files depend on them :-) and it's The Right Thing.

I could fix and reroll later next week, if necessary.

othermachines’s picture

Title: Save module path for every plugin to make features reusable » Add %conf_path% and %plugin_module_path% to plugin path render placeholders/replacements to make features reusable

A happy side effect. :) Apparently my brain checked out as I was following the thread. Issue status has been reverted.

Your changes from #6 have been rolled into #11 patch. What is it that needs fixing?

Now wondering if I should open a separate issue regarding aforementioned plugin conflicts and point it here. I would really like a fix for that in next release.

rudiedirkx’s picture

http://cgit.drupalcode.org/block_usage/tree/block_usage.modules.inc

I'm on my phone in a dubious country so I can't see the interdiff between #6 and #11.

I'm not sure what the aforementioned plug-in problem is, but if it's about the weird contrib inclusion, I agree. But that's a big CKEditor issue and I really don't want to mix into there. It should work like {first link}

OMG fucking phone sucks ass.

rudiedirkx’s picture

BTW, about your

> What is it that needs fixing?

If #6 and #11, you fixed it. I didn't see the patch (change) earlier. Stupid phone, stupid Internet, dubious connection, I'm not sure what's real anymore.

othermachines’s picture

Heh. No worries. I should've uploaded an interdiff, but it was just a reroll. I didn't fix anything, you did. Cheers and thanks -

discipolo’s picture

#6 works great for me. #11 looks like its the same patch.

othermachines’s picture

@discipolo Thanks! #11 is the same but rolled against latest -dev.

* edit: corrected username (oops)

mikran’s picture

So with this patch we can use %plugin_module_path% manually in features exports but is the an issue to make this the default?

Edit: nevermind, that was different issue #2494925: Plugin path when drupal in subdir is wrong (again).

rudiedirkx’s picture

Status: Needs review » Reviewed & tested by the community

@mikran Yes, you have to do it manually =( (The full paths don't even belong in the export code IMO, but there they are.) Recreating the feature probably breaks it again.

I RTBC because #17 and personal experience.

jcisio’s picture

Status: Reviewed & tested by the community » Needs work

We should add a change notice and ckeditor.api.php to have something like that:

From:

      'path' => base_path() . drupal_get_path('module', 'my_module') . '/plugin_dir/',

to:

      'path' => '%plugin_module_path%/editors/ckeditor/',

Also maybe file an issue in each contrib module that implements hook_ckeditor_plugin() so that the export works better. Besides, in ckeditor_load_plugins() could we add some intelligence to replace hardcoded path with %plugin_module_path% if we detect the old pattern is used (only at position 0)?

rudiedirkx’s picture

@jcisio That would be a very good next step, but could be the NEXT step. This issue still fixes a valid problem. We can make more issues to fix it even better.

rudiedirkx’s picture

Modules (not projects) that have ckeditor as dependency:

  • ado_permissions
  • ck_content_injector
  • ckeditor_blocks
  • ckeditor_kcfinder
  • ckeditor_media
  • ckeditor_paragraph_paste_fix
  • ckeditor_skin
  • ckeditor_syntaxhighlighter
  • ckeditor_widgets
  • ckgoogledoc
  • cod_wysiwyg
  • codebook_wysiwyg
  • commons_wysiwyg
  • drustack_wysiwyg
  • entity_embed
  • lightning_wysiwyg
  • local_storage_ckeditor
  • media_ckeditor
  • screenshot_paste
  • sprout_wysiwyg
  • token_insert_ckeditor
  • varbase_editor
  • vsf_wysiwyg
  • wysiwyg_fields
  • xeditor
Nebel54’s picture

Status: Needs work » Reviewed & tested by the community

The patch still applies and is used by us quite some time in production already. I agree with rudiedirkx that this issue can be commited already. Changing back to RTBC. Thanks for your great work!

jcisio’s picture

Status: Reviewed & tested by the community » Needs work

Ok to defer the notice to other contrib modules. But I think change in ckeditor.api.php is necessary and not a huge change that worths a new issue.

I've just reviewed the patch again. I don't think we need the 'module' => 'ckeditor' part, now all plugins are from the ckeditor module.

rudiedirkx’s picture

Relevant, but another issue: better tokens in Editor CSS and Styles JS paths.

I'll fix this patch this weekend. I use %conf_path% all the time.

rudiedirkx’s picture

Previous patch was broken. Not sure why. Module path replacement failed, because 'module' wasn't included in the renderable/token data anymore. Probably something changed in ckeditor.module with executing orders or something.

New patch:

  • Fixed the 'module' token
  • Added a helper to get all plugins, including 'module'
  • Removed all explicit 'module' keys from the plugins hook, as stated in #26
  • Edited ckeditor.api.php to reflect the new very useful %plugin_module_path% token

I like this a lot. If a module defines its plugin using %plugin_module_path%, it's automatically featurized like that, and reusable everywhere. %conf_path% is still only manual. We could add a pre-featurize alter to add tokens to tokenless paths, but that would have to be another issue.

The interdiff is so big because I could remove a lot from the previous patch.

My test plugin in ck_plugin.module:

/**
 * Implements hook_ckeditor_plugin().
 */
function ck_plugin_ckeditor_plugin() {
  return array(
    'ck' => array(
      'name' => 'ck',
      'desc' => t('A CKEDITOR plugin'),
      'path' => '%plugin_module_path%ckeditor/ck/',
      'buttons' => array(
        'ck' => array(
          'label' => 'CK!',
          'icon' => 'ck.png',
        ),
      ),
    ),
  );
}

Status: Needs review » Needs work

The last submitted patch, 28: ckeditor-plugin_module_paths-2422875-28.patch, failed testing.

rudiedirkx’s picture

Status: Needs work » Needs review

I've no idea what's going on with the CI, but it's not the patch.

hass’s picture

14:56:37   ERROR: No valid tests were specified.
hass’s picture

Someone added tests and now it's green.

rudiedirkx’s picture

If there are no tests, why is CI triggered? And even if it is, shouldn't no tests be an automatic pass..?

Green is Good!

zipymonkey’s picture

I found that the placeholders are not being replaced if they are added during hook_ckeditor_plugin_alter() calls. This is problematically specifically with the media_ckeditor module (http://cgit.drupalcode.org/media_ckeditor/tree/media_ckeditor.ckeditor.i...). I found that adding the adding drupal_alter('ckeditor_plugin', $plugins); in ckeditor_plugins_render fixes this, though I'm not sure this is the correct way to handle this.

I've modified patch in #28 to do this.