Fix retarded mistake in 57997, move break to within the if block or it defeats the...
[lhc/web/wiklou.git] / includes / OutputPage.php
index 844496c..7879cbb 100644 (file)
@@ -206,7 +206,7 @@ class OutputPage {
         */
        function addScriptClass( $js_class ){
                global $wgDebugJavaScript, $wgJSAutoloadLocalClasses, $wgJSAutoloadClasses,
-                               $wgEnableScriptLoader, $wgStyleVersion, $wgScriptPath, $wgEnableJS2system;
+                               $wgEnableScriptLoader, $wgStyleVersion, $wgScriptPath, $wgStylePath, $wgEnableJS2system;
 
                $path = jsScriptLoader::getJsPathFromClass( $js_class );
                if( $path !== false ){
@@ -217,7 +217,15 @@ class OutputPage {
                                }
                        } else {
                                // Source the script directly
-                               $path = $wgScriptPath . '/' . $path;
+                               $prefix = "skins/common/";
+                               if( substr( $path, 0, 1 ) == '/' ) {
+                                       // straight path
+                               } elseif( substr( $path, 0, strlen( $prefix ) ) == $prefix ) {
+                                       // Respect $wgStypePath
+                                       $path = "{$wgStylePath}/common/" . substr( $path, strlen( $prefix ) );
+                               } else {
+                                       $path = $wgScriptPath . '/' . $path;
+                               }
                                $urlAppend = ( $wgDebugJavaScript ) ? time() : $this->getURIDparam( $js_class );
                                $this->addScript( Html::linkedScript( "$path?$urlAppend" ) );
 
@@ -1799,7 +1807,6 @@ class OutputPage {
 
                //add site JS if enabled:
                if( $wgUseSiteJs ) {
-                       $sk = $wgUser->getSkin();
                        $jsCache = $wgUser->isLoggedIn() ? '&smaxage=0' : '';
                        $this->addScriptFile(  Skin::makeUrl( '-',
                                        "action=raw$jsCache&gen=js&useskin=" .
@@ -1811,7 +1818,7 @@ class OutputPage {
                //add user js if enabled:
                if( $this->isUserJsAllowed() && $wgUser->isLoggedIn() ) {
                        $action = $wgRequest->getVal( 'action', 'view' );
-                       if( $this->mTitle->isJsSubpage() and $sk->userCanPreview( $action ) ) {
+                       if( $this->mTitle && $this->mTitle->isJsSubpage() and $sk->userCanPreview( $action ) ) {
                                # XXX: additional security check/prompt?
                                $this->addInlineScript( $wgRequest->getText( 'wpTextbox1' ) );
                        } else {