473,737 Members | 1,903 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"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 <filenameminu s 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_messag e 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_messag e( $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()?>_user name"
value="" />

How do these modular sites normally differentiate from one modules POSt
to anothers?
Apr 7 '07 #1
2 1792
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_tobyinkst er_foo

If my module needed to create, say, form input fields, it would make sure
they used "uk_co_tobyinks ter_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->SetModuleIdent ifier($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_U SERMENU;
}
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 SetModuleIdenti fier( $id ) {
// TODO:
}

function ReceiveMessage( $messageid ) { TODO: add $params

switch($message id) {

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
1874
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 between them. Is there a free-standing tool or a not too expensive HTML editor that will do this, or is this capability built into any other apps? Again, this is on Mac OS 9, and my current toolkit consists of Netscape 7.0 and BBEdit (plus...
5
5102
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 try to open the database from my laptop, I get the warning "Microsoft Access cannot open this file This file is located outside your intranet or on an untrusted site. Microsoft Access will not open the file due to potential security problems. ...
8
2097
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 got a "Page could not be displayed" message. It said that "There are too many people accessing the web site at this time." I went to ISM and restarted the default web site a few times and after like 5 minutes of doing this we got right in and...
2
3454
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 in advance,
2
1754
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 site management. the popup is fired by a javascript function, when they click the site management link. there's also a "window close" function button so they can nuke it as they please. now, oddly, people who search for my site in the chinese...
1
1754
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, those controls are: <ajaxToolkit:SomeControl></ ajaxToolkit>
2
2604
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 links to any reading material on how you build this kind of facility into your site? Obviously I could take something like Mambo's source and try to fathom
0
877
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 http://www.batchmates.com/institution/regform.asp?refid=1529710&reflink=31481 please forward to ur friend's tell to them forward this message to there friend's
4
3365
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
8786
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9467
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9331
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9204
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8203
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4567
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4823
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2192
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.