adding meta keywords
authorMagnus Manske <magnusmanske@users.mediawiki.org>
Sat, 20 Mar 2004 13:27:08 +0000 (13:27 +0000)
committerMagnus Manske <magnusmanske@users.mediawiki.org>
Sat, 20 Mar 2004 13:27:08 +0000 (13:27 +0000)
includes/Article.php
includes/OutputPage.php

index ffce076..d9fe116 100644 (file)
@@ -365,6 +365,9 @@ class Article {
                        $wgOut->addWikiText( $text );
                }
 
+               # Add link titles as META keywords
+               $wgOut->addMetaTags() ;
+
                $this->viewUpdates();
                wfProfileOut( $fname );
        }
index 6552dd8..b60bf26 100644 (file)
@@ -542,6 +542,19 @@ class OutputPage {
                $wgOut->addHTML( "\n<p>$r\n" );
        }
 
+       # This function takes the existing and broken links for the page
+       # and uses the first 10 of them for META keywords
+       function addMetaTags ()
+       {
+               global $wgLinkCache , $wgOut ;
+               $good = array_keys ( $wgLinkCache->mGoodLinks ) ;
+               $bad = array_keys ( $wgLinkCache->mBadLinks ) ;
+               $a = array_merge ( $good , $bad ) ;
+               $a = array_slice ( $a , 0 , 10 ) ; # 10 keywords max
+               $a = implode ( "," , $a ) ;
+               $wgOut->addMeta ( "KEYWORDS" , $a ) ;
+       }
+
        /* private */ function headElement()
        {
                global $wgDocType, $wgDTD, $wgUser, $wgLanguageCode, $wgOutputEncoding, $wgLang, $wgRequest;