*/
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 ){
}
} 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" ) );
//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=" .
//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 {