00001 <?php
00002
00017 import('lib.pkp.classes.plugins.GenericPlugin');
00018
00019 define('TINYMCE_INSTALL_PATH', 'lib/pkp/lib/tinymce');
00020 define('TINYMCE_JS_PATH', TINYMCE_INSTALL_PATH . '/jscripts/tiny_mce');
00021
00022 class TinyMCEPlugin extends GenericPlugin {
00030 function register($category, $path) {
00031 if (parent::register($category, $path)) {
00032 if ($this->isMCEInstalled() && $this->getEnabled()) {
00033 HookRegistry::register('TemplateManager::display',array(&$this, 'callback'));
00034 }
00035 return true;
00036 }
00037 return false;
00038 }
00039
00045 function getContextSpecificPluginSettingsFile() {
00046 return $this->getPluginPath() . '/settings.xml';
00047 }
00048
00054 function getInstallSitePluginSettingsFile() {
00055 return $this->getPluginPath() . '/settings.xml';
00056 }
00057
00064 function callback($hookName, $args) {
00065 $request =& Registry::get('request');
00066 $templateManager =& $args[0];
00067
00068 $baseUrl = $templateManager->get_template_vars('baseUrl');
00069 $additionalHeadData = $templateManager->get_template_vars('additionalHeadData');
00070 $allLocales = AppLocale::getAllLocales();
00071 $localeList = array();
00072 foreach ($allLocales as $key => $locale) {
00073 $localeList[] = String::substr($key, 0, 2);
00074 }
00075
00076 $tinymceScript = '
00077 <script type="text/javascript" src="'.$baseUrl.'/'.TINYMCE_JS_PATH.'/tiny_mce_gzip.js"></script>
00078 <script type="text/javascript">
00079 <!--
00080 tinyMCE_GZ.init({
00081 relative_urls: "false",
00082 plugins: "paste,jbimages,fullscreen",
00083 themes: "advanced",
00084 languages: "' . join(',', $localeList) . '",
00085 disk_cache: true
00086 });
00087 // -->
00088 </script>
00089 <script type="text/javascript">
00090 <!--
00091 tinyMCE.init({
00092 width: "100%",
00093 entity_encoding: "raw",
00094 plugins: "paste,jbimages,fullscreen",
00095 mode: "specific_textareas",
00096 editor_selector: "richContent",
00097 language: "' . String::substr(AppLocale::getLocale(), 0, 2) . '",
00098 relative_urls: false,
00099 forced_root_block: "p",
00100 paste_auto_cleanup_on_paste: true,
00101 apply_source_formatting: false,
00102 theme : "advanced",
00103 theme_advanced_buttons1: "cut,copy,paste,|,bold,italic,underline,bullist,numlist,|,link,unlink,help,code,fullscreen,jbimages",
00104 theme_advanced_buttons2: "",
00105 theme_advanced_buttons3: "",
00106 init_instance_callback: $.pkp.controllers.SiteHandler.prototype.triggerTinyMCEInitialized
00107 });
00108 // -->
00109 </script>';
00110
00111 $templateManager->assign('additionalHeadData', $additionalHeadData."\n".$tinymceScript);
00112 return false;
00113 }
00114
00119 function getDisplayName() {
00120 return __('plugins.generic.tinymce.name');
00121 }
00122
00127 function getDescription() {
00128 if ($this->isMCEInstalled()) return __('plugins.generic.tinymce.description');
00129 return __('plugins.generic.tinymce.descriptionDisabled', array('tinyMcePath' => TINYMCE_INSTALL_PATH));
00130 }
00131
00136 function isMCEInstalled() {
00137 return file_exists(TINYMCE_JS_PATH . '/tiny_mce.js');
00138 }
00139
00144 function getManagementVerbs() {
00145 $verbs = array();
00146 if ($this->isMCEInstalled()) $verbs = parent::getManagementVerbs();
00147 return $verbs;
00148 }
00149 }
00150 ?>