Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
TinyMCEPlugin.inc.php
1 <?php
2 
18 import('lib.pkp.classes.plugins.GenericPlugin');
19 
20 define('TINYMCE_INSTALL_PATH', 'lib/pkp/lib/tinymce');
21 define('TINYMCE_JS_PATH', TINYMCE_INSTALL_PATH . '/jscripts/tiny_mce');
22 
31  function register($category, $path) {
32  if (parent::register($category, $path)) {
33  if ($this->isMCEInstalled() && $this->getEnabled()) {
34  HookRegistry::register('TemplateManager::display',array(&$this, 'callback'));
35  }
36  return true;
37  }
38  return false;
39  }
40 
47  return $this->getPluginPath() . '/settings.xml';
48  }
49 
56  return $this->getPluginPath() . '/settings.xml';
57  }
58 
65  function callback($hookName, $args) {
66  $request =& Registry::get('request');
67  $templateManager =& $args[0];
68 
69  $baseUrl = $templateManager->get_template_vars('baseUrl');
70  $additionalHeadData = $templateManager->get_template_vars('additionalHeadData');
71  $allLocales = AppLocale::getAllLocales();
72  $localeList = array();
73  foreach ($allLocales as $key => $locale) {
74  $localeList[] = String::substr($key, 0, 2);
75  }
76 
77  $tinymceScript = '
78  <script type="text/javascript" src="'.$baseUrl.'/'.TINYMCE_JS_PATH.'/tiny_mce_gzip.js"></script>
79  <script type="text/javascript">
80  <!--
81  tinyMCE_GZ.init({
82  relative_urls: "false",
83  plugins: "paste,jbimages,fullscreen",
84  themes: "advanced",
85  languages: "' . join(',', $localeList) . '",
86  disk_cache: true
87  });
88  // -->
89  </script>
90  <script type="text/javascript">
91  <!--
92  tinyMCE.init({
93  width: "100%",
94  entity_encoding: "raw",
95  plugins: "paste,jbimages,fullscreen",
96  mode: "specific_textareas",
97  editor_selector: "richContent",
98  language: "' . String::substr(AppLocale::getLocale(), 0, 2) . '",
99  relative_urls: false,
100  forced_root_block: "p",
101  paste_auto_cleanup_on_paste: true,
102  apply_source_formatting: false,
103  theme : "advanced",
104  theme_advanced_buttons1: "cut,copy,paste,|,bold,italic,underline,bullist,numlist,|,link,unlink,help,code,fullscreen,jbimages",
105  theme_advanced_buttons2: "",
106  theme_advanced_buttons3: "",
107  init_instance_callback: $.pkp.controllers.SiteHandler.prototype.triggerTinyMCEInitialized,
108  setup: $.pkp.controllers.SiteHandler.prototype.triggerTinyMCESetup
109  });
110  // -->
111  </script>';
112 
113  $templateManager->assign('additionalHeadData', $additionalHeadData."\n".$tinymceScript);
114  return false;
115  }
116 
121  function getDisplayName() {
122  return __('plugins.generic.tinymce.name');
123  }
124 
129  function getDescription() {
130  if ($this->isMCEInstalled()) return __('plugins.generic.tinymce.description');
131  return __('plugins.generic.tinymce.descriptionDisabled', array('tinyMcePath' => TINYMCE_INSTALL_PATH));
132  }
133 
138  function isMCEInstalled() {
139  return file_exists(TINYMCE_JS_PATH . '/tiny_mce.js');
140  }
141 
146  function getManagementVerbs() {
147  $verbs = array();
148  if ($this->isMCEInstalled()) $verbs = parent::getManagementVerbs();
149  return $verbs;
150  }
151 }
152 
153 ?>
static substr($string, $start, $length=false)
Definition: String.inc.php:187
getContextSpecificPluginSettingsFile()
TinyMCE WYSIWYG plugin for textareas - to allow cross-browser HTML editing.
static & getAllLocales()
static getLocale()
Abstract class for generic plugins.
getPluginPath()
Definition: Plugin.inc.php:324
callback($hookName, $args)
static & get($key, $createIfEmpty=false, $createWithDefault=null)
static register($hookName, $callback)