Dotclear

source: plugins/dcLegacyEditor/inc/dc.legacy.editor.behaviors.php @ 2679:bae19d3adbc4

Revision 2679:bae19d3adbc4, 5.4 KB checked in by Nicolas <nikrou77@…>, 11 years ago (diff)

Addresses #1896 : add choice of editor in preferences
Keeps old functions in core addFormater(), callFormater() for compatibility.

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

Sites map