Changeset 1054 for trunk/core/lib/Foswiki.pm
- Timestamp:
- 11/28/08 21:18:36 (3 years ago)
- File:
-
- 1 edited
-
trunk/core/lib/Foswiki.pm (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/core/lib/Foswiki.pm
r1051 r1054 66 66 67 67 # Other computed constants 68 our $ twikiLibDir;68 our $foswikiLibDir; 69 69 our %regex; 70 70 our %functionTags; … … 91 91 our $TranslationToken = "\0"; 92 92 93 =begin TML 94 95 ---++ StaticMethod getLibDir() -> $path 96 97 Returns the full path of the directory containing Foswiki.pm 98 99 =cut 100 101 sub getLibDir { 102 if ($twikiLibDir) { 103 return $twikiLibDir; 104 } 105 106 # FIXME: Should just use $INC{"Foswiki.pm"} to get path used to load this 107 # module. 108 my $dir = ''; 109 foreach $dir (@INC) { 110 if ( $dir && -e "$dir/Foswiki.pm" ) { 111 $twikiLibDir = $dir; 112 last; 113 } 114 } 93 # Returns the full path of the directory containing Foswiki.pm 94 sub _getLibDir { 95 return $foswikiLibDir if $foswikiLibDir; 96 97 $foswikiLibDir = $INC{'Foswiki.pm'}; 115 98 116 99 # fix path relative to location of called script 117 if ( $ twikiLibDir =~ /^\./ ) {100 if ( $foswikiLibDir =~ /^\./ ) { 118 101 print STDERR 119 "WARNING: Foswiki lib path $ twikiLibDir is relative; you should make it absolute, otherwise some scripts may not run from the command line.";102 "WARNING: Foswiki lib path $foswikiLibDir is relative; you should make it absolute, otherwise some scripts may not run from the command line."; 120 103 my $bin; 121 104 … … 140 123 $bin = cwd(); 141 124 } 142 $ twikiLibDir = "$bin/$twikiLibDir/";125 $foswikiLibDir = "$bin/$foswikiLibDir/"; 143 126 144 127 # normalize "/../" and "/./" 145 while ( $ twikiLibDir =~ s|([\\/])[^\\/]+[\\/]\.\.[\\/]|$1| ) {146 } 147 $ twikiLibDir =~ s|([\\/])\.[\\/]|$1|g;148 } 149 $ twikiLibDir =~ s|([\\/])[\\/]*|$1|g; # reduce "//" to "/"150 $ twikiLibDir =~ s|[\\/]$||; # cut trailing "/"151 152 return $ twikiLibDir;128 while ( $foswikiLibDir =~ s|([\\/])[^\\/]+[\\/]\.\.[\\/]|$1| ) { 129 } 130 $foswikiLibDir =~ s|([\\/])\.[\\/]|$1|g; 131 } 132 $foswikiLibDir =~ s|([\\/])[\\/]*|$1|g; # reduce "//" to "/" 133 $foswikiLibDir =~ s|[\\/]$||; # cut trailing "/" 134 135 return $foswikiLibDir; 153 136 } 154 137 … … 497 480 498 481 # initialize lib directory early because of later 'cd's 499 getLibDir();482 _getLibDir(); 500 483 501 484 # initialize the runtime engine … … 812 795 ---++ ObjectMethod redirect( $url, $passthrough, $action_redirectto ) 813 796 814 * $url - url or t wikitopic to redirect to797 * $url - url or topic to redirect to 815 798 * $passthrough - (optional) parameter to **FILLMEIN** 816 799 * $action_redirectto - (optional) redirect to where ?redirectto= … … 939 922 940 923 # Don't double-cache 941 return '' if ( $query->param(' twiki_redirect_cache') );924 return '' if ( $query->param('foswiki_redirect_cache') ); 942 925 943 926 require Digest::MD5; … … 955 938 $query->save( \*F ); 956 939 close(F); 957 return ' twiki_redirect_cache=' . $uid;940 return 'foswiki_redirect_cache=' . $uid; 958 941 } 959 942 … … 1095 1078 Returns the URL to a Foswiki script, providing the web and topic as 1096 1079 "path info" parameters. The result looks something like this: 1097 "http://host/ twiki/bin/$script/$web/$topic".1080 "http://host/foswiki/bin/$script/$web/$topic". 1098 1081 * =...= - an arbitrary number of name,value parameter pairs that will be url-encoded and added to the url. The special parameter name '#' is reserved for specifying an anchor. e.g. <tt>getScriptUrl('x','y','view','#'=>'XXX',a=>1,b=>2)</tt> will give <tt>.../view/x/y?a=1&b=2#XXX</tt> 1099 1082 … … 3169 3152 'Sorry, this version of Foswiki does not support the url parameter to Foswiki::initialize being different to the url in the query'; 3170 3153 } 3171 my $ twiki= new Foswiki( $theRemoteUser, $query );3154 my $session = new Foswiki( $theRemoteUser, $query ); 3172 3155 3173 3156 # Force the new session into the plugins context. 3174 $Foswiki::Plugins::SESSION = $ twiki;3157 $Foswiki::Plugins::SESSION = $session; 3175 3158 3176 3159 return ( 3177 $ twiki->{topicName}, $twiki->{webName}, $twiki->{scriptUrlPath},3178 $ twiki->{userName}, $Foswiki::cfg{DataDir}3160 $session->{topicName}, $session->{webName}, $session->{scriptUrlPath}, 3161 $session->{userName}, $Foswiki::cfg{DataDir} 3179 3162 ); 3180 3163 } … … 3631 3614 #| $web | web and | 3632 3615 #| $topic | topic to display the name for | 3633 #| $formatString | twikiformat string (like in search) |3616 #| $formatString | format string (like in search) | 3634 3617 sub REVINFO { 3635 3618 my ( $this, $params, $theTopic, $theWeb ) = @_;
Note: See TracChangeset
for help on using the changeset viewer.
