Index: trunk/phase3/index.php |
— | — | @@ -119,24 +119,15 @@ |
120 | 120 | |
121 | 121 | wfProfileIn( 'main-action' ); |
122 | 122 | |
| 123 | +# Initialize MediaWiki base class |
123 | 124 | require_once( "includes/Wiki.php" ) ; |
124 | 125 | $mediaWiki = new MediaWiki() ; |
125 | 126 | |
126 | 127 | $mediaWiki->setVal( "Server", $wgServer ); |
| 128 | +$mediaWiki->setVal( "DisableInternalSearch", $wgDisableInternalSearch ); |
127 | 129 | |
128 | | -if( !$wgDisableInternalSearch && !is_null( $search ) && $search !== '' ) { |
129 | | - require_once( 'includes/SpecialSearch.php' ); |
130 | | - $wgTitle = Title::makeTitle( NS_SPECIAL, 'Search' ); |
131 | | - wfSpecialSearch(); |
132 | | -} else if( !$wgTitle or $wgTitle->getDBkey() == '' ) { |
133 | | - $wgTitle = Title::newFromText( wfMsgForContent( 'badtitle' ) ); |
134 | | - $wgOut->errorpage( 'badtitle', 'badtitletext' ); |
135 | | -} else if ( $mediaWiki->initializeSpecialCases( $wgTitle , $wgOut , $wgRequest , $action ) ) { |
136 | | - # Do nothing, everything was already done by $mediaWiki |
| 130 | +if ( !$mediaWiki->initializeSpecialCases( $wgTitle , $wgOut , $wgRequest , $action , $search ) ) { |
137 | 131 | |
138 | | -} else { |
139 | | - |
140 | | - |
141 | 132 | $wgArticle = $mediaWiki->initializeArticle( $wgTitle, $wgRequest, $action ); |
142 | 133 | |
143 | 134 | if( in_array( $action, $wgDisabledActions ) ) { |
Index: trunk/phase3/includes/Wiki.php |
— | — | @@ -5,14 +5,14 @@ |
6 | 6 | |
7 | 7 | class MediaWiki { |
8 | 8 | |
9 | | - var $GET ; # Stores the $_GET variables at time of creation, can be changed |
| 9 | + var $GET; /* Stores the $_GET variables at time of creation, can be changed */ |
10 | 10 | var $params = array(); |
11 | 11 | |
12 | 12 | /** |
13 | 13 | * Constructor |
14 | 14 | */ |
15 | 15 | function MediaWiki () { |
16 | | - $this->GET = $_GET ; |
| 16 | + $this->GET = $_GET; |
17 | 17 | } |
18 | 18 | |
19 | 19 | function setVal( $key, &$value ) { |
— | — | @@ -30,14 +30,22 @@ |
31 | 31 | /** |
32 | 32 | * Initialize the object to be known as $wgArticle for special cases |
33 | 33 | */ |
34 | | - function initializeSpecialCases ( &$title , &$output , $request , $action ) { |
35 | | - if ( $title->getInterwiki() != '' ) { |
| 34 | + function initializeSpecialCases ( &$title , &$output , $request , $action , &$search ) { |
| 35 | + wfProfileIn( 'MediaWiki::initializeSpecialCases' ); |
| 36 | + if( !$this->getVal('DisableInternalSearch') && !is_null( $search ) && $search !== '' ) { |
| 37 | + require_once( 'includes/SpecialSearch.php' ); |
| 38 | + $title = Title::makeTitle( NS_SPECIAL, 'Search' ); |
| 39 | + wfSpecialSearch(); |
| 40 | + } else if( !$title or $title->getDBkey() == '' ) { |
| 41 | + $title = Title::newFromText( wfMsgForContent( 'badtitle' ) ); |
| 42 | + $output->errorpage( 'badtitle', 'badtitletext' ); |
| 43 | + } else if ( $title->getInterwiki() != '' ) { |
36 | 44 | if( $rdfrom = $request->getVal( 'rdfrom' ) ) { |
37 | 45 | $url = $title->getFullURL( 'rdfrom=' . urlencode( $rdfrom ) ); |
38 | 46 | } else { |
39 | 47 | $url = $title->getFullURL(); |
40 | 48 | } |
41 | | - # Check for a redirect loop |
| 49 | + /* Check for a redirect loop */ |
42 | 50 | if ( !preg_match( '/^' . preg_quote( $this->getVal('Server'), '/' ) . '/', $url ) && $title->isLocal() ) { |
43 | 51 | $output->redirect( $url ); |
44 | 52 | } else { |
— | — | @@ -52,13 +60,15 @@ |
53 | 61 | $output->setSquidMaxage( 1200 ); |
54 | 62 | $output->redirect( $title->getFullURL(), '301'); |
55 | 63 | } else if ( NS_SPECIAL == $title->getNamespace() ) { |
56 | | - # actions that need to be made when we have a special pages |
| 64 | + /* actions that need to be made when we have a special pages */ |
57 | 65 | SpecialPage::executePath( $title ); |
58 | 66 | } else { |
59 | 67 | /* No match to special cases */ |
| 68 | + wfProfileOut( 'MediaWiki::initializeSpecialCases' ); |
60 | 69 | return false; |
61 | 70 | } |
62 | 71 | /* Did match a special case */ |
| 72 | + wfProfileOut( 'MediaWiki::initializeSpecialCases' ); |
63 | 73 | return true; |
64 | 74 | } |
65 | 75 | |
— | — | @@ -66,6 +76,9 @@ |
67 | 77 | * Initialize the object to be known as $wgArticle for "standard" actions |
68 | 78 | */ |
69 | 79 | function initializeArticle( &$title, $request, $action ) { |
| 80 | + |
| 81 | + wfProfileIn( 'MediaWiki::initializeArticle' ); |
| 82 | + |
70 | 83 | if( NS_MEDIA == $title->getNamespace() ) { |
71 | 84 | $title = Title::makeTitle( NS_IMAGE, $title->getDBkey() ); |
72 | 85 | } |
— | — | @@ -77,7 +90,7 @@ |
78 | 91 | if( $action == 'view' && !$request->getVal( 'oldid' ) ) { |
79 | 92 | $rTitle = Title::newFromRedirect( $article->fetchContent() ); |
80 | 93 | if( $rTitle ) { |
81 | | - # Reload from the page pointed to later |
| 94 | + /* Reload from the page pointed to later */ |
82 | 95 | $article->mContentLoaded = false; |
83 | 96 | $ns = $rTitle->getNamespace(); |
84 | 97 | $wasRedirected = true; |
— | — | @@ -99,6 +112,7 @@ |
100 | 113 | require_once( 'includes/CategoryPage.php' ); |
101 | 114 | $article = new CategoryPage( $title ); |
102 | 115 | } |
| 116 | + wfProfileOut( 'MediaWiki::initializeArticle' ); |
103 | 117 | return $article; |
104 | 118 | } |
105 | 119 | |
— | — | @@ -106,6 +120,9 @@ |
107 | 121 | * Perform one of the "standard" actions |
108 | 122 | */ |
109 | 123 | function performAction( $action, &$output, &$article, &$title, &$user, &$request ) { |
| 124 | + |
| 125 | + wfProfileIn( 'MediaWiki::performAction' ); |
| 126 | + |
110 | 127 | switch( $action ) { |
111 | 128 | case 'view': |
112 | 129 | $output->setSquidMaxage( $this->getVal( 'SquidMaxage' ) ); |
— | — | @@ -151,17 +168,17 @@ |
152 | 169 | break; |
153 | 170 | case 'submit': |
154 | 171 | if( !$this->getVal( 'CommandLineMode' ) && !$request->checkSessionCookie() ) { |
155 | | - # Send a cookie so anons get talk message notifications |
| 172 | + /* Send a cookie so anons get talk message notifications */ |
156 | 173 | User::SetupSession(); |
157 | 174 | } |
158 | | - # Continue... |
| 175 | + /* Continue... */ |
159 | 176 | case 'edit': |
160 | 177 | $internal = $request->getVal( 'internaledit' ); |
161 | 178 | $external = $request->getVal( 'externaledit' ); |
162 | 179 | $section = $request->getVal( 'section' ); |
163 | 180 | $oldid = $request->getVal( 'oldid' ); |
164 | 181 | if( !$this->getVal( 'UseExternalEditor' ) || $action=='submit' || $internal || |
165 | | - $section || $oldid ||( !$user->getOption( 'externaleditor' ) && !$external ) ) { |
| 182 | + $section || $oldid || ( !$user->getOption( 'externaleditor' ) && !$external ) ) { |
166 | 183 | require_once( 'includes/EditPage.php' ); |
167 | 184 | $editor = new EditPage( $article ); |
168 | 185 | $editor->submit(); |
— | — | @@ -189,10 +206,12 @@ |
190 | 207 | if( wfRunHooks( 'UnknownAction', array( $action, $article ) ) ) { |
191 | 208 | $output->errorpage( 'nosuchaction', 'nosuchactiontext' ); |
192 | 209 | } |
| 210 | + wfProfileOut( 'MediaWiki::performAction' ); |
| 211 | + |
193 | 212 | } |
194 | 213 | } |
195 | 214 | |
196 | | -}; # End of class MediaWiki |
| 215 | +}; /* End of class MediaWiki */ |
197 | 216 | |
198 | 217 | ?> |
199 | 218 | |