Initial Commit
[Projects.git] / hbb-mediawiki / source / extensions / hbb-repo / require.php
blobfe6df4a808543f10569e4e9990e0c9ae58dd7238
1 <?php
2 if (!defined('MEDIAWIKI')) die();
4 $wgExtensionCredits['specialpage'][] = array(
5 'name' => 'HBB Repo',
6 'author' => 'Matthew Bauer',
7 'url' => 'http://www.wiibrew.org/wiki/Homebrew\ Browser',
8 'description' => 'This extension creates the page Special:Repo in the Wiki, which can be used by the Homebrew Browser to load Homebrew Apps.',
9 'version' => 0.01
12 require_once('includes/SpecialPage.php');
14 class SpecialRepo extends SpecialPage {
15 var $name;
16 function __construct($name) {
17 $this->name = $name;
18 $this->SpecialPage($name, $includable = true);
19 SpecialPage::$mList[$name] = $this;
22 function execute($par) {
23 global $wgRequest, $wgOut;
25 $wgOut->clearHTML();
26 $wgOut->disable();
28 $newline = "\n";
30 echo $newline;
32 $title = $wgRequest->getText('title');
33 if (strpos($title,'/')) {$title = str_replace("Special:".$this->name."/", "", $title);
34 } else $title = $this->name;
36 $title = Title::newFromText($title);
37 $article = new Article($title);
38 $content = $article->getContent();
40 $rows = explode('|-', $content);
42 foreach($rows as $key => $row){
43 if ($key == 0) {
44 $columns = explode('!', $row);
45 $headers = array(1,2,3,4,5);
46 foreach($columns as $columnkey => $column){
47 $column = trim(strtolower(str_replace("]","",str_replace("[","",str_replace("\n","",$column)))));
48 if ($column == 'title' || $column == 'name'){
49 $headers[0] = $columnkey;
50 } else if ($column == 'author'){
51 $headers[1] = $columnkey;
52 } else if ($column == 'version'){
53 $headers[2] = $columnkey;
54 } else if ($column == 'size'){
55 $headers[3] = $columnkey;
56 } else if ($column == 'shortdescription' || $column == 'description'){
57 $headers[4] = $columnkey;
58 } else if ($column == 'longdescription'){
59 $headers[5] = $columnkey;
60 } else if ($column == 'format') {
61 $headers[6] = $columnkey;
62 } else if ($column == 'directory' || $colmn == 'directories'){
63 $headers[7] = $columnkey;
64 } else if ($column == 'rating'){
65 $headers[8] = $columnkey;
66 } else if ($column == 'downloads' || $column == 'hits'){
67 $headers[9] = $columnkey;
68 } else if ($column == 'imagesize'){
69 $headers[10] = $columnkey;
70 } else if ($column == 'timestamp'){
71 $headers[11] = $columnkey;
72 } else if ($column == 'date' || $column == 'releasedate'){
73 $headers[12] = $columnkey;
74 } else if ($column == 'zipsize'){
75 $headers[13] = $columnkey;
76 } else if ($column == 'bootsize'){
77 $headers[14] = $columnkey;
78 } else if ($column == 'controllers' || $column == 'peripherals'){
79 $headers[15] = $columnkey;
82 if (!$headers[5]) $headers[5] = $headers[4];
83 else if (!$headers[4]) $headers[4] = $headers[5];
84 } else {
85 $columns = explode("\n|", $row);
86 $name = strtolower(trim(str_replace(" ", "_",
87 str_replace("\n","",str_replace("]","",str_replace("[","",$columns[$headers[0]]))))));
88 $controllers = '';
89 if (strpos($columns[$headers[14]], '{{') && strpos($columns[$headers[14]], '}}')){
90 if (strpos($columns[$headers[14]], '{{Wiimote1}}') || strpos($columns[$headers[8]], '{{Wiimote}}'))
91 $controllers = $controllers . "w";
92 if (strpos($columns[$headers[14]], '{{Wiimote2}}')) $controllers = $controllers . "ww";
93 if (strpos($columns[$headers[14]], '{{Wiimote3}}')) $controllers = $controllers . "www";
94 if (strpos($columns[$headers[14]], '{{Wiimote4}}')) $controllers = $controllers . "wwww";
95 if (strpos($columns[$headers[14]], '{{FrontSD}}') || strpos($columns[$headers[8]], '{{FrontSDHC}}'))
96 $controllers = $controllers . "s";
97 if (strpos($columns[$headers[14]], '{{Nunchuk}}')) $controllers = $controllers . "n";
98 if (strpos($columns[$headers[14]], '{{ClassicController}}')) $controllers = $controllers . "c";
99 if (strpos($columns[$headers[14]], '{{GCNController}}')) $controllers = $controllers . "g";
100 if (strpos($columns[$headers[14]], '{{USBKeyboard}}')) $controllers = $controllers . "k";
101 if (strpos($columns[$headers[14]], '{{WiiZapper}}')) $controllers = $controllers . "z";
102 } else $controllers = $columns[$headers[14]];
104 if ($columns[$headers[11]]){
105 $timestamp = $columns[$headers[11]];
106 } else if ($columns[$headers[12]]){
107 $timestamp = date();
108 } else {
109 $timestamp = date();
112 if ($columns[$headers[0]]){
115 if ($columns[$headers[1]]){
116 $columns[$headers[1]] = str_replace("User:","",$columns[$headers[1]]);
119 if ($columns[$headers[2]]){
122 if ($columns[$headers[3]]){
125 if ($columns[$headers[4]]){
128 if ($columns[$headers[5]]){
131 $format = strtolower($columns[$headers[6]]);
132 $dirs = $columns[$headers[7]];
133 if (strpos($columns[$headers[8]], "{{") && strpos($columns[$headers[8]], "}}")){
134 $rating = 0;
135 if (strpos($columns[$headers[8]], "{{Star1}}")) $rating+=1;
136 if (strpos($columns[$headers[8]], "{{Star2}}")) $rating+=2;
137 if (strpos($columns[$headers[8]], "{{Star3}}")) $rating+=3;
138 if (strpos($columns[$headers[8]], "{{Star4}}")) $rating+=4;
139 } else {
140 $rating = $columns[$headers[8]];
142 $downloads = $columns[$headers[9]];
144 $imageSize = $columns[$headers[10]];
145 $zipSize = $columns[$headers[13]];
146 $bootSize = $columns[$headers[14]];
148 echo trim(str_replace("\n","",str_replace("]","",str_replace("[","",
149 $name . ' ' . $timestamp . ' ' . $imageSize . ' ' . $bootSize . ' ' . $format . ' ' . $zipSize . ' ' . $downloads . ' ' . $rating . ' ' . $controllers . ' ' . $dirs)))) . $newline;
150 foreach($headers as $key => $header){
151 if ($key == 6) break;
152 echo trim(str_replace("]","",str_replace("[","",str_replace("\n","",$columns[$header])))) . $newline;
159 new SpecialRepo('HBB');