All pastes #538218 Raw Edit

Unnamed

public php v1 · immutable
·published 2007-06-04 23:49 UTC
rendered paste body
<?php# Define a setup function$wgExtensionFunctions[] = 'wfIncludeCat_Setup';# Add a hook to initialise the magic word$wgHooks['LanguageGetMagic'][]       = 'wfIncludeCat_Magic';function wfIncludeCat_Setup() {        global $wgParser;        $wgParser->setFunctionHook( 'includecat', 'wfIncludeCat_Render' );}function wfIncludeCat_Magic( &$magicWords, $langCode ) {        $magicWords['includecat'] = array( 0, 'includecat' );        return true;}function wfIncludeCat_Render( &$parser, $categorie = '' ) {  /* récupération des pages inclues dans la catégorie demandée */  $db = Article::getDB();  $res = $db->select('categorylinks', 'cl_sortkey', "cl_to = '$categorie'");  $cours = array();  while ($objRes = $db->fetchObject($res)){    if (! in_array($objRes->cl_sortkey, $cours)){      array_push($cours, str_replace(' ', '_', $objRes->cl_sortkey));    }  }  $retour = "";  foreach ($cours as $nom){    $retour .= "*$nom\n";    $title = Title::newFromURL($nom);    $revision = Revision::newFromTitle(&$title);    $text = $revision->getRawText();    $retour .= "$text\n";  }  return $retour;}?>