-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from OpenTechStrategies/23-spreadsheet-column-…
…special-page Add a special page that lists spreadsheet columns
- Loading branch information
Showing
4 changed files
with
61 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
TorqueDataConnect/include/specials/TorqueDataConnectColumns.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
/* | ||
* Special page that lists available spreadsheet columns | ||
*/ | ||
|
||
class TorqueDataConnectColumns extends SpecialPage { | ||
public function __construct() { | ||
parent::__construct('TorqueDataConnectColumns', 'torquedataconnect-admin'); | ||
} | ||
|
||
public function execute($subPage) { | ||
global $wgTorqueDataConnectSheetName; | ||
global $wgTorqueDataConnectServerLocation; | ||
|
||
$this->setHeaders(); | ||
$this->checkPermissions(); | ||
$ch = curl_init(); | ||
curl_setopt( | ||
$ch, | ||
CURLOPT_URL, | ||
$wgTorqueDataConnectServerLocation . | ||
'/api/sheets/' . | ||
$wgTorqueDataConnectSheetName . '.json' | ||
); | ||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | ||
$sheet = json_decode(curl_exec($ch), true); | ||
curl_close($ch); | ||
|
||
$out = "== " . $wgTorqueDataConnectSheetName . " ==\n"; | ||
|
||
// this assumes there is at least one row in the spreadsheet | ||
foreach ($sheet["columns"] as $column) { | ||
$out .= "* " . $column . "\n"; | ||
} | ||
|
||
$this->getOutput()->addWikiTextAsInterface($out); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters