[RFC|Merged] Template Events

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|Merged] Template Events

Post by imkingdavid »

Now that PHP events have been merged, we need to finish up the template events portion. As far as I am aware, the main holdup is the fact that it is not served the entire styles tree to look inside for template events in extensions. We need to figure out the best way to provide that information where needed.

What else needs to be done for this, other than the addition of template events, which will be an ongoing process anyway?

Pull Request: https://github.com/phpbb/phpbb3/pull/764
Ticket: http://tracker.phpbb.com/browse/PHPBB3-9550
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
EXreaction
Registered User
Posts: 1555
Joined: Sat Sep 10, 2005 2:15 am

Re: [RFC] Template Events

Post by EXreaction »

imkingdavid wrote:As far as I am aware, the main holdup is the fact that it is not served the entire styles tree to look inside for template events in extensions. We need to figure out the best way to provide that information where needed.
Could you explain that again?

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

Re: [RFC] Template Events

Post by imkingdavid »

Sorry for being unclear. As it currently stands (last I remember) template events appear in the code like:
<!-- EVENT i_am_an_event -->
When this event is reached, assuming the currently used style is "prosilver1" which inherits from "prosilver", the idea is that it looks in all extension folders for files like:
ext/name/styles/all/template/i_am_an_event.html
ext/name/styles/prosilver/template/i_am_an_event.html
ext/name/styles/prosilver1/template/i_am_an_event.html
It would then use the last one found in the list, ignoring any previous ones.

From what I understand, right now it only finds two of those folders, ignoring the styles tree/style inheritance. So it would only look in the /all/ folder and the /prosilver1/ folder. This is because the portion of code responsible for finding these files does not know about the entire styles tree; it only knows about the style currently being used. And it is hardcoded to look in the /all/ folder, as that can contain non-style-specific events.

So what is needed is to figure out the best way to give that code the styles tree information.

The following two commits were my attempt at it, but Oleg explained that we cannot rely on $user->theme because there are some cases in which that is not available.
https://github.com/imkingdavid/phpbb3/c ... ae69aabfe4
https://github.com/imkingdavid/phpbb3/c ... e92284192f

Does that make sense?
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
EXreaction
Registered User
Posts: 1555
Joined: Sat Sep 10, 2005 2:15 am

Re: [RFC] Template Events

Post by EXreaction »

Much better :)

In what cases would $user->theme be unavailable? I am trying to think of cases, and what comes to my mind is the login_box()? or trigger_error() before user_setup() is called. Is that pretty much it or are there others?

User avatar
Pony99CA
Registered User
Posts: 986
Joined: Sun Feb 08, 2009 2:35 am
Location: Hollister, CA
Contact:

Re: [RFC] Template Events

Post by Pony99CA »

imkingdavid wrote:Sorry for being unclear. As it currently stands (last I remember) template events appear in the code like:
<!-- EVENT i_am_an_event -->
When this event is reached, assuming the currently used style is "prosilver1" which inherits from "prosilver", the idea is that it looks in all extension folders for files like:
ext/name/styles/all/template/i_am_an_event.html
ext/name/styles/prosilver/template/i_am_an_event.html
ext/name/styles/prosilver1/template/i_am_an_event.html
It would then use the last one found in the list, ignoring any previous ones.
If you're going to ignore previous ones, is there a way to at least call the previous ones? Or is that what you're trying to do?

In OOP, an inherited method often calls the super class method to avoid duplication of efforts. Maybe that doesn't make sense for styles, but is that always true?

And, if you're going to ignore previous items, why not start with the prosilver1 item and work your way back? Doing it the above way always requires searching the whole tree, but doing it "my" way lets you stop when you've found one, so there's a potential savings.

Steve
Silicon Valley Pocket PC (http://www.svpocketpc.com)
Creator of manage_bots and spoof_user (ask me)
Need hosting for a small forum with full cPanel & MySQL access? Contact me or PM me.

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

Re: [RFC] Template Events

Post by imkingdavid »

@EXreaction: Here's what Oleg said about it. https://github.com/p/phpbb3/pull/26#iss ... nt-6234670 (the last two commits in that PR, the ones I linked above, are relevant; I'm not sure where the rest came from).
Pony99CA wrote:If you're going to ignore previous ones, is there a way to at least call the previous ones? Or is that what you're trying to do?

In OOP, an inherited method often calls the super class method to avoid duplication of efforts. Maybe that doesn't make sense for styles, but is that always true?

And, if you're going to ignore previous items, why not start with the prosilver1 item and work your way back? Doing it the above way always requires searching the whole tree, but doing it "my" way lets you stop when you've found one, so there's a potential savings.

Steve
TBH I don't remember offhand if it calls all it finds or only the most specific one. Ideally it should only call the most specific one. And it's probably most efficient to start with the most specific (i.e. the currently used style) and get more and more general from there (ending with /all/).
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
EXreaction
Registered User
Posts: 1555
Joined: Sat Sep 10, 2005 2:15 am

Re: [RFC] Template Events

Post by EXreaction »

How is inheritance handled? I would think that everything should be handled in the template engine itself and that the only thing the user or any part of the system should do is request what style it would like to display (a function in the template system is called to select a style to use). If it was done this way, all of that inheritance information would be available within the template engine itself, so this wouldn't be an issue.

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

Re: [RFC] Template Events

Post by imkingdavid »

I think the issue, though, is that the template class is now separate from the style class and is instantiated before the style object, and then fed into it, rather than the other way around. So the template class is never aware of the style information, except through the user object's theme array, which in the case mentioned does not have the style information.
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
EXreaction
Registered User
Posts: 1555
Joined: Sat Sep 10, 2005 2:15 am

Re: [RFC] Template Events

Post by EXreaction »

Have you checked the phpbb_style_extension_path_provider class out?

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

Re: [RFC] Template Events

Post by imkingdavid »

It's been a while since I've even looked into this issue, but I remember trying all the path providers and locators and finders and everything and none of them did what we were looking for. I'll see if I can take a look at it again later unless you'd like to help out. :D
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