240 lines
6.3 KiB
PHP
Executable File
240 lines
6.3 KiB
PHP
Executable File
<?php
|
|
|
|
/**
|
|
*<BR>
|
|
/**-----------------------------------------------
|
|
*
|
|
* Rooty, 2020 <rooty@rooty.me>
|
|
*
|
|
*
|
|
* This software is protected by copyright, please
|
|
* read the file COPYRIGHT.
|
|
* 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. Please
|
|
* read the file LICENCE.
|
|
*
|
|
* Fichier summernote.php
|
|
*
|
|
*Ce fichier contient la classe summernote
|
|
*
|
|
* @author Rooty <www.rooty.me|rooty@rooty.me>
|
|
* @since 2020/11/22
|
|
* @link www.rooty.me
|
|
* @version 0.1
|
|
* @package package
|
|
* @subpackage summernote
|
|
* @copyright Copyright © 2020, Rooty
|
|
*/
|
|
if ( !defined('SYSTEM_IN') )
|
|
{
|
|
die("Hacking attempt");
|
|
}
|
|
|
|
/**
|
|
* Classe summernote
|
|
*
|
|
* Permet la gestion du wyziwig de phpSummerNote.
|
|
* @package package
|
|
* @subpackage summernote
|
|
*/
|
|
class SummerNote
|
|
{
|
|
/**
|
|
* @var chaine
|
|
* @desc nom de l'élément du formulaire
|
|
*/
|
|
var $name = null;
|
|
|
|
/**
|
|
* @var chaine
|
|
* @desc nom du formulaire
|
|
*/
|
|
var $form = null;
|
|
|
|
/**
|
|
* @var chaine
|
|
* @desc nom du formulaire
|
|
*/
|
|
var $lang = null;
|
|
|
|
/**
|
|
* @var chaine
|
|
* @desc valeur de la chaine html
|
|
*/
|
|
var $string = null;
|
|
|
|
/**#@-*/
|
|
//
|
|
// Constructor
|
|
//
|
|
/**
|
|
* Constructeur de la classe summernote
|
|
*
|
|
* @param chaine nom du champ
|
|
* @param chaine nom du formulaire
|
|
* @param chaine valeur de la chaine à afficher
|
|
* @param chaine vrai ou faux pour l'utilisation des icones
|
|
*/
|
|
function summernote($name, $form, $lang, $string, $width, $height, $toolbar)
|
|
{
|
|
global $CONF_LIB_PATH;
|
|
|
|
// require_once($CONF_LIB_PATH."lib/package/wysi/summernote/summernotecode.php");
|
|
// require_once($CONF_LIB_PATH."lib/package/wysi/summernote/functions_post.php");
|
|
|
|
// if (strtolower($toolbar)=="default")
|
|
// $toolbar="Default";
|
|
//
|
|
// if (strtolower($toolbar)=="basic")
|
|
// $toolbar="Basic";
|
|
|
|
$this->name =$name;
|
|
$this->form =$form;
|
|
$this->lang =$lang;
|
|
$this->string =$string;
|
|
$this->width =$width;
|
|
$this->height =$height;
|
|
$this->toolbar =$toolbar;
|
|
}
|
|
|
|
/**
|
|
* Display retourne la chaine d'affichage du wizi wig
|
|
*/
|
|
function SetContent($src)
|
|
{
|
|
global $CONF_DATA_PATH;
|
|
|
|
$this->string =$src;
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Display retourne la chaine d'affichage du wizi wig
|
|
*/
|
|
function Display()
|
|
{
|
|
global $CONF_DATA_PATH;
|
|
|
|
$name =$this->name;
|
|
$form =$this->form;
|
|
$lang =$this->lang;
|
|
$string =$this->string;
|
|
$width =$this->width;
|
|
$height =$this->height;
|
|
$toolbar =$this->toolbar;
|
|
|
|
$element=$form.".".$name;
|
|
$html='<textarea class="form-control p-0 m-0" id="'.$name.'" name="'.$name.'" rows="12">'.$string.'</textarea>';
|
|
return $html;
|
|
}
|
|
|
|
/**
|
|
* ReturnData : retourne les données à partir de la chaine postée
|
|
* @return chaine au format html
|
|
*/
|
|
function ReturnContent()
|
|
{
|
|
global $_POST, $CONF_LIB_PATH;
|
|
|
|
$name =$this->name;
|
|
$form =$this->form;
|
|
$lang =$this->lang;
|
|
$message =$this->string;
|
|
// $message=isset($_POST[$name])?$_POST[$name]:"";
|
|
/*
|
|
$html_on=1;
|
|
$summernotecode_on=1;
|
|
$smilies_on=1;
|
|
$summernotecode_uid = ( $summernotecode_on ) ? make_summernotecode_uid() : '';
|
|
$preview_message = stripslashes(prepare_message(addslashes(unprepare_message($message)), $html_on, $summernotecode_on, $smilies_on, $summernotecode_uid));
|
|
$preview_message = summernoteencode_second_pass($preview_message, $summernotecode_uid);
|
|
$preview_message = make_clickable($preview_message);
|
|
$preview_message = $preview_message;
|
|
$preview_message = str_replace("\n", '<br />', $preview_message);
|
|
|
|
if ($this->smile)
|
|
{
|
|
$preview_message=$this->ReplaceSmile($preview_message);
|
|
}
|
|
return $preview_message;*/
|
|
|
|
/* adjust include_path to include PEAR */
|
|
// ini_set('include_path', ini_get('include_path').':'.$GLOBALS["CONF_LIB_PATH"].'lib/PEAR');
|
|
|
|
/* require PEAR and the parser */
|
|
require_once('PEAR.php');
|
|
require_once('HTML/SummerNoteCodeParser.php');
|
|
|
|
/* get options from the ini file */
|
|
|
|
$config = parse_ini_file($CONF_LIB_PATH.'lib/package/wysi/summernote/summernotecodeparser.ini', true);
|
|
$options = &PEAR::getStaticProperty('HTML_SummerNoteCodeParser', '_options');
|
|
$options = $config['HTML_SummerNoteCodeParser'];
|
|
unset($options);
|
|
|
|
/* do yer stuff! */
|
|
$parser = new HTML_SummerNoteCodeParser();
|
|
$parser->setText($message);
|
|
$parser->parse();
|
|
$parsed = $parser->getParsed();
|
|
|
|
$parsed = str_replace(chr(10), "<br/>", $parsed);
|
|
// $parsed = str_replace(" ", " ", $parsed);
|
|
return $parsed;
|
|
}
|
|
|
|
/**
|
|
* includeDependancy : retourne la chaine d'appel aux javascript indispensable
|
|
*
|
|
*<p>Retourne la chaine Javascript Avec le bon chemin (en fonction de SYSTEM_PATH)</p>
|
|
* @return chaine chaine d'appel javascript
|
|
*/
|
|
function includeDependancy()
|
|
{
|
|
$name =$this->name;
|
|
$form =$this->form;
|
|
$lang =$this->lang;
|
|
$string =$this->string;
|
|
$width =$this->width;
|
|
$height =$this->height;
|
|
$toolbar =$this->toolbar;
|
|
|
|
$element=$form.".".$name;
|
|
|
|
$arrayCallCss = array();
|
|
$arrayCallCss[] = "data/javascript/summernote/0.8.18/summernote-bs4.min.css";
|
|
$arrayCallCss[] = "";
|
|
mxCallCss($arrayCallCss);
|
|
|
|
$arrayCallJs = array();
|
|
$arrayCallJs[] = "data/javascript/summernote/0.8.18/summernote-bs4.min.js";
|
|
$arrayCallJs[] = "data/javascript/summernote/plugins/file/201910/summernote-file.js";
|
|
$arrayCallJs[] = "data/javascript/summernote/0.8.18/lang/summernote-fr-FR.min.js";
|
|
mxCallJs($arrayCallJs);
|
|
|
|
$arrayRawJs[] = "\$(document).ready( function(){\$('#".$name."').summernote({lang: '".$lang."',toolbar: [['style', ['style','fontsize']],['font', ['bold', 'underline', 'clear']],['fontname', ['fontname']],['color',['backcolor','color']],['para', ['style','ul', 'ol', 'paragraph']],['table', ['table']],['hr', ['hr']],/* File plugin not enabled */ /* ['insert', ['file','link', 'picture', 'video']], */ ['insert', ['link', 'picture', 'video']],['view', ['fullscreen', 'codeview']],['misc', ['undo', 'redo']],],height: ".$height.",disableResizeEditor: true, /* disable resizing editor */ airMode: false,});});";
|
|
$arrayRawJs[] = "";
|
|
mxRawJs($arrayRawJs);
|
|
|
|
// var_dump($arrayCallCss);
|
|
// var_dump($arrayCallJs);
|
|
// var_dump($arrayRawJs);
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* IsVideJs :permet de savoir en javascript si le champ est vide
|
|
*
|
|
*<p>donne le nom de la fonction ou l'appel permettant de determiner si vide en js</p>
|
|
*
|
|
* @return chaine chaine d'appel javascript
|
|
*/
|
|
function IsVideJs()
|
|
{
|
|
return '(document.'.$this->form.'.'.$this->name.'.value=="")?true:false;';
|
|
}
|
|
}
|
|
?>
|