-
Notifications
You must be signed in to change notification settings - Fork 0
/
VoyeurBlockPlugin.inc.php
117 lines (100 loc) · 3.22 KB
/
VoyeurBlockPlugin.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
/**
* @file VoyeurBlockPlugin.inc.php
*
* Copyright (c) 2010 Corey Slavnik and Stéfan Sinclair
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* @class VoyeurBlockPlugin
* @ingroup plugins_generic_voyeur
*
* @brief Class for block component of the Voyeur plugin.
*/
/**
* On June 2nd, 2010, the Voyeur plugin for Open Journal Systems was created.
* This program is distributed under GNU GPL v2, but is based off of the
* 'WebFeedPlugin' distributed with Open Journal Systems software, which
* was originally created and maintained by John Willinsky. Thank you.
*/
import('plugins.BlockPlugin');
class VoyeurBlockPlugin extends BlockPlugin {
/**
* Get the name of this plugin. The name must be unique within
* its category.
* @return string
* The name of the plugin.
*/
function getName() {
return 'VoyeurBlockPlugin';
}
/**
* Get the display name of this plugin.
* @return string
*/
function getDisplayName() {
return Locale::translate('plugins.generic.voyeur.displayName');
}
/**
* Get a description of the plugin.
* @return string
*/
function getDescription() {
return Locale::translate('plugins.generic.voyeur.description');
}
/**
* Get the supported contexts (e.g. BLOCK_CONTEXT_...) for this block.
* @return array
*/
function getSupportedContexts() {
return array(BLOCK_CONTEXT_LEFT_SIDEBAR, BLOCK_CONTEXT_RIGHT_SIDEBAR);
}
/**
* Get the Voyeur plugin
* @return object
*/
function &getVoyeurPlugin() {
$plugin =& PluginRegistry::getPlugin('generic', 'VoyeurPlugin');
return $plugin;
}
/**
* Override the builtin to get the correct plugin path.
* @return string
*/
function getPluginPath() {
$plugin =& $this->getVoyeurPlugin();
return $plugin->getPluginPath();
}
/**
* Override the builtin to get the correct template path.
* @return string
*/
function getTemplatePath() {
$plugin =& $this->getVoyeurPlugin();
return $plugin->getTemplatePath() . 'templates/';
}
/**
* Get the HTML contents for this block.
* @param $templateMgr object
* @return $string
*/
function getContents(&$templateManager) {
$journal =& Request::getJournal();
if (!$journal) return '';
$plugin =& $this->getVoyeurPlugin();
$displayPage = $plugin->getSetting($journal->getJournalId(), 'displayPage');
$requestedPage = Request::getRequestedPage();
$issueDao = &DAORegistry::getDAO('IssueDAO');
$currentIssue =& $issueDao->getCurrentIssue($journal->getJournalId());
// Define vars to be used in block.tpl.
$templateManager->assign('voyeurWidth', $plugin->getSetting($journal->getJournalId(), 'voyeurWidth'));
$templateManager->assign('voyeurHeight', $plugin->getSetting($journal->getJournalId(), 'voyeurHeight'));
if (!isset($displayPage)) // If admin has not set where to display Voyeur, make a default of showing it everywhere.
$displayPage = 'all';
if (($currentIssue) && (($displayPage == 'all') || ($displayPage == 'homepage' && (empty($requestedPage) || $requestedPage == 'index' || $requestedPage == 'issue')) || ($displayPage == 'issue' && $displayPage == $requestedPage)) ) {
return parent::getContents($templateManager);
} else {
return '';
}
} // end getContents()
} // end VoyeurBlock class
?>