Open Journal Systems  3.3.0
BootstrapThreeThemePlugin.inc.php
1 <?php
2 
16 import('lib.pkp.classes.plugins.ThemePlugin');
23  public function init() {
24 
25  // Register option for bootstrap themes
26  $this->addOption('bootstrapTheme', 'radio', array(
27  'label' => 'plugins.themes.bootstrap3.options.bootstrapTheme.label',
28  'description' => 'plugins.themes.bootstrap3.options.bootstrapTheme.description',
29  'options' => array(
30  'bootstrap3' => 'plugins.themes.bootstrap3.options.bootstrapTheme.bootstrap3',
31  'cerulean' => 'plugins.themes.bootstrap3.options.bootstrapTheme.cerulean',
32  'cleanblog' => 'plugins.themes.bootstrap3.options.bootstrapTheme.cleanblog',
33  'cosmo' => 'plugins.themes.bootstrap3.options.bootstrapTheme.cosmo',
34  'cyborg' => 'plugins.themes.bootstrap3.options.bootstrapTheme.cyborg',
35  'darkly' => 'plugins.themes.bootstrap3.options.bootstrapTheme.darkly',
36  'flatly' => 'plugins.themes.bootstrap3.options.bootstrapTheme.flatly',
37  'journal' => 'plugins.themes.bootstrap3.options.bootstrapTheme.journal',
38  'lumen' => 'plugins.themes.bootstrap3.options.bootstrapTheme.lumen',
39  'paper' => 'plugins.themes.bootstrap3.options.bootstrapTheme.paper',
40  'readable' => 'plugins.themes.bootstrap3.options.bootstrapTheme.readable',
41  'sandstone' => 'plugins.themes.bootstrap3.options.bootstrapTheme.sandstone',
42  'simplex' => 'plugins.themes.bootstrap3.options.bootstrapTheme.simplex',
43  'slate' => 'plugins.themes.bootstrap3.options.bootstrapTheme.slate',
44  'spacelab' => 'plugins.themes.bootstrap3.options.bootstrapTheme.spacelab',
45  'superhero' => 'plugins.themes.bootstrap3.options.bootstrapTheme.superhero',
46  'united' => 'plugins.themes.bootstrap3.options.bootstrapTheme.united',
47  'yeti' => 'plugins.themes.bootstrap3.options.bootstrapTheme.yeti',
48  )
49  ));
50 
51  $bootstrapTheme = $this->getOption('bootstrapTheme');
52  if (empty($bootstrapTheme) || $bootstrapTheme === 'bootstrap3') {
53  $this->addStyle('bootstrap', 'styles/bootstrap.less');
54  } else {
55  $this->addStyle('bootstrapTheme-' . $bootstrapTheme, 'styles/' . $bootstrapTheme . '.less');
56  }
57 
58  $locale = AppLocale::getLocale();
59  if (AppLocale::getLocaleDirection($locale) === 'rtl') {
60  if (Config::getVar('general', 'enable_cdn')) {
61  $this->addStyle('bootstrap-rtl', '//cdn.rawgit.com/morteza/bootstrap-rtl/v3.3.4/dist/css/bootstrap-rtl.min.css', array('baseUrl' => ''));
62  } else {
63  $this->addStyle('bootstrap-rtl', 'styles/bootstrap-rtl.min.css');
64  }
65  }
66 
67  // Load jQuery from a CDN or, if CDNs are disabled, from a local copy.
68  $min = Config::getVar('general', 'enable_minified') ? '.min' : '';
69  $request = Application::get()->getRequest();
70  if (Config::getVar('general', 'enable_cdn')) {
71  $jquery = '//ajax.googleapis.com/ajax/libs/jquery/' . CDN_JQUERY_VERSION . '/jquery' . $min . '.js';
72  $jqueryUI = '//ajax.googleapis.com/ajax/libs/jqueryui/' . CDN_JQUERY_UI_VERSION . '/jquery-ui' . $min . '.js';
73  } else {
74  // Use OJS's built-in jQuery files
75  $jquery = $request->getBaseUrl() . '/lib/pkp/lib/vendor/components/jquery/jquery' . $min . '.js';
76  $jqueryUI = $request->getBaseUrl() . '/lib/pkp/lib/vendor/components/jqueryui/jquery-ui' . $min . '.js';
77  }
78  // Use an empty `baseUrl` argument to prevent the theme from looking for
79  // the files within the theme directory
80  $this->addScript('jQuery', $jquery, array('baseUrl' => ''));
81  $this->addScript('jQueryUI', $jqueryUI, array('baseUrl' => ''));
82  $this->addScript('jQueryTagIt', $request->getBaseUrl() . '/lib/pkp/js/lib/jquery/plugins/jquery.tag-it.js', array('baseUrl' => ''));
83 
84  // Load Bootstrap
85  $this->addScript('bootstrap', 'bootstrap/js/bootstrap.min.js');
86 
87  // Add navigation menu areas for this theme
88  $this->addMenuArea(array('primary', 'user'));
89  }
90 
95  function getDisplayName() {
96  return __('plugins.themes.bootstrap3.name');
97  }
98 
103  function getDescription() {
104  return __('plugins.themes.bootstrap3.description');
105  }
106 }
BootstrapThreeThemePlugin\getDescription
getDescription()
Definition: BootstrapThreeThemePlugin.inc.php:103
ThemePlugin
Abstract class for theme plugins.
Definition: ThemePlugin.inc.php:21
ThemePlugin\addMenuArea
addMenuArea($menuAreas)
Definition: ThemePlugin.inc.php:662
BootstrapThreeThemePlugin
Default theme.
Definition: BootstrapThreeThemePlugin.inc.php:17
ThemePlugin\getOption
getOption($name)
Definition: ThemePlugin.inc.php:454
ThemePlugin\addScript
addScript($name, $script, $args=array())
Definition: ThemePlugin.inc.php:304
ThemePlugin\addOption
addOption($name, $type, $args=array())
Definition: ThemePlugin.inc.php:393
PKPLocale\getLocaleDirection
static getLocaleDirection($locale)
Definition: PKPLocale.inc.php:465
Config\getVar
static getVar($section, $key, $default=null)
Definition: Config.inc.php:35
BootstrapThreeThemePlugin\init
init()
Definition: BootstrapThreeThemePlugin.inc.php:23
Plugin\$request
$request
Definition: Plugin.inc.php:68
ThemePlugin\addStyle
addStyle($name, $style, $args=array())
Definition: ThemePlugin.inc.php:191
PKPApplication\get
static get()
Definition: PKPApplication.inc.php:235
AppLocale\getLocale
static getLocale()
Definition: env1/MockAppLocale.inc.php:40
BootstrapThreeThemePlugin\getDisplayName
getDisplayName()
Definition: BootstrapThreeThemePlugin.inc.php:95