[RFC] New front pages in extensions

These requests for comments/change have lead to an implemented feature that has been successfully merged into the 3.1/Ascraeus branch. Everything listed in this forum will be available in phpBB 3.1.
User avatar
imkingdavid
Registered User
Posts: 1050
Joined: Thu Jul 30, 2009 12:06 pm

[RFC] New front pages in extensions

Post by imkingdavid »

Split from extensions RFC: viewtopic.php?f=84&t=41499

Ticket

Maybe I missed it, but does this account for adding new front-facing pages (to be accessed by the user)? Or would it be something like index.php?ext=foo&action=bar which would invoke extension foo to do bar through index?

For instance, if I have a gallery MOD (which I don't, but let's just say I do) that would currently have a front-facing gallery.php file, how would that be handled?

I guess this would make sense:
  • Move phpBB/gallery.php to phpBB/ext/<ext>/gallery.php
  • When phpBB/index.php?ext=gallery&action=<action> is loaded, invoke the file phpBB/ext/gallery/gallery.php and pass the rest of the query string to the file in some way
  • Stop execution of phpBB/index.php so that only the extension is loaded
Alternatively, we could set the MOD/Ext package up like so:
  • root/
    • ext/<ext>/*.*
    • <ext>.php
  • install.xml
  • modx.prosilver.xsl
  • license.txt
So then <ext>.php (front-facing) would be copied to the root directory.
I do custom MODs. PM for a quote!
View My: MODs | Portfolio
Please do NOT contact for support via PM or email.
Remember, the enemy's gate is down.

Oleg
Posts: 1150
Joined: Tue Feb 23, 2010 2:38 am
Contact:

Re: [RFC] New front pages in extensions

Post by Oleg »

This is a whole separate RFC and I split it into its own topic.

The extensions RFC was really just the extension manager.

Oleg
Posts: 1150
Joined: Tue Feb 23, 2010 2:38 am
Contact:

Re: [RFC] New front pages in extensions

Post by Oleg »

imkingdavid wrote: Maybe I missed it, but does this account for adding new front-facing pages (to be accessed by the user)? Or would it be something like index.php?ext=foo&action=bar which would invoke extension foo to do bar through index?
I don't believe we ever considered this. The requirement for 3.1 is no core code changes are needed to add a new page. Whether new pages are added through new top-level files or via the core index.php like you say is up for discussion.

I would say go with whichever approach requires less work on the core side, which to me would seem to favor the "add new top-level files" approach.
imkingdavid wrote: Alternatively, we could set the MOD/Ext package up like so:
  • root/
    • ext/<ext>/*.*
    • <ext>.php
  • install.xml
  • modx.prosilver.xsl
  • license.txt
So then <ext>.php (front-facing) would be copied to the root directory.
At this time the idea probably is to copy all of a modification package's files under either the phpbb root or the appropriate extension directory. Modx and install.xml would not be used by the core.
imkingdavid wrote: EDIT: Also, since this is already merged, shouldn't there be an empty phpBB/ext/ directory by default?
What would this achieve and/or why is this needed?

sajaki
Registered User
Posts: 86
Joined: Mon Jun 21, 2010 8:28 pm

Re: [RFC] New front pages in extensions

Post by sajaki »

imkingdavid wrote: Alternatively, we could set the MOD/Ext package up like so:
  • root/
    • ext/<ext>/*.*
    • <ext>.php
So then <ext>.php (front-facing) would be copied to the root directory.
I would prefer keeping the front facing file. the index.php?ext=gallery alternative would break existing links.

User avatar
imkingdavid
Registered User
Posts: 1050
Joined: Thu Jul 30, 2009 12:06 pm

Re: [RFC] New front pages in extensions

Post by imkingdavid »

Thinking more, we could use some mod_rewrite (on Apache). For instance, we could allow users to access pages such as "phpBB/gallery.php", which does not exist in the root directory, but exists as an extension. The Rewrite rules would check to make sure the file does not exist (if so, go to it), and if not, send it to index.php?ext=<filename>. If it does not exist as an extension, throw a 404.

EDIT: In this way, the extension package would still all go into the ext/ directory, but front-facing files would be accessible from root.
I do custom MODs. PM for a quote!
View My: MODs | Portfolio
Please do NOT contact for support via PM or email.
Remember, the enemy's gate is down.

User avatar
MichaelC
Development Team
Development Team
Posts: 889
Joined: Thu Jan 28, 2010 6:29 pm

Re: [RFC] New front pages in extensions

Post by MichaelC »

imkingdavid wrote:Thinking more, we could use some mod_rewrite (on Apache). For instance, we could allow users to access pages such as "phpBB/gallery.php", which does not exist in the root directory, but exists as an extension. The Rewrite rules would check to make sure the file does not exist (if so, go to it), and if not, send it to index.php?ext=<filename>. If it does not exist as an extension, throw a 404.

EDIT: In this way, the extension package would still all go into the ext/ directory, but front-facing files would be accessible from root.
What about non-Apache users?
Formerly known as Unknown Bliss
psoTFX wrote: I went with Olympus because as I said to the teams ... "It's been one hell of a hill to climb"
No unsolicited PMs please except for quotes.

User avatar
naderman
Consultant
Posts: 1727
Joined: Sun Jan 11, 2004 2:11 am
Location: Berlin, Germany
Contact:

Re: [RFC] New front pages in extensions

Post by naderman »

That feature is available on any webserver, but I agree we can't really rely on that by default, so links would still have to go to index.php?... by default, similar to MediaWiki for example. Just using index.php would allow us to simply use a hook for these pages, and extensions could still remain in self contained directories.

User avatar
imkingdavid
Registered User
Posts: 1050
Joined: Thu Jul 30, 2009 12:06 pm

Re: [RFC] New front pages in extensions

Post by imkingdavid »

Here's some work I did on this so far: https://github.com/imkingdavid/phpbb3/c ... et%2F10586

I'm still learning how the extension manager and finder and such should be used so maybe this isn't the best implementation. Also, I know that there should probably be some caching going on so that file_exists() isn't run on every page load.

But I've tested this and it works. Logic flow:
- If ?ext=x is present, look for extension x in enabled extension list.
- If extension x is enabled (need to purge cache after you enable when testing it so that it shows up) look for an index.php file in extension directory
- If file is present, include it and exit further script execution (so root index page is not loaded)

Now this forces the front facing file to be index.php and for all actions to be passed into it via query string. By adding a new column on the extension table, we could instead allow the extension author to specify what file is the front facing file. Ideas?
I do custom MODs. PM for a quote!
View My: MODs | Portfolio
Please do NOT contact for support via PM or email.
Remember, the enemy's gate is down.

User avatar
brunoais
Registered User
Posts: 964
Joined: Fri Dec 18, 2009 3:55 pm

Re: [RFC] New front pages in extensions

Post by brunoais »

imkingdavid wrote:...
For instance, if I have a gallery MOD (which I don't, but let's just say I do) that would currently have a front-facing gallery.php file, how would that be handled?

I guess this would make sense:
  • Move phpBB/gallery.php to phpBB/ext/<ext>/gallery.php
  • When phpBB/index.php?ext=gallery&action=<action> is loaded, invoke the file phpBB/ext/gallery/gallery.php and pass the rest of the query string to the file in some way
  • Stop execution of phpBB/index.php so that only the extension is loaded
Personally, I don't like to pass though an index.php to go somewhere. I prefer simply just go to the file and the file gets what it needs. Check viewtopic, viewforum, etc... Generic for their kind of thing but not as generic as index.
imkingdavid wrote: Alternatively, we could set the MOD/Ext package up like so:
  • root/
    • ext/<ext>/*.*
    • <ext>.php
  • install.xml
  • modx.prosilver.xsl
  • license.txt
So then <ext>.php (front-facing) would be copied to the root directory.
That one's better. If we have a gallery extension we can have the gallery.php in the root (of the forum) and then, that file, gets all the information it needs from there.

I don't believe we would get name clashes. There may be two (or more) gallery mods but I don't belive one would want more than 1. I believe the admin of that forum would choose only one from all the one's available.

User avatar
imkingdavid
Registered User
Posts: 1050
Joined: Thu Jul 30, 2009 12:06 pm

Re: [RFC] New front pages in extensions

Post by imkingdavid »

brunoais wrote:Personally, I don't like to pass though an index.php to go somewhere. I prefer simply just go to the file and the file gets what it needs. Check viewtopic, viewforum, etc... Generic for their kind of thing but not as generic as index.
I personally like going through index because it keeps the root directory sort of clean. Instead of having a ton of new files added by extensions in the front directory, simply make index.php?ext=X access the index.php file in the ./ext/X/ directory. That way also it is easier to keep the extension files all together. The idea of extensions are to be able to simply upload a folder and run an install, rather than having to make sure all of the files are in the right place.

All of the rest of the extension's files are located in subdirectories of ext/X (where X is the extension folder) that correspond to the locations they would be in if they were in the core. (For instance, language files are in ext/X/language/y/z.php, and if it was in core it would be language/y/z.php). It only makes sense to put the front-facing file in the extension's directory. We can standardize it to require the front-facing file to be called "index.php" so that there isn't any confusion.
brunoais wrote:That one's better. If we have a gallery extension we can have the gallery.php in the root (of the forum) and then, that file, gets all the information it needs from there.
Putting the gallery.php page in the extension directory, is imo better than having it in the root directory. For one, it keeps the extension's files together.
Also, routing through index.php makes it easier to restrict access if the extension is disabled. If you try to access it through index.php, it can simply show the board index (also the behavior if an extension does not exist), but if you tried to access it through a root gallery.php file, you'd have to do the check to see if it is disabled in that file and then decide what to do (show an error or redirect, etc.). And if an extension is removed and someone tried to access gallery.php, they would get a 404 instead of gracefully ignoring the extension request.
brunoais wrote:I don't believe we would get name clashes. There may be two (or more) gallery mods but I don't belive one would want more than 1. I believe the admin of that forum would choose only one from all the one's available.
Well, maybe "gallery" isn't a good example for naming clashes, but there could be similar ext's that actually do different things but are named the same. We could perhaps keep this from happening by requiring all extensions to have a unique name in the customization database, though.
I do custom MODs. PM for a quote!
View My: MODs | Portfolio
Please do NOT contact for support via PM or email.
Remember, the enemy's gate is down.

Post Reply