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