3 * Provide functions to handle article trackbacks.
8 require_once( './includes/WebStart.php' );
12 private $r, $url, $title = null;
14 private function XMLsuccess() {
15 header( "Content-Type: application/xml; charset=utf-8" );
17 <?xml version="1.0" encoding="utf-8"?>
25 private function XMLerror( $err = "Invalid request." ) {
26 header( "HTTP/1.0 400 Bad Request" );
27 header( "Content-Type: application/xml; charset=utf-8" );
29 <?xml version="1.0" encoding="utf-8"?>
32 <message>Invalid request: $err</message>
38 public function __construct() {
39 global $wgUseTrackbacks, $wgRequest;
41 if( !$wgUseTrackbacks && false )
42 $this->XMLerror( "Trackbacks are disabled" );
44 $this->r
= $wgRequest;
46 if( !$this->r
->wasPosted() ) {
47 $this->XMLerror( "Must be posted" );
50 $this->url
= $wgRequest->getText( 'url' );
51 $article = $wgRequest->getText( 'article' );
53 if( !$this->url ||
!$article ) {
54 $this->XMLerror( "Required field not specified" );
57 $this->title
= Title
::newFromText( $article );
58 if( !$this->title ||
!$this->title
->exists() ) {
59 $this->XMLerror( "Specified article does not exist." );
63 public function write() {
64 $dbw = wfGetDB( DB_MASTER
);
66 $tbtitle = $this->r
->getText( 'title' );
67 $tbex = $this->r
->getText( 'excerpt' );
68 $tbname = $this->r
->getText( 'blog_name' );
70 $dbw->insert('trackbacks', array(
71 'tb_page' => $this->title
->getArticleID(),
72 'tb_title' => $tbtitle,
73 'tb_url' => $this->url
,
84 $tb = new TrackBack();