Posted By

CopperKo on 03/07/11


Tagged


Versions (?)

Index Hook


 / Published in: PHP
 

  1. function editText( &$parser, &$text, &$strip_state) {
  2. static $run = 0;
  3. $run++;
  4. if ($run != 2)
  5. return true;
  6.  
  7. $title = $parser->getTitle();
  8. $bot = 'MainPageBot';
  9. $wiki = '101companies';
  10. $wpapi = new wikipediaapi ( '', '', '', $bot, $wiki, true );
  11. $backlinks = $wpapi->backlinks($title);
  12.  
  13. $text .= PHP_EOL.'== Index ==';
  14. $text .= PHP_EOL.'These pages are referencing to this page:';
  15. foreach($backlinks as $backlink) {
  16. $text .= PHP_EOL.'* [['.$backlink["title"].']]';
  17. }
  18.  
  19. return true;
  20. }
  21.  
  22. require ("wikibot/wikibot.classes.php");
  23. $wgHooks['ParserBeforeStrip'][] = 'editText';

Report this snippet  

You need to login to post a comment.