This repository has been archived by the owner on May 5, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwow.php
executable file
·86 lines (69 loc) · 2.6 KB
/
wow.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
/**
* @author Branko Wilhelm <branko.wilhelm@gmail.com>
* @link http://www.z-index.net
* @copyright (c) 2013 - 2016 Branko Wilhelm
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die;
class plgSystemWow extends JPlugin
{
protected $autoloadLanguage = true;
public function onAfterInitialise()
{
JLoader::register('WoW', JPATH_LIBRARIES . '/WoW/WoW.php');
if (class_exists('WoW'))
{
WoW::getInstance($this->params); // define instance with params
} else
{
JFactory::getApplication()->enqueueMessage(JText::_('PLG_SYSTEM_WOW_LIBRARY_MISSING'), 'error');
}
}
public function onBeforeRender()
{
$app = JFactory::getApplication();
$doc = JFactory::getDocument();
if ($app->isAdmin() && JFactory::getUser()->id)
{
if (
!$this->params->get('client_id') ||
!$this->params->get('client_secret') ||
!$this->params->get('guild') ||
!$this->params->get('realm') ||
!$this->params->get('region')
)
{
$app->enqueueMessage(JText::_('PLG_SYSTEM_WOW_CONFIGURATION_MISSING'), 'error');
return true;
}
if ($doc instanceof JDocumentHTML && $this->params->get('status', true))
{
$buffer = $doc->getBuffer('modules', 'status');
$buffer .= '<div class="btn-group">';
$buffer .= '<span class="badge">WoW</span> ';
$buffer .= '<a href="' . JRoute::_('index.php?option=com_plugins&view=plugins&filter_folder=system&filter_search=wow') . '">';
$buffer .= $this->params->get('guild') . ' @ ' . strtoupper($this->params->get('region')) . '-' . $this->params->get('realm');
$buffer .= '</a>';
$buffer .= '</div>';
$doc->setBuffer($buffer, 'modules', 'status');
}
}
}
public function onBeforeCompileHead()
{
$app = JFactory::getApplication();
$Itemid = $app->input->getInt('Itemid') ? $app->input->getInt('Itemid') : 0;
if ($app->isAdmin())
{
return;
}
JHtml::_('jquery.framework');
$doc = JFactory::getDocument();
$doc->addScript('media/wow/wow.js');
$doc->addStyleSheet('media/wow/wow.css');
$js = 'window.wow.base="' . JUri::base(true) . '";';
$js .= 'window.wow.Itemid=' . $Itemid . ';';
$doc->addScriptDeclaration($js);
}
}