Skip to content

Commit

Permalink
Add tinymce5
Browse files Browse the repository at this point in the history
We add the ul.unorderedList class in ?Content; otherwise the bullets
are not shown in edit mode.

We set the default Editor to Tinymce5.  For updates this is irrelevant,
but new installations should use it right away.

Co-authored-by: Christoph M. Becker <cmbecker69@gmx.de>

Closes GH-497.
  • Loading branch information
manu37 authored and cmb69 committed Aug 8, 2021
1 parent 042a7f4 commit d53633d
Show file tree
Hide file tree
Showing 136 changed files with 30,820 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmsimple/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
$cf['show_hidden']['path_locator']="";
$cf['images']['maxsize']="150000";
$cf['downloads']['maxsize']="1000000";
$cf['editor']['external']="tinymce4";
$cf['editor']['external']="tinymce5";
$cf['editor']['height']="600";
$cf['filebrowser']['external']="";
$cf['pagemanager']['external']="";
Expand Down
4 changes: 2 additions & 2 deletions content/content.htm
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ <h2>Hilfe/ Anleitungen/ Links</h2>
<?php
$page_data[]=array(
'url'=>'Content',
'last_edit'=>'1576335349',
'last_edit'=>'1613557047',
'description'=>'',
'keywords'=>'',
'title'=>'',
Expand Down Expand Up @@ -159,7 +159,7 @@ <h6>Heading <span style="font-size: .6em; color: #999;">&lt;h6&gt;</span></h6>
<p>Fusce imperdiet, augue at dignissim ultricies, tortor libero vehicula neque, ac malesuada lorem dolor et arcu. Quisque accumsan metus vel diam.</p>
<h2>Lists</h2>
<h3>Unordered list</h3>
<ul>
<ul class="listUnordered">
<li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Quisque cursus, mauris nec sagittis dictum, nunc pede facilisis nisl, id mattis nunc nulla in ipsum.</li>
<li>Donec ullamcorper, nulla eu faucibus sagittis, wisi risus ultrices metus, a ornare purus metus eget elit.<br>
<ul>
Expand Down
674 changes: 674 additions & 0 deletions plugins/tinymce5/LICENSE

Large diffs are not rendered by default.

181 changes: 181 additions & 0 deletions plugins/tinymce5/admin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
<?php
/**
* tinyMCE5 Editor - admin module
*
* PHP version >= 7
*
* @category CMSimple_XH
*
* @package Tinymce5
* @author manu <info@pixolution.ch>
* @copyright 1999-2009 <http://cmsimple.org/>
* @copyright 2009-2021 The CMSimple_XH developers <http://cmsimple-xh.org/?The_Team>
* @license http://www.gnu.org/licenses/gpl-3.0.en.html GNU GPLv3
* @link http://cmsimple-xh.org/
* @since File available since Release 1.6.0
*/
/* utf-8 marker: äöü */

if (!XH_ADM ) {
return;
}

/**
* handle API calls
*
*/
if (isset($_GET['tinymce5']) && $_GET['tinymce5'] == 'imageuploader') {
tinymce5_imageUploader();
exit;
}

/*
* Register the plugin type.
*/
if (function_exists('XH_registerPluginType')) {
XH_registerPluginType('editor', $plugin);
}

/*
* Register the plugin menu items.
*/
if (function_exists('XH_registerStandardPluginMenuItems')) {
XH_registerStandardPluginMenuItems(false);
}

if (XH_wantsPluginAdministration($plugin)) {

//Helper-functions

/**
* Returns all available init option.
*
* @return array options
*/
function tinymce_getInits()
{
global $action, $plugin, $pth;
$inits = glob($pth['folder']['plugins'] . $plugin.'/inits/*.json');

$options = array();
foreach ($inits as $init) {
$temp = explode('_', basename($init, '.json'));
if (isset($temp[1])) {
$options[] = $temp[1];
}
}
return $options;
}

/*
* Register the plugin menu items.
*/

if (XH_wantsPluginAdministration($plugin)) {
$o .= print_plugin_admin('on');
switch ($admin) {
case '':
case 'plugin_main':
$tiny_src = $plugin_cf[$plugin]['CDN'] == true ?
$plugin_cf[$plugin]['CDN_src'] :
$pth['folder']['plugins'] . $plugin.'/' . 'tinymce/tinymce.min.js';

$o .= '<script type="text/javascript" src="' . $tiny_src . '"></script>'.PHP_EOL;

$tinymce_version
= '<script type="text/javascript">
if (typeof(tinymce) === "undefined" || tinymce === null) {
alert("tinyMCE not present! Either offline or local library missing.")
}
else {
document.write(tinymce.majorVersion + " (revision "
+ tinymce.minorVersion + ")");
}
</script>';

$o .= '<h1>TinyMCE5 for CMSimple_XH</h1>'.PHP_EOL;
$o .= '<p>Version for '.CMSIMPLE_XH_VERSION.'</p>'.PHP_EOL;
$o .= '<p>TinyMCE ';
$o .= $plugin_cf['tinymce5']['CDN'] == true ? 'Content delivery network (CDN) ': '';
$o .= 'version ' . $tinymce_version .
' &ndash; <a href="https://www.tiny.cloud/beta/" ' .
'target="_blank">www.tiny.cloud/</a><br>'.PHP_EOL;
$o .= 'Available language packs: cs, da, de, en, et, fr, it, nl, pl, ';
$o .= 'ru, sk tw, zh.</p>'.PHP_EOL;
$o .= '<p>CMSimple_XH<br>'.PHP_EOL;
$o .= 'up to version 1.5.6 &ndash; <a href="http://www.zeichenkombinat';
$o .= '.de/" target="_blank">Zeichenkombinat.de</a><br>'.PHP_EOL;
$o .= 'from &nbsp;version 1.5.7 &ndash; <a href="http://www.pixolution';
$o .= '.ch/" target="_blank">pixolution.ch</a></p>'.PHP_EOL;
$o .= '<h2>Credits</h2>'.PHP_EOL;
$o .= '<p>Font Awesome Plugin made by
<a href="https://www.cmsimple-xh.org/?About-CMSimple_XH/The-XH-Team"
target="_blank">frase</a><br>'.PHP_EOL;
$o .= 'xhPluginCall Plugin made by
<a href="http://www.cmsimple.sk/?Impressum" target="_blank">Tata</a>
and <a href="https://www.cmsimple-xh.org/?About-CMSimple_XH/The-XH-Team"
target="_blank">manu</a><br>'.PHP_EOL;
$o .= 'init script inspired by
<a href="https://www.cmsimple-xh.org/?About-CMSimple_XH/The-XH-Team"
target="_blank">cmb69\'s</a> codeeditor\'s init.<br>'.PHP_EOL;
$o .= 'imageUpload script inspired by
<a href="https://www.cmsimple-xh.org/?About-CMSimple_XH/The-XH-Team"
target="_blank">cmb69\'s</a> filebrowser upload.</p>'.PHP_EOL;
break;
default:
$o .= plugin_admin_common();
}
return;
}
}

/**
* Handles the imageUploader.
*
* @return void
*
* @global array the config array.
*/
function tinymce5_imageUploader()
{
global $cf;

$imgUploader = new Tinymce5\Uploader();
$imgUploader->setBrowseBase(CMSIMPLE_BASE);
$imgUploader->setMaxFileSize('images', $cf['images']['maxsize']);

$imgUploader->linkType = 'images';

$imgUploader->baseDirectory
= $imgUploader->baseDirectories['userfiles'];
$imgUploader->currentDirectory
= $imgUploader->baseDirectories['images'];

if (isset($_GET['subdir'])) {
$subdir = str_replace(
array('../', './', '?', '<', '>', ':'), '', $_GET['subdir']
);

if (strpos($subdir, $imgUploader->baseDirectory) === 0) {
$imgUploader->currentDirectory = rtrim($subdir, '/') . '/';
}
}
$imgUploader->determineCurrentType();

reset ($_FILES);
if ($imgUploader->uploadFile(current($_FILES))) {
echo json_encode(array('location' => $imgUploader->fileWritten));
// XH_logMessage( 'info', 'uploadFile', 'tinymce5', 'fileWritten: ' . $imgUploader->fileWritten);

} else {
foreach ($imgUploader->errMsg as $key => $val) {
XH_logMessage( 'error', 'uploadFile', 'tinymce5', $key . ': ' . $val);
}
// Notify editor that the upload failed
header("HTTP/1.0 500 Server Error, See XH logfile");
}
}
/*
* EOF tinymce5/admin.php
*/
Loading

0 comments on commit d53633d

Please sign in to comment.