Contexts have defined formats. Some of them only applies to images for example. However currently the 'edit atom properties' button in the wysiwyg lists all the contexts.

It would be nice if when clicking on an image and pressing this button, the dialog would only list the contexts that are for images. And the same with any type. If i click on a video, it should not display all the contexts that only apply for images.

Also it is possible that the site has many contexts for images for example (used at site building lets say), but we would like if the client could only select from a selected few.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

nagy.balint’s picture

Status: Active » Needs review
FileSize
2.1 KB

I created a patch which solves these issues.

In dnd.module i changed the way it constructs the context list for the settings. The contexts are listed for each type as a subarray.
Then instead of creating the itemlist for the select before the dialog is created, I create it in the onShow function where the current atom is already fetched, and the type can be retreived. Then with the type i can construct the itemlist that is for the given type only.

I added a drupal_alter call in dnd.module to let other modules alter the contexts array that is passed to the settings. That solves the last point.

jcisio’s picture

Status: Needs review » Needs work
Issue tags: +Scald-1.1

Haven't tested, patch looks good, even with variable names. It's also the idea we had when we implemented the wysiwyg context feature, but we chose an easy approach first.

It'd be nice to document the new hook in scald.api.php (yes, we have this file recently).

nagy.balint’s picture

Here is the updated patch with the api documentation.

nagy.balint’s picture

Status: Needs work » Needs review
nagy.balint’s picture

Rerolled patch.

jcisio’s picture

Title: CKEditor edit atom properties dialog to show only relevant contexts and customization » [change notice] CKEditor edit atom properties dialog to show only relevant contexts and customization
Status: Needs review » Active

Committed http://drupalcode.org/project/scald.git/commit/2a767bd. However there are two things:
- Generally speaking, formats are not "types", but for file format (jpg or png) or file MIME type, and to be used with transcoder. The "formats" for contexts are currently not used anywhere, to we don't filter contexts with formats now, just the "hidden" property.
- To hide some contexts from end users, we could introduce a "system" property for context. It is different from "hidden": hidden context would be possible to configured by admin and hidden from end user, while system contexts are hidden from both.

Also, we needs a change notice/improved doc.

Mindless-dupe’s picture

These is a great feature and we exactly looked for something like this.
But do you have a quick sample

  • how to to use the hook_scald_wysiwyg_context_list_alter ?
  • how to defined these hidden contexts for end users ?

Thank you very much !

jcisio’s picture

- The example for hook_scald_wysiwyg_context_list_alter() was in the same commit (in scald.api.php).

- "Hidden" contexts (like "no-access", "invalid-id" etc.) are defined in hook_scald_contexts or hook_scald_contexts_alter(), however they are not configurable. So I suggested introduce a new property: "system". But I'm not sure it makes sense. Maybe a "wysiwyg" property, defaults to TRUE?

jcisio’s picture

Status: Active » Fixed

Change record created http://drupal.org/node/1993154. Other issues could be done in follow-ups if necessary.

Automatically closed -- issue fixed for 2 weeks with no activity.