Dotclear

source: plugins/dcLegacyEditor/inc/dc.legacy.editor.behaviors.php @ 2614:db6f6a1f4f25

Revision 2614:db6f6a1f4f25, 5.4 KB checked in by Nicolas <nikrou77@…>, 12 years ago (diff)

Move legacy editor to a plugin. First step for alternate editors.
Addresses #1896

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

Sites map