Jump to content

User:Fxparlant~metawiki/Technorati

From Meta, a Wikimedia project coordination wiki

The Technorati_extension lacks a few functionalities:

  • the user needs to add the wiki categories AND the technorati tags. I think we should be able to hack the category section so that a technorati link is added to each category.
  • the technorati server is not pinged at modification of the category list / tag list on edit. The extension should add the ping possibilities through the use of xmlrpc protocols.


Source code tested on mw1.6

[edit]
  • Load the xmlrpc files
    • xmlrpc.inc (15 ko)
    • xmlrpcs.inc (10 ko)
    • xmlrpc.php (1 ko)


xmlrpc.php

[edit]
<?php
// $Id: xmlrpc.php,v 1.15 2005/12/10 19:26:47 dries Exp $

/**
 * @file
 * PHP page for handling incoming XML-RPC requests from clients.
 */

//include_once './includes/bootstrap.inc';
//drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
include_once 'xmlrpc.inc';
include_once 'xmlrpcs.inc';

//xmlrpc_server(module_invoke_all('xmlrpc'));
?>


Editpage.php

[edit]

Inside the function edit(), at the " save" if:

		if ( 'save' == $this->formtype ) {
			if ( !$this->attemptSave() ) {
				wfProfileOut( "$fname-business-end" );
				wfProfileOut( $fname );
				//Added FXP technorati
				$this->pingTechnorati(1);
				return;
			}
		}

And now add the function pingTechnorati:

//Added FXP to ping technorati
// from http://developers.technorati.com/wiki/pingConfigurations
// and http://www.technorati.com/developers/ping/
	function pingTechnorati($blog_ID = 1) {
   global $wgTitle, $use_technoratiping;
$fname = 'EditPage::pingTechnorati';
   
   if ( $use_technoratiping == 1)   
   {
      $client = new xmlrpc_client("/rpc/ping", "rpc.technorati.com", 80);
      $message = new xmlrpcmsg("weblogUpdates.ping", array(new xmlrpcval($wgTitle->getPrefixedDBkey()),
                                                         new xmlrpcval("http://www.fwparlant.net/")));
      $result = $client->send($message);
      if (!$result || $result->faultCode()){
         return(false);
		 wfDebug( "$fname: failed to notify 'technorati.com'\n" );
		 }
		wfDebug( "$fname: super ping to 'technorati.com'\n" );
      return(true);
   }
   else
      return(false);
}
  • There must be a variable with the url of your site, but for now, change manually fxparlant.net with your site's adress

OutputPage.php

[edit]

For mediawiki 1.6 modify the addCategoryLinks function with this

	function addCategoryLinks($categories) {
		global $wgUser, $wgContLang, $technorati ;

		# Add the links to the link cache in a batch
		$arr = array( NS_CATEGORY => $categories );
		$lb = new LinkBatch;
		$lb->setArray( $arr );
		$lb->execute();

		$sk =& $wgUser->getSkin();
		foreach ( $categories as $category => $arbitrary ) {
			$title = Title::makeTitleSafe( NS_CATEGORY, $category );
			$text = $wgContLang->convertHtml( $title->getText() );
			$this->mCategoryLinks[] = $sk->makeLinkObj( $title, $text );
			//Modified FXP technorati
			$text2 = str_replace(" ", "+", $text);
			$technorati .= "<a href=\"http://technorati.com/tag/" . $text2 .  "\" rel=\"tag\">" 
			. $text . "</a>";
		}
		//square technorati in a display none style
		$technorati = "<div class=\"technorati\" style=\"display:none\">" . $technorati . "</div>";
	}

Localsetting.php

[edit]

Add:

$use_technoratiping = 1;
include