Dotclear


Ignore:
Timestamp:
06/21/19 14:03:55 (6 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Switching from inline JS variables to JSON script, it's time for the CKEditor plugin (more will come)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • plugins/dcCKEditor/inc/dc.ckeditor.behaviors.php

    r3915 r3977  
    2020     * @param editor   <b>string</b> wanted editor 
    2121     * @param context  <b>string</b> page context (post,page,comment,event,...) 
    22      * @param tags     <b>array</b>  array of ids into inject editor 
     22     * @param tags     <b>array</b>  array of elt ids (textarea) where inject editor 
    2323     * @param syntax   <b>string</b> wanted syntax (xhtml) 
    2424     */ 
     
    3333 
    3434        $res = 
    35         '<script type="text/javascript">' . "\n" . 
    36         dcPage::jsVar('dotclear.ckeditor_context', $context) . 
    37         'dotclear.ckeditor_tags_context = ' . sprintf('{%s:["%s"]};' . "\n", $context, implode('","', $tags)) . 
    38         'var CKEDITOR_BASEPATH = "' . DC_ADMIN_URL . self::$p_url . '/js/ckeditor/";' . "\n" . 
    39         dcPage::jsVar('dotclear.admin_base_url', DC_ADMIN_URL) . 
    40         dcPage::jsVar('dotclear.base_url', $GLOBALS['core']->blog->host) . 
    41         dcPage::jsVar('dotclear.dcckeditor_plugin_url', DC_ADMIN_URL . self::$p_url) . 
    42         dcPage::jsVar('dotclear.user_language', $GLOBALS['core']->auth->getInfo('user_lang')) . 
    43         'CKEDITOR_GETURL = function(resource) { 
    44                 // If this is not a full or absolute path. 
    45                 if ( resource.indexOf(":/") == -1 && resource.indexOf("/") !== 0 ) { 
    46                     resource = this.basePath + resource; 
    47                 } 
    48                 return resource; 
    49              };' . "\n" . 
    50         "dotclear.msg.img_select_title = '" . html::escapeJS(__('Media chooser')) . "'; " . "\n" . 
    51         "dotclear.msg.img_select_accesskey = '" . html::escapeJS(__('m')) . "'; " . "\n" . 
    52         "dotclear.msg.post_link_title = '" . html::escapeJS(__('Link to an entry')) . "'; " . "\n" . 
    53         "dotclear.msg.link_title = '" . html::escapeJS(__('Link')) . "'; " . "\n" . 
    54         "dotclear.msg.link_accesskey = '" . html::escapeJS(__('l')) . "'; " . "\n" . 
    55         "dotclear.msg.img_title = '" . html::escapeJS(__('External image')) . "'; " . "\n" . 
    56         "dotclear.msg.url_cannot_be_empty = '" . html::escapeJS(__('URL field cannot be empty.')) . "';" . "\n" . 
    57         "</script>\n" . 
     35        dcPage::jsJson('ck_editor_ctx', [ 
     36            'ckeditor_context'      => $context, 
     37            'ckeditor_tags_context' => [$context => $tags], 
     38            'admin_base_url'        => DC_ADMIN_URL, 
     39            'base_url'              => $GLOBALS['core']->blog->host, 
     40            'dcckeditor_plugin_url' => DC_ADMIN_URL . self::$p_url, 
     41            'user_language'         => $GLOBALS['core']->auth->getInfo('user_lang') 
     42        ]) . 
     43        dcPage::jsJson('ck_editor_var', [ 
     44            'CKEDITOR_BASEPATH' => DC_ADMIN_URL . self::$p_url . '/js/ckeditor/' 
     45        ]) . 
     46        dcPage::jsJson('ck_editor_msg', [ 
     47            'img_select_title'     => __('Media chooser'), 
     48            'img_select_accesskey' => __('m'), 
     49            'post_link_title'      => __('Link to an entry'), 
     50            'link_title'           => __('Link'), 
     51            'link_accesskey'       => __('l'), 
     52            'img_title'            => __('External image'), 
     53            'url_cannot_be_empty'  => __('URL field cannot be empty.') 
     54        ]) . 
     55        dcPage::jsLoad(self::$p_url . '/js/_post_editor.js') . 
    5856        dcPage::jsLoad(self::$p_url . '/js/ckeditor/ckeditor.js') . 
    5957        dcPage::jsLoad(self::$p_url . '/js/ckeditor/adapters/jquery.js') . 
Note: See TracChangeset for help on using the changeset viewer.

Sites map