Dotclear

source: plugins/dcLegacyEditor/inc/dc.legacy.editor.behaviors.php @ 2681:0d5aeefe7bd8

Revision 2681:0d5aeefe7bd8, 5.5 KB checked in by Nicolas <nikrou77@…>, 11 years ago (diff)

Addresse #1896 : simplify; get editor from core instead of retrieve it from parameter

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

Sites map