473,396 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

"Modular site" mod writers name vars or use ident supplied by app

I'm writing a test "modular site". So far I have created an App class,
a Module Manager class and a couple of test modules.

The Manager looks in a directory called 'modules' and then for every
..php file is try to create a class of type <filenameminus the .php, so
eg. for testmodule.php it tries to create a class "testmodule" and puts
it into an array within the module manager called $_modules

Module Manager has a dispatch_message function which accepts an ID for
the type of message to send, which recurses through the modules in
$_modules and uses their ReceiveMessage function to send them the message.

example:

public function dispatch_message( $message_id ) {
foreach ( $this->_modules as $module ) {
$module->ReceiveMessage( $message_id );
}
}

This is all working well and good, the thing I'm wondering about is when
modules want to postback information, should i rely on module users
naming their form inputs specifically to their module, or should my app
(when register the modules) supply a module with a unique 'ident' that
the module writer should then check for in their code and all for in
their forms etc.

eg., should i force module writers to make forms as such:

<input type="text" name="<?phpecho $mymodules->ident()?>_username"
value="" />

How do these modular sites normally differentiate from one modules POSt
to anothers?
Apr 7 '07 #1
2 1769
Tyno Gendo wrote:
should i rely on module users naming their form inputs specifically to
their module, or should my app (when register the modules) supply a
module with a unique 'ident' that the module writer should then check
for in their code and all for in their forms etc.
The latter route sounds like a good idea. For my current project though, I
went the former route, though in my API document, I've described a naming
convention (similar to the naming convention used by Java packages) to
avoid naming collisions between different modules.

The convention is like this: say I'm writing a module that does "foo" for
the package, and I own the domain name "tobyinkster.co.uk", then I'd name
my module:

uk_co_tobyinkster_foo

If my module needed to create, say, form input fields, it would make sure
they used "uk_co_tobyinkster_foo" as a prefix for the field names. If it
wanted to generate some HTML output using some "class" or "id" attributes,
then it would similarly prefix them.

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.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux

* = I'm getting there!
Apr 8 '07 #2
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;

}

}

}
?>
Apr 9 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: AES/newspost | last post by:
I'd like to generate a site map or some kind of cascaded outline or tree diagram of a web site stored in a folder on a Mac under OS 9, showing the file names and the links or hierarchical relations...
5
by: RWC | last post by:
Hello, I have a database that I need to connect with that resides on my personal intranet server. I'm on a different subnet than this server (running through two different gateways). When I...
8
by: VB Programmer | last post by:
I have a web solution that I deployed to our web server. I was looking at the site (on my PC), and so was my customer (on his PC). It worked well for like 10 minutes. Then, all of a sudden we...
2
by: genc_ymeri | last post by:
Hi over there, I suddenly started to get the below error when I try to publish my websites, in any of them ! I tried to google it but not much info. Any help very much appreciated, thanks...
2
by: Word Painter | last post by:
this may be more of an "html" issue, but I'll wing it. i've got a multi-language site, where the home-page of each language group features a link to a popup window that offers background info on...
1
by: mark4asp | last post by:
Which should I use: 1. "ASP.NET AJAX-Enabled Web Site" or 2. "AJAX Control Toolkit Web Site"? In the first, controls from the control toolkit start as: <cc1:SomeControl></cc1> In the 2nd,...
2
by: Tyno Gendo | last post by:
Hi everyone Not really a specific PHP problem this, but... I have been pondering over building a "modular" site which accepts add-ons built by other people. I was wondering if anyone has any...
0
by: jack | last post by:
IF you want to meet your old school mate's & college mate's of your life there is a chance, just enter school or college details in the below site ...
4
by: Mike Gleason jr Couturier | last post by:
Hi, What's a clean way to redirect users on an information page while doing site maintenance... Can we do it with urlMappings !? (wildcard "*"?) Thanks
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.