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 | |
---|
18 | public static function adminPostEditor($editor='') { |
---|
19 | if (empty($editor) || $editor!='dcCKEditor') { return;} |
---|
20 | |
---|
21 | return |
---|
22 | '<script type="text/javascript">'."\n". |
---|
23 | "//<![CDATA[\n". |
---|
24 | 'var CKEDITOR_BASEPATH = "'.DC_ADMIN_URL.self::$p_url.'/js/ckeditor/";'."\n". |
---|
25 | dcPage::jsVar('dotclear.base_url', $GLOBALS['core']->blog->host). |
---|
26 | dcPage::jsVar('dotclear.dcckeditor_plugin_url',DC_ADMIN_URL.self::$p_url). |
---|
27 | 'CKEDITOR_GETURL = function(resource) { |
---|
28 | // If this is not a full or absolute path. |
---|
29 | if ( resource.indexOf(":/") == -1 && resource.indexOf("/") !== 0 ) { |
---|
30 | resource = this.basePath + resource; |
---|
31 | } |
---|
32 | return resource; |
---|
33 | };'. |
---|
34 | "dotclear.msg.img_select_title = '".html::escapeJS(__('Media chooser'))."'; ". |
---|
35 | "dotclear.msg.post_link_title = '".html::escapeJS(__('Link to an entry'))."'; ". |
---|
36 | "dotclear.msg.link_title = '".html::escapeJS(__('Link'))."'; ". |
---|
37 | "\n//]]>\n". |
---|
38 | "</script>\n". |
---|
39 | dcPage::jsLoad(self::$p_url.'/js/ckeditor/ckeditor.js'). |
---|
40 | dcPage::jsLoad(self::$p_url.'/js/ckeditor/adapters/jquery.js'). |
---|
41 | dcPage::jsLoad(self::$config_url); |
---|
42 | } |
---|
43 | |
---|
44 | public static function adminPopupMedia($editor='') { |
---|
45 | if (empty($editor) || $editor!='dcCKEditor') { return;} |
---|
46 | |
---|
47 | return dcPage::jsLoad(self::$p_url.'/js/popup_media.js'); |
---|
48 | } |
---|
49 | |
---|
50 | public static function adminPopupLink($editor='') { |
---|
51 | if (empty($editor) || $editor!='dcCKEditor') { return;} |
---|
52 | |
---|
53 | return dcPage::jsLoad(self::$p_url.'/js/popup_link.js'); |
---|
54 | } |
---|
55 | |
---|
56 | public static function adminPopupPosts($editor='') { |
---|
57 | if (empty($editor) || $editor!='dcCKEditor') { return;} |
---|
58 | |
---|
59 | return dcPage::jsLoad(self::$p_url.'/js/popup_posts.js'); |
---|
60 | } |
---|
61 | |
---|
62 | public static function adminMediaURL($url) { |
---|
63 | if (!empty($_GET['editor'])) { |
---|
64 | $url .= '&editor='.$_GET['editor']; |
---|
65 | } |
---|
66 | |
---|
67 | return $url; |
---|
68 | } |
---|
69 | } |
---|