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