-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLocaleRedirectPlugin.inc.php
70 lines (56 loc) · 1.77 KB
/
LocaleRedirectPlugin.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
<?php
import('lib.pkp.classes.plugins.GenericPlugin');
class LocaleRedirectPlugin extends GenericPlugin
{
function register($category, $path)
{
if (parent::register($category, $path)) {
if ($this->getEnabled()) {
// handle locales redirect
HookRegistry::register('LoadHandler', array($this, 'handleLocaleRequest'));
// add info about locale urls for google inside head
HookRegistry::register('ArticleHandler::view',array(&$this, 'articleView'));
}
return true;
}
return false;
}
/**
* Get the plugin display name.
* @return string
*/
function getDisplayName()
{
return __('plugins.generic.localeRedirect.displayName');
}
/**
* Get the plugin description.
* @return string
*/
function getDescription()
{
return __('plugins.generic.localeRedirect.description');
}
function handleLocaleRequest($hookName, $args)
{
$page = $args[0];
$op = $args[1];
$sourceFile = $args[2];
$request = $this->getRequest();
$templateMgr = TemplateManager::getManager($request);
if ($page == "login") return false;
//AppLocale::setLocale("uk_UA");
if ($_GET["locale"] == "uk_UA") {
AppLocale::setLocale("uk_UA");
print_r($request->getSession()->getSessionData());
} elseif ($_GET["locale"] == "en_US") {
AppLocale::setLocale("en_US");
print_r($request->getSession()->getSessionData());
}
}
function articleView ($hookName, $args) {
$request = $args[0];
$templateMgr = TemplateManager::getManager($request);
//$templateMgr->addHeader();
}
}