[2738] | 1 | <?php |
---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
| 3 | # |
---|
| 4 | # This file is part of Dotclear 2. |
---|
| 5 | # |
---|
| 6 | # Copyright (c) 2003-2014 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 | if (!defined('DC_CONTEXT_ADMIN')) { return; } |
---|
| 14 | header('Content-type: text/javascript'); |
---|
| 15 | $__extraPlugins = new ArrayObject(); |
---|
| 16 | $core->callBehavior('ckeditorExtraPlugins',$__extraPlugins); |
---|
| 17 | $extraPlugins = $__extraPlugins->getArrayCopy(); |
---|
| 18 | ?> |
---|
| 19 | (function($) { |
---|
| 20 | $.toolbarPopup = function toolbarPopup(url) { |
---|
| 21 | var popup_params = 'alwaysRaised=yes,dependent=yes,toolbar=yes,'; |
---|
| 22 | popup_params += 'height=420,width=520,menubar=no,resizable=yes,scrollbars=yes,status=no'; |
---|
| 23 | var popup_link = window.open(url,'dc_popup', popup_params); |
---|
| 24 | }; |
---|
| 25 | |
---|
| 26 | $.stripBaseURL = function stripBaseURL(url) { |
---|
| 27 | if (dotclear.base_url != '') { |
---|
| 28 | var pos = url.indexOf(dotclear.base_url); |
---|
| 29 | if (pos == 0) { |
---|
| 30 | url = url.substr(dotclear.base_url.length); |
---|
| 31 | } |
---|
| 32 | } |
---|
| 33 | |
---|
| 34 | return url; |
---|
| 35 | }; |
---|
| 36 | |
---|
| 37 | /* Retrieve editor name from URL */ |
---|
| 38 | $.getEditorName = function getEditorName(url) { |
---|
| 39 | return url.replace(/.*editor=([^&]*)(&.*)?/,'$1'); |
---|
| 40 | } |
---|
| 41 | })(jQuery); |
---|
| 42 | |
---|
| 43 | $(function() { |
---|
| 44 | /* By default ckeditor load related resources with a timestamp to avoid cache problem when upgrading itself |
---|
| 45 | * load_plugin_file.php does not allow other param that file to load (pf param), so remove timestamp |
---|
| 46 | */ |
---|
| 47 | |
---|
| 48 | CKEDITOR.timestamp = ''; |
---|
| 49 | CKEDITOR.config.skin = 'dotclear,'+dotclear.dcckeditor_plugin_url+'/js/ckeditor-skins/dotclear/'; |
---|
| 50 | |
---|
| 51 | <?php if (!empty($dcckeditor_cancollapse_button)):?> |
---|
| 52 | CKEDITOR.config.toolbarCanCollapse = true; |
---|
| 53 | <?php endif;?> |
---|
| 54 | |
---|
| 55 | CKEDITOR.plugins.addExternal('entrylink',dotclear.dcckeditor_plugin_url+'/js/ckeditor-plugins/entrylink/'); |
---|
| 56 | CKEDITOR.plugins.addExternal('dclink',dotclear.dcckeditor_plugin_url+'/js/ckeditor-plugins/dclink/'); |
---|
| 57 | CKEDITOR.plugins.addExternal('media',dotclear.dcckeditor_plugin_url+'/js/ckeditor-plugins/media/'); |
---|
| 58 | |
---|
| 59 | <?php if (!empty($extraPlugins) && count($extraPlugins)>0) { |
---|
| 60 | foreach ($extraPlugins as $plugin) { |
---|
| 61 | printf("\tCKEDITOR.plugins.addExternal('%s','%s');\n", $plugin['name'], $plugin['url']); |
---|
| 62 | } |
---|
| 63 | } |
---|
| 64 | ?> |
---|
| 65 | |
---|
| 66 | $('<?php echo $dcckeditor_textareas;?>').ckeditor({ |
---|
| 67 | <?php |
---|
| 68 | $defautExtraPlugins = 'entrylink,dclink,media,justify,colorbutton,format'; |
---|
| 69 | if (!empty($extraPlugins) && count($extraPlugins)>0) { |
---|
| 70 | foreach ($extraPlugins as $plugin) { |
---|
| 71 | $defautExtraPlugins .= ','. $plugin['name']; |
---|
| 72 | } |
---|
| 73 | } |
---|
| 74 | ?> |
---|
| 75 | extraPlugins: '<?php echo $defautExtraPlugins;?>', |
---|
| 76 | |
---|
| 77 | <?php if (!empty($dcckeditor_format_select)):?> |
---|
| 78 | // format tags |
---|
| 79 | format_tags: 'p;h1;h2;h3;h4;h5;h6;pre;address', |
---|
| 80 | |
---|
| 81 | // following definition are needed to be specialized |
---|
| 82 | format_p: { element: 'p' }, |
---|
| 83 | format_h1: { element: 'h1' }, |
---|
| 84 | format_h2: { element: 'h2' }, |
---|
| 85 | format_h3: { element: 'h3' }, |
---|
| 86 | format_h4: { element: 'h4' }, |
---|
| 87 | format_h5: { element: 'h5' }, |
---|
| 88 | format_h6: { element: 'h6' }, |
---|
| 89 | format_pre: { element: 'pre' }, |
---|
| 90 | format_address: { element: 'address' }, |
---|
| 91 | <?php endif;?> |
---|
| 92 | |
---|
| 93 | entities: false, |
---|
| 94 | removeButtons: '', |
---|
| 95 | allowedContent: true, |
---|
| 96 | toolbar: [ |
---|
| 97 | { |
---|
| 98 | name: 'basicstyles', |
---|
| 99 | items: [ |
---|
| 100 | <?php if (!empty($dcckeditor_format_select)):?> |
---|
| 101 | 'Format', |
---|
| 102 | <?php endif;?> |
---|
| 103 | 'Bold','Italic','Underline','Strike','Subscript','Superscript','Code','Blockquote', |
---|
| 104 | |
---|
| 105 | <?php if (!empty($dcckeditor_list_buttons)):?> |
---|
| 106 | 'NumberedList', 'BulletedList', |
---|
| 107 | <?php endif;?> |
---|
| 108 | 'RemoveFormat' |
---|
| 109 | ] |
---|
| 110 | }, |
---|
| 111 | <?php if (!empty($dcckeditor_clipboard_buttons)):?> |
---|
| 112 | { |
---|
| 113 | name: 'clipoard', |
---|
| 114 | items: ['Cut','Copy','Paste','PasteText','PasteFromWord'] |
---|
| 115 | }, |
---|
| 116 | <?php endif;?> |
---|
| 117 | <?php if (!empty($dcckeditor_alignment_buttons)):?> |
---|
| 118 | { |
---|
| 119 | name: 'paragraph', |
---|
| 120 | items: ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'] |
---|
| 121 | }, |
---|
| 122 | <?php endif;?> |
---|
| 123 | <?php if (!empty($dcckeditor_table_button)):?> |
---|
| 124 | { |
---|
| 125 | name: 'table', |
---|
| 126 | items: ['Table'] |
---|
| 127 | }, |
---|
| 128 | <?php endif;?> |
---|
| 129 | { |
---|
| 130 | name: 'custom', |
---|
| 131 | items: [ |
---|
| 132 | 'EntryLink','dcLink','Media','-', |
---|
| 133 | 'Source', 'Maximize' |
---|
| 134 | <?php if (!empty($dcckeditor_textcolor_button)):?> |
---|
| 135 | ,'TextColor' |
---|
| 136 | <?php endif;?> |
---|
| 137 | ] |
---|
| 138 | }, |
---|
| 139 | <?php // add extra buttons comming from dotclear plugins |
---|
| 140 | if (!empty($extraPlugins) && count($extraPlugins)>0) { |
---|
| 141 | $extraPlugins_str = "{name: 'extra', items: [%s]},\n"; |
---|
| 142 | $extra_icons = ''; |
---|
| 143 | foreach ($extraPlugins as $plugin) { |
---|
| 144 | $extra_icons .= sprintf("'%s',", $plugin['button']); |
---|
| 145 | } |
---|
| 146 | printf($extraPlugins_str, $extra_icons); |
---|
| 147 | } |
---|
| 148 | ?> |
---|
| 149 | ] |
---|
| 150 | }); |
---|
| 151 | |
---|
| 152 | CKEDITOR.on('instanceReady', function(e) { |
---|
| 153 | if ($('label[for="post_excerpt"] a img').attr('src')==dotclear.img_minus_src) { |
---|
| 154 | $('#cke_post_excerpt').removeClass('hide'); |
---|
| 155 | } else { |
---|
| 156 | $('#cke_post_excerpt').addClass('hide'); |
---|
| 157 | } |
---|
| 158 | |
---|
| 159 | $('#excerpt-area label').click(function() { |
---|
| 160 | $('#cke_post_excerpt').toggleClass('hide',$('#post_excerpt').hasClass('hide')); |
---|
| 161 | }); |
---|
| 162 | }); |
---|
| 163 | }); |
---|