openrat-cms

OpenRat Content Management System
git clone http://git.code.weiherhei.de/openrat-cms.git
Log | Files | Refs | README

commit 5f86947dda9383ab7476ca71a3471c1cdfddb601
parent b45b94bc937a4daab56d6cdbd8c367538bab3ff9
Author: Jan Dankert <develop@jandankert.de>
Date:   Thu, 12 Nov 2020 01:12:45 +0100

Fix: Workflow for changing the users email adress; Mail sending; Forwarding forms

Diffstat:
Mmodules/cms/action/ProfileAction.class.php | 26++++++++++++++------------
Mmodules/cms/base/DefaultConfig.class.php | 4++--
Mmodules/cms/ui/themes/default/html/views/profile/confirmmail.php | 2+-
Mmodules/cms/ui/themes/default/html/views/profile/confirmmail.tpl.src.xml | 2+-
Mmodules/cms/ui/themes/default/html/views/profile/mail.php | 20+++-----------------
Mmodules/cms/ui/themes/default/html/views/profile/mail.tpl.src.xml | 39++++++++++++++++++---------------------
Mmodules/cms/ui/themes/default/script/openrat.js | 41+++++++++++++++++++++++++++++------------
Mmodules/cms/ui/themes/default/script/openrat.min.js | 9+++++----
Mmodules/cms/ui/themes/default/script/openrat/form.js | 29++++++++++++++++++-----------
Mmodules/cms/ui/themes/default/script/openrat/view.js | 12+++++++++++-
Mmodules/template_engine/components/html/component_form/FormComponent.class.php | 3+++
Mmodules/template_engine/components/template.xsd | 1+
Mmodules/util/Mail.class.php | 12++++--------
Mmodules/util/Session.class.php | 2++
14 files changed, 112 insertions(+), 90 deletions(-)

diff --git a/modules/cms/action/ProfileAction.class.php b/modules/cms/action/ProfileAction.class.php @@ -25,7 +25,10 @@ use cms\model\BaseObject; use cms\model\User; use language\Language; use language\Messages; +use logger\Logger; use LogicException; +use security\Password; +use util\exception\ValidationException; use util\Mail; use util\UIUtils; use security\Base2n; @@ -132,14 +135,13 @@ class ProfileAction extends BaseAction if ( empty($newMail) ) { // Keine E-Mail-Adresse eingegeben. - $this->addValidationError('mail'); - return; + throw new ValidationException('mail'); } else { // Der Freischaltcode wird in der Sitzung gespeichert. - Session::set('mailChangeCode',$code ); - Session::set('mailChangeMail',$newMail); + Session::set( Session::KEY_MAIL_CHANGE_CODE,$code ); + Session::set( Session::KEY_MAIL_CHANGE_MAIL,$newMail); // E-Mail an die neue Adresse senden. $mail = new Mail( $newMail,'mail_change_code' ); @@ -148,12 +150,12 @@ class ProfileAction extends BaseAction if ( $mail->send() ) { - $this->addNotice('user', 0, $this->user->name, 'mail_sent', Action::NOTICE_OK); // Meldung + $this->addNoticeFor( $this->user, Messages::MAIL_SENT); } else { - $this->addNotice('user', 0, $this->user->name, 'mail_not_sent', Action::NOTICE_ERROR, array(), $mail->error); // Meldung - return; + Logger::warn('Mail could not be sent: '.$mail->error); + $this->addNoticeFor($this->user, Messages::MAIL_NOT_SENT,[],$mail->error); // Meldung } } } @@ -175,8 +177,8 @@ class ProfileAction extends BaseAction */ function confirmmailPost() { - $sessionCode = Session::get('mailChangeCode'); - $newMail = Session::get('mailChangeMail'); + $sessionCode = Session::get( Session::KEY_MAIL_CHANGE_CODE ); + $newMail = Session::get( Session::KEY_MAIL_CHANGE_MAIL ); $inputRegisterCode = $this->getRequestVar('code'); if ( $sessionCode == $inputRegisterCode ) @@ -186,12 +188,12 @@ class ProfileAction extends BaseAction $this->user->mail = $newMail; $this->user->save(); - $this->addNotice('user', 0, $this->user->name, 'SAVED', Action::NOTICE_OK); + $this->addNoticeFor( $this->user,Messages::SAVED ); } else { - // Best�tigungscode stimmt nicht. - $this->addValidationError('code','code_not_match'); + // Validation code does not match + throw new ValidationException('code',Messages::CODE_NOT_MATCH ); } } diff --git a/modules/cms/base/DefaultConfig.class.php b/modules/cms/base/DefaultConfig.class.php @@ -423,8 +423,8 @@ class DefaultConfig { 'priority' => '3', 'header_encoding' => 'Quoted-printable', 'client' => 'php', - 'whitelist' => '', - 'blacklist' => '', + 'whitelist' => [], + 'blacklist' => [], 'smtp' => [ 'host' => 'locahost', diff --git a/modules/cms/ui/themes/default/html/views/profile/confirmmail.php b/modules/cms/ui/themes/default/html/views/profile/confirmmail.php @@ -20,7 +20,7 @@ <input type="<?php echo O::escapeHtml('hidden') ?>" name="<?php echo O::escapeHtml('subaction') ?>" value="<?php echo O::escapeHtml('confirmmail') ?>" /><?php echo O::escapeHtml('') ?> <input type="<?php echo O::escapeHtml('hidden') ?>" name="<?php echo O::escapeHtml('id') ?>" value="<?php echo O::escapeHtml(''.@$_id.'') ?>" /><?php echo O::escapeHtml('') ?> <section class="<?php echo O::escapeHtml('or-fieldset') ?>"><?php echo O::escapeHtml('') ?> - <h3 class="<?php echo O::escapeHtml('or-fieldset-label') ?>"><?php echo O::escapeHtml('mail_code') ?> + <h3 class="<?php echo O::escapeHtml('or-fieldset-label') ?>"><?php echo O::escapeHtml(''.@O::lang('mail_code').'') ?> </h3> <div class="<?php echo O::escapeHtml('or-fieldset-value') ?>"><?php echo O::escapeHtml('') ?> <input name="<?php echo O::escapeHtml('code') ?>" required="<?php echo O::escapeHtml('required') ?>" autofocus="<?php echo O::escapeHtml('autofocus') ?>" type="<?php echo O::escapeHtml('text') ?>" maxlength="<?php echo O::escapeHtml('256') ?>" value="<?php echo O::escapeHtml(''.@$code.'') ?>" class="<?php echo O::escapeHtml('or-input') ?>" /><?php echo O::escapeHtml('') ?> diff --git a/modules/cms/ui/themes/default/html/views/profile/confirmmail.tpl.src.xml b/modules/cms/ui/themes/default/html/views/profile/confirmmail.tpl.src.xml @@ -2,7 +2,7 @@ xsi:schemaLocation="http://www.openrat.de/template ../../../../../../../template_engine/components/template.xsd"> <logo name="changemail"/> <form> - <fieldset label="mail_code"> + <fieldset label="${message:mail_code}"> <input type="text" name="code" size="30" focus="true" required="true"/> </fieldset> </form> diff --git a/modules/cms/ui/themes/default/html/views/profile/mail.php b/modules/cms/ui/themes/default/html/views/profile/mail.php @@ -1,5 +1,5 @@ <?php /* THIS FILE IS GENERATED from mail.tpl.src.xml - DO NOT CHANGE */ defined('APP_STARTED') || die('Forbidden'); use \template_engine\Output as O; ?> - <form name="<?php echo O::escapeHtml('') ?>" target="<?php echo O::escapeHtml('_self') ?>" data-target="<?php echo O::escapeHtml('view') ?>" action="<?php echo O::escapeHtml('./') ?>" data-method="<?php echo O::escapeHtml('mail') ?>" data-action="<?php echo O::escapeHtml('profile') ?>" data-id="<?php echo O::escapeHtml(''.@$_id.'') ?>" method="<?php echo O::escapeHtml('post') ?>" enctype="<?php echo O::escapeHtml('application/x-www-form-urlencoded') ?>" data-async="<?php echo O::escapeHtml('') ?>" data-autosave="<?php echo O::escapeHtml('') ?>" class="<?php echo O::escapeHtml('or-form or-profile') ?>"><?php echo O::escapeHtml('') ?> + <form name="<?php echo O::escapeHtml('') ?>" target="<?php echo O::escapeHtml('_self') ?>" data-target="<?php echo O::escapeHtml('view') ?>" action="<?php echo O::escapeHtml('./') ?>" data-forward-to="<?php echo O::escapeHtml('confirmmail') ?>" data-method="<?php echo O::escapeHtml('mail') ?>" data-action="<?php echo O::escapeHtml('profile') ?>" data-id="<?php echo O::escapeHtml(''.@$_id.'') ?>" method="<?php echo O::escapeHtml('post') ?>" enctype="<?php echo O::escapeHtml('application/x-www-form-urlencoded') ?>" data-async="<?php echo O::escapeHtml('') ?>" data-autosave="<?php echo O::escapeHtml('') ?>" data-after-success="<?php echo O::escapeHtml('forward') ?>" class="<?php echo O::escapeHtml('or-form or-profile') ?>"><?php echo O::escapeHtml('') ?> <div class="<?php echo O::escapeHtml('or-form-headline') ?>"><?php echo O::escapeHtml('') ?> </div> <div class="<?php echo O::escapeHtml('or-form-content') ?>"><?php echo O::escapeHtml('') ?> @@ -30,28 +30,14 @@ </h2> <div class="<?php echo O::escapeHtml('or-collapsible-value or-group-value') ?>"><?php echo O::escapeHtml('') ?> <section class="<?php echo O::escapeHtml('or-fieldset') ?>"><?php echo O::escapeHtml('') ?> - <h3 class="<?php echo O::escapeHtml('or-fieldset-label') ?>"><?php echo O::escapeHtml('') ?> + <h3 class="<?php echo O::escapeHtml('or-fieldset-label') ?>"><?php echo O::escapeHtml(''.@O::lang('user_new_mail').'') ?> </h3> <div class="<?php echo O::escapeHtml('or-fieldset-value') ?>"><?php echo O::escapeHtml('') ?> - <div class="<?php echo O::escapeHtml('or-label') ?>"><?php echo O::escapeHtml('') ?> - <label class="<?php echo O::escapeHtml('or-label') ?>"><?php echo O::escapeHtml('') ?> - <span><?php echo O::escapeHtml(''.@O::lang('user_new_mail').'') ?> - </span> - </label> - </div> - <div class="<?php echo O::escapeHtml('or-value') ?>"><?php echo O::escapeHtml('') ?> - <input name="<?php echo O::escapeHtml('mail') ?>" type="<?php echo O::escapeHtml('text') ?>" maxlength="<?php echo O::escapeHtml('256') ?>" value="<?php echo O::escapeHtml(''.@$mail.'') ?>" class="<?php echo O::escapeHtml('or-input') ?>" /><?php echo O::escapeHtml('') ?> - </div> + <input name="<?php echo O::escapeHtml('mail') ?>" autofocus="<?php echo O::escapeHtml('autofocus') ?>" type="<?php echo O::escapeHtml('text') ?>" maxlength="<?php echo O::escapeHtml('256') ?>" value="<?php echo O::escapeHtml(''.@$mail.'') ?>" class="<?php echo O::escapeHtml('or-input') ?>" /><?php echo O::escapeHtml('') ?> </div> </section> </div> </section> - <div class="<?php echo O::escapeHtml('or-act-clickable') ?>"><?php echo O::escapeHtml('') ?> - <a target="<?php echo O::escapeHtml('_self') ?>" data-type="<?php echo O::escapeHtml('dialog') ?>" data-action="<?php echo O::escapeHtml('profile') ?>" data-method="<?php echo O::escapeHtml('confirmmail') ?>" data-id="<?php echo O::escapeHtml('') ?>" data-extra-dialogAction="<?php echo O::escapeHtml('profile') ?>" data-extra-dialogMethod="<?php echo O::escapeHtml('confirmmail') ?>" data-extra="<?php echo O::escapeHtml('{\'dialogAction\':\'profile\',\'dialogMethod\':\'confirmmail\'}') ?>" href="<?php echo O::escapeHtml('#/profile') ?>" class="<?php echo O::escapeHtml('or-link') ?>"><?php echo O::escapeHtml('') ?> - <span><?php echo O::escapeHtml(''.@$mail_code.'') ?> - </span> - </a> - </div> </div> <div class="<?php echo O::escapeHtml('or-form-actionbar') ?>"><?php echo O::escapeHtml('') ?> <div class="<?php echo O::escapeHtml('or-btn or-btn--secondary or-act-form-cancel') ?>"><?php echo O::escapeHtml('') ?> diff --git a/modules/cms/ui/themes/default/html/views/profile/mail.tpl.src.xml b/modules/cms/ui/themes/default/html/views/profile/mail.tpl.src.xml @@ -1,22 +1,19 @@ -<output xmlns="http://www.openrat.de/template" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openrat.de/template ../../../../../../../template_engine/components/template.xsd"> - <form method="post"> - <logo name="changemail"/> - <group title="${message:user_mail}"> - <fieldset class="line" label=""> - <part class="label"> - <label for="mail"> - <text value="${message:user_new_mail}"/> - </label> - </part> - <part class="value"> - <input name="mail"/> - </part> - </fieldset> - </group> - <part class="act-clickable"> - <link action="profile" subaction="confirmmail" type="dialog"> - <text value="${mail_code}"/> - </link> - </part> - </form> +<output xmlns="http://www.openrat.de/template" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.openrat.de/template ../../../../../../../template_engine/components/template.xsd"> + <form method="post" forwardTo="confirmmail" afterSuccess="forward"> + <logo name="changemail"/> + + <group title="${message:user_mail}"> + <fieldset label="${message:user_new_mail}"> + <input name="mail" focus="true"/> + </fieldset> + </group> + + <!-- + <part class="act-clickable"> + <link action="profile" subaction="confirmmail" type="dialog"> + <text value="${mail_code}"/> + </link> + </part>--> + </form> </output> diff --git a/modules/cms/ui/themes/default/script/openrat.js b/modules/cms/ui/themes/default/script/openrat.js @@ -1686,12 +1686,22 @@ Openrat.View = function( action,method,id,params ) { $(element).html(data).removeClass("loader"); $(element).find('form').each( function() { + let form = new Openrat.Form(); + form.close = function() { view.close(); } - form.initOnElement(this); + form.forwardTo = function (action, subaction, id, data) { + view.action = action; + view.method = subaction; + view.id = id; + view.params = data; + view.loadView(); + } + + form.initOnElement(this); }); fireViewLoadedEvents( element ); @@ -1844,13 +1854,9 @@ Openrat.Form = function() { } this.close = function() { - } this.forwardTo = function (action, subaction, id, data) { - - let view = new Openrat.View( action, subaction, id, data ); - view.start( $(this.element).closest('.view') ); } this.submit = function( mode ) { @@ -1863,13 +1869,13 @@ Openrat.Form = function() { // Show progress - let status = $('<div class="notice info"><div class="text loader"></div></div>'); - $('#noticebar').prepend(status); // Notice anhängen. + let status = $('<div class="or-notice or-notice--info"><div class="or-text or-loader"></div></div>'); + $('.or-notices').prepend(status); // Notice anhängen. $(status).show(); // Alle vorhandenen Error-Marker entfernen. // Falls wieder ein Fehler auftritt, werden diese erneut gesetzt. - $(this.element).find('.or-input.error').removeClass('error'); + $(this.element).find('.or-input.or-error').removeClass('error'); let params = $(this.element).serializeArray(); let data = {}; @@ -1908,12 +1914,19 @@ Openrat.Form = function() { // Async: Window is closed, but the action will be startet now. let form = this; - $.ajax( { 'type':'POST',url:url, data:data, success:function(data, textStatus, jqXHR) + $.ajax( { 'type':'POST',url:url, data:data, success:function(responseData, textStatus, jqXHR) { form.setLoadStatus(false); $(status).remove(); - form.doResponse(data,textStatus,form.element, function() { + form.doResponse(responseData,textStatus,form.element, function() { + + let afterSuccess = $(form.element).data('afterSuccess'); + let forwardTo = $(form.element).data('forwardTo' ); + let async = $(form.element).data('async' ); + + if ( afterSuccess == 'forward' ) + mode = modes.keepOpen; // The data was successful saved. // Now we can close the form. @@ -1925,14 +1938,18 @@ Openrat.Form = function() { $(form.element).closest('div.panel').find('div.header ul.views li.action.active').removeClass('dirty'); } - let afterSuccess = $(form.element).data('afterSuccess'); - let async = $(form.element).data('async' ); if ( afterSuccess ) { if ( afterSuccess == 'reloadAll' ) { Openrat.Workbench.reloadAll(); } + else if ( afterSuccess == 'forward' ) + { + // Forwarding to next subaction. + if ( forwardTo ) + form.forwardTo( data.action, forwardTo, data.id,[] ); + } } else { if ( async ) ; // do not reload diff --git a/modules/cms/ui/themes/default/script/openrat.min.js b/modules/cms/ui/themes/default/script/openrat.min.js @@ -1170,12 +1170,13 @@ header:o[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:o[2].replace(/^ *|\ /** Trumbowyg v2.10.0 - A lightweight WYSIWYG editor - alex-d.github.io/Trumbowyg - License MIT - Author : Alexandre Demode (Alex-D) / alex-d.fr */ jQuery.trumbowyg={langs:{en:{viewHTML:"View HTML",undo:"Undo",redo:"Redo",formatting:"Formatting",p:"Paragraph",blockquote:"Quote",code:"Code",header:"Header",bold:"Bold",italic:"Italic",strikethrough:"Stroke",underline:"Underline",strong:"Strong",em:"Emphasis",del:"Deleted",superscript:"Superscript",subscript:"Subscript",unorderedList:"Unordered list",orderedList:"Ordered list",insertImage:"Insert Image",link:"Link",createLink:"Insert link",unlink:"Remove link",justifyLeft:"Align Left",justifyCenter:"Align Center",justifyRight:"Align Right",justifyFull:"Align Justify",horizontalRule:"Insert horizontal rule",removeformat:"Remove format",fullscreen:"Fullscreen",close:"Close",submit:"Confirm",reset:"Cancel",required:"Required",description:"Description",title:"Title",text:"Text",target:"Target",width:"Width"}},plugins:{},svgPath:null,hideButtonTexts:null},Object.defineProperty(jQuery.trumbowyg,"defaultOptions",{value:{lang:"en",fixedBtnPane:!1,fixedFullWidth:!1,autogrow:!1,autogrowOnEnter:!1,imageWidthModalEdit:!1,prefix:"trumbowyg-",semantic:!0,resetCss:!1,removeformatPasted:!1,tagsToRemove:[],btns:[["viewHTML"],["undo","redo"],["formatting"],["strong","em","del"],["superscript","subscript"],["link"],["insertImage"],["justifyLeft","justifyCenter","justifyRight","justifyFull"],["unorderedList","orderedList"],["horizontalRule"],["removeformat"],["fullscreen"]],btnsDef:{},inlineElementsSelector:"a,abbr,acronym,b,caption,cite,code,col,dfn,dir,dt,dd,em,font,hr,i,kbd,li,q,span,strikeout,strong,sub,sup,u",pasteHandlers:[],plugins:{},urlProtocol:!1,minimalLinks:!1},writable:!1,enumerable:!0,configurable:!1}),function(e,t,n,a){"use strict";var o="tbwconfirm",r="tbwcancel";a.fn.trumbowyg=function(e,t){var n="trumbowyg";if(e===Object(e)||!e)return this.each(function(){a(this).data(n)||a(this).data(n,new i(this,e))});if(1===this.length)try{var o=a(this).data(n);switch(e){case"execCmd":return o.execCmd(t.cmd,t.param,t.forceCss);case"openModal":return o.openModal(t.title,t.content);case"closeModal":return o.closeModal();case"openModalInsert":return o.openModalInsert(t.title,t.fields,t.callback);case"saveRange":return o.saveRange();case"getRange":return o.range;case"getRangeText":return o.getRangeText();case"restoreRange":return o.restoreRange();case"enable":return o.setDisabled(!1);case"disable":return o.setDisabled(!0);case"toggle":return o.toggle();case"destroy":return o.destroy();case"empty":return o.empty();case"html":return o.html(t)}}catch(r){}return!1};var i=function(o,r){var i=this,s="trumbowyg-icons",l=a.trumbowyg;i.doc=o.ownerDocument||n,i.$ta=a(o),i.$c=a(o),r=r||{},null!=r.lang||null!=l.langs[r.lang]?i.lang=a.extend(!0,{},l.langs.en,l.langs[r.lang]):i.lang=l.langs.en,i.hideButtonTexts=null!=l.hideButtonTexts?l.hideButtonTexts:r.hideButtonTexts;var d=null!=l.svgPath?l.svgPath:r.svgPath;if(i.hasSvg=d!==!1,i.svgPath=i.doc.querySelector("base")?t.location.href.split("#")[0]:"",0===a("#"+s,i.doc).length&&d!==!1){if(null==d){for(var c=n.getElementsByTagName("script"),u=0;u<c.length;u+=1){var g=c[u].src,f=g.match("trumbowyg(.min)?.js");null!=f&&(d=g.substring(0,g.indexOf(f[0]))+"ui/icons.svg")}null==d&&console.warn("You must define svgPath: https://goo.gl/CfTY9U")}var h=i.doc.createElement("div");h.id=s,i.doc.body.insertBefore(h,i.doc.body.childNodes[0]),a.ajax({async:!0,type:"GET",contentType:"application/x-www-form-urlencoded; charset=UTF-8",dataType:"xml",crossDomain:!0,url:d,data:null,beforeSend:null,complete:null,success:function(e){h.innerHTML=(new XMLSerializer).serializeToString(e.documentElement)}})}var p=i.lang.header,m=function(){return(t.chrome||t.Intl&&Intl.v8BreakIterator)&&"CSS"in t};i.btnsDef={viewHTML:{fn:"toggle"},undo:{isSupported:m,key:"Z"},redo:{isSupported:m,key:"Y"},p:{fn:"formatBlock"},blockquote:{fn:"formatBlock"},h1:{fn:"formatBlock",title:p+" 1"},h2:{fn:"formatBlock",title:p+" 2"},h3:{fn:"formatBlock",title:p+" 3"},h4:{fn:"formatBlock",title:p+" 4"},subscript:{tag:"sub"},superscript:{tag:"sup"},bold:{key:"B",tag:"b"},italic:{key:"I",tag:"i"},underline:{tag:"u"},strikethrough:{tag:"strike"},strong:{fn:"bold",key:"B"},em:{fn:"italic",key:"I"},del:{fn:"strikethrough"},createLink:{key:"K",tag:"a"},unlink:{},insertImage:{},justifyLeft:{tag:"left",forceCss:!0},justifyCenter:{tag:"center",forceCss:!0},justifyRight:{tag:"right",forceCss:!0},justifyFull:{tag:"justify",forceCss:!0},unorderedList:{fn:"insertUnorderedList",tag:"ul"},orderedList:{fn:"insertOrderedList",tag:"ol"},horizontalRule:{fn:"insertHorizontalRule"},removeformat:{},fullscreen:{"class":"trumbowyg-not-disable"},close:{fn:"destroy","class":"trumbowyg-not-disable"},formatting:{dropdown:["p","blockquote","h1","h2","h3","h4"],ico:"p"},link:{dropdown:["createLink","unlink"]}},i.o=a.extend(!0,{},l.defaultOptions,r),i.o.hasOwnProperty("imgDblClickHandler")||(i.o.imgDblClickHandler=i.getDefaultImgDblClickHandler()),i.urlPrefix=i.setupUrlPrefix(),i.disabled=i.o.disabled||"TEXTAREA"===o.nodeName&&o.disabled,r.btns?i.o.btns=r.btns:i.o.semantic||(i.o.btns[3]=["bold","italic","underline","strikethrough"]),a.each(i.o.btnsDef,function(e,t){i.addBtnDef(e,t)}),i.eventNamespace="trumbowyg-event",i.keys=[],i.tagToButton={},i.tagHandlers=[],i.pasteHandlers=[].concat(i.o.pasteHandlers),i.isIE=e.userAgent.indexOf("MSIE")!==-1||e.appVersion.indexOf("Trident/")!==-1,i.init()};i.prototype={DEFAULT_SEMANTIC_MAP:{b:"strong",i:"em",s:"del",strike:"del",div:"p"},init:function(){var e=this;e.height=e.$ta.height(),e.initPlugins();try{e.doc.execCommand("enableObjectResizing",!1,!1),e.doc.execCommand("defaultParagraphSeparator",!1,"p")}catch(t){}e.buildEditor(),e.buildBtnPane(),e.fixedBtnPaneEvents(),e.buildOverlay(),setTimeout(function(){e.disabled&&e.setDisabled(!0),e.$c.trigger("tbwinit")})},addBtnDef:function(e,t){this.btnsDef[e]=t},setupUrlPrefix:function(){var e=this.o.urlProtocol;if(e)return"string"!=typeof e?"https://":/:\/\/$/.test(e)?e:e+"://"},buildEditor:function(){var e=this,n=e.o.prefix,o="";e.$box=a("<div/>",{"class":n+"box "+n+"editor-visible "+n+e.o.lang+" trumbowyg"}),e.isTextarea=e.$ta.is("textarea"),e.isTextarea?(o=e.$ta.val(),e.$ed=a("<div/>"),e.$box.insertAfter(e.$ta).append(e.$ed,e.$ta)):(e.$ed=e.$ta,o=e.$ed.html(),e.$ta=a("<textarea/>",{name:e.$ta.attr("id"),height:e.height}).val(o),e.$box.insertAfter(e.$ed).append(e.$ta,e.$ed),e.syncCode()),e.$ta.addClass(n+"textarea").attr("tabindex",-1),e.$ed.addClass(n+"editor").attr({contenteditable:!0,dir:e.lang._dir||"ltr"}).html(o),e.o.tabindex&&e.$ed.attr("tabindex",e.o.tabindex),e.$c.is("[placeholder]")&&e.$ed.attr("placeholder",e.$c.attr("placeholder")),e.$c.is("[spellcheck]")&&e.$ed.attr("spellcheck",e.$c.attr("spellcheck")),e.o.resetCss&&e.$ed.addClass(n+"reset-css"),e.o.autogrow||e.$ta.add(e.$ed).css({height:e.height}),e.semanticCode(),e.o.autogrowOnEnter&&e.$ed.addClass(n+"autogrow-on-enter");var r,i=!1,s=!1,l="keyup";e.$ed.on("dblclick","img",e.o.imgDblClickHandler).on("keydown",function(t){if((t.ctrlKey||t.metaKey)&&!t.altKey){i=!0;var n=e.keys[String.fromCharCode(t.which).toUpperCase()];try{return e.execCmd(n.fn,n.param),!1}catch(a){}}}).on("compositionstart compositionupdate",function(){s=!0}).on(l+" compositionend",function(t){if("compositionend"===t.type)s=!1;else if(s)return;var n=t.which;if(!(n>=37&&n<=40)){if(!t.ctrlKey&&!t.metaKey||89!==n&&90!==n)if(i||17===n)"undefined"==typeof t.which&&e.semanticCode(!1,!1,!0);else{var a=!e.isIE||"compositionend"===t.type;e.semanticCode(!1,a&&13===n),e.$c.trigger("tbwchange")}else e.$c.trigger("tbwchange");setTimeout(function(){i=!1},50)}}).on("mouseup keydown keyup",function(t){(!t.ctrlKey&&!t.metaKey||t.altKey)&&setTimeout(function(){i=!1},50),clearTimeout(r),r=setTimeout(function(){e.updateButtonPaneStatus()},50)}).on("focus blur",function(t){if(e.$c.trigger("tbw"+t.type),"blur"===t.type&&a("."+n+"active-button",e.$btnPane).removeClass(n+"active-button "+n+"active"),e.o.autogrowOnEnter){if(e.autogrowOnEnterDontClose)return;"focus"===t.type?(e.autogrowOnEnterWasFocused=!0,e.autogrowEditorOnEnter()):e.o.autogrow||(e.$ed.css({height:e.$ed.css("min-height")}),e.$c.trigger("tbwresize"))}}).on("cut",function(){setTimeout(function(){e.semanticCode(!1,!0),e.$c.trigger("tbwchange")},0)}).on("paste",function(n){if(e.o.removeformatPasted){n.preventDefault(),t.getSelection&&t.getSelection().deleteFromDocument&&t.getSelection().deleteFromDocument();try{var o=t.clipboardData.getData("Text");try{e.doc.selection.createRange().pasteHTML(o)}catch(r){e.doc.getSelection().getRangeAt(0).insertNode(e.doc.createTextNode(o))}e.$c.trigger("tbwchange",n)}catch(i){e.execCmd("insertText",(n.originalEvent||n).clipboardData.getData("text/plain"))}}a.each(e.pasteHandlers,function(e,t){t(n)}),setTimeout(function(){e.semanticCode(!1,!0),e.$c.trigger("tbwpaste",n)},0)}),e.$ta.on("keyup",function(){e.$c.trigger("tbwchange")}).on("paste",function(){setTimeout(function(){e.$c.trigger("tbwchange")},0)}),e.$box.on("keydown",function(t){if(27===t.which&&1===a("."+n+"modal-box",e.$box).length)return e.closeModal(),!1})},autogrowEditorOnEnter:function(){var e=this;e.$ed.removeClass("autogrow-on-enter");var t=e.$ed[0].clientHeight;e.$ed.height("auto");var n=e.$ed[0].scrollHeight;e.$ed.addClass("autogrow-on-enter"),t!==n&&(e.$ed.height(t),setTimeout(function(){e.$ed.css({height:n}),e.$c.trigger("tbwresize")},0))},buildBtnPane:function(){var e=this,t=e.o.prefix,n=e.$btnPane=a("<div/>",{"class":t+"button-pane"});a.each(e.o.btns,function(o,r){a.isArray(r)||(r=[r]);var i=a("<div/>",{"class":t+"button-group "+(r.indexOf("fullscreen")>=0?t+"right":"")});a.each(r,function(t,n){try{e.isSupportedBtn(n)&&i.append(e.buildBtn(n))}catch(a){}}),i.html().trim().length>0&&n.append(i)}),e.$box.prepend(n)},buildBtn:function(e){var t=this,n=t.o.prefix,o=t.btnsDef[e],r=o.dropdown,i=null==o.hasIcon||o.hasIcon,s=t.lang[e]||e,l=a("<button/>",{type:"button","class":n+e+"-button "+(o["class"]||"")+(i?"":" "+n+"textual-button"),html:t.hasSvg&&i?'<svg><use xlink:href="'+t.svgPath+"#"+n+(o.ico||e).replace(/([A-Z]+)/g,"-$1").toLowerCase()+'"/></svg>':t.hideButtonTexts?"":o.text||o.title||t.lang[e]||e,title:(o.title||o.text||s)+(o.key?" (Ctrl + "+o.key+")":""),tabindex:-1,mousedown:function(){return r&&!a("."+e+"-"+n+"dropdown",t.$box).is(":hidden")||a("body",t.doc).trigger("mousedown"),!((t.$btnPane.hasClass(n+"disable")||t.$box.hasClass(n+"disabled"))&&!a(this).hasClass(n+"active")&&!a(this).hasClass(n+"not-disable"))&&(t.execCmd(!!r&&"dropdown"||o.fn||e,o.param||e,o.forceCss),!1)}});if(r){l.addClass(n+"open-dropdown");var d=n+"dropdown",c={"class":d+"-"+e+" "+d+" "+n+"fixed-top"};c["data-"+d]=e;var u=a("<div/>",c);a.each(r,function(e,n){t.btnsDef[n]&&t.isSupportedBtn(n)&&u.append(t.buildSubBtn(n))}),t.$box.append(u.hide())}else o.key&&(t.keys[o.key]={fn:o.fn||e,param:o.param||e});return r||(t.tagToButton[(o.tag||e).toLowerCase()]=e),l},buildSubBtn:function(e){var t=this,n=t.o.prefix,o=t.btnsDef[e],r=null==o.hasIcon||o.hasIcon;return o.key&&(t.keys[o.key]={fn:o.fn||e,param:o.param||e}),t.tagToButton[(o.tag||e).toLowerCase()]=e,a("<button/>",{type:"button","class":n+e+"-dropdown-button"+(o.ico?" "+n+o.ico+"-button":""),html:t.hasSvg&&r?'<svg><use xlink:href="'+t.svgPath+"#"+n+(o.ico||e).replace(/([A-Z]+)/g,"-$1").toLowerCase()+'"/></svg>'+(o.text||o.title||t.lang[e]||e):o.text||o.title||t.lang[e]||e,title:o.key?" (Ctrl + "+o.key+")":null,style:o.style||null,mousedown:function(){return a("body",t.doc).trigger("mousedown"),t.execCmd(o.fn||e,o.param||e,o.forceCss),!1}})},isSupportedBtn:function(e){try{return this.btnsDef[e].isSupported()}catch(t){}return!0},buildOverlay:function(){var e=this;return e.$overlay=a("<div/>",{"class":e.o.prefix+"overlay"}).appendTo(e.$box),e.$overlay},showOverlay:function(){var e=this;a(t).trigger("scroll"),e.$overlay.fadeIn(200),e.$box.addClass(e.o.prefix+"box-blur")},hideOverlay:function(){var e=this;e.$overlay.fadeOut(50),e.$box.removeClass(e.o.prefix+"box-blur")},fixedBtnPaneEvents:function(){var e=this,n=e.o.fixedFullWidth,o=e.$box;e.o.fixedBtnPane&&(e.isFixed=!1,a(t).on("scroll."+e.eventNamespace+" resize."+e.eventNamespace,function(){if(o){e.syncCode();var r=a(t).scrollTop(),i=o.offset().top+1,s=e.$btnPane,l=s.outerHeight()-2;r-i>0&&r-i-e.height<0?(e.isFixed||(e.isFixed=!0,s.css({position:"fixed",top:0,left:n?"0":"auto",zIndex:7}),a([e.$ta,e.$ed]).css({marginTop:s.height()})),s.css({width:n?"100%":o.width()-1+"px"}),a("."+e.o.prefix+"fixed-top",o).css({position:n?"fixed":"absolute",top:n?l:l+(r-i)+"px",zIndex:15})):e.isFixed&&(e.isFixed=!1,s.removeAttr("style"),a([e.$ta,e.$ed]).css({marginTop:0}),a("."+e.o.prefix+"fixed-top",o).css({position:"absolute",top:l}))}}))},setDisabled:function(e){var t=this,n=t.o.prefix;t.disabled=e,e?t.$ta.attr("disabled",!0):t.$ta.removeAttr("disabled"),t.$box.toggleClass(n+"disabled",e),t.$ed.attr("contenteditable",!e)},destroy:function(){var e=this,n=e.o.prefix;e.isTextarea?e.$box.after(e.$ta.css({height:""}).val(e.html()).removeClass(n+"textarea").show()):e.$box.after(e.$ed.css({height:""}).removeClass(n+"editor").removeAttr("contenteditable").removeAttr("dir").html(e.html()).show()),e.$ed.off("dblclick","img"),e.destroyPlugins(),e.$box.remove(),e.$c.removeData("trumbowyg"),a("body").removeClass(n+"body-fullscreen"),e.$c.trigger("tbwclose"),a(t).off("scroll."+e.eventNamespace+" resize."+e.eventNamespace)},empty:function(){this.$ta.val(""),this.syncCode(!0)},toggle:function(){var e=this,t=e.o.prefix;e.o.autogrowOnEnter&&(e.autogrowOnEnterDontClose=!e.$box.hasClass(t+"editor-hidden")),e.semanticCode(!1,!0),setTimeout(function(){e.doc.activeElement.blur(),e.$box.toggleClass(t+"editor-hidden "+t+"editor-visible"),e.$btnPane.toggleClass(t+"disable"),a("."+t+"viewHTML-button",e.$btnPane).toggleClass(t+"active"),e.$box.hasClass(t+"editor-visible")?e.$ta.attr("tabindex",-1):e.$ta.removeAttr("tabindex"),e.o.autogrowOnEnter&&!e.autogrowOnEnterDontClose&&e.autogrowEditorOnEnter()},0)},dropdown:function(e){var n=this,o=n.doc,r=n.o.prefix,i=a("[data-"+r+"dropdown="+e+"]",n.$box),s=a("."+r+e+"-button",n.$btnPane),l=i.is(":hidden");if(a("body",o).trigger("mousedown"),l){var d=s.offset().left;s.addClass(r+"active"),i.css({position:"absolute",top:s.offset().top-n.$btnPane.offset().top+s.outerHeight(),left:n.o.fixedFullWidth&&n.isFixed?d+"px":d-n.$btnPane.offset().left+"px"}).show(),a(t).trigger("scroll"),a("body",o).on("mousedown."+n.eventNamespace,function(e){i.is(e.target)||(a("."+r+"dropdown",n.$box).hide(),a("."+r+"active",n.$btnPane).removeClass(r+"active"),a("body",o).off("mousedown."+n.eventNamespace))})}},html:function(e){var t=this;return null!=e?(t.$ta.val(e),t.syncCode(!0),t.$c.trigger("tbwchange"),t):t.$ta.val()},syncTextarea:function(){var e=this;e.$ta.val(e.$ed.text().trim().length>0||e.$ed.find("hr,img,embed,iframe,input").length>0?e.$ed.html():"")},syncCode:function(e){var t=this;if(!e&&t.$ed.is(":visible"))t.syncTextarea();else{var n=a("<div>").html(t.$ta.val()),o=a("<div>").append(n);a(t.o.tagsToRemove.join(","),o).remove(),t.$ed.html(o.contents().html())}if(t.o.autogrow&&(t.height=t.$ed.height(),t.height!==t.$ta.css("height")&&(t.$ta.css({height:t.height}),t.$c.trigger("tbwresize"))),t.o.autogrowOnEnter){t.$ed.height("auto");var r=t.autogrowOnEnterWasFocused?t.$ed[0].scrollHeight:t.$ed.css("min-height");r!==t.$ta.css("height")&&(t.$ed.css({height:r}),t.$c.trigger("tbwresize"))}},semanticCode:function(e,t,n){var o=this;if(o.saveRange(),o.syncCode(e),o.o.semantic){if(o.semanticTag("b"),o.semanticTag("i"),o.semanticTag("s"),o.semanticTag("strike"),t){var r=o.o.inlineElementsSelector,i=":not("+r+")";o.$ed.contents().filter(function(){return 3===this.nodeType&&this.nodeValue.trim().length>0}).wrap("<span data-tbw/>");var s=function(e){if(0!==e.length){var t=e.nextUntil(i).addBack().wrapAll("<p/>").parent(),n=t.nextAll(r).first();t.next("br").remove(),s(n)}};s(o.$ed.children(r).first()),o.semanticTag("div",!0),o.$ed.find("p").filter(function(){return(!o.range||this!==o.range.startContainer)&&(0===a(this).text().trim().length&&0===a(this).children().not("br,span").length)}).contents().unwrap(),a("[data-tbw]",o.$ed).contents().unwrap(),o.$ed.find("p:empty").remove()}n||o.restoreRange(),o.syncTextarea()}},semanticTag:function(e,t){var n;if(null!=this.o.semantic&&"object"==typeof this.o.semantic&&this.o.semantic.hasOwnProperty(e))n=this.o.semantic[e];else{if(this.o.semantic!==!0||!this.DEFAULT_SEMANTIC_MAP.hasOwnProperty(e))return;n=this.DEFAULT_SEMANTIC_MAP[e]}a(e,this.$ed).each(function(){var e=a(this);e.wrap("<"+n+"/>"),t&&a.each(e.prop("attributes"),function(){e.parent().attr(this.name,this.value)}),e.contents().unwrap()})},createLink:function(){for(var e,t,n,o=this,r=o.doc.getSelection(),i=r.focusNode,s=(new XMLSerializer).serializeToString(r.getRangeAt(0).cloneContents());["A","DIV"].indexOf(i.nodeName)<0;)i=i.parentNode;if(i&&"A"===i.nodeName){var l=a(i);s=l.text(),e=l.attr("href"),o.o.minimalLinks||(t=l.attr("title"),n=l.attr("target"));var d=o.doc.createRange();d.selectNode(i),r.removeAllRanges(),r.addRange(d)}o.saveRange();var c={url:{label:"URL",required:!0,value:e},text:{label:o.lang.text,value:s}};o.o.minimalLinks||Object.assign(c,{title:{label:o.lang.title,value:t},target:{label:o.lang.target,value:n}}),o.openModalInsert(o.lang.createLink,c,function(e){var t=o.prependUrlPrefix(e.url);if(!t.length)return!1;var n=a(['<a href="',e.url,'">',e.text||e.url,"</a>"].join(""));return o.o.minimalLinks||(e.title.length>0&&n.attr("title",e.title),e.target.length>0&&n.attr("target",e.target)),o.range.deleteContents(),o.range.insertNode(n[0]),o.syncCode(),o.$c.trigger("tbwchange"),!0})},prependUrlPrefix:function(e){var t=this;if(!t.urlPrefix)return e;const n=/^([a-z][-+.a-z0-9]*:|\/|#)/i;if(n.test(e))return e;const a=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;return a.test(e)?"mailto:"+e:t.urlPrefix+e},unlink:function(){var e=this,t=e.doc.getSelection(),n=t.focusNode;if(t.isCollapsed){for(;["A","DIV"].indexOf(n.nodeName)<0;)n=n.parentNode;if(n&&"A"===n.nodeName){var a=e.doc.createRange();a.selectNode(n),t.removeAllRanges(),t.addRange(a)}}e.execCmd("unlink",void 0,void 0,!0)},insertImage:function(){var e=this;e.saveRange();var t={url:{label:"URL",required:!0},alt:{label:e.lang.description,value:e.getRangeText()}};e.o.imageWidthModalEdit&&(t.width={}),e.openModalInsert(e.lang.insertImage,t,function(t){e.execCmd("insertImage",t.url);var n=a('img[src="'+t.url+'"]:not([alt])',e.$box);return n.attr("alt",t.alt),e.o.imageWidthModalEdit&&n.attr({width:t.width}),e.syncCode(),e.$c.trigger("tbwchange"),!0})},fullscreen:function(){var e,n=this,o=n.o.prefix,r=o+"fullscreen";n.$box.toggleClass(r),e=n.$box.hasClass(r),a("body").toggleClass(o+"body-fullscreen",e),a(t).trigger("scroll"),n.$c.trigger("tbw"+(e?"open":"close")+"fullscreen")},execCmd:function(e,t,n,a){var o=this;a=!!a||"","dropdown"!==e&&o.$ed.focus();try{o.doc.execCommand("styleWithCSS",!1,n||!1)}catch(r){}try{o[e+a](t)}catch(r){try{e(t)}catch(i){"insertHorizontalRule"===e?t=void 0:"formatBlock"===e&&o.isIE&&(t="<"+t+">"),o.doc.execCommand(e,!1,t),o.syncCode(),o.semanticCode(!1,!0)}"dropdown"!==e&&(o.updateButtonPaneStatus(),o.$c.trigger("tbwchange"))}},openModal:function(e,n){var i=this,s=i.o.prefix;if(a("."+s+"modal-box",i.$box).length>0)return!1;i.o.autogrowOnEnter&&(i.autogrowOnEnterDontClose=!0),i.saveRange(),i.showOverlay(),i.$btnPane.addClass(s+"disable");var l=a("<div/>",{"class":s+"modal "+s+"fixed-top"}).css({top:i.$btnPane.height()}).appendTo(i.$box);i.$overlay.one("click",function(){return l.trigger(r),!1});var d=a("<form/>",{action:"",html:n}).on("submit",function(){return l.trigger(o),!1}).on("reset",function(){return l.trigger(r),!1}).on("submit reset",function(){i.o.autogrowOnEnter&&(i.autogrowOnEnterDontClose=!1)}),c=a("<div/>",{"class":s+"modal-box",html:d}).css({top:"-"+i.$btnPane.outerHeight()+"px",opacity:0}).appendTo(l).animate({top:0,opacity:1},100);return a("<span/>",{text:e,"class":s+"modal-title"}).prependTo(c),l.height(c.outerHeight()+10),a("input:first",c).focus(),i.buildModalBtn("submit",c),i.buildModalBtn("reset",c),a(t).trigger("scroll"),l},buildModalBtn:function(e,t){var n=this,o=n.o.prefix;return a("<button/>",{"class":o+"modal-button "+o+"modal-"+e,type:e,text:n.lang[e]||e}).appendTo(a("form",t))},closeModal:function(){var e=this,t=e.o.prefix;e.$btnPane.removeClass(t+"disable"),e.$overlay.off();var n=a("."+t+"modal-box",e.$box);n.animate({top:"-"+n.height()},100,function(){n.parent().remove(),e.hideOverlay()}),e.restoreRange()},openModalInsert:function(e,t,n){var i=this,s=i.o.prefix,l=i.lang,d="";return a.each(t,function(e,t){var n=t.label||e,a=t.name||e,o=t.attributes||{},r=Object.keys(o).map(function(e){return e+'="'+o[e]+'"'}).join(" ");d+='<label><input type="'+(t.type||"text")+'" name="'+a+'"'+("checkbox"===t.type&&t.value?' checked="checked"':' value="'+(t.value||"").replace(/"/g,"&quot;"))+'"'+r+'><span class="'+s+'input-infos"><span>'+(l[n]?l[n]:n)+"</span></span></label>"}),i.openModal(e,d).on(o,function(){var e=a("form",a(this)),r=!0,s={};a.each(t,function(t,n){var o=n.name||t,l=a('input[name="'+o+'"]',e),d=l.attr("type");switch(d.toLowerCase()){case"checkbox":s[o]=l.is(":checked");break;case"radio":s[o]=l.filter(":checked").val();break;default:s[o]=a.trim(l.val())}n.required&&""===s[o]?(r=!1,i.addErrorOnModalField(l,i.lang.required)):n.pattern&&!n.pattern.test(s[o])&&(r=!1,i.addErrorOnModalField(l,n.patternError))}),r&&(i.restoreRange(),n(s,t)&&(i.syncCode(),i.$c.trigger("tbwchange"),i.closeModal(),a(this).off(o)))}).one(r,function(){a(this).off(o),i.closeModal()})},addErrorOnModalField:function(e,t){var n=this.o.prefix,o=e.parent();e.on("change keyup",function(){o.removeClass(n+"input-error")}),o.addClass(n+"input-error").find("input+span").append(a("<span/>",{"class":n+"msg-error",text:t}))},getDefaultImgDblClickHandler:function(){var e=this;return function(){var t=a(this),n=t.attr("src"),o="(Base64)";0===n.indexOf("data:image")&&(n=o);var r={url:{label:"URL",value:n,required:!0},alt:{label:e.lang.description,value:t.attr("alt")}};return e.o.imageWidthModalEdit&&(r.width={value:t.attr("width")?t.attr("width"):""}),e.openModalInsert(e.lang.insertImage,r,function(n){return n.src!==o&&t.attr({src:n.url}),t.attr({alt:n.alt}),e.o.imageWidthModalEdit&&(parseInt(n.width)>0?t.attr({width:n.width}):t.removeAttr("width")),!0}),!1}},saveRange:function(){var e=this,t=e.doc.getSelection();if(e.range=null,t.rangeCount){var n,a=e.range=t.getRangeAt(0),o=e.doc.createRange();o.selectNodeContents(e.$ed[0]),o.setEnd(a.startContainer,a.startOffset),n=(o+"").length,e.metaRange={start:n,end:n+(a+"").length}}},restoreRange:function(){var e,t=this,n=t.metaRange,a=t.range,o=t.doc.getSelection();if(a){if(n&&n.start!==n.end){var r,i=0,s=[t.$ed[0]],l=!1,d=!1;for(e=t.doc.createRange();!d&&(r=s.pop());)if(3===r.nodeType){var c=i+r.length;!l&&n.start>=i&&n.start<=c&&(e.setStart(r,n.start-i),l=!0),l&&n.end>=i&&n.end<=c&&(e.setEnd(r,n.end-i),d=!0),i=c}else for(var u=r.childNodes,g=u.length;g>0;)g-=1,s.push(u[g])}o.removeAllRanges(),o.addRange(e||a)}},getRangeText:function(){return this.range+""},updateButtonPaneStatus:function(){var e=this,t=e.o.prefix,n=e.getTagsRecursive(e.doc.getSelection().focusNode),o=t+"active-button "+t+"active";a("."+t+"active-button",e.$btnPane).removeClass(o),a.each(n,function(n,r){var i=e.tagToButton[r.toLowerCase()],s=a("."+t+i+"-button",e.$btnPane);if(s.length>0)s.addClass(o);else try{s=a("."+t+"dropdown ."+t+i+"-dropdown-button",e.$box);var l=s.parent().data("dropdown");a("."+t+l+"-button",e.$box).addClass(o)}catch(d){}})},getTagsRecursive:function(e,t){var n=this;if(t=t||(e&&e.tagName?[e.tagName]:[]),!e||!e.parentNode)return t;e=e.parentNode;var o=e.tagName;return"DIV"===o?t:("P"===o&&""!==e.style.textAlign&&t.push(e.style.textAlign),a.each(n.tagHandlers,function(a,o){t=t.concat(o(e,n))}),t.push(o),n.getTagsRecursive(e,t).filter(function(e){return null!=e}))},initPlugins:function(){var e=this;e.loadedPlugins=[],a.each(a.trumbowyg.plugins,function(t,n){n.shouldInit&&!n.shouldInit(e)||(n.init(e),n.tagHandler&&e.tagHandlers.push(n.tagHandler),e.loadedPlugins.push(n))})},destroyPlugins:function(){a.each(this.loadedPlugins,function(e,t){t.destroy&&t.destroy()})}}}(navigator,window,document,jQuery); ;window.Openrat={};let originalAddClass=jQuery.fn.addClass;jQuery.fn.addClass=function(s){return originalAddClass.call(this,'or-'+s)};let originalRemoveClass=jQuery.fn.removeClass;jQuery.fn.removeClass=function(s){return originalRemoveClass.call(this,'or-'+s)};let originalHasClass=jQuery.fn.hasClass;jQuery.fn.hasClass=function(s){return originalHasClass.call(this,'or-'+s)}; -;Openrat.View=function(e,t,i,r){this.action=e;this.method=t;this.id=i;this.params=r;this.before=function(){};this.start=function(e){this.before();this.element=e;return this.loadView()};this.afterLoad=function(){};this.close=function(){};function n(e){Openrat.Workbench.afterViewLoadedHandler.fire(e)};this.loadView=function(){let url=Openrat.View.createUrl(this.action,this.method,this.id,this.params,!1);let element=this.element;let view=this;let loadViewHtmlPromise=$.ajax(url);$(this.element).addClass('loader');loadViewHtmlPromise.done(function(e,t){if(!e)e='';$(element).html(e).removeClass('loader');$(element).find('form').each(function(){let form=new Openrat.Form();form.close=function(){view.close()};form.initOnElement(this)});n(element)});loadViewHtmlPromise.fail(function(e,t,i){$(element).html('');Openrat.Workbench.notify('',0,'','error','Server Error',['Server Error while requesting url '+url,t])});let apiUrl=Openrat.View.createUrl(this.action,this.method,this.id,this.params,!0);return loadViewHtmlPromise};Openrat.View.createUrl=function(e,subaction,i,extraid={},api=!1){let url='./';if(api)url+='api/';url+='?';if(e)url+='&action='+e;if(subaction)url+='&subaction='+subaction;if(i)url+='&id='+i;if(typeof extraid==='string'){extraid=extraid.replace(/'/g,'"');let extraObject=jQuery.parseJSON(extraid);jQuery.each(extraObject,function(e,t){url=url+'&'+e+'='+t})} +;Openrat.View=function(e,t,i,r){this.action=e;this.method=t;this.id=i;this.params=r;this.before=function(){};this.start=function(e){this.before();this.element=e;return this.loadView()};this.afterLoad=function(){};this.close=function(){};function n(e){Openrat.Workbench.afterViewLoadedHandler.fire(e)};this.loadView=function(){let url=Openrat.View.createUrl(this.action,this.method,this.id,this.params,!1);let element=this.element;let view=this;let loadViewHtmlPromise=$.ajax(url);$(this.element).addClass('loader');loadViewHtmlPromise.done(function(e,t){if(!e)e='';$(element).html(e).removeClass('loader');$(element).find('form').each(function(){let form=new Openrat.Form();form.close=function(){view.close()};form.forwardTo=function(e,t,i,r){view.action=e;view.method=t;view.id=i;view.params=r;view.loadView()};form.initOnElement(this)});n(element)});loadViewHtmlPromise.fail(function(e,t,i){$(element).html('');Openrat.Workbench.notify('',0,'','error','Server Error',['Server Error while requesting url '+url,t])});let apiUrl=Openrat.View.createUrl(this.action,this.method,this.id,this.params,!0);return loadViewHtmlPromise};Openrat.View.createUrl=function(e,subaction,i,extraid={},api=!1){let url='./';if(api)url+='api/';url+='?';if(e)url+='&action='+e;if(subaction)url+='&subaction='+subaction;if(i)url+='&id='+i;if(typeof extraid==='string'){extraid=extraid.replace(/'/g,'"');let extraObject=jQuery.parseJSON(extraid);jQuery.each(extraObject,function(e,t){url=url+'&'+e+'='+t})} else if(typeof extraid==='object'){jQuery.each(extraid,function(e,t){url=url+'&'+e+'='+t})} else{};return url}}; -;Openrat.Form=function(){const modes={showBrowserNotice:1,keepOpen:2,closeAfterSubmit:4,closeAfterSuccess:8,};this.setLoadStatus=function(e){$(this.element).closest('div.content').toggleClass('loader',e)};this.initOnElement=function(e){this.element=e;let form=this;if($(this.element).data('autosave')){$(this.element).find('input[type="checkbox"]').click(function(){form.submit(modes.keepOpen)});$(this.element).find('select').change(function(){form.submit(modes.keepOpen)})};$(e).find('.or-act-form-cancel').click(function(){form.cancel()});$(e).find('.or-act-form-reset').click(function(){form.rollback()});$(e).find('.or-act-form-apply').click(function(){form.submit(modes.keepOpen)});$(e).find('.or-act-form-save').click(function(){form.submit()});$(e).submit(function(e){if($(this).data('target')=='view'){form.submit();e.preventDefault()}})};this.cancel=function(){this.close()};this.rollback=function(){this.element.trigger('reset')};this.close=function(){};this.forwardTo=function(e,t,s,o){let view=new Openrat.View(e,t,s,o);view.start($(this.element).closest('.view'))};this.submit=function(e){if(e===undefined)if($(this.element).data('async'))e=modes.closeAfterSubmit;else e=modes.closeAfterSuccess;let status=$('<div class="notice info"><div class="text loader"></div></div>');$('#noticebar').prepend(status);$(status).show();$(this.element).find('.or-input.error').removeClass('error');let params=$(this.element).serializeArray();let data={};$(params).each(function(e,t){data[t.name]=t.value});if(!data.id)data.id=Openrat.Workbench.state.id;if(!data.action)data.action=Openrat.Workbench.state.action;let formMethod=$(this.element).attr('method').toUpperCase();if(formMethod=='GET'){this.forwardTo(data.action,data.subaction,data.id,data);$(status).remove()} -else{let url='./api/';this.setLoadStatus(!0);url+='';data.output='json';if(e==modes.closeAfterSubmit)this.close();let form=this;$.ajax({'type':'POST',url:url,data:data,success:function(t,s,o){form.setLoadStatus(!1);$(status).remove();form.doResponse(t,s,form.element,function(){if(e==modes.closeAfterSuccess){form.close();$(form.element).closest('div.panel').find('div.header ul.views li.action.active').removeClass('dirty')};let afterSuccess=$(form.element).data('afterSuccess');let async=$(form.element).data('async');if(afterSuccess){if(afterSuccess=='reloadAll'){Openrat.Workbench.reloadAll()}} -else{if(async);else Openrat.Workbench.reloadViews()}})},error:function(e,t,s){form.setLoadStatus(!1);$(status).remove();try{let error=jQuery.parseJSON(e.responseText);Openrat.Workbench.notify('',0,'','error',error.error,[error.description])}catch(o){let msg=e.responseText;Openrat.Workbench.notify('',0,'','error','Server Error',[msg])}}});$(form.element).fadeIn()}};this.doResponse=function(e,t,s,onSuccess=$.noop){if(t!='success'){alert('Server error: '+t);return};let form=this;$.each(e['notices'],function(t,e){let notifyBrowser=$(s).data('async');Openrat.Workbench.notify(e.type,e.id,e.name,e.status,e.text,e.log,notifyBrowser);if(e.status=='ok'){onSuccess();Openrat.Workbench.dataChangedHandler.fire()} +;Openrat.Form=function(){const modes={showBrowserNotice:1,keepOpen:2,closeAfterSubmit:4,closeAfterSuccess:8,};this.setLoadStatus=function(e){$(this.element).closest('div.content').toggleClass('loader',e)};this.initOnElement=function(e){this.element=e;let form=this;if($(this.element).data('autosave')){$(this.element).find('input[type="checkbox"]').click(function(){form.submit(modes.keepOpen)});$(this.element).find('select').change(function(){form.submit(modes.keepOpen)})};$(e).find('.or-act-form-cancel').click(function(){form.cancel()});$(e).find('.or-act-form-reset').click(function(){form.rollback()});$(e).find('.or-act-form-apply').click(function(){form.submit(modes.keepOpen)});$(e).find('.or-act-form-save').click(function(){form.submit()});$(e).submit(function(e){if($(this).data('target')=='view'){form.submit();e.preventDefault()}})};this.cancel=function(){this.close()};this.rollback=function(){this.element.trigger('reset')};this.close=function(){};this.forwardTo=function(e,t,o,r){};this.submit=function(e){if(e===undefined)if($(this.element).data('async'))e=modes.closeAfterSubmit;else e=modes.closeAfterSuccess;let status=$('<div class="or-notice or-notice--info"><div class="or-text or-loader"></div></div>');$('.or-notices').prepend(status);$(status).show();$(this.element).find('.or-input.or-error').removeClass('error');let params=$(this.element).serializeArray();let data={};$(params).each(function(e,t){data[t.name]=t.value});if(!data.id)data.id=Openrat.Workbench.state.id;if(!data.action)data.action=Openrat.Workbench.state.action;let formMethod=$(this.element).attr('method').toUpperCase();if(formMethod=='GET'){this.forwardTo(data.action,data.subaction,data.id,data);$(status).remove()} +else{let url='./api/';this.setLoadStatus(!0);url+='';data.output='json';if(e==modes.closeAfterSubmit)this.close();let form=this;$.ajax({'type':'POST',url:url,data:data,success:function(t,o,r){form.setLoadStatus(!1);$(status).remove();form.doResponse(t,o,form.element,function(){let afterSuccess=$(form.element).data('afterSuccess');let forwardTo=$(form.element).data('forwardTo');let async=$(form.element).data('async');if(afterSuccess=='forward')e=modes.keepOpen;if(e==modes.closeAfterSuccess){form.close();$(form.element).closest('div.panel').find('div.header ul.views li.action.active').removeClass('dirty')};if(afterSuccess){if(afterSuccess=='reloadAll'){Openrat.Workbench.reloadAll()} +else if(afterSuccess=='forward'){if(forwardTo)form.forwardTo(data.action,forwardTo,data.id,[])}} +else{if(async);else Openrat.Workbench.reloadViews()}})},error:function(e,t,o){form.setLoadStatus(!1);$(status).remove();try{let error=jQuery.parseJSON(e.responseText);Openrat.Workbench.notify('',0,'','error',error.error,[error.description])}catch(r){let msg=e.responseText;Openrat.Workbench.notify('',0,'','error','Server Error',[msg])}}});$(form.element).fadeIn()}};this.doResponse=function(e,t,o,onSuccess=$.noop){if(t!='success'){alert('Server error: '+t);return};let form=this;$.each(e['notices'],function(t,e){let notifyBrowser=$(o).data('async');Openrat.Workbench.notify(e.type,e.id,e.name,e.status,e.text,e.log,notifyBrowser);if(e.status=='ok'){onSuccess();Openrat.Workbench.dataChangedHandler.fire()} else{}});$.each(e['errors'],function(e,t){$('.or-input[name='+t+']').addClass('error').parent().addClass('error').parents('fieldset').removeClass('closed').addClass('show').addClass('open')})}}; ;Openrat.Workbench=new function(){'use strict';this.state={action:'',id:0,extra:{}};this.popupWindow=null;this.initialize=function(){this.initializePingTimer();this.initializeDirtyWarning();this.initializeState();this.openModalDialog();Openrat.Workbench.registerOpenClose($('.or-collapsible'))};this.initializeDirtyWarning=function(){window.addEventListener('beforeunload',function(e){if($('.or-view--is-dirty').length>0){e.preventDefault();return'Unsaved content will be lost.'} else{return undefined}})};this.openModalDialog=function(){if($('#dialog').data('action')){this.startDialog('',$('#dialog').data('action'),$('#dialog').data('action'),0,{})}};this.initializeState=function(){let parts=window.location.hash.split('/');let state={action:'index',id:0};if(parts.length>=2)state.action=parts[1].toLowerCase();if(parts.length>=3)state.id=parts[2].replace(/[^0-9_]/gim,'');Openrat.Workbench.state=state;Openrat.Navigator.toActualHistory(state)};this.initializePingTimer=function(){let ping=function(){let pingPromise=$.getJSON(Openrat.View.createUrl('profile','ping',0,{},!0));pingPromise.fail(function(){console.warn('The server ping has failed.');if($('.view.dirty').length>0){window.alert('The server session is lost, please save your data.')} diff --git a/modules/cms/ui/themes/default/script/openrat/form.js b/modules/cms/ui/themes/default/script/openrat/form.js @@ -81,13 +81,9 @@ Openrat.Form = function() { } this.close = function() { - } this.forwardTo = function (action, subaction, id, data) { - - let view = new Openrat.View( action, subaction, id, data ); - view.start( $(this.element).closest('.view') ); } this.submit = function( mode ) { @@ -100,13 +96,13 @@ Openrat.Form = function() { // Show progress - let status = $('<div class="notice info"><div class="text loader"></div></div>'); - $('#noticebar').prepend(status); // Notice anhängen. + let status = $('<div class="or-notice or-notice--info"><div class="or-text or-loader"></div></div>'); + $('.or-notices').prepend(status); // Notice anhängen. $(status).show(); // Alle vorhandenen Error-Marker entfernen. // Falls wieder ein Fehler auftritt, werden diese erneut gesetzt. - $(this.element).find('.or-input.error').removeClass('error'); + $(this.element).find('.or-input.or-error').removeClass('error'); let params = $(this.element).serializeArray(); let data = {}; @@ -145,12 +141,19 @@ Openrat.Form = function() { // Async: Window is closed, but the action will be startet now. let form = this; - $.ajax( { 'type':'POST',url:url, data:data, success:function(data, textStatus, jqXHR) + $.ajax( { 'type':'POST',url:url, data:data, success:function(responseData, textStatus, jqXHR) { form.setLoadStatus(false); $(status).remove(); - form.doResponse(data,textStatus,form.element, function() { + form.doResponse(responseData,textStatus,form.element, function() { + + let afterSuccess = $(form.element).data('afterSuccess'); + let forwardTo = $(form.element).data('forwardTo' ); + let async = $(form.element).data('async' ); + + if ( afterSuccess == 'forward' ) + mode = modes.keepOpen; // The data was successful saved. // Now we can close the form. @@ -162,14 +165,18 @@ Openrat.Form = function() { $(form.element).closest('div.panel').find('div.header ul.views li.action.active').removeClass('dirty'); } - let afterSuccess = $(form.element).data('afterSuccess'); - let async = $(form.element).data('async' ); if ( afterSuccess ) { if ( afterSuccess == 'reloadAll' ) { Openrat.Workbench.reloadAll(); } + else if ( afterSuccess == 'forward' ) + { + // Forwarding to next subaction. + if ( forwardTo ) + form.forwardTo( data.action, forwardTo, data.id,[] ); + } } else { if ( async ) ; // do not reload diff --git a/modules/cms/ui/themes/default/script/openrat/view.js b/modules/cms/ui/themes/default/script/openrat/view.js @@ -63,12 +63,22 @@ Openrat.View = function( action,method,id,params ) { $(element).html(data).removeClass("loader"); $(element).find('form').each( function() { + let form = new Openrat.Form(); + form.close = function() { view.close(); } - form.initOnElement(this); + form.forwardTo = function (action, subaction, id, data) { + view.action = action; + view.method = subaction; + view.id = id; + view.params = data; + view.loadView(); + } + + form.initOnElement(this); }); fireViewLoadedEvents( element ); diff --git a/modules/template_engine/components/html/component_form/FormComponent.class.php b/modules/template_engine/components/html/component_form/FormComponent.class.php @@ -20,6 +20,7 @@ class FormComponent extends Component public $action = null; public $subaction = null; + public $forwardTo = null; public $id = '${_id}'; @@ -72,6 +73,8 @@ class FormComponent extends Component $form->addAttribute('target', '_self'); $form->addAttribute('data-target', $this->target); $form->addAttribute('action', './'); + if ( $this->forwardTo ) + $form->addAttribute('data-forward-to', $this->forwardTo); $form->addAttribute('data-method', $this->subaction); $form->addAttribute('data-action', $this->action); $form->addAttribute('data-id', $this->id); diff --git a/modules/template_engine/components/template.xsd b/modules/template_engine/components/template.xsd @@ -372,6 +372,7 @@ <xsd:attribute name="name" type="xsd:string"/> <xsd:attribute name="action" type="xsd:string"/> <xsd:attribute name="subaction" type="xsd:string"/> + <xsd:attribute name="forwardTo" type="xsd:string"/> <xsd:attribute name="id" type="xsd:string"/> <xsd:attribute name="languageid" type="xsd:string"/> <xsd:attribute name="modelid" type="xsd:string"/> diff --git a/modules/util/Mail.class.php b/modules/util/Mail.class.php @@ -525,13 +525,11 @@ class Mail * Prüft, ob eine Domain in einer List von Domains enthalten ist. * * @param $checkDomain string zu prüfende Domain - * @param $domain_list string Liste von Domains als kommaseparierte Liste + * @param $domains string Liste von Domains als kommaseparierte Liste * @return true, falls vorhanden, sonst false */ - private static function containsDomain($checkDomain, $domain_list) + private static function containsDomain($checkDomain, $domains) { - $domains = explode(',', $domain_list); - foreach ($domains as $domain) { $domain = trim($domain); @@ -544,7 +542,4 @@ class Mail } return false; } -} - - -?> +}+ \ No newline at end of file diff --git a/modules/util/Session.class.php b/modules/util/Session.class.php @@ -27,6 +27,8 @@ class Session const KEY_CONFIG = 'config'; const KEY_PASSWORD_COMMIT_CODE = 'password_commit_code'; const KEY_PASSWORD_COMMIT_NAME = 'password_commit_name'; + const KEY_MAIL_CHANGE_CODE = 'mail_change_code'; + const KEY_MAIL_CHANGE_MAIL = 'mail_change_mail'; const PRAEFIX = 'ors_';