[opencms-dev] How to add a new resource type

M Butcher mbutcher at grcomputing.net
Fri Feb 27 23:38:01 CET 2004


Achim,

Sorry about the confusion... let me try to explain.

The file /system/workplace/restype/plain contains the code (Javascript, 
I think) for building the workplace menus. The first line looks 
something like this (I added line breaks to make it readable):

vi.resource[resource_id]=new res(
   "plain",
   "language_key(fileicon.plain)",
   vi.iconPath+"ic_file_plain.gif",
   "explorer_files_new_othertype.html?initial=true&type=plain",
   true);

This defines how the resource type will show up in the Explorer view of 
the worlplace.

The rest of the lines look like this (again, I added line breaks):

addMenuEntry(
   resource_id,
   "language_key(explorer.context.lock)",
   "lock.html?initial=true",
   "''",
   "rules_key(d d aaai dddd dddd dddd dddd)");

Each addMenuItem adds a new item to the popup menu in the Explorer view. 
The one above is for the "lock" menu item. Here's one for unlock:

addMenuEntry(
   resource_id,
   "language_key(explorer.context.unlock)",
   "unlock.html?initial=true",
   "''",
   "rules_key(d d dddd aaai dddd dddd dddd)");

Now, the first argument (resource_id) gets created automatically, and 
correlates to the ID for the resource it describes. So for a list of 
files, each file has its own resource_id.

The second argument gets the correct label from the 
workplace_*.properties file. So if your language is set to Englsih, it 
gets the label from workplace_en.properties. For German, it uses 
workplace_de.properties.

The third argument is the URL that will be executed when the menu item 
is clicked. The fourth item is the frame/window target which will 
determine which frame or window the URL will be opened in. (Usually, 
this is either blank ("''") or top ("'_top'").

The last argument, rules_key, determines when the menu item will be 
active (a), inactive (i), or not shown (d).

Unfortunately, the example I gave last night was kind of boring... but 
if you compare the lock and unlock commands above, it should make more 
sense.

Lock rules: "rules_key(d d aaai dddd dddd dddd dddd)"
When no one owns a lock on the resource, then the "lock" command shows 
up in the menu. If the file is not modified (0), modified(1) or new(2), 
then the lock command will be active (a). If the file is deleted(3), 
then the command will be shown, but will be gray and inactive(i).

In all other cases, the lock command does not show up at all.

Now, the second command is the unlock command.

Unlock rules: "rules_key(d d dddd aaai dddd dddd dddd)"
The unlock command will only show up in the case where the current user 
owns the lock and the lock exists in the project that the user is 
currently using. (Sorry... I know that's confusing).

In the case where the user owns the lock in the current project, if the 
file is not modified (0), modified(1) or new(2), then the lock command 
will be active (a). If the file is deleted(3), then the command will be 
shown, but will be gray and inactive(i).

To see more examples, look at /system/workplace/restype/plain.

If you are a masochist, you can try to interpret the JavaScript that 
uses these locks. It is in /system/workplace/scripts/explorer.js. Search 
for 'rules.charAt'.

I hope this helps more.

I am going to post this in the forum in the resources types thread.

Matt

Joachim Arrasz wrote:
> Dear Matt,
> 
> 
> 
>>In each of the 5 groups of keys (aaai, dddd, dddd, dddd) the positions
>>correspond to this four states:
>>0 - not modified
>>1 - modified
>>2 - new
>>3 - deleted
>>
>>Now, the five groups correspond to various publishing states, where
>>three things are considered: lock owner, lock state, and project.
>>
>>1 (aaai): resource is unlocked
>>2 (dddd): resource is locked by the current user in the current project
>>3 (dddd): resource is locked by another user in the current project 4
>>4 (dddd): resource is locked by current user in a different project 5
>>5 (dddd): resource is locked by another user in a different project
> 
> 
> is it possible that above are some copy and paste errors? Or why are all
> shorts the same dddd
> If this is no error, then i didn`t understand it :-)
> 
> Nevertheless, is it possible that you enhance this in opencms-forum.de in
> the tutorial section too?
> Bye Achim
> 
> 
> _______________________________________________
> This mail is send to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://mail.opencms.org/mailman/listinfo/opencms-dev




More information about the opencms-dev mailing list