-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.php
More file actions
153 lines (133 loc) · 5.72 KB
/
Copy pathplugin.php
File metadata and controls
153 lines (133 loc) · 5.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<?php
/**
* Ckeditor + filemanager
*
* @package Bludit
* @subpackage Plugins
* @author Frédéric K.
* @copyright 2015-2016 Frédéric K.
* @version 1.0.8
* @release 2015-07-14
* @update 2016-03-07
*
*/
class pluginCKeditor extends Plugin {
private $loadWhenController = array(
'new-post',
'new-page',
'edit-post',
'edit-page'
);
public function init()
{
$this->dbFields = array(
'toolbar' => 'basic',
'skin' => 'bludit',
'akey' => pluginCKeditor::randomString()
);
}
/**
* AFFICHE LA FEUILLE DE STYLE ET LE JAVASCRIPT UNIQUEMENT EN ADMINISTRATION (POSTS/PAGES).
*
*/
public function adminHead()
{
global $Site;
global $layout;
$pluginPath = $this->htmlPath(). 'libs' .DS. 'ckeditor'. DS;
$html = '';
if(in_array($layout['controller'], $this->loadWhenController))
{
$language = $Site->shortLanguage();
$_SESSION["editor_lang"] = $Site->language();
$html .= '<script src="'.$pluginPath. 'ckeditor.js"></script>'.PHP_EOL;
$html .= '<script src="'.$pluginPath. 'lang' .DS. $language.'.js"></script>'.PHP_EOL;
}
return $html;
}
public function adminBodyEnd()
{
global $Security, $Site, $layout;
$pluginPath = $this->htmlPath(). 'libs' .DS. 'filemanager' .DS;
$html = '';
if(in_array($layout['controller'], $this->loadWhenController))
{
$language = $Site->shortLanguage();
$html .= '
<script>
$(\'textarea[name="content"]\').each(function(){
CKEDITOR.replace( this , {
language: \''.$language.'\',
fullPage: false,
allowedContent: false,
filebrowserBrowseUrl : \''.$pluginPath.'dialog.php?type=2&editor=ckeditor&akey='.$this->getDbField('akey').'&fldr=\',
filebrowserImageBrowseUrl : \''.$pluginPath.'dialog.php?type=1&editor=ckeditor&akey='.$this->getDbField('akey').'&fldr=\',
filebrowserUploadUrl : \''.$pluginPath.'dialog.php?type=2&editor=ckeditor&akey='.$this->getDbField('akey').'&fldr=\'
});
CKEDITOR.config.entities = false; // pour faciliter la lecture du code source, les accents ne sont pas transformés en entités HTML (inutiles avec le codage utf-8 des pages)
// Correction orthographique en français par défaut :
CKEDITOR.config.language = \''.$language.'\';
CKEDITOR.config.wsc_lang = \''.$Site->locale().'\';
CKEDITOR.config.scayt_sLang = \''.$Site->locale().'\';
// config.scayt_autoStartup = false; // Ligne à activer s’il faut supprimer la correction orthographique automatique, qui génère beaucoup d’accès Internet et peut ralentir l’édition.
'.($this->getDbField('toolbar') == 'standard' ? 'CKEDITOR.config.toolbar =
[[\'Bold\', \'Italic\', \'Underline\', \'-\', \'NumberedList\', \'BulletedList\', \'-\', \'JustifyLeft\',\'JustifyCenter\',\'JustifyRight\',\'JustifyBlock\', \'-\', \'Link\', \'Unlink\', \'Image\', \'RemoveFormat\', \'-\', \'Table\', \'TextColor\', \'BGColor\', \'ShowBlocks\'], [\'Source\'], [\'Maximize\'],
\'/\',
[\'Styles\',\'Format\',\'Font\',\'FontSize\']];' : '').'
'.($this->getDbField('toolbar') == 'basic' ? 'CKEDITOR.config.toolbar =
[[\'Bold\', \'Italic\', \'Underline\', \'-\', \'NumberedList\', \'BulletedList\', \'-\', \'JustifyLeft\',\'JustifyCenter\',\'JustifyRight\',\'JustifyBlock\', \'-\', \'Link\', \'Unlink\', \'Image\', \'RemoveFormat\'], [\'Source\'], [\'Maximize\'] ];' : '').'
CKEDITOR.config.skin = \''.$this->getDbField('skin').'\';
});
</script>'.PHP_EOL;
}
return $html;
}
public function form()
{
global $Language;
$html = '<div class="uk-form-select" data-uk-form-select>
<span></span>';
$html .= '<label for="toolbar">'.$Language->get('Select toolbar').'</label>';
$html .= '<select name="toolbar">';
$toolbarOptions = array('basic' => $Language->get('Basic'),'standard' => $Language->get('Standard'),'advanced' => $Language->get('Advanced'));
foreach($toolbarOptions as $text=>$value)
$html .= '<option value="'.$text.'"'.( ($this->getDbField('toolbar')===$text)?' selected="selected"':'').'>'.$value.'</option>';
$html .= '</select>';
$html .= '<div class="uk-form-help-block">'.$Language->get('Advanced is the full package of CKEditor').'</div>';
$html .= '</div>';
$html .= '<div>';
$html .= '<label for="jsakey">'.$Language->get('Filemanager Access Key').'</label>';
$html .= '<div class="uk-form-icon">';
$html .= '<i class="uk-icon-key"></i>';
$html .= '<input class="uk-form-width-large" name="akey" id="jsakey" type="text" value="'.$this->getDbField('akey').'">';
$html .= '</div>';
$html .= '<div class="uk-form-help-block">'.$Language->get('Generate key (refresh for new):'). ' <b>'.pluginCKeditor::randomString().'</b></div>';
$html .= '</div>';
$html .= '<div class="uk-form-select" data-uk-form-select>
<span></span>';
$html .= '<label for="skin">'.$Language->get('Select skin').'</label>';
$html .= '<select name="skin">';
$skinOptions = array('kama'=>'Kama','flat'=>'Flat','moono'=>'Moono','minimalist'=>'Minimalist','icy_orange'=>'Icy Orange','moono-dark'=>'Moono Dark','bludit'=>'Bludit');
foreach($skinOptions as $text=>$value)
$html .= '<option value="'.$text.'"'.( ($this->getDbField('skin')===$text)?' selected="selected"':'').'>'.$value.'</option>';
$html .= '</select>';
$html .= '</div>';
return $html;
}
/*
* Create a random string
* @author XEWeb <>
* @param $length the length of the string to create
* @return $str the string
*/
public function randomString($length = 12) {
$str = "";
$characters = array_merge(range('A','Z'), range('a','z'), range('0','9'));
$max = count($characters) - 1;
for ($i = 0; $i < $length; $i++) {
$rand = mt_rand(0, $max);
$str .= $characters[$rand];
}
return $str;
}
}