Handlers and Hooks
This are the handlers and hooks that the core of the Mason Framework define:Hooks
$zone=bodyfield
The zone bodyfield is used to allow diferent content editors to be installed and used to the body fields.This field type is a special type, intented to allow diferent users to insert their content in diferent ways. In the Mabliki (until 0.3, that will be written over the MFWork) the content is inserted using a textarea, and you can use html or mfwiki. But Catarina (my wife) was always asking me How do I make bold?, How do I make a link?, How do I ... (you got the ideia), so I thoght, once again, that I should not impose preferences in one more item. So I created this way to allow users to choose diferent body types.
the MFWork core provide handlers for 'default' and 'wysiwyg', the first is used to every bodytype that don't have it's own handler, and 'wysiwyg' is the RTE (provide link when online).
This zone handlers will get two parameters, the first is $field, the field definition, as provided to the formargs. The second is a scalarref to a string that will be used as body for a javascript function to be used as submit checker. This will be executed client side.
$zone='extendbody'
This zone handlers are intented to add options to the formating languages. When formating a body value to html, the $mf->format() will call $mf->handler() with this $zone twice. The first time before converting the value to html (or other destination language), and the second after the convertion. The $zonetype will be the language the value is in, that is, the first type it will be the original language it was written, and the second time the destination language (usually html).This zone handlers will get as parameter only $vault_name, the name of a shared_vault where the body value will be. Every handler that (completly) modify the value must put the new value back in the vault, in $vault->{body}.
A small 'extendbody' handler would look like:
<%args> $mf $vault_name </%args> <%perl> use MFWork::Handler;
my $vault=$mf->get_shared_vault($vault_name);
my $body=$vault->{body}; $body=~s{:-)}{<img src='/images/smileys/smiley.png' />}msg;
$vault->{body}=$body;
return OK; </%perl>
$zone='menucreate', $zonetype='plain'
This handler is called when creating the default admin menu. It is not called by the MFWork core itself, but by the core module menu/create/plain modulo, which is the default (and only at this moment) menu module provided.Handlers of this zone and zonetype get as args $menu that is an arrayref, where they are expected to push their own menu items.
A menu item is a hashref like this:
{
label => '<?=lng:MENUITEM?>',
url => '<?=sitebase?>admin/menuitem',
order => 123,
}
The menu items added to @$menu don't need to be ordered, as they will be sorted by order before they are displayed.