forked from cul/cdrs-bootstrappish
/
BootstrappishThemePlugin.inc.php
executable file
·86 lines (68 loc) · 2.34 KB
/
BootstrappishThemePlugin.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
<?php
/**
* @file BootstrappishThemePlugin.inc.php
*
* Copyright (c) 2013 Christopher Anderton
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* @class BootstrappishThemePlugin
* @ingroup plugins_themes_bootstrappish
*
* @brief "Bootstrappish" theme plugin
*/
//$Id$
import('classes.plugins.ThemePlugin');
class BootstrappishThemePlugin extends ThemePlugin {
/**
* Get the name of this plugin. The name must be unique within
* its category.
* @return String name of plugin
*/
function getName() {
return 'BootstrappishThemePlugin';
}
function getDisplayName() {
return 'Bootstrappish Theme';
}
function getDescription() {
return 'Remaps twitter Bootstrap to fit PKP without modifying templates';
}
function getStylesheetFilename() {
return 'bootstrap.css';
}
function getLocaleFilename($locale) {
return null; // No locale data
}
/**
* Add a page-specific script.
*
* Note: Implementing for OCS v2.5.3 support
*
* @param $url string the URL to be included
*/
function addJavaScript(&$templateMgr, $url) {
$extra_js = '<script type="text/javascript" src="' . Request::getBaseUrl() . '/' . $url . '"></script>';
$templateMgr->assign('additionalHeadData', $additionalHeadData . "\n" . $extra_js);
}
/**
* Activate the theme.
*/
function activate(&$templateMgr) {
// Add in jQuery from CMS
$jQueryCMS = ' <script language="javascript" type="text/javascript" src="http://code.jquery.com/jquery.js"></script>';
$additionalHeadData = $templateMgr->get_template_vars('additionalHeadData');
$templateMgr->assign('additionalHeadData', $additionalHeadData."\n".$jQueryCMS);
// Method addJavaScript doesn't exists on OCS v2.3.5.
// Not even the javascript array as in the case of stylesheets
$object_aux = ( method_exists($templateMgr, 'addJavaScript') ) ? $templateMgr : $this;
// Add in Bootstrap JS
$object_aux->addJavaScript($templateMgr, 'plugins/themes/bootstrappish/js/bootstrap.min.js');
// Add in custom JS scripts to hold miscellany
$object_aux->addJavaScript($templateMgr, 'plugins/themes/bootstrappish/js/custom.js');
if (($stylesheetFilename = $this->getStylesheetFilename()) != null) {
$path = Request::getBaseUrl() . '/' . $this->getPluginPath() . '/css/' . $stylesheetFilename .'?bootstrappish';
$templateMgr->addStyleSheet($path);
}
}
}
?>