Dotclear

source: plugins/dcCKEditor/inc/dc.ckeditor.behaviors.php @ 2868:2f77d528185b

Revision 2868:2f77d528185b, 3.4 KB checked in by Nicolas <nikrou77@…>, 11 years ago (diff)

Add external media for CKEditor
Allow link around external media

RevLine 
[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
13class 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'))."'; ".
[2868]51            "dotclear.msg.external_media_title = '".html::escapeJS(__('External image'))."'; ".
52            "dotclear.msg.url_cannot_be_empty = '".html::escapeJS(__('URL field cannot be empty.'))."';".
[2738]53            "\n//]]>\n".
54            "</script>\n".
55            dcPage::jsLoad(self::$p_url.'/js/ckeditor/ckeditor.js').
56            dcPage::jsLoad(self::$p_url.'/js/ckeditor/adapters/jquery.js').
[2761]57            dcPage::jsLoad($config_js);
[2738]58     }
59
[2749]60    public static function adminPopupMedia($editor='') {
61        if (empty($editor) || $editor!='dcCKEditor') { return;}
62
[2738]63     return dcPage::jsLoad(self::$p_url.'/js/popup_media.js');
64    }
65
[2749]66    public static function adminPopupLink($editor='') {
67        if (empty($editor) || $editor!='dcCKEditor') { return;}
68
[2738]69     return dcPage::jsLoad(self::$p_url.'/js/popup_link.js');
70    }
71
[2749]72    public static function adminPopupPosts($editor='') {
73        if (empty($editor) || $editor!='dcCKEditor') { return;}
74
[2738]75     return dcPage::jsLoad(self::$p_url.'/js/popup_posts.js');
76    }
77
[2852]78    public static function adminMediaURLParams($p) {
[2738]79        if (!empty($_GET['editor'])) {
[2852]80            $p['editor']=html::sanitiseURL($_GET['editor']);
[2738]81        }
82    }
[2854]83
84    public static function getTagsContext() {
85        return self::$tagsContext;
86    }
[2738]87}
Note: See TracBrowser for help on using the repository browser.

Sites map