/**----------------------------------------------- * * Rooty, 2020 * * * 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 * @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; $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=''; 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; /* 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), "
", $parsed); return $parsed; } /** * includeDependancy : retourne la chaine d'appel aux javascript indispensable * *

Retourne la chaine Javascript Avec le bon chemin (en fonction de SYSTEM_PATH)

* @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,});});"; mxRawJs($arrayRawJs); return true; } /** * includeDependancy : retourne la chaine d'appel aux javascript indispensable * *

Retourne la chaine Javascript Avec le bon chemin (en fonction de SYSTEM_PATH)

* @return chaine chaine d'appel javascript */ function includeRawJs() { $name =$this->name; // $form =$this->form; $lang =$this->lang; // $string =$this->string; $width =$this->width; $height =$this->height; // $toolbar =$this->toolbar; $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,});});"; mxRawJs($arrayRawJs); return true; } /** * IsVideJs :permet de savoir en javascript si le champ est vide * *

donne le nom de la fonction ou l'appel permettant de determiner si vide en js

* * @return chaine chaine d'appel javascript */ function IsVideJs() { return '(document.'.$this->form.'.'.$this->name.'.value=="")?true:false;'; } } ?>