summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/WfextStyle/wikifabstyle.php
blob: c9a301806b4100b6e6883e017afc2aaf1e5e688f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php

$wgMessagesDirs['WfExtStyle'] = __DIR__ . "/i18n";

$wgResourceModules['ext.Wikifab.js'] = array(
	'scripts' => 'wikifab-style.js',
	'styles' => array(),
	'messages' => array(
	),
	'dependencies' => array(
			'jquery.ui.core'
	),
	'position' => 'bottom',
	'localBasePath' => __DIR__ . '',
	'remoteExtPath' => 'WfextStyle',
);

$wgResourceModules['ext.Wikifab.css'] = array(
	'styles' => array(
		'wikifab-style.css',
	),
	'localBasePath' => __DIR__,
	'remoteExtPath' => 'WfextStyle',
);

// Specify the function that will change the user menu.
$wgHooks['PersonalUrls'][] = 'PersonalUrlsWikifabCustom';
function PersonalUrlsWikifabCustom( &$personal_urls, &$title, $that  ) {
	unset($personal_urls['mytalk']);
	if(isset($personal_urls['userpage']['text'])) {
		$personal_urls['userpage']['text'] = wfMessage( 'wfextstyle-my_profil');
	}
	if(isset($personal_urls['anonuserpage'])) {
		unset($personal_urls['anonuserpage']);
	}
	if(isset($personal_urls['anontalk'])) {
		unset($personal_urls['anontalk']);
	}
	if(isset($personal_urls['watchlist'])) {
		unset($personal_urls['watchlist']);
	}
	if(isset($personal_urls['mycontris'])) {
		unset($personal_urls['mycontris']);
	}
}

$wgWikifabStyleForceUpdate = true;

// hook to launch synchronous update properties of new pages
// this has been added because if not, after create new page,
// the page has not instantly his properties, and so the forms links (action=formedit) are not setted
$wgHooks['ArticleEditUpdates'][] = 'wfExtStyleArticleEditUpdates';
function wfExtStyleArticleEditUpdates( WikiPage $wikipage, $editInfo, $changed  ) {
	global $wgWikifabStyleForceUpdate;
	if ($wgWikifabStyleForceUpdate) {
		$title = $wikipage->getTitle();
		$output = $editInfo->output;

		if( ! $editInfo->oldContent ) {
			$linksUpdate = new LinksUpdate( $title, $output, $recursive = false );
			$linksUpdate->doUpdate();
		}
	}
}


$wgHooks['ParserMakeImageParams'][] = 'onParserMakeImageParams';
function onParserMakeImageParams( $title, $file, &$params, $parser ) {
	if(method_exists($file, 'getMimeType')){
		switch ($file->getMimeType()) {
			case 'application/sla':
				$params['frame']['class'] = 'file-3D';
				break;
			case 'video/mp4':
				$params['frame']['class'] = 'videofile';
				break;
		}
	}
	return true;
}

$wgHooks['BeforePageDisplay'][] = 'onBeforePageDisplay';
function onBeforePageDisplay( OutputPage &$out, Skin &$skin ) {
		$out->addModuleStyles('ext.Wikifab.css');
}