Last modified: 2010-01-27 05:23:51 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T5264, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 3264 - User-defined variables packed into one array
User-defined variables packed into one array
Status: RESOLVED FIXED
Product: MediaWiki extensions
Classification: Unclassified
Extensions requests (Other open bugs)
unspecified
All All
: Normal enhancement with 1 vote (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2005-08-25 14:32 UTC by SV Resolution
Modified: 2010-01-27 05:23 UTC (History)
1 user (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description SV Resolution 2005-08-25 14:32:57 UTC
User-defined variables are useful while an article is being written.
I could write the code, but have nowhere to test my work...

BENEFIT OF EXTENSION:
Example 1:  Keep a group of images the same size
Editor has several images on page, needs them all the same size.
Editor decides to change the size of all the images.  The ability
to create and use a variable would make this a lot easier
<VarSet>imagesize=250px</VarSet>
[[Image:imageA.jpg|<VarGet>imagesize</VarGet>]]
[[Image:imageB.jpg|<VarGet>imagesize</VarGet>]]
... a lot of text ...
[[Image:imageC.jpg|<VarGet>imagesize</VarGet>]]

Example 2:  Print or Supress all footnotes
A set of children's books is being developed at WikiJunior.
During development, we want to display citations so we can see which 
facts have been checked and which have not.  After development, we 
would like to supress display of citations, because they are not 
used in children's books.  But we would not like to have to delete 
all of the citations.

We could create a set of templates that would depend on the value of 
a single variable -- showrefs.  At the top of the document,
<!-- Today, no refs --><VarSet>showrefs=0</VarSet>
In Template:WJFootnote we have {{WJCite<VarGet>showrefs</VarGet>}}
Which would select template WJCite0 (which does nothing) or WJCite1 
(which generates the citation reference) depending on how showrefs 
was set at the top of the document

IMPLEMENTATION:
$uservar['myvar']='string'
The variables would only exist during the display of a page.
The variables MUST BE GLOBAL --accessible even within nested 
templates
The variables SHOULD BE passable as parameters to templates.
The variables COULD BE made available when an editor was 
editing/previewing only one section of the page if, for example, 
they were stuffed into a new magic word.

USER INTERFACE:
Variables would be manipulated by a set of wiki extensions:
VarSet
   <VarSet>myvar</VarSet>
   <VarSet>myvar="string"</VarSet> 
   <VarSet>myvar=6.02E23</VarSet>
   sets the variable, produces no output.
   if no value is given for myvar, default value is 1
VarIsSet
  <VarIsSet>myvar</VarIsSet>
  returns 1 or 0, which could be incorporated into a templatename
VarGet
  <VarGet>myvar</VarGet> 
  returns the value of myvar
  if the var is not set, produces no output
VarUnSet
  <VarUnSet>myvar</VarUnSet>
  unsets the variable, produces no output.
Comment 1 SV Resolution 2005-09-15 19:56:19 UTC
Someone suggested this bug depends on 1911.  I don't think it does.
* 1911 requests the creation of properties for articles.  These 
properties would probably have to be stored in a separate field on the 
database so they could be efficiently retrieved for Special pages.
* This request is simpler.  It does not involve saving anything new on 
the database.  The values would be set and used within the php scripts 
that do the rendering.  It would only be available to another page if 
that page transcluded the page in which the variable is set.  
* This request can be done with some simple php.  And if I had a place to 
test it, I could write it myself.  But I don't have a test wiki to 
practice on...
Comment 2 Antoine "hashar" Musso (WMF) 2005-09-15 20:03:39 UTC
Taking your first example, you can load the text in an external editor
and use the search&replace function

[[Image:imageA.jpg|300px]]
[[Image:imageB.jpg|300px]]
... a lot of text ...
[[Image:imageC.jpg|300px]]

In vi it would be something like:

%s/300px/250px/g

(to change the size of images to 250px.
Comment 3 SV Resolution 2005-09-15 21:01:10 UTC
That is one possible workaround for examples #1 and #2 both
%s/{{ab/{{ab0/g
%s/{{abn/{{abn0/g
to change the citations from ab and abn which render to ab0 and abn0 
which do not.
Comment 4 Philippe Verdy 2008-11-13 23:49:27 UTC
Hmmm... I've just posted bug 16337 describing a more general ParserFunction extension to handle what I call "Context Variables" (at first only "Global Context Variables") for a similar task.

There's a page on Meta discussing it and why we need something like that for existing problems on Wiktionary and similar multilingual projects on Commons (where the same page needs specialization of templates according to a "language context", without depending only on explicit template parameters.

Basically, it defined first the following two syntaxes {{#v:get:x}} and {{#v:set:x|value}}, part of a proposal for a parserfunction identified by {{#v: }} ("v" for "variable") and with general form {{#v:action:variableName|optional parameters...}} and a default "action" which would be "get".

The syntax adopted here is very near from the syntax already used for template parameters, and its use would be similar. No more embedded braces, no difficult syntax with XML-like open/close tags, and more versatile, using an approach that would be easy to adopt by existing MW template designers.

See [[Meta:GlobalContextVariables_Extension]] for the discussion started there, and Bug 16337 where I have posted this reference and an introduction.

Comment 5 SV Resolution 2008-11-14 00:06:24 UTC
(In reply to comment #4)
> Hmmm... I've just posted bug 16337 describing a more general ParserFunction
>...
> Basically, it defined first the following two syntaxes {{#v:get:x}} and
> {{#v:set:x|value}}, part of a proposal for a parserfunction identified by {{#v:
> }} ("v" for "variable") and with general form {{#v:action:variableName|optional
> parameters...}} and a default "action" which would be "get".
>
I think your number 16337 does encompass the functionality I've requested, although it has the potential to do quite a lot more in subtle ways, I think.

If you have a test wiki, why not implement just  part of this functionality and demo it.  I think the discussions that follow a concrete demo will be very useful.
Comment 6 Chad H. 2010-01-27 05:23:51 UTC
Functionality seems to be provided in http://www.mediawiki.org/wiki/Extension:VariablesExtension (and probably a few other ones by now), so I'm marking this FIXED.

Getting it enabled on Wikimedia sites requires consensus, and approval/review by a senior developer.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links