[2614] | 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 | |
---|
| 13 | class dcLegacyEditorBehaviors |
---|
| 14 | { |
---|
| 15 | protected static $p_url = 'index.php?pf=dcLegacyEditor'; |
---|
| 16 | |
---|
[3003] | 17 | /** |
---|
| 18 | * adminPostEditor add javascript to the DOM to load ckeditor depending on context |
---|
| 19 | * |
---|
| 20 | * @param editor <b>string</b> wanted editor |
---|
| 21 | * @param context <b>string</b> page context (post,page,comment,event,...) |
---|
| 22 | * @param tags <b>array</b> array of ids to inject editor |
---|
| 23 | */ |
---|
[2856] | 24 | public static function adminPostEditor($editor='',$context='',array $tags=array()) { |
---|
[2749] | 25 | if (empty($editor) || $editor!='dcLegacyEditor') {return;} |
---|
[2679] | 26 | |
---|
[2614] | 27 | return |
---|
| 28 | self::jsToolBar(). |
---|
[3021] | 29 | dcPage::jsLoad(dcPage::getPF('dcLegacyEditor/js/_post_editor.js')). |
---|
[2856] | 30 | '<script type="text/javascript">'."\n". |
---|
| 31 | "//<![CDATA[\n". |
---|
| 32 | dcPage::jsVar('dotclear.legacy_editor_context', $context). |
---|
| 33 | 'dotclear.legacy_editor_tags_context = '.sprintf('{%s:["%s"]};'."\n", $context, implode('","', $tags)). |
---|
| 34 | "\n//]]>\n". |
---|
| 35 | "</script>\n"; |
---|
[2614] | 36 | } |
---|
| 37 | |
---|
[2749] | 38 | public static function adminPopupMedia($editor='') { |
---|
| 39 | if (empty($editor) || $editor!='dcLegacyEditor') {return;} |
---|
| 40 | |
---|
[3021] | 41 | return dcPage::jsLoad(dcPage::getPF('dcLegacyEditor/js/jsToolBar/popup_media.js')); |
---|
[2614] | 42 | } |
---|
| 43 | |
---|
[2749] | 44 | public static function adminPopupLink($editor='') { |
---|
| 45 | if (empty($editor) || $editor!='dcLegacyEditor') {return;} |
---|
| 46 | |
---|
[3021] | 47 | return dcPage::jsLoad(dcPage::getPF('dcLegacyEditor/js/jsToolBar/popup_link.js')); |
---|
[2614] | 48 | } |
---|
| 49 | |
---|
[2749] | 50 | public static function adminPopupPosts($editor='') { |
---|
| 51 | if (empty($editor) || $editor!='dcLegacyEditor') {return;} |
---|
| 52 | |
---|
[3021] | 53 | return dcPage::jsLoad(dcPage::getPF('dcLegacyEditor/js/jsToolBar/popup_posts.js')); |
---|
[2614] | 54 | } |
---|
| 55 | |
---|
| 56 | protected static function jsToolBar() { |
---|
| 57 | $res = |
---|
[3021] | 58 | dcPage::cssLoad(dcPage::getPF('dcLegacyEditor/css/jsToolBar/jsToolBar.css')). |
---|
| 59 | dcPage::jsLoad(dcPage::getPF('dcLegacyEditor/js/jsToolBar/jsToolBar.js')); |
---|
[2614] | 60 | |
---|
| 61 | if (isset($GLOBALS['core']->auth) && $GLOBALS['core']->auth->getOption('enable_wysiwyg')) { |
---|
[3021] | 62 | $res .= dcPage::jsLoad(dcPage::getPF('dcLegacyEditor/js/jsToolBar/jsToolBar.wysiwyg.js')); |
---|
[3003] | 63 | } |
---|
[2614] | 64 | |
---|
| 65 | $res .= |
---|
[3021] | 66 | dcPage::jsLoad(dcPage::getPF('dcLegacyEditor/js/jsToolBar/jsToolBar.dotclear.js')). |
---|
[2614] | 67 | '<script type="text/javascript">'."\n". |
---|
| 68 | "//<![CDATA[\n". |
---|
| 69 | "jsToolBar.prototype.dialog_url = 'popup.php'; ". |
---|
| 70 | "jsToolBar.prototype.iframe_css = '". |
---|
| 71 | 'body{'. |
---|
| 72 | 'font: 12px "DejaVu Sans","Lucida Grande","Lucida Sans Unicode",Arial,sans-serif;'. |
---|
| 73 | 'color : #000;'. |
---|
| 74 | 'background: #f9f9f9;'. |
---|
| 75 | 'margin: 0;'. |
---|
| 76 | 'padding : 2px;'. |
---|
| 77 | 'border: none;'. |
---|
| 78 | (l10n::getTextDirection($GLOBALS['_lang']) == 'rtl' ? 'direction:rtl;' : ''). |
---|
| 79 | '}'. |
---|
| 80 | 'pre, code, kbd, samp {'. |
---|
| 81 | 'font-family:"Courier New",Courier,monospace;'. |
---|
| 82 | 'font-size : 1.1em;'. |
---|
| 83 | '}'. |
---|
| 84 | 'code {'. |
---|
| 85 | 'color : #666;'. |
---|
| 86 | 'font-weight : bold;'. |
---|
| 87 | '}'. |
---|
| 88 | 'body > p:first-child {'. |
---|
| 89 | 'margin-top: 0;'. |
---|
| 90 | '}'. |
---|
| 91 | "'; ". |
---|
| 92 | "jsToolBar.prototype.base_url = '".html::escapeJS($GLOBALS['core']->blog->host)."'; ". |
---|
| 93 | "jsToolBar.prototype.switcher_visual_title = '".html::escapeJS(__('visual'))."'; ". |
---|
| 94 | "jsToolBar.prototype.switcher_source_title = '".html::escapeJS(__('source'))."'; ". |
---|
| 95 | "jsToolBar.prototype.legend_msg = '". |
---|
| 96 | html::escapeJS(__('You can use the following shortcuts to format your text.'))."'; ". |
---|
| 97 | "jsToolBar.prototype.elements.blocks.options.none = '".html::escapeJS(__('-- none --'))."'; ". |
---|
| 98 | "jsToolBar.prototype.elements.blocks.options.nonebis = '".html::escapeJS(__('-- block format --'))."'; ". |
---|
| 99 | "jsToolBar.prototype.elements.blocks.options.p = '".html::escapeJS(__('Paragraph'))."'; ". |
---|
| 100 | "jsToolBar.prototype.elements.blocks.options.h1 = '".html::escapeJS(__('Level 1 header'))."'; ". |
---|
| 101 | "jsToolBar.prototype.elements.blocks.options.h2 = '".html::escapeJS(__('Level 2 header'))."'; ". |
---|
| 102 | "jsToolBar.prototype.elements.blocks.options.h3 = '".html::escapeJS(__('Level 3 header'))."'; ". |
---|
| 103 | "jsToolBar.prototype.elements.blocks.options.h4 = '".html::escapeJS(__('Level 4 header'))."'; ". |
---|
| 104 | "jsToolBar.prototype.elements.blocks.options.h5 = '".html::escapeJS(__('Level 5 header'))."'; ". |
---|
| 105 | "jsToolBar.prototype.elements.blocks.options.h6 = '".html::escapeJS(__('Level 6 header'))."'; ". |
---|
| 106 | "jsToolBar.prototype.elements.strong.title = '".html::escapeJS(__('Strong emphasis'))."'; ". |
---|
| 107 | "jsToolBar.prototype.elements.em.title = '".html::escapeJS(__('Emphasis'))."'; ". |
---|
| 108 | "jsToolBar.prototype.elements.ins.title = '".html::escapeJS(__('Inserted'))."'; ". |
---|
| 109 | "jsToolBar.prototype.elements.del.title = '".html::escapeJS(__('Deleted'))."'; ". |
---|
| 110 | "jsToolBar.prototype.elements.quote.title = '".html::escapeJS(__('Inline quote'))."'; ". |
---|
| 111 | "jsToolBar.prototype.elements.code.title = '".html::escapeJS(__('Code'))."'; ". |
---|
| 112 | "jsToolBar.prototype.elements.br.title = '".html::escapeJS(__('Line break'))."'; ". |
---|
| 113 | "jsToolBar.prototype.elements.blockquote.title = '".html::escapeJS(__('Blockquote'))."'; ". |
---|
| 114 | "jsToolBar.prototype.elements.pre.title = '".html::escapeJS(__('Preformated text'))."'; ". |
---|
| 115 | "jsToolBar.prototype.elements.ul.title = '".html::escapeJS(__('Unordered list'))."'; ". |
---|
| 116 | "jsToolBar.prototype.elements.ol.title = '".html::escapeJS(__('Ordered list'))."'; ". |
---|
| 117 | |
---|
| 118 | "jsToolBar.prototype.elements.link.title = '".html::escapeJS(__('Link'))."'; ". |
---|
| 119 | "jsToolBar.prototype.elements.link.href_prompt = '".html::escapeJS(__('URL?'))."'; ". |
---|
| 120 | "jsToolBar.prototype.elements.link.hreflang_prompt = '".html::escapeJS(__('Language?'))."'; ". |
---|
| 121 | |
---|
| 122 | "jsToolBar.prototype.elements.img.title = '".html::escapeJS(__('External image'))."'; ". |
---|
| 123 | "jsToolBar.prototype.elements.img.src_prompt = '".html::escapeJS(__('URL?'))."'; ". |
---|
| 124 | |
---|
| 125 | "jsToolBar.prototype.elements.img_select.title = '".html::escapeJS(__('Media chooser'))."'; ". |
---|
| 126 | "jsToolBar.prototype.elements.post_link.title = '".html::escapeJS(__('Link to an entry'))."'; ". |
---|
| 127 | "jsToolBar.prototype.elements.removeFormat = jsToolBar.prototype.elements.removeFormat || {}; ". |
---|
| 128 | "jsToolBar.prototype.elements.removeFormat.title = '".html::escapeJS(__('Remove text formating'))."'; "; |
---|
| 129 | |
---|
| 130 | if (!$GLOBALS['core']->auth->check('media,media_admin',$GLOBALS['core']->blog->id)) { |
---|
| 131 | $res .= "jsToolBar.prototype.elements.img_select.disabled = true;\n"; |
---|
| 132 | } |
---|
| 133 | |
---|
[3003] | 134 | $res .= "jsToolBar.prototype.toolbar_bottom = ". |
---|
| 135 | (isset($GLOBALS['core']->auth) && $GLOBALS['core']->auth->getOption('toolbar_bottom') ? 'true' : 'false').";\n"; |
---|
| 136 | |
---|
[2614] | 137 | $res .= |
---|
| 138 | "\n//]]>\n". |
---|
| 139 | "</script>\n"; |
---|
| 140 | |
---|
| 141 | return $res; |
---|
| 142 | } |
---|
[3003] | 143 | } |
---|