|
Posted by Tyno Gendo on 04/09/07 11:40
Toby A Inkster wrote:
<snip>
> If a module user didn't own their own domain name, they could simply use
> their e-mail address:
>
> com_hotmail_at_joebloggs_foo
>
> Although you do end up with some fairly ugly-looking module names, this is
> a pretty sure-fire way to avoid naming collisions. Because of the ugly
> names, in my plugin registration function, I do allow plugin authors to
> provide a "friendly" name for their plugin, which is displayed anywhere a
> user is likely to see it. I also allow them to provide a link, the author's
> name, some version information and so on.
>
Thanks for that reply, useful. I think I will go with supplying an
ident to each module as it registers, using the code from uniqid example:
$ident = md5(uniqid(rand(), true));
This will created the ident and call the module (see below) on creation
with $module->SetModuleIdentifier($ident);
Then a module writer can use the ident as prefix to forms/session values
etc.
PRESENTATION
------------
What's the best way of handling where a module loads in terms of
presentation??? I notice most "modular" sites has presentation areas,
such as header, menu, user_menu, footers etc.
So best way to handle is to have a module specify where it wants to
appear on creation???
eg. test module below should have something like the following which the
module registration utiltity could call after creation to find out where
this modules sits???
function GetPlacement() {
return OBJ_PLACEMENT_USERMENU;
}
MESSAGING VS. HOOKS??
---------------------
I was thinking of using a messaging system to alert modules that they an
event has happened but other people seem to have a hook's based system
where modules say they want to handle an event in advance, what's the
pro's and con's ??
I'm thinking of handling like so:
<?php
class testmodule {
function SetModuleIdentifier( $id ) {
// TODO:
}
function ReceiveMessage( $messageid ) { TODO: add $params
switch($messageid) {
case MSG_APPLICATION_PAGELOAD:
echo "Hello from module 1!\n";
break;
case MSG_APPLICATION_PAGERENDER:
if ( $_SERVER["REQUEST_METHOD"]<>"POST" ) {
?>
<p>
<form action="<?php echo $_SERVER["PHP_SELF"]?>"
method="post">
Please chose a registered name
<input type="text" name="username" value="" />
<input type="submit" name="submit" />
</form>
</p>
<?php
}
else {
?>
<p>
You chose the registered name <?php echo
$_POST["username"]; ?>
</p>
<?php
}
break;
case MSG_APPLICATION_PAGEUNLOAD:
echo "Goodbye!\n";
break;
}
}
}
?>
Navigation:
[Reply to this message]
|