Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP
Author Message
64bitguy
The Mouse Is Extension Of Arm



Joined: Mar 06, 2004
Posts: 1164

PostPosted: Sat Sep 10, 2005 8:54 pm Reply with quote

Okay guys....

I've been pulling my hair out on this one and I figured I come out and ask for a quick hand. Try to stay with me as it gets rather complicated to do this simple function.

Here's the premise:

In recoding my new port of phpBB, I've found a ton of little problems that needed to be addressed specifically because this is in a Nuke Wrapper instead of using its own header files.

In that, one little bugger that plagued me for three whole days was the stupid Private Messages Popup window.... You know, that thing that pops up whenever you have a new PM.

In a nuthsell, this puppy relies on 4 different functions to get the job done. Now granted, I'm not wild about the darn thing because frankly I wanted to move that entire function into nuke and out of phpBB so that when you get a PM, you'll get the Popop regardless if you are in Nuke OR in Forums. As it is now, you need to be the forums module to get this little bugger to popup.

Now, if anyone knows of an easy way to pull that off (like a new j-a-v-a-s-c-r-i-p-t.php based function would be great) let me know and you can even forget about the rest of this post. If not, bear with me.

Okay, the first part of this comes together in the forums template known as "overall_header.php". In there, you'll find the jabascript function that actually looks to see if it should come up. That is in the following code:
Code:


   if ( {PRIVATE_MESSAGE_NEW_FLAG} )
   {
      window.open('{U_PRIVATEMSGS_POPUP}', '_phpbbprivmsg', 'HEIGHT=225,resizable=yes,WIDTH=400');;
   }
which appears just before the closing < / h e a d > tag. NOTE: You'll notice I am having to change the word jabacript because that is a forbidden post word, so please ignore it... It is modified just so you can see what is actually there.

Now... In moving forward, the includes/page_header.php has the next piece of this huge pie with the following functions being established:

Code:
        'U_PRIVATEMSGS' => append_sid('privmsg.'.$phpEx.'?folder=inbox'),

        'U_PRIVATEMSGS_POPUP' => append_sid('privmsg.'.$phpEx.'?mode=newpm&popup=1'),


Now, this little bugger is a huge nightmare compliance wise. In "After-Patched" I have actually hard coded the U_PRIVATEMSGS_POPUP function to eliminate a few problems, but I'll get to that next.

Now, at this point, you've got to keep in mind that the setup for these functions are also here in the includes/page_header.php.... but I digress, let me keep going.

The real problem with this whole deal comes into play in the next file, the includes/sessions.php. This is where most people really go awry in trying to make BBtoNuke compliant. You've got to really watch your step in here or you'll create more problems than you solve. Anyway, in addressing compliance, I have modded the heck out of this file and the results are fine with the exception of the Private Messages module. Now again, you have to remember that this is actually a "half-and-half" module. Half of its functions rest in Forums and the other half in Nuke.

But anyway, the lines of code in question are as follows:
Code:
   else if ((ereg("privmsg", $url)) && (!ereg("highlight=privmsg", $url)))

   {
           $url = str_replace("?", "&", $url); // As we are already in nuke, change the ? to &
           $url = str_replace("privmsg.php", "modules.php?name=Private_Messages&file=index", $url); //  and put it back for the modules.php
   }


Okay, last but not least, this all comes together in the last part which is the template of the popup itself which is at modules/Forums/templates/privmsgs_popup.tpl. In that code, this request for the link is made with the code:
Code:
function jump_to_inbox()

{
   opener.document.location.href = "{U_PRIVATEMSGS}";
   window.close();
}


Okay.. after all of that, let me explain the problem. (Also, I should mention that as you can see, finding all of these elements was a full-time job, so please keep in mind that dealing with this was anything but a quick deal)... anyway...

As it stands, I have modified a significant amount of this code to achieve compliance. For example, the code in the sessions.php that I have above has been modified so that the & symbols are followed by amp; to make all of those links compliant.

Now, in doing that, I have created the problem ONLY FOR THIS ONE FUNCTION in that the reference in the page_header.php is using an append_sid function to create the link properties, thus, the popup window ends up with amp; in the link itself which is BAD. The reason this is bad is visible at sites such as BBtoNuke's home (nukeresources.com) where instead of getting a popup window, you get a full screen inside the area of the popup window.

To combat that, again, I have hardcoded U_PRIVATEMSGS_POPUP to be messages-popup.html

Okay.. so now the popup comes up right... or does it.... The next problem we see is that because the sessions.php is "fixing" the link properties, it is also adding amp; to the properties of the link INSIDE the popup window. Now normally this probably wouldn't be a problem, but it's not compliant when the amp; actually appears in the browser address bar... sooo.... that lead me to the bright idea of using str_replace to change the properties of the U_PRIVATEMSGS function. It worked great... too great in fact. I ended up with compliance errors of OTHER functions that use the U_PRIVATEMSGS feature that needed the amp; in there..... For example, the Private Messages icon that appears with the others on any "posting" screen...

Okay, so at this point, I'm about ready to pull my hair out when I realize... "Doh"... (Yeah, I actually stopped to say Doh!)... I can change that by hard coding the link properties in in the privmsgs_popup.tpl file, which I did...
Code:
opener.document.location.href = "modules.php?name=Private_Messages&file=index&folder=inbox";


Okay... So I've fixed everything now. It all works, it's all function, zero compliance errors.

But I am concerned about anyone that might have changed any module locations or titles, so in the interest of being standardized, I pause and am prompted to ask.

Is there any way to change those hard coded values to instead use the old dynamic value; however, with the caveat of using a jabascript function that would be similar to str_replace to change the
Code:
&amp;
in the urls to be just & symbols. This would be applied in the privmsgs_popup.tpl ONLY, or I could change that function to a new variable in the page_header.php and use the php function of str_replace to do it in there instead.

Of course, if we could do this whole darn thing in Nuke, that would be better as we could get the popup to appear regardless of where you were (site wise).

Ideas? Thoughts?

Thanks
Steph

_________________
Steph Benoit
100% Section 508 and W3C HTML5 and CSS Compliant (Truly) Code, because I love compliance. 
View user's profile Send private message
VinDSL
Life Cycles Becoming CPU Cycles



Joined: Jul 11, 2004
Posts: 614
Location: Arizona (USA) Admin: NukeCops.com Admin: Disipal Designs Admin: Lenon.com

PostPosted: Sun Sep 11, 2005 3:12 am Reply with quote

You probably already tried this, but... Wink

http://www.google.com/search?q=javascript+string+replace

_________________
.:: "The further in you go, the bigger it gets!" ::.
.:: Only registered users can see links on this board! Get registered or login! | Only registered users can see links on this board! Get registered or login! ::. 
View user's profile Send private message Visit poster's website ICQ Number
64bitguy







PostPosted: Sun Sep 11, 2005 1:05 pm Reply with quote

DOH!

(again with the doh!)...

Ya know I searched for this darn function for 2 hours last night and never found that!

Probably because I was searching by str replace. Go figure.

Thanks Vin! I changed the function in privmsgs_popup.tpl to be:

Code:
function jump_to_inbox()

{
   s = new String({U_PRIVATEMSGS});
   s = s.replace(/&amp;/g,"&");
   opener.document.location.href=(s);
   window.close();
}

And it works great!

I'm going to go back and change the other one now!

Thanks for the link!
Steph
 
64bitguy







PostPosted: Sun Sep 11, 2005 2:38 pm Reply with quote

Well.. I spoke too soon.

I was unable to convert the other function as it would create errors in creating the popup window.

Next, as it turns out the above code creates an error in Internet Explorer (I hate MS).

I've looked this code 100 times, but I can't figure out where it thinks there should be a : in there, which MS says there should be.

In the end, I had to revert to my hard coding to get everything to work without errors.

Any other ideas?
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©