Added an extension, called EditSectionHiliteLink, that highlights the appropriate...
[lhc/web/wiklou.git] / extensions / EditSectionHiliteLink / EditSectionHiliteLink.hooks.php
1 <?php
2 /**
3 * Hooks for EditSectionHiliteLink extension
4 *
5 * @file
6 * @ingroup Extensions
7 */
8
9 class EditSectionHiliteLinkHooks {
10
11 /* Static Functions */
12
13 /**
14 * interceptLink hook
15 */
16 public static function interceptLink($this, $nt, $section, $tooltip, &$result) {
17 global $wgSectionContainers;
18
19 if ( $wgSectionContainers ) {
20 $section = $section -1;
21 $section_name = 'section_' . $section . '_container';
22 $result = preg_replace('/(\D+)( title=)(\D+)/', '${1} onmouseover="editSectionHiliteOn(\'' . $section_name . '\')" onmouseout="editSectionHiliteOff(\'' . $section_name . '\')" title=$3', $result);
23 }
24 return true;
25 }
26
27 /**
28 * AjaxAddScript hook
29 * Add ajax support script
30 */
31 public static function addJS(
32 $out
33 ) {
34 global $wgScriptPath, $wgJsMimeType, $wgEditSectionHiliteLinkStyleVersion;
35 // FIXME: assumes standard dir structure
36 // Add javascript to support section edit link highlighting saving
37 $out->addScript(
38 Xml::element(
39 'script',
40 array(
41 'type' => $wgJsMimeType,
42 'src' => $wgScriptPath . '/extensions/EditSectionHiliteLink/EditSectionHiliteLink.js?' .
43 $wgEditSectionHiliteLinkStyleVersion
44 ),
45 '',
46 false
47 )
48 );
49 // Continue
50 return true;
51 }
52
53 /**
54 * BeforePageDisplay hook
55 * Add css style sheet
56 */
57 public static function addCSS(
58 $out
59 ) {
60 global $wgScriptPath, $wgEditSectionHiliteLinkStyleVersion;
61 // FIXME: assumes standard dir structure
62 // Add css for various styles
63 $out->addLink(
64 array(
65 'rel' => 'stylesheet',
66 'type' => 'text/css',
67 'href' => $wgScriptPath . '/extensions/EditSectionHiliteLink/EditSectionHiliteLink.css?' .
68 $wgEditSectionHiliteLinkStyleVersion,
69 )
70 );
71 // Continue
72 return true;
73 }
74 }