From OrganicDesign Wiki
| This talk page pertains specifically to the development of this extension. For more general discussion about bugs and usage etc, please refer to the mediawiki.org talk page at MW:Extension talk:Packages
|
|
Overview
A common problem with MediaWiki is that a clean installation usually requires many templates added to become useful. Often the required templates will be from ones that you've come to use frequently from your own wikis in the field, and often they're from the various WikiMedia projects.
This extension is designed to allow collections of diverse templates to be defined as bullet lists of internal or interwiki links. In a wiki which is running the extension, the Special:Packages page is used to manage the packages, and the MediaWiki:Packages article contains the actual lists (and is editable from the special page).
The packages can be built by running the extension script from the shell or from the crontab (not from the specialpage because it can take a long time to execute). The resulting packages are PHP includable just like a normal extension (but they require the Packages extension to be installed on the target wiki to work).
Dev notes
Craziest PHP error ever:
- syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM, expecting T_STRING or T_VARIABLE - WTF!? --Nad 14:36, 8 November 2007 (NZDT)
- Or maybe not so crazy - Paamayim Nekudotayim is the official name for the Scope Resolution Operator (::) in PHP. It means "double colon" in Hebrew.
- Nekudotayim (נקודתיים) means 'colon'; it comes from nekuda, 'point' or 'dot', and the dual suffix ayim (יים-), hence 'two points'. Similarly, the word paamayim (פעמיים) is derived by attaching the dual suffix to paam ('one time' or 'once'), thus yielding 'twice'. The name was introduced in the Israeli developed Zend Engine 0.5 used in PHP3. Although it has been confusing to many developers, it is still being used in PHP5, as in the above error message.
Features
- Doesn't affect database content
- Handles dependency templates
- Renames templates and dependencies to match package name/prefix
- Use interwiki links to specify content on remote wikis
Regex bug
# Extract the package sections in the definitions article and loop through them building a file for each
preg_match_all('/=+\\s*(.+?)\\s*=+([^=]+)/',$text,$m1);
This will fail if any table content is present, e.g.
<table cellpadding="1" cellspacing="1" border="1">
...
</table>
will parse the content and fetch
"1" cellspacing
between the equals. We need to lock the regex to the beginning of a line, something like /^=+\\s*(.+?)\\s*=+([^=]+)/m --Sven 11:44, 13 December 2007 (NZDT)
</php>
- I quick solution to this is to use preg_match_all to extract section names, and then use preg_split to create an array of section content to process
# Match sections
preg_match_all('/^=+\\s*(.+?)\\s*=+$/m',$wikitext,$sectionNames);
# Split wikitext on sections
$sections = preg_split('/^=+\\s*(.+?)\\s*=+$/ms', $wikitext);
foreach($sections as $key => $value) {
if($key) {
print("KEY: $key <br />----<br /> VALUE: $value<br />----</br />");
}
}
--Sven 13:18, 13 December 2007 (NZDT)
- This regex does not work
preg_match_all('/^={2,}\\s*(.+?)\\s*={2,}(.+)(?!={2,})/ms',$wikitext,$m1);. the problem is the greedy (.+) part does not match more than one section. The lookahead is trying to match later ^= symbols --Sven 23:10, 13 December 2007 (NZDT)