Extension talk:Data

Add topic
From mediawiki.org
Latest comment: 12 years ago by 31.181.121.105 in topic MySQL requirement
The following discussion has been transferred from Meta-Wiki.
Any user names refer to users of that site, who are not necessarily users of MediaWiki.org (even if they share the same username).

Indexes[edit]

What indexing should be used on the data_extension table. John Stanton 19:47, 4 November 2006 (UTC)Reply

I think at least item and key columns should be indexed. Nikola 02:28, 16 November 2006 (UTC)Reply

Code[edit]

It seems that the following is needed to avoid PHP warnings:

$wgHooks['LanguageGetMagic'][] = 'wfDataLanguageGetMagic';

function wfDataLanguageGetMagic( &$magicWords, $langCode ) {
    switch ( $langCode ) {
        default:
            $magicWords['data']          = array( 0, 'data' );
            $magicWords['sort']          = array( 0, 'sort' );
    }
    return true;
}

Patrick 11:36, 5 February 2007 (UTC)Reply

Added default handling[edit]

Hi!

I just want to inform you that I have added the handling of defaults to the get function, so that one can use constructs like

{{#data:key|default}}

which will output "default" if key is not set. I have made it such, that it looks like parameter references in templates

{{{paramname|default}}}

I noticed that I needed this functionality pretty often, and that it can replace the somewhat lengthy

{{#if:{{#data:item->key}}|{{#data:item->key}}|default}}

If you want to include this functionality into the extension, just go ahead. Here is the modified "get" function:

function get(&$parser,$desc="",$default="") {
  list($lang,$item,$key)=$this->parseDesc($desc);
  if($key=="")
     return $item;
#echo "$lang|$item|$key";
  $res=mysql_query("SELECT `value` FROM data_extension WHERE `item`='".
                   mysql_real_escape_string($item).
                   "' AND `key`='".
                   mysql_real_escape_string($key)."'");
  $res=mysql_fetch_row($res);
  $r=$res[0];
  if ($r=="") $r=$default;
  return array($r,"noparse"=>TRUE);
}

Cheers --141.2.138.89 16:27, 6 November 2007 (UTC) (de:Benutzer:olenz)Reply

PHP failing[edit]

Just downloaded the code from the 3 Feb update. I get the following error (twice) when I load any wiki page

Warning: array_slice() [function.array-slice]: The first argument should be an array in /var/www/wikijfh/languages/Language.php on line 1153

Noted that an extra piece of code (function wfDataLanguageGetMagic) is recommended and included in the latest version, except for the line

$wgHooks['LanguageGetMagic'][] = 'wfDataLanguageGetMagic';

I get the error with and without this extra line. I have created the required table in wikidb. My LocalSettings includes the following lines

include("extensions/Expr.php");
include("extensions/ParserFunctions.php");
include("extensions/Data.php");

Ideas ???

The line is there, fourth line of code in wfDataExtension() function. But something weird is going on. Try moving data extension to the top of your list of extensions (including it before any other extension), see if that works. Alternarively, you could add a @ at the beginning of the line 1153 in languages/Language.php . Nikola Smolenski 09:32, 9 February 2008 (UTC)Reply

Comparison of Dynamic Pagelist x Semantic Mediawiki[edit]

Do you think, Extension:Data should also be listed in this comparison: Comparison of Dynamic Pagelist x Semantic Mediawiki?

If "yes" just add it there. --Jannis 13:49, 29 December 2009 (UTC)Reply

Discussion of Potential Applications of Data Extension[edit]

I was recently researching the potential of a WikiData project, but it seems lost and forgotton and that this might be the best avenue for its completion. Is this the case?

Current Understandings[edit]

My current understanding is that this extension allows you to search for data left as parser functions within Wikipedia pages. It could be extended into a wikipedia project should there be enough support. It currently uses only text values.

Current Confusions[edit]

How can it be used now? (I don't know how to put the php into use...)

Questions on the Potential applications[edit]

Permaculture Database application[edit]

Could this be used for an implimentation of a Permaculture Design database in which aspects of permaculture design could be parsed onto wikipedia page (actually better yet wikiSpecies pages) and then searched for and retrieved to find data such as which plants are suitable nitrogen fixers for which climates or forest layers, or the amount of biomass produced by such an animal. The questions associated with this application are:

  1. Could this be used in conjuction with the existing wikispecies database as invisible parsers which do not interfere with the viewing of wikispecies but piggyback their database offering varous information?
  2. What might a wikiDB project look like? For instance, might a Permaculture wikiDB page be a list of potential data fields, and standardized inputs with interpertation of fields as a launchpad for wikipedia/wikispecies based editing of data function parsers along with information on export of data, how data can be used etc and related wiki projects etc?
  3. Could this extension be used to extract data from the wikipedia database into a file (such as an excel file or other database files?)
  4. And could the data concivably be converted to other formats (like number) easily IF it conforms to certain standards?

Supaiku 15:58, 10 November 2010 (UTC)Reply

Update ExtData::set signature[edit]

Hi. I updated ExtData::set 's function signature in the source code to match the current definition. See Manual:Hooks/ArticleSaveComplete for reference.

Previous version made Extension:Data crash when adding new data to article. --Kevin

MySQL requirement[edit]

As far as I see, this extensions requires MySQL and thus must not be installed if MediaWiki installation is based on SQLite, postgreSQL or any other DB engine. —31.181.121.105 22:03, 15 September 2011 (UTC)Reply

Working in 1.18[edit]

To get this working with 1.18 I changed line 34 and removed line 40 because $wgMessageCache is no longer supported.

New line 34: global $IP,$wgParser,$wgHooks,$wgExtData;

Removed line 40:$wgMessageCache->addMessage( 'joindata', 'Joindata' );