Index: trunk/extensions/EducationProgram/EducationProgram.hooks.php |
— | — | @@ -227,11 +227,20 @@ |
228 | 228 | } |
229 | 229 | |
230 | 230 | protected static function displayTabs( SkinTemplate &$sktemplate, array &$links, Title $title ) { |
231 | | - $classes = array( |
| 231 | + $classes = array( |
232 | 232 | EP_NS_INSTITUTION => 'EPOrg', |
233 | 233 | EP_NS_COURSE => 'EPCourse', |
234 | 234 | ); |
235 | 235 | |
| 236 | + $ns = array( |
| 237 | + EP_NS_COURSE, |
| 238 | + EP_NS_COURSE_TALK, |
| 239 | + EP_NS_INSTITUTION, |
| 240 | + EP_NS_INSTITUTION_TALK, |
| 241 | + ); |
| 242 | + |
| 243 | + $exists = null; |
| 244 | + |
236 | 245 | if ( array_key_exists( $title->getNamespace(), $classes ) ) { |
237 | 246 | $links['views'] = array(); |
238 | 247 | $links['actions'] = array(); |
— | — | @@ -277,14 +286,23 @@ |
278 | 287 | } |
279 | 288 | } |
280 | 289 | } |
| 290 | + } |
| 291 | + |
| 292 | + if ( in_array( $title->getNamespace(), $ns ) ) { |
| 293 | + $subjectTitle = $title->getSubjectPage(); |
281 | 294 | |
| 295 | + if ( is_null( $exists ) ) { |
| 296 | + $class = $classes[$subjectTitle->getNamespace()]; |
| 297 | + $exists = $class::hasIdentifier( $title->getText() ); |
| 298 | + } |
| 299 | + |
282 | 300 | $tab = array_shift( $links['namespaces'] ); |
283 | | - self::fixNewClass( $tab, $exists ); |
| 301 | + self::fixRedlinking( $tab, $exists, $subjectTitle ); |
284 | 302 | array_unshift( $links['namespaces'], $tab ); |
285 | | - } |
| 303 | + } |
286 | 304 | } |
287 | 305 | |
288 | | - protected static function fixNewClass( &$tab, $exists ) { |
| 306 | + protected static function fixRedlinking( array &$tab, $exists, Title $title ) { |
289 | 307 | $classes = explode( ' ', $tab['class'] ); |
290 | 308 | $classes = array_flip( $classes ); |
291 | 309 | |
— | — | @@ -299,6 +317,15 @@ |
300 | 318 | } |
301 | 319 | |
302 | 320 | $tab['class'] = implode( ' ', $classes ); |
| 321 | + |
| 322 | + $query = array(); |
| 323 | + |
| 324 | + if ( !$exists ) { |
| 325 | + $query['action'] = 'edit'; |
| 326 | + $query['redlink'] = '1'; |
| 327 | + } |
| 328 | + |
| 329 | + $tab['href'] = $title->getLocalURL( $query ); |
303 | 330 | } |
304 | 331 | |
305 | 332 | } |