r75587 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75586‎ | r75587 | r75588 >
Date:22:22, 27 October 2010
Author:catrope
Status:deferred (Comments)
Tags:
Comment:
(bug 25339) Allow specifying separate base paths for local and remote paths in ResourceLoaderFileModule::__construct(). Extensions can use this to properly point the resource loader to their resources in a way that doesn't depend on the extensions/ directory being a subdirectory of phase3/ on the filesystem and that respects $wgExtensionAssetsPath. Also converted all extensions using ResourceLoader to use this approach, except MWEmbed which uses way more indirection building its module registrations than I can deal with after midnight.

What actually happens here
* Add $localBasePath, $remoteBasePath params to the FileModule constructor, defaulting to $IP and $wgScriptPath respectively
* Add getLocalPath() and getRemotePath(), which use this information to build a proper FS or URL path for a file
* Make readScriptFiles() non-static so it can use these functions
* Run every single file path we use through either getLocalPath() or getRemotePath() as appropriate
** Except file dependencies, these are already prefixed. Our inability to give them special treatment caused bugs earlier
* Kill prefixFilePathList() and resolveFilePath(), no longer needed
Modified paths:
  • /trunk/extensions/ArticleEmblems/ArticleEmblems.hooks.php (modified) (history)
  • /trunk/extensions/ClickTracking/ClickTracking.hooks.php (modified) (history)
  • /trunk/extensions/Maps/Maps.hooks.php (modified) (history)
  • /trunk/extensions/PrefSwitch/PrefSwitch.hooks.php (modified) (history)
  • /trunk/extensions/ProofreadPage/ProofreadPage_body.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_Utils.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/SMW.hooks.php (modified) (history)
  • /trunk/extensions/Translate/Translate.php (modified) (history)
  • /trunk/extensions/Vector/Vector.hooks.php (modified) (history)
  • /trunk/extensions/WikiEditor/WikiEditor.hooks.php (modified) (history)
  • /trunk/extensions/WikiEditor/modules/ext.wikiEditor.toolbar.js (modified) (history)
  • /trunk/phase3/includes/resourceloader/ResourceLoaderFileModule.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/resourceloader/ResourceLoaderFileModule.php
@@ -29,6 +29,10 @@
3030
3131 /* Protected Members */
3232
 33+ /** @var {string} Local base path, see __construct() */
 34+ protected $localBasePath = '';
 35+ /** @var {string} Remote base path, see __construct() */
 36+ protected $remoteBasePath = '';
3337 /**
3438 * @var {array} List of paths to JavaScript files to always include
3539 * @format array( [file-path], [file-path], ... )
@@ -95,7 +99,8 @@
96100 * Constructs a new module from an options array.
97101 *
98102 * @param {array} $options Options array. If not given or empty, an empty module will be constructed
99 - * @param {string} $basePath base path to prepend to all paths in $options
 103+ * @param {string} $localBasePath base path to prepend to all local paths in $options. Defaults to $IP
 104+ * @param {string} $remoteBasePath base path to prepend to all remote paths in $options. Defaults to $wgScriptPath
100105 *
101106 * @format $options
102107 * array(
@@ -127,7 +132,10 @@
128133 * 'group' => [group name string],
129134 * )
130135 */
131 - public function __construct( $options = array(), $basePath = null ) {
 136+ public function __construct( $options = array(), $localBasePath = null, $remoteBasePath = null ) {
 137+ global $IP, $wgScriptPath;
 138+ $this->localBasePath = $localBasePath === null ? $IP : $localBasePath;
 139+ $this->remoteBasePath = $remoteBasePath === null ? $wgScriptPath : $remoteBasePath;
132140 foreach ( $options as $member => $option ) {
133141 switch ( $member ) {
134142 // Lists of file paths
@@ -135,7 +143,7 @@
136144 case 'debugScripts':
137145 case 'loaderScripts':
138146 case 'styles':
139 - $this->{$member} = self::prefixFilePathList( (array) $option, $basePath );
 147+ $this->{$member} = (array) $option;
140148 break;
141149 // Collated lists of file paths
142150 case 'languageScripts':
@@ -152,7 +160,7 @@
153161 "Invalid collated file path list key error. '$key' given, string expected."
154162 );
155163 }
156 - $this->{$member}[$key] = self::prefixFilePathList( (array) $value, $basePath );
 164+ $this->{$member}[$key] = (array) $value;
157165 }
158166 break;
159167 // Lists of strings
@@ -191,13 +199,13 @@
192200 if ( $this->debugRaw ) {
193201 $script = '';
194202 foreach ( $files as $file ) {
195 - $path = FormatJson::encode( "$wgServer$wgScriptPath/$file" );
 203+ $path = FormatJson::encode( $wgServer . $this->getRemotePath( $file ) );
196204 $script .= "\n\tmediaWiki.loader.load( $path );";
197205 }
198206 return $script;
199207 }
200208 }
201 - return self::readScriptFiles( $files );
 209+ return $this->readScriptFiles( $files );
202210 }
203211
204212 /**
@@ -209,7 +217,7 @@
210218 if ( count( $this->loaderScripts ) == 0 ) {
211219 return false;
212220 }
213 - return self::readScriptFiles( $this->loaderScripts );
 221+ return $this->readScriptFiles( $this->loaderScripts );
214222 }
215223
216224 /**
@@ -311,9 +319,11 @@
312320 $context->getDebug() ? $this->debugScripts : array(),
313321 self::tryForKey( $this->languageScripts, $context->getLanguage() ),
314322 self::tryForKey( $this->skinScripts, $context->getSkin(), 'default' ),
315 - $this->loaderScripts,
316 - $this->getFileDependencies( $context->getSkin() )
 323+ $this->loaderScripts
317324 );
 325+ $files = array_map( array( $this, 'getLocalPath' ), $files );
 326+ // File deps need to be treated separately because they're already prefixed
 327+ $files = array_merge( $files, $this->getFileDependencies( $context->getSkin() ) );
318328
319329 // If a module is nothing but a list of dependencies, we need to avoid giving max() an empty array
320330 if ( count( $files ) === 0 ) {
@@ -321,7 +331,7 @@
322332 }
323333
324334 wfProfileIn( __METHOD__.'-filemtime' );
325 - $filesMtime = max( array_map( 'filemtime', array_map( array( __CLASS__, 'resolveFilePath' ), $files ) ) );
 335+ $filesMtime = max( array_map( 'filemtime', $files ) );
326336 wfProfileOut( __METHOD__.'-filemtime' );
327337 $this->modifiedTime[$context->getHash()] = max( $filesMtime, $this->getMsgBlobMtime( $context->getLanguage() ) );
328338 wfProfileOut( __METHOD__ );
@@ -330,28 +340,13 @@
331341
332342 /* Protected Members */
333343
334 - /**
335 - * Prefixes each file path in a list.
336 - *
337 - * @param {array} $list List of file paths in any combination of index/path or path/options pairs
338 - * @param {string} $prefix String to prepend to each file path in $list
339 - * @return {array} List of prefixed file paths
340 - */
341 - protected static function prefixFilePathList( array $list, $prefix ) {
342 - $prefixed = array();
343 - foreach ( $list as $key => $value ) {
344 - if ( is_string( $key ) && is_array( $value ) ) {
345 - // array( [path] => array( [options] ) )
346 - $prefixed[$prefix . $key] = $value;
347 - } else if ( is_int( $key ) && is_string( $value ) ) {
348 - // array( [path] )
349 - $prefixed[$key] = $prefix . $value;
350 - } else {
351 - throw new MWException( "Invalid file path list error. '$key' => '$value' given." );
352 - }
353 - }
354 - return $prefixed;
 344+ protected function getLocalPath( $path ) {
 345+ return "{$this->localBasePath}/$path";
355346 }
 347+
 348+ protected function getRemotePath( $path ) {
 349+ return "{$this->remoteBasePath}/$path";
 350+ }
356351
357352 /**
358353 * Collates file paths by option (where provided).
@@ -403,11 +398,11 @@
404399 * @param {array} $scripts List of file paths to scripts to read, remap and concetenate
405400 * @return {string} Concatenated and remapped JavaScript data from $scripts
406401 */
407 - protected static function readScriptFiles( array $scripts ) {
 402+ protected function readScriptFiles( array $scripts ) {
408403 if ( empty( $scripts ) ) {
409404 return '';
410405 }
411 - return implode( "\n", array_map( array( __CLASS__, 'readScriptFile' ), array_unique( $scripts ) ) );
 406+ return implode( "\n", array_map( 'file_get_contents', array_map( array( $this, 'getLocalPath' ), array_unique( $scripts ) ) ) );
412407 }
413408
414409 /**
@@ -430,20 +425,6 @@
431426 }
432427
433428 /**
434 - * Reads a script file.
435 - *
436 - * This method can be used as a callback for array_map()
437 - *
438 - * @param {string} $path File path of script file to read
439 - * @return {string} JavaScript data in script file
440 - */
441 - protected static function readScriptFile( $path ) {
442 - global $IP;
443 -
444 - return file_get_contents( "$IP/$path" );
445 - }
446 -
447 - /**
448429 * Reads a style file.
449430 *
450431 * This method can be used as a callback for array_map()
@@ -452,28 +433,15 @@
453434 * @return {string} CSS data in script file
454435 */
455436 protected function readStyleFile( $path ) {
456 - global $wgScriptPath, $IP;
 437+ global $wgScriptPath;
457438
458 - $style = file_get_contents( "$IP/$path" );
459 - $dir = dirname( "$IP/$path" );
 439+ $style = file_get_contents( $this->getLocalPath( $path ) );
 440+ $dir = $this->getLocalPath( dirname( $path ) );
 441+ $remoteDir = $this->getRemotePath( dirname( $path ) );
460442 // Get and register local file references
461443 $this->localFileRefs = array_merge( $this->localFileRefs, CSSMin::getLocalFileReferences( $style, $dir ) );
462444 return CSSMin::remap(
463 - $style, $dir, $wgScriptPath . '/' . dirname( $path ), true
 445+ $style, $dir, $remoteDir, true
464446 );
465447 }
466 -
467 - /**
468 - * Resolves a file name.
469 - *
470 - * This method can be used as a callback for array_map()
471 - *
472 - * @param {string} $path File path to resolve
473 - * @return {string} Absolute file path
474 - */
475 - protected static function resolveFilePath( $path ) {
476 - global $IP;
477 -
478 - return "$IP/$path";
479 - }
480448 }
Index: trunk/extensions/SemanticMediaWiki/SMW.hooks.php
@@ -29,17 +29,18 @@
3030
3131 $modules = array(
3232 'ext.smw.style' => array(
33 - 'styles' => ( $wgContLang->isRTL() ? 'SMW_custom_rtl.css' : 'SMW_custom.css' )
 33+ // FIXME: Won't work right, ResourceLoader does RTL flipping itself
 34+ 'styles' => ( $wgContLang->isRTL() ? 'SMW_custom_rtl.css' : 'SMW_custom.css' )
3435 ),
3536 'ext.smw.tooltips' => array(
36 - 'scripts' => 'SMW_tooltip.js',
 37+ 'scripts' => 'SMW_tooltip.js',
3738 'dependencies' => array(
3839 'mediawiki.legacy.wikibits',
3940 'ext.smw.style'
4041 )
4142 ),
4243 'ext.smw.sorttable' => array(
43 - 'scripts' => dirname( __FILE__ ) . 'SMW_sorttable.js',
 44+ 'scripts' => 'SMW_sorttable.js',
4445 'dependencies' => 'ext.smw.style'
4546 )
4647 );
@@ -49,7 +50,7 @@
5051 $name,
5152 new ResourceLoaderFileModule(
5253 array_merge_recursive( $resources, array( 'group' => 'ext.smw' ) ),
53 - 'extensions/SemanticMediaWiki/skins/'
 54+ dirname( __FILE__ ) . '/skins', $smwgScriptPath . '/skins'
5455 )
5556 );
5657 }
Index: trunk/extensions/WikiEditor/WikiEditor.hooks.php
@@ -694,9 +694,12 @@
695695 * Adds modules to ResourceLoader
696696 */
697697 public static function resourceLoaderRegisterModules( &$resourceLoader ) {
 698+ global $wgExtensionAssetsPath;
 699+ $localpath = dirname( __FILE__ ) . '/modules';
 700+ $remotepath = "$wgExtensionAssetsPath/WikiEditor/modules";
698701 foreach ( self::$modules as $name => $resources ) {
699702 $resourceLoader->register(
700 - $name, new ResourceLoaderFileModule( $resources, 'extensions/WikiEditor/modules/' )
 703+ $name, new ResourceLoaderFileModule( $resources, $localpath, $remotepath )
701704 );
702705 }
703706 return true;
Index: trunk/extensions/WikiEditor/modules/ext.wikiEditor.toolbar.js
@@ -9,6 +9,8 @@
1010 // The old toolbar is still in place and needs to be removed so there aren't two toolbars
1111 $( '#toolbar' ).remove();
1212 // Add toolbar module
 13+ // FIXME: Make config object retrievable for reusers
 14+ // TODO: Implement .wikiEditor( 'remove' )
1315 $( '#wpTextbox1' ).wikiEditor( 'addModule', { 'toolbar': {
1416 // Main section
1517 'main': {
Index: trunk/extensions/Maps/Maps.hooks.php
@@ -69,7 +69,7 @@
7070 * @return true
7171 */
7272 public static function registerResourceLoaderModules( ResourceLoader &$resourceLoader ) {
73 - global $smwgScriptPath, $wgContLang;
 73+ global $wgExtensionAssetsPath;
7474
7575 $modules = array(
7676 );
@@ -77,7 +77,7 @@
7878 foreach ( $modules as $name => $resources ) {
7979 $resourceLoader->register( $name, new ResourceLoaderFileModule(
8080 array_merge_recursive( $resources, array( 'group' => 'ext.maps' ) )
81 - ) );
 81+ ), dirname( __FILE__ ), "$wgExtensionAssetsPath/Maps" );
8282 }
8383
8484 return true;
Index: trunk/extensions/Vector/Vector.hooks.php
@@ -215,9 +215,12 @@
216216 * Adds modules to ResourceLoader
217217 */
218218 public static function resourceLoaderRegisterModules( &$resourceLoader ) {
 219+ global $wgExtensionAssetsPath;
 220+ $localpath = dirname( __FILE__ ) . '/modules';
 221+ $remotepath = "$wgExtensionAssetsPath/Vector/modules";
219222 foreach ( self::$modules as $name => $resources ) {
220223 $resourceLoader->register(
221 - $name, new ResourceLoaderFileModule( $resources, 'extensions/Vector/modules/' )
 224+ $name, new ResourceLoaderFileModule( $resources, $localpath, $remotepath )
222225 );
223226 }
224227 return true;
Index: trunk/extensions/ProofreadPage/ProofreadPage_body.php
@@ -83,11 +83,14 @@
8484 }
8585
8686 public static function resourceLoaderRegisterModules( &$resourceLoader ) {
 87+ global $wgExtensionAssetsPath;
 88+ $localpath = dirname( __FILE__ );
 89+ $remotepath = "$wgExtensionAssetsPath/ProofreadPage";
8790 $resourceLoader->register(
8891 'ext.proofreadpage.page',
8992 new ResourceLoaderFileModule(
9093 array(
91 - 'scripts' => 'extensions/ProofreadPage/proofread.js',
 94+ 'scripts' => 'proofread.js',
9295 'messages' => array(
9396 'proofreadpage_header',
9497 'proofreadpage_body',
@@ -100,7 +103,7 @@
101104 'proofreadpage_quality3_category',
102105 'proofreadpage_quality4_category',
103106 )
104 - )
 107+ ), $basepath, $remotepath
105108 )
106109 );
107110
@@ -108,14 +111,17 @@
109112 'ext.proofreadpage.article',
110113 new ResourceLoaderFileModule(
111114 array(
112 - 'scripts' => 'extensions/ProofreadPage/proofread_article.js'
113 - )
 115+ 'scripts' => 'proofread_article.js'
 116+ ), $basepath, $remotepath
114117 )
115118 );
116119
117120 $resourceLoader->register(
118121 'ext.proofreadpage.index',
119 - new ResourceLoaderFileModule( array( 'scripts' => 'extensions/ProofreadPage/proofread_index.js' ) )
 122+ new ResourceLoaderFileModule(
 123+ array( 'scripts' => 'proofread_index.js' ),
 124+ $basepath, $remotepath
 125+ )
120126 );
121127
122128 return true;
Index: trunk/extensions/SemanticForms/includes/SF_Utils.php
@@ -106,46 +106,39 @@
107107 * and CSS
108108 */
109109 static function registerModules( $resourceLoader ) {
110 - global $sfgPartialPath, $smwgScriptPath;
 110+ global $wgExtensionAssetsPath;
 111+ $localpath = dirname( dirname( __FILE__ ) );
 112+ $remotepath = "$wgExtensionAssetsPath/SemanticForms";
111113
112114 $resourceLoader->register(
113115 array(
114 - 'semanticforms.main' =>
115 - new ResourceLoaderFileModule(
 116+ 'semanticforms.main' => new ResourceLoaderFileModule(
116117 array(
117 - 'scripts' =>
118 - "$sfgPartialPath/libs/SemanticForms.js",
119 - 'styles' =>
120 - array(
121 - "$sfgPartialPath/skins/SemanticForms.css",
122 - "$sfgPartialPath/skins/SF_jquery_ui_overrides.css",
 118+ 'scripts' => 'libs/SemanticForms.js',
 119+ 'styles' => array(
 120+ 'skins/SemanticForms.css',
 121+ 'skins/SF_jquery_ui_overrides.css',
123122 ),
124 - )
 123+ ), $localpath, $remotepath
125124 ),
126 - 'semanticforms.fancybox' =>
127 - new ResourceLoaderFileModule(
 125+ 'semanticforms.fancybox' => new ResourceLoaderFileModule(
128126 array(
129 - 'scripts' =>
130 - "$sfgPartialPath/libs/jquery.fancybox-1.3.1.js",
131 - 'styles' =>
132 - "$sfgPartialPath/skins/jquery.fancybox-1.3.1.css",
133 - )
 127+ 'scripts' => 'libs/jquery.fancybox-1.3.1.js',
 128+ 'styles' => 'skins/jquery.fancybox-1.3.1.css',
 129+ ), $localpath, $remotepath
134130 ),
135 - 'semanticforms.autogrow' =>
136 - new ResourceLoaderFileModule(
 131+ 'semanticforms.autogrow' => new ResourceLoaderFileModule(
137132 array(
138 - 'scripts' =>
139 - "$sfgPartialPath/libs/SF_autogrow.js",
140 - )
 133+ 'scripts' => 'libs/SF_autogrow.js',
 134+ ), $localpath, $remotepath
141135 ),
142 - 'semanticforms.smw_utilities' =>
143 - new ResourceLoaderFileModule(
 136+ 'semanticforms.smw_utilities' => new ResourceLoaderFileModule(
144137 array(
145 - 'scripts' =>
146 - // no $smwgPartialPath variable exists yet
147 - "/extensions/SemanticMediaWiki/skins/SMW_tooltip.js",
148 - "/extension/SemanticMediaWiki/skins/SMW_sorttable.js",
149 - )
 138+ 'scripts' => array(
 139+ 'skins/SMW_tooltip.js',
 140+ 'skins/SMW_sorttable.js',
 141+ )
 142+ ), $localpath, $remotepath
150143 ),
151144 )
152145 );
Index: trunk/extensions/ArticleEmblems/ArticleEmblems.hooks.php
@@ -89,11 +89,12 @@
9090 * ResourceLoaderRegisterModules hook
9191 */
9292 public static function resourceLoaderRegisterModules( &$resourceLoader ) {
 93+ global $wgExtensionAssetsPath;
9394 $resourceLoader->register(
9495 'ext.articleEmblems',
9596 new ResourceLoaderFileModule( array(
96 - 'styles' => 'extensions/ArticleEmblems/modules/ext.articleEmblems.css',
97 - ) )
 97+ 'styles' => 'ext.articleEmblems.css',
 98+ ), dirname( __FILE__ ) . '/modules', "$wgExtensionAssetsPath/ArticleEmblems/modules" )
9899 );
99100 return true;
100101 }
Index: trunk/extensions/ClickTracking/ClickTracking.hooks.php
@@ -83,21 +83,24 @@
8484 * @return Boolean: always true
8585 */
8686 public static function resourceLoaderRegisterModules( &$resourceLoader ) {
 87+ global $wgExtensionAssetsPath;
 88+ $localpath = dirname( __FILE__ ) . '/modules';
 89+ $remotepath = "$wgExtensionAssetsPath/extensions/ClickTracking/modules";
8790 $resourceLoader->register( array(
8891 'jquery.clickTracking' => new ResourceLoaderFileModule( array(
89 - 'scripts' => 'extensions/ClickTracking/modules/jquery.clickTracking.js',
 92+ 'scripts' => 'jquery.clickTracking.js',
9093 'dependencies' => 'jquery.cookie',
9194 ) ),
9295 'ext.clickTracking' => new ResourceLoaderFileModule( array(
93 - 'scripts' => 'extensions/ClickTracking/modules/ext.clickTracking.js',
 96+ 'scripts' => 'ext.clickTracking.js',
9497 'dependencies' => 'jquery.clickTracking',
9598 ) ),
9699 'ext.clickTracking.special' => new ResourceLoaderFileModule( array(
97 - 'scripts' => 'extensions/ClickTracking/modules/ext.clickTracking.special.js',
98 - 'styles' => 'extensions/ClickTracking/modules/ext.clickTracking.special.css',
 100+ 'scripts' => 'ext.clickTracking.special.js',
 101+ 'styles' => 'ext.clickTracking.special.css',
99102 'dependencies' => array( 'jquery.ui.datepicker', 'jquery.ui.dialog' ),
100103 ) ),
101 - ) );
 104+ ), $localpath, $remotepath );
102105 return true;
103106 }
104107
Index: trunk/extensions/PrefSwitch/PrefSwitch.hooks.php
@@ -12,8 +12,8 @@
1313
1414 protected static $modules = array(
1515 'ext.prefSwitch' => array(
16 - 'scripts' => 'extensions/PrefSwitch/modules/ext.prefSwitch.js',
17 - 'styles' => 'extensions/PrefSwitch/modules/ext.prefSwitch.css',
 16+ 'scripts' => 'ext.prefSwitch.js',
 17+ 'styles' => 'ext.prefSwitch.css',
1818 'dependencies' => 'jquery.client',
1919 ),
2020 );
@@ -84,8 +84,11 @@
8585 * ResourceLoaderRegisterModules hook
8686 */
8787 public static function resourceLoaderRegisterModules( &$resourceLoader ) {
 88+ global $wgExtensionAssetsPath;
 89+ $localpath = dirname( __FILE__ ) . '/modules';
 90+ $remotepath = "$wgExtensionAssetsPath/PrefSwitch/moduless";
8891 foreach ( self::$modules as $name => $resources ) {
89 - $resourceLoader->register( $name, new ResourceLoaderFileModule( $resources ) );
 92+ $resourceLoader->register( $name, new ResourceLoaderFileModule( $resources, $localpath, $remotepath ) );
9093 }
9194 return true;
9295 }
Index: trunk/extensions/Translate/Translate.php
@@ -420,9 +420,10 @@
421421
422422 # Startup code
423423 function efTranslateResources( &$resourceLoader ) {
 424+ global $wgExtensionAssetsPath;
424425 $resourceLoader->register( array( 'translate-css' =>
425 - new ResourceLoaderFileModule( array( 'styles' => 'extensions/Translate/Translate.css' ) )
426 - ) );
 426+ new ResourceLoaderFileModule( array( 'styles' => 'Translate.css' ) )
 427+ ), dirname( __FILE__ ), "$wgExtensionAssetsPath/Translate" );
427428 return true;
428429 }
429430

Follow-up revisions

RevisionCommit summaryAuthorDate
r75590Fix Translate breakage in r75587catrope22:57, 27 October 2010
r75591Fix Maps breakage in r75587, and fix ClickTracking which apparently has been ...catrope23:00, 27 October 2010
r75733Temporary workaround for problem with ResourceLoader in r75587 ; moved inclus...yaron18:41, 31 October 2010
r75744Removed my "workaround" for r75587 (the problem turned out to be coming from ...yaron20:25, 31 October 2010
r76640Per CR on r75587, use local/remote path variables here toocatrope18:59, 13 November 2010

Comments

#Comment by Yaron Koren (talk | contribs)   17:21, 31 October 2010

This apparently broke JS loading in Semantic Forms - the issue seems to be that $remotepath gets set to (on my server) "/w/extensions/SemanticForms", but it should be just "/extensions/SemanticForms". Or at least, it works again when I change it to that.

#Comment by Catrope (talk | contribs)   17:37, 31 October 2010

Have you configured $wgExtensionAssetsPath correctly?

#Comment by Yaron Koren (talk | contribs)   19:07, 31 October 2010

Well, according to the manual, that variable defaults to "{$wgScriptPath}/extensions"; and my $wgScriptPath is set to "/w", which I think is correct (that's what it's been set to since the beginning, I think). Do I need to change it from the default?

#Comment by Catrope (talk | contribs)   19:13, 31 October 2010

If your URL structure is such that the SF stuff is at /extensions/SemanticForms as opposed to /w/extensions/SemanticForms , then yes, you need to set it to "/extensions".

#Comment by Yaron Koren (talk | contribs)   19:15, 31 October 2010

Okay, but the SF stuff is indeed at /w/extensions/SemanticForms - see here, for instance:

http://discoursedb.org/w/extensions/SemanticForms/libs/SemanticForms.js

#Comment by Catrope (talk | contribs)   19:34, 31 October 2010

But you said before:

This apparently broke JS loading in Semantic Forms - the issue seems to be that $remotepath gets set to (on my server) "/w/extensions/SemanticForms", but it should be just "/extensions/SemanticForms". Or at least, it works again when I change it to that.

That in combination with your recent post sounds contradictory to me. I'll just install SemanticForms and see what's going on.

#Comment by Yaron Koren (talk | contribs)   19:37, 31 October 2010

Well, it makes sense that it should be "/w/extensions/SemanticForms", yes - but all I know is that when it's that, it doesn't work, and when it's "/extensions/SemanticForms", it does work.

Good luck with the installation - I'll be glad to help with any part of it.

#Comment by Catrope (talk | contribs)   20:11, 31 October 2010

We worked this out on IRC, something weird was going on with Yaron's setup. It's all good now.

#Comment by Yaron Koren (talk | contribs)   20:12, 31 October 2010

Thanks again for the help.

#Comment by Nikerabbit (talk | contribs)   16:00, 13 November 2010

I would break the long line, for example like this:

-		return implode( "\n", array_map( 'file_get_contents', array_map( array( $this, 'getLocalPath' ), array_unique( $scripts ) ) ) );
+		$files = array_map( array( $this, 'getLocalPath' ), array_unique( $scripts ) );
+		return implode( "\n", array_map( 'file_get_contents', $files  ) );

In readStyleFile the variable names a bit confusing. I would rename $style to $content or $styleContent and $dir to $directory, same for the $remoteDir.

Also in Translate.php, I think you should do like in the others and use $remotepath and $localpath to make the code more readable. Shouldn't they actually be $localDirectory and $remotePath (or even $webPath) to follow camelCase and directory/path separation used in some existing configuration variables?

#Comment by Catrope (talk | contribs)   19:00, 13 November 2010

Long line broken by Tim in r76074.

Translate.php fixed in r76640.

As to the naming of variables: I don't care either way. Anyone who wants to change it, knock yourself out.

Status & tagging log