Current oav website
This commit is contained in:
80
dotclear._no/plugins/dcCKEditor/inc/_config.php
Normal file
80
dotclear._no/plugins/dcCKEditor/inc/_config.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief dcCKEditor, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugins
|
||||
*
|
||||
* @copyright Olivier Meunier & Association Dotclear
|
||||
* @copyright GPL-2.0-only
|
||||
*/
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {return;}
|
||||
|
||||
$dcckeditor_was_actived = $dcckeditor_active;
|
||||
|
||||
if (!empty($_POST['saveconfig'])) {
|
||||
try {
|
||||
$dcckeditor_active = (empty($_POST['dcckeditor_active'])) ? false : true;
|
||||
$core->blog->settings->dcckeditor->put('active', $dcckeditor_active, 'boolean');
|
||||
|
||||
// change other settings only if they were in html page
|
||||
if ($dcckeditor_was_actived) {
|
||||
$dcckeditor_alignement_buttons = (empty($_POST['dcckeditor_alignment_buttons'])) ? false : true;
|
||||
$core->blog->settings->dcckeditor->put('alignment_buttons', $dcckeditor_alignement_buttons, 'boolean');
|
||||
|
||||
$dcckeditor_list_buttons = (empty($_POST['dcckeditor_list_buttons'])) ? false : true;
|
||||
$core->blog->settings->dcckeditor->put('list_buttons', $dcckeditor_list_buttons, 'boolean');
|
||||
|
||||
$dcckeditor_textcolor_button = (empty($_POST['dcckeditor_textcolor_button'])) ? false : true;
|
||||
$core->blog->settings->dcckeditor->put('textcolor_button', $dcckeditor_textcolor_button, 'boolean');
|
||||
|
||||
$dcckeditor_background_textcolor_button = (empty($_POST['dcckeditor_background_textcolor_button'])) ? false : true;
|
||||
$core->blog->settings->dcckeditor->put('background_textcolor_button', $dcckeditor_background_textcolor_button, 'boolean');
|
||||
|
||||
$dcckeditor_cancollapse_button = (empty($_POST['dcckeditor_cancollapse_button'])) ? false : true;
|
||||
$core->blog->settings->dcckeditor->put('cancollapse_button', $dcckeditor_cancollapse_button, 'boolean');
|
||||
|
||||
$dcckeditor_format_select = (empty($_POST['dcckeditor_format_select'])) ? false : true;
|
||||
$core->blog->settings->dcckeditor->put('format_select', $dcckeditor_format_select, 'boolean');
|
||||
|
||||
// default tags : p;h1;h2;h3;h4;h5;h6;pre;address
|
||||
$allowed_tags = ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'pre', 'address'];
|
||||
if (!empty($_POST['dcckeditor_format_tags'])) {
|
||||
$tags = explode(';', $_POST['dcckeditor_format_tags']);
|
||||
$new_tags = true;
|
||||
foreach ($tags as $tag) {
|
||||
if (!in_array($tag, $allowed_tags)) {
|
||||
$new_tags = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($new_tags) {
|
||||
$dcckeditor_format_tags = $_POST['dcckeditor_format_tags'];
|
||||
}
|
||||
} else {
|
||||
$dcckeditor_format_tags = 'p;h1;h2;h3;h4;h5;h6;pre;address';
|
||||
}
|
||||
$core->blog->settings->dcckeditor->put('format_tags', $dcckeditor_format_tags, 'string');
|
||||
|
||||
$dcckeditor_table_button = (empty($_POST['dcckeditor_table_button'])) ? false : true;
|
||||
$core->blog->settings->dcckeditor->put('table_button', $dcckeditor_table_button, 'boolean');
|
||||
|
||||
$dcckeditor_clipboard_buttons = (empty($_POST['dcckeditor_clipboard_buttons'])) ? false : true;
|
||||
$core->blog->settings->dcckeditor->put('clipboard_buttons', $dcckeditor_clipboard_buttons, 'boolean');
|
||||
|
||||
$dcckeditor_action_buttons = (empty($_POST['dcckeditor_action_buttons'])) ? false : true;
|
||||
$core->blog->settings->dcckeditor->put('action_buttons', $dcckeditor_action_buttons, 'boolean');
|
||||
|
||||
$dcckeditor_disable_native_spellchecker = (empty($_POST['dcckeditor_disable_native_spellchecker'])) ? false : true;
|
||||
$core->blog->settings->dcckeditor->put('disable_native_spellchecker', $dcckeditor_disable_native_spellchecker, 'boolean');
|
||||
}
|
||||
|
||||
dcPage::addSuccessNotice(__('The configuration has been updated.'));
|
||||
http::redirect($p_url);
|
||||
} catch (Exception $e) {
|
||||
$core->error->add($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
include dirname(__FILE__) . '/../tpl/index.php';
|
||||
109
dotclear._no/plugins/dcCKEditor/inc/dc.ckeditor.behaviors.php
Normal file
109
dotclear._no/plugins/dcCKEditor/inc/dc.ckeditor.behaviors.php
Normal file
@ -0,0 +1,109 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief dcCKEditor, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugins
|
||||
*
|
||||
* @copyright Olivier Meunier & Association Dotclear
|
||||
* @copyright GPL-2.0-only
|
||||
*/
|
||||
|
||||
class dcCKEditorBehaviors
|
||||
{
|
||||
protected static $p_url = 'index.php?pf=dcCKEditor';
|
||||
protected static $config_url = 'plugin.php?p=dcCKEditor&config=1';
|
||||
|
||||
/**
|
||||
* adminPostEditor add javascript to the DOM to load ckeditor depending on context
|
||||
*
|
||||
* @param editor <b>string</b> wanted editor
|
||||
* @param context <b>string</b> page context (post,page,comment,event,...)
|
||||
* @param tags <b>array</b> array of elt ids (textarea) where inject editor
|
||||
* @param syntax <b>string</b> wanted syntax (xhtml)
|
||||
*/
|
||||
public static function adminPostEditor($editor = '', $context = '', array $tags = [], $syntax = 'xhtml')
|
||||
{
|
||||
if (empty($editor) || $editor != 'dcCKEditor' || $syntax != 'xhtml') {return;}
|
||||
|
||||
$config_js = self::$config_url;
|
||||
if (!empty($context)) {
|
||||
$config_js .= '&context=' . $context;
|
||||
}
|
||||
|
||||
$res =
|
||||
dcPage::jsJson('ck_editor_ctx', [
|
||||
'ckeditor_context' => $context,
|
||||
'ckeditor_tags_context' => [$context => $tags],
|
||||
'admin_base_url' => DC_ADMIN_URL,
|
||||
'base_url' => $GLOBALS['core']->blog->host,
|
||||
'dcckeditor_plugin_url' => DC_ADMIN_URL . self::$p_url,
|
||||
'user_language' => $GLOBALS['core']->auth->getInfo('user_lang')
|
||||
]) .
|
||||
dcPage::jsJson('ck_editor_var', [
|
||||
'CKEDITOR_BASEPATH' => DC_ADMIN_URL . self::$p_url . '/js/ckeditor/'
|
||||
]) .
|
||||
dcPage::jsJson('ck_editor_msg', [
|
||||
'img_select_title' => __('Media chooser'),
|
||||
'img_select_accesskey' => __('m'),
|
||||
'post_link_title' => __('Link to an entry'),
|
||||
'link_title' => __('Link'),
|
||||
'link_accesskey' => __('l'),
|
||||
'img_title' => __('External image'),
|
||||
'url_cannot_be_empty' => __('URL field cannot be empty.')
|
||||
]) .
|
||||
dcPage::jsLoad(self::$p_url . '/js/_post_editor.js') .
|
||||
dcPage::jsLoad(self::$p_url . '/js/ckeditor/ckeditor.js') .
|
||||
dcPage::jsLoad(self::$p_url . '/js/ckeditor/adapters/jquery.js') .
|
||||
dcPage::jsLoad($config_js);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
public static function adminPopupMedia($editor = '')
|
||||
{
|
||||
if (empty($editor) || $editor != 'dcCKEditor') {return;}
|
||||
|
||||
return dcPage::jsLoad(self::$p_url . '/js/popup_media.js');
|
||||
}
|
||||
|
||||
public static function adminPopupLink($editor = '')
|
||||
{
|
||||
if (empty($editor) || $editor != 'dcCKEditor') {return;}
|
||||
|
||||
return dcPage::jsLoad(self::$p_url . '/js/popup_link.js');
|
||||
}
|
||||
|
||||
public static function adminPopupPosts($editor = '')
|
||||
{
|
||||
if (empty($editor) || $editor != 'dcCKEditor') {return;}
|
||||
|
||||
return dcPage::jsLoad(self::$p_url . '/js/popup_posts.js');
|
||||
}
|
||||
|
||||
public static function adminMediaURLParams($p)
|
||||
{
|
||||
if (!empty($_GET['editor'])) {
|
||||
$p['editor'] = html::sanitizeURL($_GET['editor']);
|
||||
}
|
||||
}
|
||||
|
||||
public static function getTagsContext()
|
||||
{
|
||||
return self::$tagsContext;
|
||||
}
|
||||
|
||||
public static function adminPageHTTPHeaderCSP($csp)
|
||||
{
|
||||
// add 'unsafe-inline' for CSS, add 'unsafe-eval' for scripts as far as CKEditor 4.x is used
|
||||
if (strpos($csp['style-src'], 'unsafe-inline') === false) {
|
||||
$csp['style-src'] .= " 'unsafe-inline'";
|
||||
}
|
||||
if (strpos($csp['script-src'], 'unsafe-inline') === false) {
|
||||
$csp['script-src'] .= " 'unsafe-inline'";
|
||||
}
|
||||
if (strpos($csp['script-src'], 'unsafe-eval') === false) {
|
||||
$csp['script-src'] .= " 'unsafe-eval'";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user