Dotclear

source: plugins/dcLegacyEditor/inc/dc.legacy.editor.behaviors.php @ 2736:09dd799a19bd

Revision 2736:09dd799a19bd, 5.5 KB checked in by Nicolas <nikrou77@…>, 11 years ago (diff)

Addresses #1896
Preferences: one editor for each available formats.

Line 
1<?php
2# -- BEGIN LICENSE BLOCK ---------------------------------------
3#
4# This file is part of Dotclear 2.
5#
6# Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear
7# Licensed under the GPL version 2.0 license.
8# See LICENSE file or
9# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
10#
11# -- END LICENSE BLOCK -----------------------------------------
12
13class dcLegacyEditorBehaviors
14{
15     protected static $p_url = 'index.php?pf=dcLegacyEditor';
16
17     public static function adminPostEditor($editor) {
18          global $core;
19
20          if ($editor!='dcLegacyEditor') {
21               return;
22          }
23
24          return
25               self::jsToolBar().
26               dcPage::jsLoad(self::$p_url.'/js/_post_editor.js');
27     }
28
29     public static function adminPopupMedia() {
30          return dcPage::jsLoad(self::$p_url.'/js/jsToolBar/popup_media.js');
31     }
32
33     public static function adminPopupLink() {
34          return dcPage::jsLoad(self::$p_url.'/js/jsToolBar/popup_link.js');
35     }
36
37     public static function adminPopupPosts() {
38          return dcPage::jsLoad(self::$p_url.'/js/jsToolBar/popup_posts.js');
39     }
40
41     protected static function jsToolBar() {
42          $res =
43          '<link rel="stylesheet" type="text/css" href="'.self::$p_url.'/css/jsToolBar/jsToolBar.css" />'.
44          '<script type="text/javascript" src="'.self::$p_url.'/js/jsToolBar/jsToolBar.js"></script>';
45
46          if (isset($GLOBALS['core']->auth) && $GLOBALS['core']->auth->getOption('enable_wysiwyg')) {
47               $res .= '<script type="text/javascript" src="'.self::$p_url.'/js/jsToolBar/jsToolBar.wysiwyg.js"></script>';
48          }
49
50          $res .=
51          '<script type="text/javascript" src="'.self::$p_url.'/js/jsToolBar/jsToolBar.dotclear.js"></script>'.
52          '<script type="text/javascript">'."\n".
53          "//<![CDATA[\n".
54          "jsToolBar.prototype.dialog_url = 'popup.php'; ".
55          "jsToolBar.prototype.iframe_css = '".
56          'body{'.
57          'font: 12px "DejaVu Sans","Lucida Grande","Lucida Sans Unicode",Arial,sans-serif;'.
58          'color : #000;'.
59          'background: #f9f9f9;'.
60          'margin: 0;'.
61          'padding : 2px;'.
62          'border: none;'.
63          (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl' ? 'direction:rtl;' : '').
64          '}'.
65          'pre, code, kbd, samp {'.
66          'font-family:"Courier New",Courier,monospace;'.
67          'font-size : 1.1em;'.
68          '}'.
69          'code {'.
70          'color : #666;'.
71          'font-weight : bold;'.
72          '}'.
73          'body > p:first-child {'.
74          'margin-top: 0;'.
75          '}'.
76          "'; ".
77          "jsToolBar.prototype.base_url = '".html::escapeJS($GLOBALS['core']->blog->host)."'; ".
78          "jsToolBar.prototype.switcher_visual_title = '".html::escapeJS(__('visual'))."'; ".
79          "jsToolBar.prototype.switcher_source_title = '".html::escapeJS(__('source'))."'; ".
80          "jsToolBar.prototype.legend_msg = '".
81          html::escapeJS(__('You can use the following shortcuts to format your text.'))."'; ".
82          "jsToolBar.prototype.elements.blocks.options.none = '".html::escapeJS(__('-- none --'))."'; ".
83          "jsToolBar.prototype.elements.blocks.options.nonebis = '".html::escapeJS(__('-- block format --'))."'; ".
84          "jsToolBar.prototype.elements.blocks.options.p = '".html::escapeJS(__('Paragraph'))."'; ".
85          "jsToolBar.prototype.elements.blocks.options.h1 = '".html::escapeJS(__('Level 1 header'))."'; ".
86          "jsToolBar.prototype.elements.blocks.options.h2 = '".html::escapeJS(__('Level 2 header'))."'; ".
87          "jsToolBar.prototype.elements.blocks.options.h3 = '".html::escapeJS(__('Level 3 header'))."'; ".
88          "jsToolBar.prototype.elements.blocks.options.h4 = '".html::escapeJS(__('Level 4 header'))."'; ".
89          "jsToolBar.prototype.elements.blocks.options.h5 = '".html::escapeJS(__('Level 5 header'))."'; ".
90          "jsToolBar.prototype.elements.blocks.options.h6 = '".html::escapeJS(__('Level 6 header'))."'; ".
91          "jsToolBar.prototype.elements.strong.title = '".html::escapeJS(__('Strong emphasis'))."'; ".
92          "jsToolBar.prototype.elements.em.title = '".html::escapeJS(__('Emphasis'))."'; ".
93          "jsToolBar.prototype.elements.ins.title = '".html::escapeJS(__('Inserted'))."'; ".
94          "jsToolBar.prototype.elements.del.title = '".html::escapeJS(__('Deleted'))."'; ".
95          "jsToolBar.prototype.elements.quote.title = '".html::escapeJS(__('Inline quote'))."'; ".
96          "jsToolBar.prototype.elements.code.title = '".html::escapeJS(__('Code'))."'; ".
97          "jsToolBar.prototype.elements.br.title = '".html::escapeJS(__('Line break'))."'; ".
98          "jsToolBar.prototype.elements.blockquote.title = '".html::escapeJS(__('Blockquote'))."'; ".
99          "jsToolBar.prototype.elements.pre.title = '".html::escapeJS(__('Preformated text'))."'; ".
100          "jsToolBar.prototype.elements.ul.title = '".html::escapeJS(__('Unordered list'))."'; ".
101          "jsToolBar.prototype.elements.ol.title = '".html::escapeJS(__('Ordered list'))."'; ".
102
103          "jsToolBar.prototype.elements.link.title = '".html::escapeJS(__('Link'))."'; ".
104          "jsToolBar.prototype.elements.link.href_prompt = '".html::escapeJS(__('URL?'))."'; ".
105          "jsToolBar.prototype.elements.link.hreflang_prompt = '".html::escapeJS(__('Language?'))."'; ".
106
107          "jsToolBar.prototype.elements.img.title = '".html::escapeJS(__('External image'))."'; ".
108          "jsToolBar.prototype.elements.img.src_prompt = '".html::escapeJS(__('URL?'))."'; ".
109
110          "jsToolBar.prototype.elements.img_select.title = '".html::escapeJS(__('Media chooser'))."'; ".
111          "jsToolBar.prototype.elements.post_link.title = '".html::escapeJS(__('Link to an entry'))."'; ".
112          "jsToolBar.prototype.elements.removeFormat = jsToolBar.prototype.elements.removeFormat || {}; ".
113          "jsToolBar.prototype.elements.removeFormat.title = '".html::escapeJS(__('Remove text formating'))."'; ";
114
115          if (!$GLOBALS['core']->auth->check('media,media_admin',$GLOBALS['core']->blog->id)) {
116               $res .= "jsToolBar.prototype.elements.img_select.disabled = true;\n";
117          }
118
119          $res .=
120          "\n//]]>\n".
121          "</script>\n";
122
123          return $res;
124     }
125}
Note: See TracBrowser for help on using the repository browser.

Sites map