Skip to content

Xoops Editor TinyMCE 5 #1053

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Sep 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions htdocs/class/xoopseditor/tinymce5/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# tinyMCE5ForXoops
TinyMCE 5 pour xoops
29 changes: 29 additions & 0 deletions htdocs/class/xoopseditor/tinymce5/editor_registry.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
/**
* You may not change or alter any portion of this comment or credits
* of supporting developers from this source code or any supporting source code
* which is considered copyrighted (c) material of the original comment or credit authors.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/

/**
* TinyMCE5 adapter for XOOPS
*
* @category XoopsEditor
* @package TinyMCE5
* @author Gregory Mage
* @author Taiwen Jiang <[email protected]>
* @copyright 2020 XOOPS Project (http://xoops.org)
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
* @link http://xoops.org
*/

return $config = array(
'name' => 'tinymce5',
'class' => 'XoopsFormTinymce5',
'file' => XOOPS_ROOT_PATH . '/class/xoopseditor/tinymce5/formtinymce5.php',
'title' => _XOOPS_EDITOR_TINYMCE5,
'order' => 5,
'nohtml' => 0);
4 changes: 4 additions & 0 deletions htdocs/class/xoopseditor/tinymce5/extra/Config.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
To integrate the css of your theme in tinymce (for an identical rendering in the tinymce window and your theme),
it is necessary to copy the css file from this folder to the root of your theme.

If you use several css files, it is necessary to include them in tinymce.css (@import url ());
1 change: 1 addition & 0 deletions htdocs/class/xoopseditor/tinymce5/extra/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<script>history.go(-1);</script>
9 changes: 9 additions & 0 deletions htdocs/class/xoopseditor/tinymce5/extra/tinymce.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.tinymce5-body {
background-color: white;
color: black;
padding-top: 0px;
padding-left: 5px;
}

@import url(css-cerulean/bootstrap.min.css);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IS it possible to read the css file automatically with XOOPS smarty ?
Cause if someone use dark theme, css-cerulean is not the good css file !

But Strange cause I used dark theme (slate theme) and the background, is the same dark background, not the cerulean background color.

Strange but it works ! ;-)

Bonnes vacances, Nicolas !

@import url(style.css);
129 changes: 129 additions & 0 deletions htdocs/class/xoopseditor/tinymce5/formtinymce5.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
<?php
/**
* You may not change or alter any portion of this comment or credits
* of supporting developers from this source code or any supporting source code
* which is considered copyrighted (c) material of the original comment or credit authors.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/

/**
* TinyMCE5 adapter for XOOPS
*
* @category XoopsEditor
* @package TinyMCE5
* @author Gregory Mage
* @author Taiwen Jiang <[email protected]>
* @copyright 2020 XOOPS Project (http://xoops.org)
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
* @link http://xoops.org
*/

xoops_load('XoopsEditor');

/**
* Class XoopsFormTinymce
*/
class XoopsFormTinymce5 extends XoopsEditor
{
public $language;
public $width = '100%';
public $height = '500px';

public $editor;

/**
* Constructor
*
* @param array $configs Editor Options
*/
public function __construct($configs)
{
$current_path = __FILE__;
if (DIRECTORY_SEPARATOR !== '/') {
$current_path = str_replace(strpos($current_path, "\\\\", 2) ? "\\\\" : DIRECTORY_SEPARATOR, '/', $current_path);
}

$this->rootPath = '/class/xoopseditor/tinymce5';
parent::__construct($configs);
$this->configs['elements'] = $this->getName();
$this->configs['language'] = $this->getLanguage();
$this->configs['rootpath'] = $this->rootPath;
$this->configs['area_width'] = isset($this->configs['width']) ? $this->configs['width'] : $this->width;
$this->configs['area_height'] = isset($this->configs['height']) ? $this->configs['height'] : $this->height;

require_once __DIR__ . '/tinymce5.php';
$this->editor = new TinyMCE($this->configs);
}

/**
* Renders the Javascript function needed for client-side for validation
*
* I'VE USED THIS EXAMPLE TO WRITE VALIDATION CODE
* http://tinymce.moxiecode.com/punbb/viewtopic.php?id=12616
*
* @return string
*/
public function renderValidationJS()
{
if ($this->isRequired() && $eltname = $this->getName()) {
//$eltname = $this->getName();
$eltcaption = $this->getCaption();
$eltmsg = empty($eltcaption) ? sprintf(_FORM_ENTER, $eltname) : sprintf(_FORM_ENTER, $eltcaption);
$eltmsg = str_replace('"', '\"', stripslashes($eltmsg));
$ret = "\n";
$ret .= "if ( tinyMCE.get('{$eltname}').getContent() == \"\" || tinyMCE.get('{$eltname}').getContent() == null) ";
$ret .= "{ window.alert(\"{$eltmsg}\"); tinyMCE.get('{$eltname}').focus(); return false; }";

return $ret;
}

return '';
}

/**
* get language
*
* @return string
*/
public function getLanguage()
{
if ($this->language) {
return $this->language;
}
if (defined('_XOOPS_EDITOR_TINYMCE5_LANGUAGE')) {
$this->language = strtolower(constant('_XOOPS_EDITOR_TINYMCE5_LANGUAGE'));
} else {
$this->language = str_replace('_', '-', strtolower(_LANGCODE));
if (strtolower(_CHARSET) === 'utf-8') {
$this->language .= '_utf8';
}
}

return $this->language;
}

/**
* prepare HTML for output
*
* @return string HTML
*/
public function render()
{
$ret = $this->editor->render();
$ret .= parent::render();

return $ret;
}

/**
* Check if compatible
*
* @return bool
*/
public function isActive()
{
return is_readable(XOOPS_ROOT_PATH . $this->rootPath . '/tinymce5.php');
}
}
1 change: 1 addition & 0 deletions htdocs/class/xoopseditor/tinymce5/include/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<script>history.go(-1);</script>
17 changes: 17 additions & 0 deletions htdocs/class/xoopseditor/tinymce5/include/xoopscode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
/**
* TinyMCE adapter for XOOPS
*
* @copyright (c) 2000-2016 XOOPS Project (www.xoops.org)
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
* @package class
* @subpackage editor
* @since 2.3.0
* @author Laurent JEN <[email protected]>
*/

defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined');

// Add your code here to check access by groups

return true;
18 changes: 18 additions & 0 deletions htdocs/class/xoopseditor/tinymce5/include/xoopsemotions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
/**
* TinyMCE adapter for XOOPS
*
* @copyright (c) 2000-2016 XOOPS Project (www.xoops.org)
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
* @package class
* @subpackage editor
* @since 2.3.0
* @author Laurent JEN <[email protected]>
*/

defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined');

include_once XOOPS_ROOT_PATH . '/modules/system/constants.php';
// Add your code here to check access by groups

return true;
19 changes: 19 additions & 0 deletions htdocs/class/xoopseditor/tinymce5/include/xoopsimagemanager.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
/**
* TinyMCE adapter for XOOPS
*
* @copyright (c) 2000-2016 XOOPS Project (www.xoops.org)
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
* @package class
* @subpackage editor
* @since 2.3.0
* @author Laurent JEN <[email protected]>
*/

defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined');

// check categories readability by group
$groups = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : array(XOOPS_GROUP_ANONYMOUS);
$imgcat_handler = xoops_getHandler('imagecategory');

return !(count($imgcat_handler->getList($groups, 'imgcat_read', 1)) == 0);
21 changes: 21 additions & 0 deletions htdocs/class/xoopseditor/tinymce5/include/xoopsmlcontent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
/**
* TinyMCE adapter for XOOPS
*
* @copyright (c) 2000-2016 XOOPS Project (www.xoops.org)
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
* @package class
* @subpackage editor
* @since 2.3.0
* @author Laurent JEN <[email protected]>
*/

defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined');

// Xlanguage
if ($GLOBALS['module_handler']->getByDirname('xlanguage') && defined('XLANGUAGE_LANG_TAG')) {
return true;
}

// Easiest Multi-Language Hack (EMLH)
return defined('EASIESTML_LANGS') && defined('EASIESTML_LANGNAMES');
17 changes: 17 additions & 0 deletions htdocs/class/xoopseditor/tinymce5/include/xoopsquote.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
/**
* TinyMCE adapter for XOOPS
*
* @copyright (c) 2000-2016 XOOPS Project (www.xoops.org)
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
* @package class / xoopseditor
* @subpackage tinymce
* @since 2.3.0
* @author Laurent JEN <[email protected]>
*/

defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined');

// Add your code here to check access by groups

return true;
1 change: 1 addition & 0 deletions htdocs/class/xoopseditor/tinymce5/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<script>history.go(-1);</script>
26 changes: 26 additions & 0 deletions htdocs/class/xoopseditor/tinymce5/language/english.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
/**
* You may not change or alter any portion of this comment or credits
* of supporting developers from this source code or any supporting source code
* which is considered copyrighted (c) material of the original comment or credit authors.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/

/**
* TinyMCE5 adapter for XOOPS
*
* @category XoopsEditor
* @package TinyMCE5
* @author Gregory Mage
* @author Taiwen Jiang <[email protected]>
* @copyright 2020 XOOPS Project (http://xoops.org)
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
* @link http://xoops.org
*/
// Name of the editor
define('_XOOPS_EDITOR_TINYMCE5', 'TinyMCE5');
// The value must be the same as /tinymce/jscripts/langs/your_language_code, for example, "en" for English, "fr" for French
// For details, check http://tinymce.moxiecode.com/download_i18n.php
define('_XOOPS_EDITOR_TINYMCE_LANGUAGE5', 'en');
26 changes: 26 additions & 0 deletions htdocs/class/xoopseditor/tinymce5/language/french.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
/**
* You may not change or alter any portion of this comment or credits
* of supporting developers from this source code or any supporting source code
* which is considered copyrighted (c) material of the original comment or credit authors.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/

/**
* TinyMCE5 adapter for XOOPS
*
* @category XoopsEditor
* @package TinyMCE5
* @author Gregory Mage
* @author Taiwen Jiang <[email protected]>
* @copyright 2020 XOOPS Project (http://xoops.org)
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
* @link http://xoops.org
*/
// Name of the editor
define('_XOOPS_EDITOR_TINYMCE5', 'TinyMCE5');
// The value must be the same as /tinymce/jscripts/langs/your_language_code, for example, "en" for English, "fr" for French
// For details, check http://tinymce.moxiecode.com/download_i18n.php
define('_XOOPS_EDITOR_TINYMCE5_LANGUAGE', 'fr');
1 change: 1 addition & 0 deletions htdocs/class/xoopseditor/tinymce5/language/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<script>history.go(-1);</script>
39 changes: 39 additions & 0 deletions htdocs/class/xoopseditor/tinymce5/settings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
/**
* You may not change or alter any portion of this comment or credits
* of supporting developers from this source code or any supporting source code
* which is considered copyrighted (c) material of the original comment or credit authors.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/

/**
* TinyMCE5 adapter for XOOPS
*
* @category XoopsEditor
* @package TinyMCE5
* @author Gregory Mage
* @copyright 2020 XOOPS Project (http://xoops.org)
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
* @link http://xoops.org
*/
return array(
'theme' => 'silver',
'mode' => 'exact',
'plugins' => 'advlist,anchor,autolink,charmap,code,hr,image,imagetools,lists,link,media,preview,searchreplace,table,xoopsemoticons,xoopscode,xoopsimagemanager',
'toolbar' => 'undo redo | styleselect | bold italic | forecolor backcolor removeformat | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | table tabledelete | insertfile image media link | hr | xoopsemoticons xoopscode | code',
'image_title' => true,
'table_use_colgroups' => true,
/*'image_class_list' => [
{title: 'None', value: ''},
{title: 'Width auto', value: 'col-12'}
],*/
//'image_advtab' => true, dot work !!
// This option prevents tinyeditor from deleting empty tags
'valid_elements' => '*[*]',
// Use of relative urls?
'relative_urls' => false,
'body_class' => 'tinymce5-body',
'menubar' => false
);
6 changes: 6 additions & 0 deletions htdocs/class/xoopseditor/tinymce5/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
body.mceContentBody {
margin: 0;
padding: 0;
background: #fff none;
color: #000;
}
Loading