/
AddRobotMetaPlugin.inc.php
71 lines (53 loc) · 1.48 KB
/
AddRobotMetaPlugin.inc.php
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
<?php
/**
* @file plugins/generic/addRobotMeta/AddRobotMetaPlugin.inc.php
*
* Copyright (c) 2015 Antti-Jussi Nygård
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* @class AddRobotMetaPlugin
* @ingroup plugins_generic_addRobotMeta
*
* @brief Add robot meta for hidden unpublished journals, just because
*/
import('lib.pkp.classes.plugins.GenericPlugin');
class AddRobotMetaPlugin extends GenericPlugin {
function register($category, $path) {
if (parent::register($category, $path)) {
HookRegistry::register('TemplateManager::display', array(&$this, 'addmeta'));
return true;
}
return false;
}
function getName() {
return 'AddRobotMeta';
}
function getDisplayName() {
return "AddRobotMeta plugin";
}
function getEnabled() {
return true;
}
function isSitePlugin() {
return true;
}
function getManagementVerbs() {
return array();
}
function getDescription() {
return "Add robot meta for hidden journals to prevent unwanted indexing";
}
function addmeta($hookName, $args) {
$journal =& Request::getJournal();
if (isset($journal)){
$isEnabled = $journal->getEnabled();
if ($isEnabled == 0){
$templateManager =& $args[0];
$additionalHeadData = $templateManager->get_template_vars('additionalHeadData');
$robottext = '<meta name="robots" content="noindex, nofollow">';
$templateManager->assign('additionalHeadData', $additionalHeadData."\n\t".$robottext);
}
}
}
}
?>