-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExampleSIRIndexer.hooks.php
More file actions
35 lines (31 loc) · 1.02 KB
/
ExampleSIRIndexer.hooks.php
File metadata and controls
35 lines (31 loc) · 1.02 KB
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
<?php
/**
* Hooks for BoilerPlate extension
*
* @file
* @ingroup Extensions
*/
class ExampleSIRIndexerHooks {
static function onPageContentSaveComplete($article, $user, $content, $summary, $isMinor,
$isWatch, $section, $flags, $status) {
$pageName = $article->mTitle->mUrlform;
$categories = Page::getMWPropertyInstanceValues($pageName, 'categories');
if(in_array('Subject', $categories)) {
#error_log('A');
$_SESSION['elasticIndexThisPage'] = 'true';
}
return true;
}
static function onOutputPageParserOutput( OutputPage &$out, ParserOutput $parseroutput ) {
$pageName = $out->getPageTitle();
if($pageName <> "" && $_SESSION['elasticIndexThisPage'] == 'true') {
$categories = Page::getMWPropertyInstanceValues($pageName, 'categories');
if(in_array('Subject', $categories)) {
$subjectIndexer = new ExampleElasticsearchSubjectIndexer($pageName);
$subjectIndexer->indexPage();
}
}
$_SESSION['elasticIndexThisPage'] = 'false';
return true;
}
}