Dotclear

source: plugins/dcLegacyEditor/inc/dc.legacy.editor.behaviors.php @ 2749:993aebff97bb

Revision 2749:993aebff97bb, 5.7 KB checked in by Nicolas <nikrou77@…>, 11 years ago (diff)

Fix call of javascript of all editors on media_item page but also popup_link and popup_posts
Closes #1983

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

Sites map