Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Open in a new window (Read 1 times)
Imp_In_Training
God Member
*****
Offline


Don't follow me, I'm lost
too!

Posts: 608
Location: Aberdeen
Joined: Jun 17th, 2004
Gender: Male
Open in a new window
Mar 22nd, 2013 at 8:38pm
Print Post  
I am working on a YaBB 2.5.2 mod which is executable from any page of the forum because it is form driven and the form is within the HTML code.

Now I have a little delimma.  I have the following code:
Code
Select All
  $yySetLocation = qq~$scripturl?action=logrolldisplay~;
  &redirectexit; 


After the form is executed and certain conditions are met, it redirects you to a log of results.  That works great, mind you... except I'm concerned that someone might be in the middle of doing something else and then get whisked away to the log results inadvertently.

What I would like is to append the code in such a way that it uses the above code if you are already looking at the log of results ($scripturl?action=logrolldisplay), but if you are not, it opens up a separate window.

Any idea how can I do this?
  
Back to top
WWW  
IP Logged
 
Imp_In_Training
God Member
*****
Offline


Don't follow me, I'm lost
too!

Posts: 608
Location: Aberdeen
Joined: Jun 17th, 2004
Gender: Male
Re: Open in a new window
Reply #1 - Mar 24th, 2013 at 4:49am
Print Post  
So elsewhere ... where Perl-coding people seem to have a pulse as of late... I was given this suggestion:

Code
Select All
my $log_url = qq{$scripturl?action=logrolldisplay};
if ( $env{'script_url'} eq $log_url )
  {
    # already looking at log therefore redirect.
    # perform redirect...
  } else {
    # not looking at log therefore open new window.
    print qq{content-type: text/html\n\n};
    print qq{<script type="text/javascript">window.open('$log_url')</script>\n};
}
 



So basically, check the URL to see if it matches the URL displayed when the RollLog would be up and running.  If it doesn't match, then the 'else' part would open another window. 

I know I can probably find the tag relating to the current URL somewhere in the YaBB Codex.  I'm wondering if anyone has any major qualms about opening a window this way?
  
Back to top
WWW  
IP Logged
 
Imp_In_Training
God Member
*****
Offline


Don't follow me, I'm lost
too!

Posts: 608
Location: Aberdeen
Joined: Jun 17th, 2004
Gender: Male
Re: Open in a new window
Reply #2 - Mar 25th, 2013 at 12:09am
Print Post  
I figure it might work like so:

Code
Select All
	my $log_url=qq~{$sourcedir/YaBB.pl?action=logrolldisplay}~;
	if ( $ENV {'SCRIPT_URI'} !eq $log_url ) {
		print qq{content-type: text/html\n\n};
		print qq{<script type="text/javascript">window.open('$log_url')</script>\n};
	} 



Anybody think otherwise?
  
Back to top
WWW  
IP Logged
 
Imp_In_Training
God Member
*****
Offline


Don't follow me, I'm lost
too!

Posts: 608
Location: Aberdeen
Joined: Jun 17th, 2004
Gender: Male
Re: Open in a new window
Reply #3 - Mar 25th, 2013 at 12:52am
Print Post  
No Joy...


Oh well, I'll get it eventually I guess.
  
Back to top
WWW  
IP Logged
 
Derek Barnstorm
God Member
*****
Offline



Posts: 1146
Location: Warwickshire
Joined: Mar 23rd, 2008
Gender: Male
Re: Open in a new window
Reply #4 - Mar 25th, 2013 at 1:44am
Print Post  
On the first line:

Code
Select All
        my $log_url=qq~{$sourcedir/YaBB.pl?action=logrolldisplay}~; 


Either use one:

Code
Select All
        my $log_url=qq{$sourcedir/YaBB.pl?action=logrolldisplay}; 


Or the other:

Code
Select All
        my $log_url=qq~$sourcedir/YaBB.pl?action=logrolldisplay~; 


But not both. That will print:

Code
Select All
{./Sources/YaBB.pl?action=logrolldisplay} 


But that's different from what you want from the $ENV{'SCRIPT_URL'} variable anyway, so will never be equal.

And there is no such operator as:

Code
Select All
!eq 


For not equal to, it's:

Code
Select All
ne 


Use != for numerics and ne for anything else.

  
Back to top
 
IP Logged
 
Imp_In_Training
God Member
*****
Offline


Don't follow me, I'm lost
too!

Posts: 608
Location: Aberdeen
Joined: Jun 17th, 2004
Gender: Male
Re: Open in a new window
Reply #5 - Mar 25th, 2013 at 2:09pm
Print Post  
Derek Barnstorm wrote on Mar 25th, 2013 at 1:44am:
But that's different from what you want from the $ENV{'SCRIPT_URL'} variable anyway, so will never be equal.


I don't doubt you... but I have no idea what I need to put in there.  Any suggestions?
  
Back to top
WWW  
IP Logged
 
Derek Barnstorm
God Member
*****
Offline



Posts: 1146
Location: Warwickshire
Joined: Mar 23rd, 2008
Gender: Male
Re: Open in a new window
Reply #6 - Mar 25th, 2013 at 7:01pm
Print Post  
I don't think there is an environment variable for the whole url, so would need to do something like this:

Code
Select All
    my $log_url = "$scripturl?action=logrolldisplay";
    my $user_log_url = "http://$ENV{'HTTP_HOST'}$ENV{'REQUEST_URI'}"; 

  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint