[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 | class dcCKEditorBehaviors |
---|
| 14 | { |
---|
| 15 | protected static $p_url = 'index.php?pf=dcCKEditor'; |
---|
| 16 | protected static $config_url = 'plugin.php?p=dcCKEditor&config=1'; |
---|
| 17 | |
---|
[2854] | 18 | /** |
---|
| 19 | * adminPostEditor add javascript to the DOM to load ckeditor depending on context |
---|
| 20 | * |
---|
| 21 | * @param editor <b>string</b> wanted editor |
---|
| 22 | * @param context <b>string</b> page context (post,page,comment,event,...) |
---|
| 23 | * @param tags <b>array</b> array of ids into inject editor |
---|
| 24 | */ |
---|
| 25 | public static function adminPostEditor($editor='',$context='',array $tags=array()) { |
---|
[2738] | 26 | if (empty($editor) || $editor!='dcCKEditor') { return;} |
---|
| 27 | |
---|
[2761] | 28 | $config_js = self::$config_url; |
---|
| 29 | if (!empty($context)) { |
---|
| 30 | $config_js .= '&context='.$context; |
---|
| 31 | } |
---|
| 32 | |
---|
[2738] | 33 | return |
---|
| 34 | '<script type="text/javascript">'."\n". |
---|
| 35 | "//<![CDATA[\n". |
---|
[2854] | 36 | dcPage::jsVar('dotclear.ckeditor_context', $context). |
---|
| 37 | 'dotclear.ckeditor_tags_context = '.sprintf('{%s:["%s"]};'."\n", $context, implode('","', $tags)). |
---|
[2738] | 38 | 'var CKEDITOR_BASEPATH = "'.DC_ADMIN_URL.self::$p_url.'/js/ckeditor/";'."\n". |
---|
| 39 | dcPage::jsVar('dotclear.base_url', $GLOBALS['core']->blog->host). |
---|
| 40 | dcPage::jsVar('dotclear.dcckeditor_plugin_url',DC_ADMIN_URL.self::$p_url). |
---|
| 41 | 'CKEDITOR_GETURL = function(resource) { |
---|
| 42 | // If this is not a full or absolute path. |
---|
| 43 | if ( resource.indexOf(":/") == -1 && resource.indexOf("/") !== 0 ) { |
---|
| 44 | resource = this.basePath + resource; |
---|
| 45 | } |
---|
| 46 | return resource; |
---|
| 47 | };'. |
---|
[2743] | 48 | "dotclear.msg.img_select_title = '".html::escapeJS(__('Media chooser'))."'; ". |
---|
| 49 | "dotclear.msg.post_link_title = '".html::escapeJS(__('Link to an entry'))."'; ". |
---|
| 50 | "dotclear.msg.link_title = '".html::escapeJS(__('Link'))."'; ". |
---|
[2738] | 51 | "\n//]]>\n". |
---|
| 52 | "</script>\n". |
---|
| 53 | dcPage::jsLoad(self::$p_url.'/js/ckeditor/ckeditor.js'). |
---|
| 54 | dcPage::jsLoad(self::$p_url.'/js/ckeditor/adapters/jquery.js'). |
---|
[2761] | 55 | dcPage::jsLoad($config_js); |
---|
[2738] | 56 | } |
---|
| 57 | |
---|
[2749] | 58 | public static function adminPopupMedia($editor='') { |
---|
| 59 | if (empty($editor) || $editor!='dcCKEditor') { return;} |
---|
| 60 | |
---|
[2738] | 61 | return dcPage::jsLoad(self::$p_url.'/js/popup_media.js'); |
---|
| 62 | } |
---|
| 63 | |
---|
[2749] | 64 | public static function adminPopupLink($editor='') { |
---|
| 65 | if (empty($editor) || $editor!='dcCKEditor') { return;} |
---|
| 66 | |
---|
[2738] | 67 | return dcPage::jsLoad(self::$p_url.'/js/popup_link.js'); |
---|
| 68 | } |
---|
| 69 | |
---|
[2749] | 70 | public static function adminPopupPosts($editor='') { |
---|
| 71 | if (empty($editor) || $editor!='dcCKEditor') { return;} |
---|
| 72 | |
---|
[2738] | 73 | return dcPage::jsLoad(self::$p_url.'/js/popup_posts.js'); |
---|
| 74 | } |
---|
| 75 | |
---|
[2852] | 76 | public static function adminMediaURLParams($p) { |
---|
[2738] | 77 | if (!empty($_GET['editor'])) { |
---|
[2852] | 78 | $p['editor']=html::sanitiseURL($_GET['editor']); |
---|
[2738] | 79 | } |
---|
| 80 | } |
---|
[2854] | 81 | |
---|
| 82 | public static function getTagsContext() { |
---|
| 83 | return self::$tagsContext; |
---|
| 84 | } |
---|
[2738] | 85 | } |
---|