Index: trunk/extensions/SiteMatrix/SiteMatrixApi.php |
— | — | @@ -34,11 +34,12 @@ |
35 | 35 | $params = $this->extractRequestParams(); |
36 | 36 | $type = array_flip( $params['type'] ); |
37 | 37 | $state = array_flip( $params['state'] ); |
38 | | - |
39 | | - $allOrClosed = isset( $state['all'] ) || isset( $state['closed'] ); |
40 | | - $allOrPrivate = isset( $state['all'] ) || isset( $state['private'] ); |
41 | | - $allOrFishbowl = isset( $state['all'] ) || isset( $state['fishbowl'] ); |
42 | 38 | |
| 39 | + $all = isset( $state['all'] ); |
| 40 | + $closed = isset( $state['closed'] ); |
| 41 | + $private = isset( $state['private'] ); |
| 42 | + $fishbowl = isset( $state['fishbowl'] ); |
| 43 | + |
43 | 44 | if ( isset( $type['language'] ) ) { |
44 | 45 | foreach ( $matrix->getLangList() as $lang ) { |
45 | 46 | $langhost = str_replace( '_', '-', $lang ); |
— | — | @@ -53,6 +54,12 @@ |
54 | 55 | |
55 | 56 | foreach ( $matrix->getSites() as $site ) { |
56 | 57 | if ( $matrix->exist( $lang, $site ) ) { |
| 58 | + $skip = true; |
| 59 | + |
| 60 | + if ( $all ) { |
| 61 | + $skip = false; |
| 62 | + } |
| 63 | + |
57 | 64 | $url = $matrix->getUrl( $lang, $site ); |
58 | 65 | $site_out = array( |
59 | 66 | 'url' => $url, |
— | — | @@ -60,7 +67,14 @@ |
61 | 68 | ); |
62 | 69 | if( $matrix->isClosed( $lang, $site ) ) { |
63 | 70 | $site_out['closed'] = ''; |
| 71 | + if ( $closed ) { |
| 72 | + $skip = false; |
| 73 | + } |
64 | 74 | } |
| 75 | + |
| 76 | + if ( $skip ) { |
| 77 | + continue; |
| 78 | + } |
65 | 79 | $language['site'][] = $site_out; |
66 | 80 | } |
67 | 81 | } |
— | — | @@ -84,16 +98,37 @@ |
85 | 99 | $wiki['url'] = $url; |
86 | 100 | $wiki['code'] = str_replace( '_', '-', $lang ) . ( $site != 'wiki' ? $site : '' ); |
87 | 101 | |
| 102 | + $skip = true; |
| 103 | + |
| 104 | + if ( $all ) { |
| 105 | + $skip = false; |
| 106 | + } |
88 | 107 | if ( $matrix->isPrivate( $lang . $site ) ) { |
89 | 108 | $wiki['private'] = ''; |
| 109 | + |
| 110 | + if ( $private ) { |
| 111 | + $skip = false; |
| 112 | + } |
90 | 113 | } |
91 | 114 | if ( $matrix->isFishbowl( $lang . $site ) ) { |
92 | 115 | $wiki['fishbowl'] = ''; |
| 116 | + |
| 117 | + if ( $fishbowl ) { |
| 118 | + $skip = false; |
| 119 | + } |
93 | 120 | } |
94 | 121 | if ( $matrix->isClosed( $lang, $site ) ) { |
95 | 122 | $wiki['closed'] = ''; |
| 123 | + |
| 124 | + if ( $closed ) { |
| 125 | + $skip = false; |
| 126 | + } |
96 | 127 | } |
97 | 128 | |
| 129 | + if ( $skip ) { |
| 130 | + continue; |
| 131 | + } |
| 132 | + |
98 | 133 | $specials[] = $wiki; |
99 | 134 | } |
100 | 135 | |
— | — | @@ -112,12 +147,23 @@ |
113 | 148 | ), |
114 | 149 | ApiBase::PARAM_DFLT => 'special|language', |
115 | 150 | ), |
| 151 | + 'state' => array( |
| 152 | + ApiBase::PARAM_ISMULTI => true, |
| 153 | + ApiBase::PARAM_TYPE => array( |
| 154 | + 'all', |
| 155 | + 'closed', |
| 156 | + 'private', |
| 157 | + 'fishbowl' |
| 158 | + ), |
| 159 | + ApiBase::PARAM_DFLT => 'all', |
| 160 | + ) |
116 | 161 | ); |
117 | 162 | } |
118 | 163 | |
119 | 164 | protected function getParamDescription() { |
120 | 165 | return array( |
121 | 166 | 'type' => 'Filter the Site Matrix by type', |
| 167 | + 'state' => 'Filter the Site Matrix by wiki state', |
122 | 168 | ); |
123 | 169 | } |
124 | 170 | |