now you should be able to get the variables in JS with mw.config.get...
On 02.07.2015 15:25, Krabina Bernhard wrote:
repacing the line breaks somehting else.
So I added both
$GLOBALS['wgHooks']['MakeGlobalVariablesScript'][] =
'MapsHooks::onMakeGlobalVariablesScript';
$GLOBALS['wgHooks']['ResourceLoaderGetConfigVars'][] =
'MapsHooks::onResourceLoaderGetConfigVars';
which doesn't seem to break anything.
but still no luck. can anybody point me to a simple and working example?
cheers,
Bernhard
----- Am 2. Jul 2015 um 14:41 schrieb James Montalvo
<jamesmontal...@gmail.com>:
I believe what you want is for this line:
https://github.com/krabina/Maps/blob/master/Maps.php#L85
to instead say:
$GLOBALS['wgHooks']['ResourceLoaderGetConfigVars'][] =
'MapsHooks::onMakeGlobalVariablesScript';
On Thu, Jul 2, 2015 at 7:33 AM, Krabina Bernhard
<krab...@kdz.or.at <mailto:krab...@kdz.or.at>> wrote:
Sorry, but I can't sort this out.
What I want to achieve can be seen here:
https://github.com/krabina/Maps/blob/master/includes/services/Leaflet/jquery.leaflet.js#L133-136
I want to be able to configure whicht service should be called.
In https://github.com/krabina/Maps/blob/master/Maps_Settings.php
I added:
$GLOBALS['$egMapsTest'] = array (
'Test1' => "http://{s}.tile.osm.org/{z}/{x}/{y}.png
<http://tile.osm.org/%7Bz%7D/%7Bx%7D/%7By%7D.png>",
'Test2' => 'http://{s}.tile.osm.org/{z}/{x}/{y}.png
<http://tile.osm.org/%7Bz%7D/%7Bx%7D/%7By%7D.png>',
);
If I just add the variable here:
https://github.com/krabina/Maps/blob/master/Maps.hooks.php#L76
it does not work.
MWJames pointed me to do something like
public static function onResourceLoaderGetConfigVars( &$vars ) {
global $egMapsTestTest;
$vars['egMapsTestTest'] = array(
'Test1' => $GLOBALS['egMapsTest']
);
return true;
}
But where and how to "attach the hook", whatever that means.
$wgHooks['ResourceLoaderGetConfigVars'][] =
'MyExtensionHooks::onResourceLoaderGetConfigVars';
probably here, but I don't understand how:
https://github.com/krabina/Maps/blob/master/includes/services/Leaflet/Leaflet.php
cheers,
Bernhard
----- Am 2. Jul 2015 um 13:45 schrieb James Montalvo
<jamesmontal...@gmail.com <mailto:jamesmontal...@gmail.com>>:
You need to tell MW to expose the PHP variables in JS,
which you do by adding a
ResourceLoaderGetConfigVars hook.
https://www.mediawiki.org/wiki/Manual:Hooks/ResourceLoaderGetConfigVars
On Jul 2, 2015 6:21 AM, "Frank Baxmann" <
serv...@frankbaxmann.de <mailto:serv...@frankbaxmann.de> >
wrote:
Hi Bernhard,
JavaScript (on browser) can not access php variables
(on server).
You have to make them available to JS by sending them
to the browser.
I use additional JS for this, but there is somewhere
in MW a class for
adding variables with MW. And these you can then
catch in JS with
mw.config.get.
Greetings
Frank
On 02.07.2015 13:07, Krabina Bernhard wrote:
> Hi,
> I'm hacking my way around these days and I have a
newbie question:
> If a variable is set in an extension (e.g.
> $GLOBALS['$egMapsTest'] = 'http://{s}.
tile.osm.org/{z}/{x}/{y}.png
<http://tile.osm.org/%7Bz%7D/%7Bx%7D/%7By%7D.png> ';
> How can I access this variable in a JavaScript?
> The only hint I found so far is
> var Test2 = mw.config.get('egMapsTest');
> but this doesn't work...
I have the feeling that mw.config.get onyl works
for mw variables (wg...), but
> how can I access eg-Variables that are set by an
extension?
> cheers,
> Bernhard
>
------------------------------------------------------------------------------
> Don't Limit Your Business. Reach for the Cloud.
> GigeNET's Cloud Solutions provide you with the
tools and support that
> you need to offload your IT needs and focus on
growing your business.
> Configured For All Businesses. Start Your Cloud Today.
> https://www.gigenetcloud.com/
> _______________________________________________
> Semediawiki-devel mailing list
> Semediawiki-devel@lists.sourceforge.net
<mailto:Semediawiki-devel@lists.sourceforge.net>
>
https://lists.sourceforge.net/lists/listinfo/semediawiki-devel
------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools
and support that
you need to offload your IT needs and focus on
growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
Semediawiki-devel mailing list
Semediawiki-devel@lists.sourceforge.net
<mailto:Semediawiki-devel@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/semediawiki-devel
------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and
support that
you need to offload your IT needs and focus on growing
your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
Semediawiki-devel mailing list
Semediawiki-devel@lists.sourceforge.net
<mailto:Semediawiki-devel@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/semediawiki-devel
------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
Semediawiki-devel mailing list
Semediawiki-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/semediawiki-devel