r98505 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98504‎ | r98505 | r98506 >
Date:11:46, 30 September 2011
Author:reedy
Status:deferred
Tags:
Comment:
Update script to pull from original spreadsheet

TODO: Can this be done non-authed?
Modified paths:
  • /trunk/extensions/MetricsReporting/fetchOfflineGoogleSpreadsheet.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MetricsReporting/fetchOfflineGoogleSpreadsheet.php
@@ -2,15 +2,14 @@
33
44 require( "MetricsMaintenance.php" );
55
6 -class FetchGoogleSpreadsheet extends MetricsMaintenance {
 6+class FetchOfflineGoogleSpreadsheet extends MetricsMaintenance {
77 public function __construct() {
88 parent::__construct();
99 $this->mDescription = "Grabs and does stuff with a Google Documents Spreadsheet";
10 - $this->addArg( 'spreadsheet', 'URL or something to document' );
1110 }
1211
1312 public function execute() {
14 - $url = $this->getArg( 0 );
 13+ $url = 'https://spreadsheets.google.com/feeds/worksheets/0Au8PHt8_RuNedDJZU0V0NDNJT3JIWlVyVzd3WmFZb1E/private/full';
1514
1615 // Headers
1716 $http = MWHttpRequest::factory( 'https://www.google.com/accounts/ClientLogin',
@@ -27,7 +26,7 @@
2827 );
2928 $http->setHeader( 'User-Agent', self::getUserAgent() );
3029
31 - $res = $http->execute();
 30+ $http->execute();
3231 if ( $http->getStatus() == 403 ) {
3332 $this->error( '403', true );
3433 }
@@ -93,10 +92,10 @@
9493 $this->output( 'Spreadsheet tab title: ' . $xml->title . "\n" );
9594 $this->output( "\n" );
9695
97 - if ( $xml->title != 'Deployments' ) {
 96+ if ( $xml->title != 'For Report Card' ) {
9897 continue;
9998 }
100 - //continue;
 99+
101100 $sheetData = array();
102101 // foreach "tab"/worksheet
103102 foreach( $xml->entry as $entry ) {
@@ -148,7 +147,7 @@
149148 * @param $cookies CookieJar
150149 * @return MWHttpRequest
151150 */
152 - function buildAuthedRequest( $url, $token, $cookies = null ) {
 151+ function buildAuthedRequest( $url, $token = null, $cookies = null ) {
153152 $http = MWHttpRequest::factory( $url, array(
154153 'method' => 'GET',
155154 )
@@ -158,7 +157,9 @@
159158 $http->setCookieJar( $cookies );
160159 }
161160 $http->setHeader( 'GData-Version', '3.0' );
162 - $http->setHeader( 'Authorization', "GoogleLogin auth=\"{$token}\"" );
 161+ if ( $token !== null ) {
 162+ $http->setHeader( 'Authorization', "GoogleLogin auth=\"{$token}\"" );
 163+ }
163164 return $http;
164165 }
165166
@@ -170,5 +171,5 @@
171172 }
172173 }
173174
174 -$maintClass = "FetchGoogleSpreadsheet";
 175+$maintClass = "FetchOfflineGoogleSpreadsheet";
175176 require_once( DO_MAINTENANCE );

Status & tagging log