Jump to content

User:M2mtech

From mediawiki.org

Hi, we are from the technical support of the m2m server software gmbh - a small Austrian software company. Setting up some wikis for our clients we found some hacks which we summarized on our blog. Some of them we find useful and want to share with you ;)

RSS (GISWiki) not working in 1.18.3

[edit]

for the rss extension

To get rid of some annoying warning messages change in rss.php around line 162 change:

 if ($item['description']) {$description = True; break;}

to

 if (isset($item['description']) && $item['description']) {$description = True; break;}

around line 171 add before the foreach line:

  '''if (!isset($output)) $output = ""; else $output.="";'''
  foreach ($rss->items as $item) {

and for the actual functionality - around line 261 change:
  if ($DisableCache) {
    global $wgVersion;
    # Do not cache this wiki page.
    # for details see http://public.kitware.com/Wiki/User:Barre/MediaWiki/Extensions
    global $wgTitle, $wgDBprefix;
    $ts = mktime();
    $now = gmdate("YmdHis", $ts + 120);
    $ns = $wgTitle->getNamespace();
    $ti = wfStrencode($wgTitle->getDBkey());
    $version = preg_replace("/^([1-9]).([1-9]).*/", "\\1\\2", $wgVersion);
    if ($version>14) $sql = "UPDATE $wgDBprefix"."page SET page_touched='$now' WHERE page_namespace=$ns AND page_title='$ti'";
    else             $sql = "UPDATE $wgDBprefix"."cur SET cur_touched='$now' WHERE cur_namespace=$ns AND cur_title='$ti'";
    wfQuery($sql, DB_WRITE, "");
  }
to
  if ($DisableCache) {
    global $wgVersion;
    '''$dbr =& wfGetDB( DB_SLAVE );'''
    # Do not cache this wiki page.
    # for details see http://public.kitware.com/Wiki/User:Barre/MediaWiki/Extensions
    global $wgTitle, $wgDBprefix;
    $ts = mktime();
    $now = gmdate("YmdHis", $ts +120);
    $ns = $wgTitle->getNamespace();
    '''$ti = $dbr->addQuotes($wgTitle->getDBkey());'''
    $version = preg_replace("/^([1-9]).([1-9]).*/", "\\1\\2", $wgVersion);
    '''$sql = "UPDATE $wgDBprefix" . "page SET page_touched='$now' WHERE page_namespace=$ns AND page_title=$ti";
    $dbr->query($sql, __METHOD__);'''       
  }
In '''rss_utils.inc''' around line 28 change
  $pat = "/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(:(\d{2}))?(?:([-+])(\d{2}):?(\d{2})|(Z))?/";
to
  $pat = "/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})('''?:''':(\d{2}'''\.\d{3}'''))?(?:([-+])(\d{2}):?(\d{2})|(Z))?/";
around line 38 change:
  if ( $match[10] == 'Z' ) {
to
  if ( '''isset($match[10]) && ('''$match[10] == 'Z'''')''' ) {
and finally around line 43 change:
  array( $match[8], $match[9], $match[10]);
to
  array( $match['''7'''], $match['''8'''], $match['''9''']);

--M2mtech (talk) 16:45, 29 April 2012 (UTC)

multilang not working in 1.18.3

[edit]

for the multilang extension

To fix this we had to remove ampersand in function definition:

 function renderMultilang($input, $argv=array(), $parser) {  

and disable the limit report functionality inside the extension:

 $parser->mOptions->enableLimitReport(false);

--M2mtech (talk) 09:48, 29 April 2012 (UTC)

multilang breaks NOSECTIONEDIT magic word

[edit]

for the multilang extension

To fix this we had to add the following line:

 $parser->mOptions->mEditSection = false;

--M2mtech 18:51, 6 January 2007 (UTC)