diff --git a/bootstrap.php b/bootstrap.php index a2a942b..2a947eb 100755 --- a/bootstrap.php +++ b/bootstrap.php @@ -3,7 +3,7 @@ Plugin Name: Visitors contributions Plugin URI: http://codecanyon.net/user/Leavy Description: A wordpress plugin that gives your visitors the possiblity to develop your website content by submiting new versions to your articles. -Version: 1.07 +Version: 1.11 Author: Leavy Author URI: http://codecanyon.net/user/Leavy */ diff --git a/css/grid.css b/css/grid.css index 4280774..8e448fd 100755 --- a/css/grid.css +++ b/css/grid.css @@ -1,230 +1,230 @@ -/* line 2, style.scss */ -* { - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; -} - -/* line 3, style.scss */ -body { - margin: 0; - padding: 0; - font-family: sans-serif; -} - -/* line 6, _grid.scss */ -.col-1, .col-m-1, .col-l-1, .col-2, .col-m-2, .col-l-2, .col-3, .col-m-3, .col-l-3, .col-4, .col-m-4, .col-l-4, .col-5, .col-m-5, .col-l-5, .col-6, .col-m-6, .col-l-6, .col-7, .col-m-7, .col-l-7, .col-8, .col-m-8, .col-l-8, .col-9, .col-m-9, .col-l-9, .col-10, .col-m-10, .col-l-10, .col-11, .col-m-11, .col-l-11, .col-12, .col-m-12, .col-l-12 { - float: right; - position: relative; - min-height: 1px; - padding: 0 10px; - /*border: 1px solid rgba(255, 0, 0, 0.5);*/ -} - -/* line 16, _grid.scss */ -.col-1 { - width: 8.33333%; -} - -/* line 16, _grid.scss */ -.col-2 { - width: 16.66667%; -} - -/* line 16, _grid.scss */ -.col-3 { - width: 25%; -} - -/* line 16, _grid.scss */ -.col-4 { - width: 33.33333%; -} - -/* line 16, _grid.scss */ -.col-5 { - width: 41.66667%; -} - -/* line 16, _grid.scss */ -.col-6 { - width: 50%; -} - -/* line 16, _grid.scss */ -.col-7 { - width: 58.33333%; -} - -/* line 16, _grid.scss */ -.col-8 { - width: 66.66667%; -} - -/* line 16, _grid.scss */ -.col-9 { - width: 75%; -} - -/* line 16, _grid.scss */ -.col-10 { - width: 83.33333%; -} - -/* line 16, _grid.scss */ -.col-11 { - width: 91.66667%; -} - -/* line 16, _grid.scss */ -.col-12 { - width: 100%; -} - -/* line 23, _grid.scss */ -.row { - margin: 0 -10px; - overflow: hidden; - *zoom: 1; -} - -/* line 27, _grid.scss */ -.col-center { - margin: 0 auto; - float: none; -} - -@media only screen and (min-width: 640px) { - /* line 30, _grid.scss */ - .col-m-center { - margin: 0 auto; - float: none; - } - - /* line 32, _grid.scss */ - .col-m-1 { - width: 8.33333%; - } - - /* line 32, _grid.scss */ - .col-m-2 { - width: 16.66667%; - } - - /* line 32, _grid.scss */ - .col-m-3 { - width: 25%; - } - - /* line 32, _grid.scss */ - .col-m-4 { - width: 33.33333%; - } - - /* line 32, _grid.scss */ - .col-m-5 { - width: 41.66667%; - } - - /* line 32, _grid.scss */ - .col-m-6 { - width: 50%; - } - - /* line 32, _grid.scss */ - .col-m-7 { - width: 58.33333%; - } - - /* line 32, _grid.scss */ - .col-m-8 { - width: 66.66667%; - } - - /* line 32, _grid.scss */ - .col-m-9 { - width: 75%; - } - - /* line 32, _grid.scss */ - .col-m-10 { - width: 83.33333%; - } - - /* line 32, _grid.scss */ - .col-m-11 { - width: 91.66667%; - } - - /* line 32, _grid.scss */ - .col-m-12 { - width: 100%; - } -} -@media only screen and (min-width: 1024px) { - /* line 39, _grid.scss */ - .col-l-center { - margin: 0 auto; - float: none; - } - - /* line 41, _grid.scss */ - .col-l-1 { - width: 8.33333%; - } - - /* line 41, _grid.scss */ - .col-l-2 { - width: 16.66667%; - } - - /* line 41, _grid.scss */ - .col-l-3 { - width: 25%; - } - - /* line 41, _grid.scss */ - .col-l-4 { - width: 33.33333%; - } - - /* line 41, _grid.scss */ - .col-l-5 { - width: 41.66667%; - } - - /* line 41, _grid.scss */ - .col-l-6 { - width: 50%; - } - - /* line 41, _grid.scss */ - .col-l-7 { - width: 58.33333%; - } - - /* line 41, _grid.scss */ - .col-l-8 { - width: 66.66667%; - } - - /* line 41, _grid.scss */ - .col-l-9 { - width: 75%; - } - - /* line 41, _grid.scss */ - .col-l-10 { - width: 83.33333%; - } - - /* line 41, _grid.scss */ - .col-l-11 { - width: 91.66667%; - } - - /* line 41, _grid.scss */ - .col-l-12 { - width: 100%; - } -} +/* line 2, style.scss */ +* { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} + +/* line 3, style.scss */ +body { + margin: 0; + padding: 0; + font-family: sans-serif; +} + +/* line 6, _grid.scss */ +.col-1, .col-m-1, .col-l-1, .col-2, .col-m-2, .col-l-2, .col-3, .col-m-3, .col-l-3, .col-4, .col-m-4, .col-l-4, .col-5, .col-m-5, .col-l-5, .col-6, .col-m-6, .col-l-6, .col-7, .col-m-7, .col-l-7, .col-8, .col-m-8, .col-l-8, .col-9, .col-m-9, .col-l-9, .col-10, .col-m-10, .col-l-10, .col-11, .col-m-11, .col-l-11, .col-12, .col-m-12, .col-l-12 { + float: right; + position: relative; + min-height: 1px; + padding: 0 10px; + /*border: 1px solid rgba(255, 0, 0, 0.5);*/ +} + +/* line 16, _grid.scss */ +.col-1 { + width: 8.33333%; +} + +/* line 16, _grid.scss */ +.col-2 { + width: 16.66667%; +} + +/* line 16, _grid.scss */ +.col-3 { + width: 25%; +} + +/* line 16, _grid.scss */ +.col-4 { + width: 33.33333%; +} + +/* line 16, _grid.scss */ +.col-5 { + width: 41.66667%; +} + +/* line 16, _grid.scss */ +.col-6 { + width: 50%; +} + +/* line 16, _grid.scss */ +.col-7 { + width: 58.33333%; +} + +/* line 16, _grid.scss */ +.col-8 { + width: 66.66667%; +} + +/* line 16, _grid.scss */ +.col-9 { + width: 75%; +} + +/* line 16, _grid.scss */ +.col-10 { + width: 83.33333%; +} + +/* line 16, _grid.scss */ +.col-11 { + width: 91.66667%; +} + +/* line 16, _grid.scss */ +.col-12 { + width: 100%; +} + +/* line 23, _grid.scss */ +.row { + margin: 0 -10px; + overflow: hidden; + *zoom: 1; +} + +/* line 27, _grid.scss */ +.col-center { + margin: 0 auto; + float: none; +} + +@media only screen and (min-width: 640px) { + /* line 30, _grid.scss */ + .col-m-center { + margin: 0 auto; + float: none; + } + + /* line 32, _grid.scss */ + .col-m-1 { + width: 8.33333%; + } + + /* line 32, _grid.scss */ + .col-m-2 { + width: 16.66667%; + } + + /* line 32, _grid.scss */ + .col-m-3 { + width: 25%; + } + + /* line 32, _grid.scss */ + .col-m-4 { + width: 33.33333%; + } + + /* line 32, _grid.scss */ + .col-m-5 { + width: 41.66667%; + } + + /* line 32, _grid.scss */ + .col-m-6 { + width: 50%; + } + + /* line 32, _grid.scss */ + .col-m-7 { + width: 58.33333%; + } + + /* line 32, _grid.scss */ + .col-m-8 { + width: 66.66667%; + } + + /* line 32, _grid.scss */ + .col-m-9 { + width: 75%; + } + + /* line 32, _grid.scss */ + .col-m-10 { + width: 83.33333%; + } + + /* line 32, _grid.scss */ + .col-m-11 { + width: 91.66667%; + } + + /* line 32, _grid.scss */ + .col-m-12 { + width: 100%; + } +} +@media only screen and (min-width: 1024px) { + /* line 39, _grid.scss */ + .col-l-center { + margin: 0 auto; + float: none; + } + + /* line 41, _grid.scss */ + .col-l-1 { + width: 8.33333%; + } + + /* line 41, _grid.scss */ + .col-l-2 { + width: 16.66667%; + } + + /* line 41, _grid.scss */ + .col-l-3 { + width: 25%; + } + + /* line 41, _grid.scss */ + .col-l-4 { + width: 33.33333%; + } + + /* line 41, _grid.scss */ + .col-l-5 { + width: 41.66667%; + } + + /* line 41, _grid.scss */ + .col-l-6 { + width: 50%; + } + + /* line 41, _grid.scss */ + .col-l-7 { + width: 58.33333%; + } + + /* line 41, _grid.scss */ + .col-l-8 { + width: 66.66667%; + } + + /* line 41, _grid.scss */ + .col-l-9 { + width: 75%; + } + + /* line 41, _grid.scss */ + .col-l-10 { + width: 83.33333%; + } + + /* line 41, _grid.scss */ + .col-l-11 { + width: 91.66667%; + } + + /* line 41, _grid.scss */ + .col-l-12 { + width: 100%; + } +} diff --git a/inc/editor.php b/inc/editor.php index ecec8f6..71cccc8 100755 --- a/inc/editor.php +++ b/inc/editor.php @@ -32,12 +32,14 @@ if(!empty($_POST)){ "visitor_notif_message"=>"Your suggestion was submitted.", "admin_notif_message"=>"A new suggestion was submitted." ]); + $mail = [ "post_title"=>$post->post_title, "post_url"=>get_permalink($post_id), "visitor_name"=>$visitor_name, + "visitor_comment"=>$visitor_comment, "visitor_email"=>$visitor_email, - "edit_time"=>date('H:i')." - ".date('d/m/y'), + "edit_time"=>date('m/d/Y')." at ".date('h:i a'), "blog_title" => get_bloginfo("name"), "visitor_notif_message"=>$options["visitor_notif_message"], "admin_notif_message"=>$options["admin_notif_message"] diff --git a/inc/mail.php b/inc/mail.php index a40daa9..4f0459c 100755 --- a/inc/mail.php +++ b/inc/mail.php @@ -14,8 +14,14 @@ class visitors_edits_EMAIL{ "notify_admin"=>null ]); - $headers = "Content-Type: text/html; charset=UTF-8\r\n"; - wp_mail($destination, $this->subject, $this->body, $headers); + $headers= "MIME-Version: 1.0\r\n"; + $headers .= "Content-Type: text/html; charset=UTF-8\r\n"; + + wp_mail($destination, $this->subject, $this->body,$headers); + /* + subject : $this->subject + body : $this->body + */ } private function loadTemplate($template){ ob_start(); diff --git a/inc/mail_templates/admin_submition.html b/inc/mail_templates/admin_submition.html index 0dedb34..7d2e81e 100755 --- a/inc/mail_templates/admin_submition.html +++ b/inc/mail_templates/admin_submition.html @@ -64,6 +64,11 @@ Author : #visitor_name# (#visitor_email#) + + + Summary : #visitor_comment# + +   diff --git a/js/approve.js b/js/approve.js index 34f1270..3e87082 100755 --- a/js/approve.js +++ b/js/approve.js @@ -1,16 +1,13 @@ visitors_edits_tools={ data:{}, - clearTag:function(content,tag){ - var regexp=RegExp("<"+tag+">.*?<\/"+tag+">", "gi"); - var editedContent=content.replace(regexp,""); - return editedContent; - }, clearTag:function(content,tag){ var $contentDiv=jQuery("
").html(content); $contentDiv.find(tag).each(function(){ $tag=jQuery(this); $tag.remove(); }); + if($contentDiv.find(tag).length>0) + return visitors_edits_tools.clearTag($contentDiv.html(),tag); return $contentDiv.html(); }, clearTagName:function(content,tag){ @@ -19,6 +16,8 @@ visitors_edits_tools={ $tag=jQuery(this); $tag.replaceWith($tag.html()); }); + if($contentDiv.find(tag).length>0) + return visitors_edits_tools.clearTagName($contentDiv.html(),tag); return $contentDiv.html(); }, clearClassName:function(content,classname){ @@ -27,6 +26,8 @@ visitors_edits_tools={ $elm=jQuery(this); $elm.removeClass(classname); }); + if($contentDiv.find("."+classname).length>0) + return visitors_edits_tools.clearTagName($contentDiv.html(),classname); return $contentDiv.html(); }, clear:function(ed){ @@ -87,6 +88,7 @@ visitors_edits_tools={ content=visitors_edits_tools.clearTag(content,"del"); content=visitors_edits_tools.clearClassName(content,"diffmod"); ed.setContent(content); + console.log("Cleaned"); }); //Load content setTimeout(function(){ @@ -117,5 +119,5 @@ visitors_edits_tools={ })(jQuery); function editSubmit(){ tinyMCE.activeEditor.execCommand("visitors_edits_clean"); - return true; + return true; } \ No newline at end of file diff --git a/js/jquery.validate.js b/js/jquery.validate.js index 3fc1676..a64549c 100755 --- a/js/jquery.validate.js +++ b/js/jquery.validate.js @@ -16,1517 +16,1517 @@ } }(function( $ ) { -$.extend( $.fn, { - - // http://jqueryvalidation.org/validate/ - validate: function( options ) { - - // If nothing is selected, return nothing; can't chain anyway - if ( !this.length ) { - if ( options && options.debug && window.console ) { - console.warn( "Nothing selected, can't validate, returning nothing." ); - } - return; - } - - // Check if a validator for this form was already created - var validator = $.data( this[ 0 ], "validator" ); - if ( validator ) { - return validator; - } - - // Add novalidate tag if HTML5. - this.attr( "novalidate", "novalidate" ); - - validator = new $.validator( options, this[ 0 ] ); - $.data( this[ 0 ], "validator", validator ); - - if ( validator.settings.onsubmit ) { - - this.on( "click.validate", ":submit", function( event ) { - if ( validator.settings.submitHandler ) { - validator.submitButton = event.target; - } - - // Allow suppressing validation by adding a cancel class to the submit button - if ( $( this ).hasClass( "cancel" ) ) { - validator.cancelSubmit = true; - } - - // Allow suppressing validation by adding the html5 formnovalidate attribute to the submit button - if ( $( this ).attr( "formnovalidate" ) !== undefined ) { - validator.cancelSubmit = true; - } - } ); - - // Validate the form on submit - this.on( "submit.validate", function( event ) { - if ( validator.settings.debug ) { - - // Prevent form submit to be able to see console output - event.preventDefault(); - } - function handle() { - var hidden, result; - if ( validator.settings.submitHandler ) { - if ( validator.submitButton ) { - - // Insert a hidden input as a replacement for the missing submit button - hidden = $( "" ) - .attr( "name", validator.submitButton.name ) - .val( $( validator.submitButton ).val() ) - .appendTo( validator.currentForm ); - } - result = validator.settings.submitHandler.call( validator, validator.currentForm, event ); - if ( validator.submitButton ) { - - // And clean up afterwards; thanks to no-block-scope, hidden can be referenced - hidden.remove(); - } - if ( result !== undefined ) { - return result; - } - return false; - } - return true; - } - - // Prevent submit for invalid forms or custom submit handlers - if ( validator.cancelSubmit ) { - validator.cancelSubmit = false; - return handle(); - } - if ( validator.form() ) { - if ( validator.pendingRequest ) { - validator.formSubmitted = true; - return false; - } - return handle(); - } else { - validator.focusInvalid(); - return false; - } - } ); - } - - return validator; - }, - - // http://jqueryvalidation.org/valid/ - valid: function() { - var valid, validator, errorList; - - if ( $( this[ 0 ] ).is( "form" ) ) { - valid = this.validate().form(); - } else { - errorList = []; - valid = true; - validator = $( this[ 0 ].form ).validate(); - this.each( function() { - valid = validator.element( this ) && valid; - if ( !valid ) { - errorList = errorList.concat( validator.errorList ); - } - } ); - validator.errorList = errorList; - } - return valid; - }, - - // http://jqueryvalidation.org/rules/ - rules: function( command, argument ) { - - // If nothing is selected, return nothing; can't chain anyway - if ( !this.length ) { - return; - } - - var element = this[ 0 ], - settings, staticRules, existingRules, data, param, filtered; - - if ( command ) { - settings = $.data( element.form, "validator" ).settings; - staticRules = settings.rules; - existingRules = $.validator.staticRules( element ); - switch ( command ) { - case "add": - $.extend( existingRules, $.validator.normalizeRule( argument ) ); - - // Remove messages from rules, but allow them to be set separately - delete existingRules.messages; - staticRules[ element.name ] = existingRules; - if ( argument.messages ) { - settings.messages[ element.name ] = $.extend( settings.messages[ element.name ], argument.messages ); - } - break; - case "remove": - if ( !argument ) { - delete staticRules[ element.name ]; - return existingRules; - } - filtered = {}; - $.each( argument.split( /\s/ ), function( index, method ) { - filtered[ method ] = existingRules[ method ]; - delete existingRules[ method ]; - if ( method === "required" ) { - $( element ).removeAttr( "aria-required" ); - } - } ); - return filtered; - } - } - - data = $.validator.normalizeRules( - $.extend( - {}, - $.validator.classRules( element ), - $.validator.attributeRules( element ), - $.validator.dataRules( element ), - $.validator.staticRules( element ) - ), element ); - - // Make sure required is at front - if ( data.required ) { - param = data.required; - delete data.required; - data = $.extend( { required: param }, data ); - $( element ).attr( "aria-required", "true" ); - } - - // Make sure remote is at back - if ( data.remote ) { - param = data.remote; - delete data.remote; - data = $.extend( data, { remote: param } ); - } - - return data; - } -} ); - -// Custom selectors -$.extend( $.expr[ ":" ], { - - // http://jqueryvalidation.org/blank-selector/ - blank: function( a ) { - return !$.trim( "" + $( a ).val() ); - }, - - // http://jqueryvalidation.org/filled-selector/ - filled: function( a ) { - var val = $( a ).val(); - return val !== null && !!$.trim( "" + val ); - }, - - // http://jqueryvalidation.org/unchecked-selector/ - unchecked: function( a ) { - return !$( a ).prop( "checked" ); - } -} ); - -// Constructor for validator -$.validator = function( options, form ) { - this.settings = $.extend( true, {}, $.validator.defaults, options ); - this.currentForm = form; - this.init(); -}; - -// http://jqueryvalidation.org/jQuery.validator.format/ -$.validator.format = function( source, params ) { - if ( arguments.length === 1 ) { - return function() { - var args = $.makeArray( arguments ); - args.unshift( source ); - return $.validator.format.apply( this, args ); - }; - } - if ( params === undefined ) { - return source; - } - if ( arguments.length > 2 && params.constructor !== Array ) { - params = $.makeArray( arguments ).slice( 1 ); - } - if ( params.constructor !== Array ) { - params = [ params ]; - } - $.each( params, function( i, n ) { - source = source.replace( new RegExp( "\\{" + i + "\\}", "g" ), function() { - return n; - } ); - } ); - return source; -}; - -$.extend( $.validator, { - - defaults: { - messages: {}, - groups: {}, - rules: {}, - errorClass: "error", - pendingClass: "pending", - validClass: "valid", - errorElement: "label", - focusCleanup: false, - focusInvalid: true, - errorContainer: $( [] ), - errorLabelContainer: $( [] ), - onsubmit: true, - ignore: ":hidden", - ignoreTitle: false, - onfocusin: function( element ) { - this.lastActive = element; - - // Hide error label and remove error class on focus if enabled - if ( this.settings.focusCleanup ) { - if ( this.settings.unhighlight ) { - this.settings.unhighlight.call( this, element, this.settings.errorClass, this.settings.validClass ); - } - this.hideThese( this.errorsFor( element ) ); - } - }, - onfocusout: function( element ) { - if ( !this.checkable( element ) && ( element.name in this.submitted || !this.optional( element ) ) ) { - this.element( element ); - } - }, - onkeyup: function( element, event ) { - - // Avoid revalidate the field when pressing one of the following keys - // Shift => 16 - // Ctrl => 17 - // Alt => 18 - // Caps lock => 20 - // End => 35 - // Home => 36 - // Left arrow => 37 - // Up arrow => 38 - // Right arrow => 39 - // Down arrow => 40 - // Insert => 45 - // Num lock => 144 - // AltGr key => 225 - var excludedKeys = [ - 16, 17, 18, 20, 35, 36, 37, - 38, 39, 40, 45, 144, 225 - ]; - - if ( event.which === 9 && this.elementValue( element ) === "" || $.inArray( event.keyCode, excludedKeys ) !== -1 ) { - return; - } else if ( element.name in this.submitted || element.name in this.invalid ) { - this.element( element ); - } - }, - onclick: function( element ) { - - // Click on selects, radiobuttons and checkboxes - if ( element.name in this.submitted ) { - this.element( element ); - - // Or option elements, check parent select in that case - } else if ( element.parentNode.name in this.submitted ) { - this.element( element.parentNode ); - } - }, - highlight: function( element, errorClass, validClass ) { - if ( element.type === "radio" ) { - this.findByName( element.name ).addClass( errorClass ).removeClass( validClass ); - } else { - $( element ).addClass( errorClass ).removeClass( validClass ); - } - }, - unhighlight: function( element, errorClass, validClass ) { - if ( element.type === "radio" ) { - this.findByName( element.name ).removeClass( errorClass ).addClass( validClass ); - } else { - $( element ).removeClass( errorClass ).addClass( validClass ); - } - } - }, - - // http://jqueryvalidation.org/jQuery.validator.setDefaults/ - setDefaults: function( settings ) { - $.extend( $.validator.defaults, settings ); - }, - - messages: { - required: "This field is required.", - remote: "Please fix this field.", - email: "Please enter a valid email address.", - url: "Please enter a valid URL.", - date: "Please enter a valid date.", - dateISO: "Please enter a valid date ( ISO ).", - number: "Please enter a valid number.", - digits: "Please enter only digits.", - equalTo: "Please enter the same value again.", - maxlength: $.validator.format( "Please enter no more than {0} characters." ), - minlength: $.validator.format( "Please enter at least {0} characters." ), - rangelength: $.validator.format( "Please enter a value between {0} and {1} characters long." ), - range: $.validator.format( "Please enter a value between {0} and {1}." ), - max: $.validator.format( "Please enter a value less than or equal to {0}." ), - min: $.validator.format( "Please enter a value greater than or equal to {0}." ), - step: $.validator.format( "Please enter a multiple of {0}." ) - }, - - autoCreateRanges: false, - - prototype: { - - init: function() { - this.labelContainer = $( this.settings.errorLabelContainer ); - this.errorContext = this.labelContainer.length && this.labelContainer || $( this.currentForm ); - this.containers = $( this.settings.errorContainer ).add( this.settings.errorLabelContainer ); - this.submitted = {}; - this.valueCache = {}; - this.pendingRequest = 0; - this.pending = {}; - this.invalid = {}; - this.reset(); - - var groups = ( this.groups = {} ), - rules; - $.each( this.settings.groups, function( key, value ) { - if ( typeof value === "string" ) { - value = value.split( /\s/ ); - } - $.each( value, function( index, name ) { - groups[ name ] = key; - } ); - } ); - rules = this.settings.rules; - $.each( rules, function( key, value ) { - rules[ key ] = $.validator.normalizeRule( value ); - } ); - - function delegate( event ) { - var validator = $.data( this.form, "validator" ), - eventType = "on" + event.type.replace( /^validate/, "" ), - settings = validator.settings; - if ( settings[ eventType ] && !$( this ).is( settings.ignore ) ) { - settings[ eventType ].call( validator, this, event ); - } - } - - $( this.currentForm ) - .on( "focusin.validate focusout.validate keyup.validate", - ":text, [type='password'], [type='file'], select, textarea, [type='number'], [type='search'], " + - "[type='tel'], [type='url'], [type='email'], [type='datetime'], [type='date'], [type='month'], " + - "[type='week'], [type='time'], [type='datetime-local'], [type='range'], [type='color'], " + - "[type='radio'], [type='checkbox'], [contenteditable]", delegate ) - - // Support: Chrome, oldIE - // "select" is provided as event.target when clicking a option - .on( "click.validate", "select, option, [type='radio'], [type='checkbox']", delegate ); - - if ( this.settings.invalidHandler ) { - $( this.currentForm ).on( "invalid-form.validate", this.settings.invalidHandler ); - } - - // Add aria-required to any Static/Data/Class required fields before first validation - // Screen readers require this attribute to be present before the initial submission http://www.w3.org/TR/WCAG-TECHS/ARIA2.html - $( this.currentForm ).find( "[required], [data-rule-required], .required" ).attr( "aria-required", "true" ); - }, - - // http://jqueryvalidation.org/Validator.form/ - form: function() { - this.checkForm(); - $.extend( this.submitted, this.errorMap ); - this.invalid = $.extend( {}, this.errorMap ); - if ( !this.valid() ) { - $( this.currentForm ).triggerHandler( "invalid-form", [ this ] ); - } - this.showErrors(); - return this.valid(); - }, - - checkForm: function() { - this.prepareForm(); - for ( var i = 0, elements = ( this.currentElements = this.elements() ); elements[ i ]; i++ ) { - this.check( elements[ i ] ); - } - return this.valid(); - }, - - // http://jqueryvalidation.org/Validator.element/ - element: function( element ) { - var cleanElement = this.clean( element ), - checkElement = this.validationTargetFor( cleanElement ), - v = this, - result = true, - rs, group; - - if ( checkElement === undefined ) { - delete this.invalid[ cleanElement.name ]; - } else { - this.prepareElement( checkElement ); - this.currentElements = $( checkElement ); - - // If this element is grouped, then validate all group elements already - // containing a value - group = this.groups[ checkElement.name ]; - if ( group ) { - $.each( this.groups, function( name, testgroup ) { - if ( testgroup === group && name !== checkElement.name ) { - cleanElement = v.validationTargetFor( v.clean( v.findByName( name ) ) ); - if ( cleanElement && cleanElement.name in v.invalid ) { - v.currentElements.push( cleanElement ); - result = result && v.check( cleanElement ); - } - } - } ); - } - - rs = this.check( checkElement ) !== false; - result = result && rs; - if ( rs ) { - this.invalid[ checkElement.name ] = false; - } else { - this.invalid[ checkElement.name ] = true; - } - - if ( !this.numberOfInvalids() ) { - - // Hide error containers on last error - this.toHide = this.toHide.add( this.containers ); - } - this.showErrors(); - - // Add aria-invalid status for screen readers - $( element ).attr( "aria-invalid", !rs ); - } - - return result; - }, - - // http://jqueryvalidation.org/Validator.showErrors/ - showErrors: function( errors ) { - if ( errors ) { - var validator = this; - - // Add items to error list and map - $.extend( this.errorMap, errors ); - this.errorList = $.map( this.errorMap, function( message, name ) { - return { - message: message, - element: validator.findByName( name )[ 0 ] - }; - } ); - - // Remove items from success list - this.successList = $.grep( this.successList, function( element ) { - return !( element.name in errors ); - } ); - } - if ( this.settings.showErrors ) { - this.settings.showErrors.call( this, this.errorMap, this.errorList ); - } else { - this.defaultShowErrors(); - } - }, - - // http://jqueryvalidation.org/Validator.resetForm/ - resetForm: function() { - if ( $.fn.resetForm ) { - $( this.currentForm ).resetForm(); - } - this.invalid = {}; - this.submitted = {}; - this.prepareForm(); - this.hideErrors(); - var elements = this.elements() - .removeData( "previousValue" ) - .removeAttr( "aria-invalid" ); - - this.resetElements( elements ); - }, - - resetElements: function( elements ) { - var i; - - if ( this.settings.unhighlight ) { - for ( i = 0; elements[ i ]; i++ ) { - this.settings.unhighlight.call( this, elements[ i ], - this.settings.errorClass, "" ); - this.findByName( elements[ i ].name ).removeClass( this.settings.validClass ); - } - } else { - elements - .removeClass( this.settings.errorClass ) - .removeClass( this.settings.validClass ); - } - }, - - numberOfInvalids: function() { - return this.objectLength( this.invalid ); - }, - - objectLength: function( obj ) { - /* jshint unused: false */ - var count = 0, - i; - for ( i in obj ) { - if ( obj[ i ] ) { - count++; - } - } - return count; - }, - - hideErrors: function() { - this.hideThese( this.toHide ); - }, - - hideThese: function( errors ) { - errors.not( this.containers ).text( "" ); - this.addWrapper( errors ).hide(); - }, - - valid: function() { - return this.size() === 0; - }, - - size: function() { - return this.errorList.length; - }, - - focusInvalid: function() { - if ( this.settings.focusInvalid ) { - try { - $( this.findLastActive() || this.errorList.length && this.errorList[ 0 ].element || [] ) - .filter( ":visible" ) - .focus() - - // Manually trigger focusin event; without it, focusin handler isn't called, findLastActive won't have anything to find - .trigger( "focusin" ); - } catch ( e ) { - - // Ignore IE throwing errors when focusing hidden elements - } - } - }, - - findLastActive: function() { - var lastActive = this.lastActive; - return lastActive && $.grep( this.errorList, function( n ) { - return n.element.name === lastActive.name; - } ).length === 1 && lastActive; - }, - - elements: function() { - var validator = this, - rulesCache = {}; - - // Select all valid inputs inside the form (no submit or reset buttons) - return $( this.currentForm ) - .find( "input, select, textarea, [contenteditable]" ) - .not( ":submit, :reset, :image, :disabled" ) - .not( this.settings.ignore ) - .filter( function() { - var name = this.name || $( this ).attr( "name" ); // For contenteditable - if ( !name && validator.settings.debug && window.console ) { - console.error( "%o has no name assigned", this ); - } - - // Set form expando on contenteditable - if ( this.hasAttribute( "contenteditable" ) ) { - this.form = $( this ).closest( "form" )[ 0 ]; - } - - // Select only the first element for each name, and only those with rules specified - if ( name in rulesCache || !validator.objectLength( $( this ).rules() ) ) { - return false; - } - - rulesCache[ name ] = true; - return true; - } ); - }, - - clean: function( selector ) { - return $( selector )[ 0 ]; - }, - - errors: function() { - var errorClass = this.settings.errorClass.split( " " ).join( "." ); - return $( this.settings.errorElement + "." + errorClass, this.errorContext ); - }, - - resetInternals: function() { - this.successList = []; - this.errorList = []; - this.errorMap = {}; - this.toShow = $( [] ); - this.toHide = $( [] ); - }, - - reset: function() { - this.resetInternals(); - this.currentElements = $( [] ); - }, - - prepareForm: function() { - this.reset(); - this.toHide = this.errors().add( this.containers ); - }, - - prepareElement: function( element ) { - this.reset(); - this.toHide = this.errorsFor( element ); - }, - - elementValue: function( element ) { - var $element = $( element ), - type = element.type, - val, idx; - - if ( type === "radio" || type === "checkbox" ) { - return this.findByName( element.name ).filter( ":checked" ).val(); - } else if ( type === "number" && typeof element.validity !== "undefined" ) { - return element.validity.badInput ? "NaN" : $element.val(); - } - - if ( element.hasAttribute( "contenteditable" ) ) { - val = $element.text(); - } else { - val = $element.val(); - } - - if ( type === "file" ) { - - // Modern browser (chrome & safari) - if ( val.substr( 0, 12 ) === "C:\\fakepath\\" ) { - return val.substr( 12 ); - } - - // Legacy browsers - // Unix-based path - idx = val.lastIndexOf( "/" ); - if ( idx >= 0 ) { - return val.substr( idx + 1 ); - } - - // Windows-based path - idx = val.lastIndexOf( "\\" ); - if ( idx >= 0 ) { - return val.substr( idx + 1 ); - } - - // Just the file name - return val; - } - - if ( typeof val === "string" ) { - return val.replace( /\r/g, "" ); - } - return val; - }, - - check: function( element ) { - element = this.validationTargetFor( this.clean( element ) ); - - var rules = $( element ).rules(), - rulesCount = $.map( rules, function( n, i ) { - return i; - } ).length, - dependencyMismatch = false, - val = this.elementValue( element ), - result, method, rule; - - // If a normalizer is defined for this element, then - // call it to retreive the changed value instead - // of using the real one. - // Note that `this` in the normalizer is `element`. - if ( typeof rules.normalizer === "function" ) { - val = rules.normalizer.call( element, val ); - - if ( typeof val !== "string" ) { - throw new TypeError( "The normalizer should return a string value." ); - } - - // Delete the normalizer from rules to avoid treating - // it as a pre-defined method. - delete rules.normalizer; - } - - for ( method in rules ) { - rule = { method: method, parameters: rules[ method ] }; - try { - result = $.validator.methods[ method ].call( this, val, element, rule.parameters ); - - // If a method indicates that the field is optional and therefore valid, - // don't mark it as valid when there are no other rules - if ( result === "dependency-mismatch" && rulesCount === 1 ) { - dependencyMismatch = true; - continue; - } - dependencyMismatch = false; - - if ( result === "pending" ) { - this.toHide = this.toHide.not( this.errorsFor( element ) ); - return; - } - - if ( !result ) { - this.formatAndAdd( element, rule ); - return false; - } - } catch ( e ) { - if ( this.settings.debug && window.console ) { - console.log( "Exception occurred when checking element " + element.id + ", check the '" + rule.method + "' method.", e ); - } - if ( e instanceof TypeError ) { - e.message += ". Exception occurred when checking element " + element.id + ", check the '" + rule.method + "' method."; - } - - throw e; - } - } - if ( dependencyMismatch ) { - return; - } - if ( this.objectLength( rules ) ) { - this.successList.push( element ); - } - return true; - }, - - // Return the custom message for the given element and validation method - // specified in the element's HTML5 data attribute - // return the generic message if present and no method specific message is present - customDataMessage: function( element, method ) { - return $( element ).data( "msg" + method.charAt( 0 ).toUpperCase() + - method.substring( 1 ).toLowerCase() ) || $( element ).data( "msg" ); - }, - - // Return the custom message for the given element name and validation method - customMessage: function( name, method ) { - var m = this.settings.messages[ name ]; - return m && ( m.constructor === String ? m : m[ method ] ); - }, - - // Return the first defined argument, allowing empty strings - findDefined: function() { - for ( var i = 0; i < arguments.length; i++ ) { - if ( arguments[ i ] !== undefined ) { - return arguments[ i ]; - } - } - return undefined; - }, - - defaultMessage: function( element, rule ) { - var message = this.findDefined( - this.customMessage( element.name, rule.method ), - this.customDataMessage( element, rule.method ), - - // 'title' is never undefined, so handle empty string as undefined - !this.settings.ignoreTitle && element.title || undefined, - $.validator.messages[ rule.method ], - "Warning: No message defined for " + element.name + "" - ), - theregex = /\$?\{(\d+)\}/g; - if ( typeof message === "function" ) { - message = message.call( this, rule.parameters, element ); - } else if ( theregex.test( message ) ) { - message = $.validator.format( message.replace( theregex, "{$1}" ), rule.parameters ); - } - - return message; - }, - - formatAndAdd: function( element, rule ) { - var message = this.defaultMessage( element, rule ); - - this.errorList.push( { - message: message, - element: element, - method: rule.method - } ); - - this.errorMap[ element.name ] = message; - this.submitted[ element.name ] = message; - }, - - addWrapper: function( toToggle ) { - if ( this.settings.wrapper ) { - toToggle = toToggle.add( toToggle.parent( this.settings.wrapper ) ); - } - return toToggle; - }, - - defaultShowErrors: function() { - var i, elements, error; - for ( i = 0; this.errorList[ i ]; i++ ) { - error = this.errorList[ i ]; - if ( this.settings.highlight ) { - this.settings.highlight.call( this, error.element, this.settings.errorClass, this.settings.validClass ); - } - this.showLabel( error.element, error.message ); - } - if ( this.errorList.length ) { - this.toShow = this.toShow.add( this.containers ); - } - if ( this.settings.success ) { - for ( i = 0; this.successList[ i ]; i++ ) { - this.showLabel( this.successList[ i ] ); - } - } - if ( this.settings.unhighlight ) { - for ( i = 0, elements = this.validElements(); elements[ i ]; i++ ) { - this.settings.unhighlight.call( this, elements[ i ], this.settings.errorClass, this.settings.validClass ); - } - } - this.toHide = this.toHide.not( this.toShow ); - this.hideErrors(); - this.addWrapper( this.toShow ).show(); - }, - - validElements: function() { - return this.currentElements.not( this.invalidElements() ); - }, - - invalidElements: function() { - return $( this.errorList ).map( function() { - return this.element; - } ); - }, - - showLabel: function( element, message ) { - var place, group, errorID, v, - error = this.errorsFor( element ), - elementID = this.idOrName( element ), - describedBy = $( element ).attr( "aria-describedby" ); - - if ( error.length ) { - - // Refresh error/success class - error.removeClass( this.settings.validClass ).addClass( this.settings.errorClass ); - - // Replace message on existing label - error.html( message ); - } else { - - // Create error element - error = $( "<" + this.settings.errorElement + ">" ) - .attr( "id", elementID + "-error" ) - .addClass( this.settings.errorClass ) - .html( message || "" ); - - // Maintain reference to the element to be placed into the DOM - place = error; - if ( this.settings.wrapper ) { - - // Make sure the element is visible, even in IE - // actually showing the wrapped element is handled elsewhere - place = error.hide().show().wrap( "<" + this.settings.wrapper + "/>" ).parent(); - } - if ( this.labelContainer.length ) { - this.labelContainer.append( place ); - } else if ( this.settings.errorPlacement ) { - this.settings.errorPlacement( place, $( element ) ); - } else { - place.insertAfter( element ); - } - - // Link error back to the element - if ( error.is( "label" ) ) { - - // If the error is a label, then associate using 'for' - error.attr( "for", elementID ); - - // If the element is not a child of an associated label, then it's necessary - // to explicitly apply aria-describedby - } else if ( error.parents( "label[for='" + this.escapeCssMeta( elementID ) + "']" ).length === 0 ) { - errorID = error.attr( "id" ); - - // Respect existing non-error aria-describedby - if ( !describedBy ) { - describedBy = errorID; - } else if ( !describedBy.match( new RegExp( "\\b" + this.escapeCssMeta( errorID ) + "\\b" ) ) ) { - - // Add to end of list if not already present - describedBy += " " + errorID; - } - $( element ).attr( "aria-describedby", describedBy ); - - // If this element is grouped, then assign to all elements in the same group - group = this.groups[ element.name ]; - if ( group ) { - v = this; - $.each( v.groups, function( name, testgroup ) { - if ( testgroup === group ) { - $( "[name='" + v.escapeCssMeta( name ) + "']", v.currentForm ) - .attr( "aria-describedby", error.attr( "id" ) ); - } - } ); - } - } - } - if ( !message && this.settings.success ) { - error.text( "" ); - if ( typeof this.settings.success === "string" ) { - error.addClass( this.settings.success ); - } else { - this.settings.success( error, element ); - } - } - this.toShow = this.toShow.add( error ); - }, - - errorsFor: function( element ) { - var name = this.escapeCssMeta( this.idOrName( element ) ), - describer = $( element ).attr( "aria-describedby" ), - selector = "label[for='" + name + "'], label[for='" + name + "'] *"; - - // 'aria-describedby' should directly reference the error element - if ( describer ) { - selector = selector + ", #" + this.escapeCssMeta( describer ) - .replace( /\s+/g, ", #" ); - } - - return this - .errors() - .filter( selector ); - }, - - // See https://api.jquery.com/category/selectors/, for CSS - // meta-characters that should be escaped in order to be used with JQuery - // as a literal part of a name/id or any selector. - escapeCssMeta: function( string ) { - return string.replace( /([\\!"#$%&'()*+,./:;<=>?@\[\]^`{|}~])/g, "\\$1" ); - }, - - idOrName: function( element ) { - return this.groups[ element.name ] || ( this.checkable( element ) ? element.name : element.id || element.name ); - }, - - validationTargetFor: function( element ) { - - // If radio/checkbox, validate first element in group instead - if ( this.checkable( element ) ) { - element = this.findByName( element.name ); - } - - // Always apply ignore filter - return $( element ).not( this.settings.ignore )[ 0 ]; - }, - - checkable: function( element ) { - return ( /radio|checkbox/i ).test( element.type ); - }, - - findByName: function( name ) { - return $( this.currentForm ).find( "[name='" + this.escapeCssMeta( name ) + "']" ); - }, - - getLength: function( value, element ) { - switch ( element.nodeName.toLowerCase() ) { - case "select": - return $( "option:selected", element ).length; - case "input": - if ( this.checkable( element ) ) { - return this.findByName( element.name ).filter( ":checked" ).length; - } - } - return value.length; - }, - - depend: function( param, element ) { - return this.dependTypes[ typeof param ] ? this.dependTypes[ typeof param ]( param, element ) : true; - }, - - dependTypes: { - "boolean": function( param ) { - return param; - }, - "string": function( param, element ) { - return !!$( param, element.form ).length; - }, - "function": function( param, element ) { - return param( element ); - } - }, - - optional: function( element ) { - var val = this.elementValue( element ); - return !$.validator.methods.required.call( this, val, element ) && "dependency-mismatch"; - }, - - startRequest: function( element ) { - if ( !this.pending[ element.name ] ) { - this.pendingRequest++; - $( element ).addClass( this.settings.pendingClass ); - this.pending[ element.name ] = true; - } - }, - - stopRequest: function( element, valid ) { - this.pendingRequest--; - - // Sometimes synchronization fails, make sure pendingRequest is never < 0 - if ( this.pendingRequest < 0 ) { - this.pendingRequest = 0; - } - delete this.pending[ element.name ]; - $( element ).removeClass( this.settings.pendingClass ); - if ( valid && this.pendingRequest === 0 && this.formSubmitted && this.form() ) { - $( this.currentForm ).submit(); - this.formSubmitted = false; - } else if ( !valid && this.pendingRequest === 0 && this.formSubmitted ) { - $( this.currentForm ).triggerHandler( "invalid-form", [ this ] ); - this.formSubmitted = false; - } - }, - - previousValue: function( element, method ) { - return $.data( element, "previousValue" ) || $.data( element, "previousValue", { - old: null, - valid: true, - message: this.defaultMessage( element, { method: method } ) - } ); - }, - - // Cleans up all forms and elements, removes validator-specific events - destroy: function() { - this.resetForm(); - - $( this.currentForm ) - .off( ".validate" ) - .removeData( "validator" ) - .find( ".validate-equalTo-blur" ) - .off( ".validate-equalTo" ) - .removeClass( "validate-equalTo-blur" ); - } - - }, - - classRuleSettings: { - required: { required: true }, - email: { email: true }, - url: { url: true }, - date: { date: true }, - dateISO: { dateISO: true }, - number: { number: true }, - digits: { digits: true }, - creditcard: { creditcard: true } - }, - - addClassRules: function( className, rules ) { - if ( className.constructor === String ) { - this.classRuleSettings[ className ] = rules; - } else { - $.extend( this.classRuleSettings, className ); - } - }, - - classRules: function( element ) { - var rules = {}, - classes = $( element ).attr( "class" ); - - if ( classes ) { - $.each( classes.split( " " ), function() { - if ( this in $.validator.classRuleSettings ) { - $.extend( rules, $.validator.classRuleSettings[ this ] ); - } - } ); - } - return rules; - }, - - normalizeAttributeRule: function( rules, type, method, value ) { - - // Convert the value to a number for number inputs, and for text for backwards compability - // allows type="date" and others to be compared as strings - if ( /min|max|step/.test( method ) && ( type === null || /number|range|text/.test( type ) ) ) { - value = Number( value ); - - // Support Opera Mini, which returns NaN for undefined minlength - if ( isNaN( value ) ) { - value = undefined; - } - } - - if ( value || value === 0 ) { - rules[ method ] = value; - } else if ( type === method && type !== "range" ) { - - // Exception: the jquery validate 'range' method - // does not test for the html5 'range' type - rules[ method ] = true; - } - }, - - attributeRules: function( element ) { - var rules = {}, - $element = $( element ), - type = element.getAttribute( "type" ), - method, value; - - for ( method in $.validator.methods ) { - - // Support for in both html5 and older browsers - if ( method === "required" ) { - value = element.getAttribute( method ); - - // Some browsers return an empty string for the required attribute - // and non-HTML5 browsers might have required="" markup - if ( value === "" ) { - value = true; - } - - // Force non-HTML5 browsers to return bool - value = !!value; - } else { - value = $element.attr( method ); - } - - this.normalizeAttributeRule( rules, type, method, value ); - } - - // 'maxlength' may be returned as -1, 2147483647 ( IE ) and 524288 ( safari ) for text inputs - if ( rules.maxlength && /-1|2147483647|524288/.test( rules.maxlength ) ) { - delete rules.maxlength; - } - - return rules; - }, - - dataRules: function( element ) { - var rules = {}, - $element = $( element ), - type = element.getAttribute( "type" ), - method, value; - - for ( method in $.validator.methods ) { - value = $element.data( "rule" + method.charAt( 0 ).toUpperCase() + method.substring( 1 ).toLowerCase() ); - this.normalizeAttributeRule( rules, type, method, value ); - } - return rules; - }, - - staticRules: function( element ) { - var rules = {}, - validator = $.data( element.form, "validator" ); - - if ( validator.settings.rules ) { - rules = $.validator.normalizeRule( validator.settings.rules[ element.name ] ) || {}; - } - return rules; - }, - - normalizeRules: function( rules, element ) { - - // Handle dependency check - $.each( rules, function( prop, val ) { - - // Ignore rule when param is explicitly false, eg. required:false - if ( val === false ) { - delete rules[ prop ]; - return; - } - if ( val.param || val.depends ) { - var keepRule = true; - switch ( typeof val.depends ) { - case "string": - keepRule = !!$( val.depends, element.form ).length; - break; - case "function": - keepRule = val.depends.call( element, element ); - break; - } - if ( keepRule ) { - rules[ prop ] = val.param !== undefined ? val.param : true; - } else { - $.data( element.form, "validator" ).resetElements( $( element ) ); - delete rules[ prop ]; - } - } - } ); - - // Evaluate parameters - $.each( rules, function( rule, parameter ) { - rules[ rule ] = $.isFunction( parameter ) && rule !== "normalizer" ? parameter( element ) : parameter; - } ); - - // Clean number parameters - $.each( [ "minlength", "maxlength" ], function() { - if ( rules[ this ] ) { - rules[ this ] = Number( rules[ this ] ); - } - } ); - $.each( [ "rangelength", "range" ], function() { - var parts; - if ( rules[ this ] ) { - if ( $.isArray( rules[ this ] ) ) { - rules[ this ] = [ Number( rules[ this ][ 0 ] ), Number( rules[ this ][ 1 ] ) ]; - } else if ( typeof rules[ this ] === "string" ) { - parts = rules[ this ].replace( /[\[\]]/g, "" ).split( /[\s,]+/ ); - rules[ this ] = [ Number( parts[ 0 ] ), Number( parts[ 1 ] ) ]; - } - } - } ); - - if ( $.validator.autoCreateRanges ) { - - // Auto-create ranges - if ( rules.min != null && rules.max != null ) { - rules.range = [ rules.min, rules.max ]; - delete rules.min; - delete rules.max; - } - if ( rules.minlength != null && rules.maxlength != null ) { - rules.rangelength = [ rules.minlength, rules.maxlength ]; - delete rules.minlength; - delete rules.maxlength; - } - } - - return rules; - }, - - // Converts a simple string to a {string: true} rule, e.g., "required" to {required:true} - normalizeRule: function( data ) { - if ( typeof data === "string" ) { - var transformed = {}; - $.each( data.split( /\s/ ), function() { - transformed[ this ] = true; - } ); - data = transformed; - } - return data; - }, - - // http://jqueryvalidation.org/jQuery.validator.addMethod/ - addMethod: function( name, method, message ) { - $.validator.methods[ name ] = method; - $.validator.messages[ name ] = message !== undefined ? message : $.validator.messages[ name ]; - if ( method.length < 3 ) { - $.validator.addClassRules( name, $.validator.normalizeRule( name ) ); - } - }, - - // http://jqueryvalidation.org/jQuery.validator.methods/ - methods: { - - // http://jqueryvalidation.org/required-method/ - required: function( value, element, param ) { - - // Check if dependency is met - if ( !this.depend( param, element ) ) { - return "dependency-mismatch"; - } - if ( element.nodeName.toLowerCase() === "select" ) { - - // Could be an array for select-multiple or a string, both are fine this way - var val = $( element ).val(); - return val && val.length > 0; - } - if ( this.checkable( element ) ) { - return this.getLength( value, element ) > 0; - } - return value.length > 0; - }, - - // http://jqueryvalidation.org/email-method/ - email: function( value, element ) { - - // From https://html.spec.whatwg.org/multipage/forms.html#valid-e-mail-address - // Retrieved 2014-01-14 - // If you have a problem with this implementation, report a bug against the above spec - // Or use custom methods to implement your own email validation - return this.optional( element ) || /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test( value ); - }, - - // http://jqueryvalidation.org/url-method/ - url: function( value, element ) { - - // Copyright (c) 2010-2013 Diego Perini, MIT licensed - // https://gist.github.com/dperini/729294 - // see also https://mathiasbynens.be/demo/url-regex - // modified to allow protocol-relative URLs - return this.optional( element ) || /^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})).?)(?::\d{2,5})?(?:[/?#]\S*)?$/i.test( value ); - }, - - // http://jqueryvalidation.org/date-method/ - date: function( value, element ) { - return this.optional( element ) || !/Invalid|NaN/.test( new Date( value ).toString() ); - }, - - // http://jqueryvalidation.org/dateISO-method/ - dateISO: function( value, element ) { - return this.optional( element ) || /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/.test( value ); - }, - - // http://jqueryvalidation.org/number-method/ - number: function( value, element ) { - return this.optional( element ) || /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test( value ); - }, - - // http://jqueryvalidation.org/digits-method/ - digits: function( value, element ) { - return this.optional( element ) || /^\d+$/.test( value ); - }, - - // http://jqueryvalidation.org/minlength-method/ - minlength: function( value, element, param ) { - var length = $.isArray( value ) ? value.length : this.getLength( value, element ); - return this.optional( element ) || length >= param; - }, - - // http://jqueryvalidation.org/maxlength-method/ - maxlength: function( value, element, param ) { - var length = $.isArray( value ) ? value.length : this.getLength( value, element ); - return this.optional( element ) || length <= param; - }, - - // http://jqueryvalidation.org/rangelength-method/ - rangelength: function( value, element, param ) { - var length = $.isArray( value ) ? value.length : this.getLength( value, element ); - return this.optional( element ) || ( length >= param[ 0 ] && length <= param[ 1 ] ); - }, - - // http://jqueryvalidation.org/min-method/ - min: function( value, element, param ) { - return this.optional( element ) || value >= param; - }, - - // http://jqueryvalidation.org/max-method/ - max: function( value, element, param ) { - return this.optional( element ) || value <= param; - }, - - // http://jqueryvalidation.org/range-method/ - range: function( value, element, param ) { - return this.optional( element ) || ( value >= param[ 0 ] && value <= param[ 1 ] ); - }, - - // http://jqueryvalidation.org/step-method/ - step: function( value, element, param ) { - var type = $( element ).attr( "type" ), - errorMessage = "Step attribute on input type " + type + " is not supported.", - supportedTypes = [ "text", "number", "range" ], - re = new RegExp( "\\b" + type + "\\b" ), - notSupported = type && !re.test( supportedTypes.join() ); - - // Works only for text, number and range input types - // TODO find a way to support input types date, datetime, datetime-local, month, time and week - if ( notSupported ) { - throw new Error( errorMessage ); - } - return this.optional( element ) || ( value % param === 0 ); - }, - - // http://jqueryvalidation.org/equalTo-method/ - equalTo: function( value, element, param ) { - - // Bind to the blur event of the target in order to revalidate whenever the target field is updated - var target = $( param ); - if ( this.settings.onfocusout && target.not( ".validate-equalTo-blur" ).length ) { - target.addClass( "validate-equalTo-blur" ).on( "blur.validate-equalTo", function() { - $( element ).valid(); - } ); - } - return value === target.val(); - }, - - // http://jqueryvalidation.org/remote-method/ - remote: function( value, element, param, method ) { - if ( this.optional( element ) ) { - return "dependency-mismatch"; - } - - method = typeof method === "string" && method || "remote"; - - var previous = this.previousValue( element, method ), - validator, data, optionDataString; - - if ( !this.settings.messages[ element.name ] ) { - this.settings.messages[ element.name ] = {}; - } - previous.originalMessage = previous.originalMessage || this.settings.messages[ element.name ][ method ]; - this.settings.messages[ element.name ][ method ] = previous.message; - - param = typeof param === "string" && { url: param } || param; - optionDataString = $.param( $.extend( { data: value }, param.data ) ); - if ( previous.old === optionDataString ) { - return previous.valid; - } - - previous.old = optionDataString; - validator = this; - this.startRequest( element ); - data = {}; - data[ element.name ] = value; - $.ajax( $.extend( true, { - mode: "abort", - port: "validate" + element.name, - dataType: "json", - data: data, - context: validator.currentForm, - success: function( response ) { - var valid = response === true || response === "true", - errors, message, submitted; - - validator.settings.messages[ element.name ][ method ] = previous.originalMessage; - if ( valid ) { - submitted = validator.formSubmitted; - validator.resetInternals(); - validator.toHide = validator.errorsFor( element ); - validator.formSubmitted = submitted; - validator.successList.push( element ); - validator.invalid[ element.name ] = false; - validator.showErrors(); - } else { - errors = {}; - message = response || validator.defaultMessage( element, { method: method, parameters: value } ); - errors[ element.name ] = previous.message = message; - validator.invalid[ element.name ] = true; - validator.showErrors( errors ); - } - previous.valid = valid; - validator.stopRequest( element, valid ); - } - }, param ) ); - return "pending"; - } - } - -} ); - -// Ajax mode: abort -// usage: $.ajax({ mode: "abort"[, port: "uniqueport"]}); -// if mode:"abort" is used, the previous request on that port (port can be undefined) is aborted via XMLHttpRequest.abort() - -var pendingRequests = {}, - ajax; - -// Use a prefilter if available (1.5+) -if ( $.ajaxPrefilter ) { - $.ajaxPrefilter( function( settings, _, xhr ) { - var port = settings.port; - if ( settings.mode === "abort" ) { - if ( pendingRequests[ port ] ) { - pendingRequests[ port ].abort(); - } - pendingRequests[ port ] = xhr; - } - } ); -} else { - - // Proxy ajax - ajax = $.ajax; - $.ajax = function( settings ) { - var mode = ( "mode" in settings ? settings : $.ajaxSettings ).mode, - port = ( "port" in settings ? settings : $.ajaxSettings ).port; - if ( mode === "abort" ) { - if ( pendingRequests[ port ] ) { - pendingRequests[ port ].abort(); - } - pendingRequests[ port ] = ajax.apply( this, arguments ); - return pendingRequests[ port ]; - } - return ajax.apply( this, arguments ); - }; -} +$.extend( $.fn, { + + // http://jqueryvalidation.org/validate/ + validate: function( options ) { + + // If nothing is selected, return nothing; can't chain anyway + if ( !this.length ) { + if ( options && options.debug && window.console ) { + console.warn( "Nothing selected, can't validate, returning nothing." ); + } + return; + } + + // Check if a validator for this form was already created + var validator = $.data( this[ 0 ], "validator" ); + if ( validator ) { + return validator; + } + + // Add novalidate tag if HTML5. + this.attr( "novalidate", "novalidate" ); + + validator = new $.validator( options, this[ 0 ] ); + $.data( this[ 0 ], "validator", validator ); + + if ( validator.settings.onsubmit ) { + + this.on( "click.validate", ":submit", function( event ) { + if ( validator.settings.submitHandler ) { + validator.submitButton = event.target; + } + + // Allow suppressing validation by adding a cancel class to the submit button + if ( $( this ).hasClass( "cancel" ) ) { + validator.cancelSubmit = true; + } + + // Allow suppressing validation by adding the html5 formnovalidate attribute to the submit button + if ( $( this ).attr( "formnovalidate" ) !== undefined ) { + validator.cancelSubmit = true; + } + } ); + + // Validate the form on submit + this.on( "submit.validate", function( event ) { + if ( validator.settings.debug ) { + + // Prevent form submit to be able to see console output + event.preventDefault(); + } + function handle() { + var hidden, result; + if ( validator.settings.submitHandler ) { + if ( validator.submitButton ) { + + // Insert a hidden input as a replacement for the missing submit button + hidden = $( "" ) + .attr( "name", validator.submitButton.name ) + .val( $( validator.submitButton ).val() ) + .appendTo( validator.currentForm ); + } + result = validator.settings.submitHandler.call( validator, validator.currentForm, event ); + if ( validator.submitButton ) { + + // And clean up afterwards; thanks to no-block-scope, hidden can be referenced + hidden.remove(); + } + if ( result !== undefined ) { + return result; + } + return false; + } + return true; + } + + // Prevent submit for invalid forms or custom submit handlers + if ( validator.cancelSubmit ) { + validator.cancelSubmit = false; + return handle(); + } + if ( validator.form() ) { + if ( validator.pendingRequest ) { + validator.formSubmitted = true; + return false; + } + return handle(); + } else { + validator.focusInvalid(); + return false; + } + } ); + } + + return validator; + }, + + // http://jqueryvalidation.org/valid/ + valid: function() { + var valid, validator, errorList; + + if ( $( this[ 0 ] ).is( "form" ) ) { + valid = this.validate().form(); + } else { + errorList = []; + valid = true; + validator = $( this[ 0 ].form ).validate(); + this.each( function() { + valid = validator.element( this ) && valid; + if ( !valid ) { + errorList = errorList.concat( validator.errorList ); + } + } ); + validator.errorList = errorList; + } + return valid; + }, + + // http://jqueryvalidation.org/rules/ + rules: function( command, argument ) { + + // If nothing is selected, return nothing; can't chain anyway + if ( !this.length ) { + return; + } + + var element = this[ 0 ], + settings, staticRules, existingRules, data, param, filtered; + + if ( command ) { + settings = $.data( element.form, "validator" ).settings; + staticRules = settings.rules; + existingRules = $.validator.staticRules( element ); + switch ( command ) { + case "add": + $.extend( existingRules, $.validator.normalizeRule( argument ) ); + + // Remove messages from rules, but allow them to be set separately + delete existingRules.messages; + staticRules[ element.name ] = existingRules; + if ( argument.messages ) { + settings.messages[ element.name ] = $.extend( settings.messages[ element.name ], argument.messages ); + } + break; + case "remove": + if ( !argument ) { + delete staticRules[ element.name ]; + return existingRules; + } + filtered = {}; + $.each( argument.split( /\s/ ), function( index, method ) { + filtered[ method ] = existingRules[ method ]; + delete existingRules[ method ]; + if ( method === "required" ) { + $( element ).removeAttr( "aria-required" ); + } + } ); + return filtered; + } + } + + data = $.validator.normalizeRules( + $.extend( + {}, + $.validator.classRules( element ), + $.validator.attributeRules( element ), + $.validator.dataRules( element ), + $.validator.staticRules( element ) + ), element ); + + // Make sure required is at front + if ( data.required ) { + param = data.required; + delete data.required; + data = $.extend( { required: param }, data ); + $( element ).attr( "aria-required", "true" ); + } + + // Make sure remote is at back + if ( data.remote ) { + param = data.remote; + delete data.remote; + data = $.extend( data, { remote: param } ); + } + + return data; + } +} ); + +// Custom selectors +$.extend( $.expr[ ":" ], { + + // http://jqueryvalidation.org/blank-selector/ + blank: function( a ) { + return !$.trim( "" + $( a ).val() ); + }, + + // http://jqueryvalidation.org/filled-selector/ + filled: function( a ) { + var val = $( a ).val(); + return val !== null && !!$.trim( "" + val ); + }, + + // http://jqueryvalidation.org/unchecked-selector/ + unchecked: function( a ) { + return !$( a ).prop( "checked" ); + } +} ); + +// Constructor for validator +$.validator = function( options, form ) { + this.settings = $.extend( true, {}, $.validator.defaults, options ); + this.currentForm = form; + this.init(); +}; + +// http://jqueryvalidation.org/jQuery.validator.format/ +$.validator.format = function( source, params ) { + if ( arguments.length === 1 ) { + return function() { + var args = $.makeArray( arguments ); + args.unshift( source ); + return $.validator.format.apply( this, args ); + }; + } + if ( params === undefined ) { + return source; + } + if ( arguments.length > 2 && params.constructor !== Array ) { + params = $.makeArray( arguments ).slice( 1 ); + } + if ( params.constructor !== Array ) { + params = [ params ]; + } + $.each( params, function( i, n ) { + source = source.replace( new RegExp( "\\{" + i + "\\}", "g" ), function() { + return n; + } ); + } ); + return source; +}; + +$.extend( $.validator, { + + defaults: { + messages: {}, + groups: {}, + rules: {}, + errorClass: "error", + pendingClass: "pending", + validClass: "valid", + errorElement: "label", + focusCleanup: false, + focusInvalid: true, + errorContainer: $( [] ), + errorLabelContainer: $( [] ), + onsubmit: true, + ignore: ":hidden", + ignoreTitle: false, + onfocusin: function( element ) { + this.lastActive = element; + + // Hide error label and remove error class on focus if enabled + if ( this.settings.focusCleanup ) { + if ( this.settings.unhighlight ) { + this.settings.unhighlight.call( this, element, this.settings.errorClass, this.settings.validClass ); + } + this.hideThese( this.errorsFor( element ) ); + } + }, + onfocusout: function( element ) { + if ( !this.checkable( element ) && ( element.name in this.submitted || !this.optional( element ) ) ) { + this.element( element ); + } + }, + onkeyup: function( element, event ) { + + // Avoid revalidate the field when pressing one of the following keys + // Shift => 16 + // Ctrl => 17 + // Alt => 18 + // Caps lock => 20 + // End => 35 + // Home => 36 + // Left arrow => 37 + // Up arrow => 38 + // Right arrow => 39 + // Down arrow => 40 + // Insert => 45 + // Num lock => 144 + // AltGr key => 225 + var excludedKeys = [ + 16, 17, 18, 20, 35, 36, 37, + 38, 39, 40, 45, 144, 225 + ]; + + if ( event.which === 9 && this.elementValue( element ) === "" || $.inArray( event.keyCode, excludedKeys ) !== -1 ) { + return; + } else if ( element.name in this.submitted || element.name in this.invalid ) { + this.element( element ); + } + }, + onclick: function( element ) { + + // Click on selects, radiobuttons and checkboxes + if ( element.name in this.submitted ) { + this.element( element ); + + // Or option elements, check parent select in that case + } else if ( element.parentNode.name in this.submitted ) { + this.element( element.parentNode ); + } + }, + highlight: function( element, errorClass, validClass ) { + if ( element.type === "radio" ) { + this.findByName( element.name ).addClass( errorClass ).removeClass( validClass ); + } else { + $( element ).addClass( errorClass ).removeClass( validClass ); + } + }, + unhighlight: function( element, errorClass, validClass ) { + if ( element.type === "radio" ) { + this.findByName( element.name ).removeClass( errorClass ).addClass( validClass ); + } else { + $( element ).removeClass( errorClass ).addClass( validClass ); + } + } + }, + + // http://jqueryvalidation.org/jQuery.validator.setDefaults/ + setDefaults: function( settings ) { + $.extend( $.validator.defaults, settings ); + }, + + messages: { + required: "This field is required.", + remote: "Please fix this field.", + email: "Please enter a valid email address.", + url: "Please enter a valid URL.", + date: "Please enter a valid date.", + dateISO: "Please enter a valid date ( ISO ).", + number: "Please enter a valid number.", + digits: "Please enter only digits.", + equalTo: "Please enter the same value again.", + maxlength: $.validator.format( "Please enter no more than {0} characters." ), + minlength: $.validator.format( "Please enter at least {0} characters." ), + rangelength: $.validator.format( "Please enter a value between {0} and {1} characters long." ), + range: $.validator.format( "Please enter a value between {0} and {1}." ), + max: $.validator.format( "Please enter a value less than or equal to {0}." ), + min: $.validator.format( "Please enter a value greater than or equal to {0}." ), + step: $.validator.format( "Please enter a multiple of {0}." ) + }, + + autoCreateRanges: false, + + prototype: { + + init: function() { + this.labelContainer = $( this.settings.errorLabelContainer ); + this.errorContext = this.labelContainer.length && this.labelContainer || $( this.currentForm ); + this.containers = $( this.settings.errorContainer ).add( this.settings.errorLabelContainer ); + this.submitted = {}; + this.valueCache = {}; + this.pendingRequest = 0; + this.pending = {}; + this.invalid = {}; + this.reset(); + + var groups = ( this.groups = {} ), + rules; + $.each( this.settings.groups, function( key, value ) { + if ( typeof value === "string" ) { + value = value.split( /\s/ ); + } + $.each( value, function( index, name ) { + groups[ name ] = key; + } ); + } ); + rules = this.settings.rules; + $.each( rules, function( key, value ) { + rules[ key ] = $.validator.normalizeRule( value ); + } ); + + function delegate( event ) { + var validator = $.data( this.form, "validator" ), + eventType = "on" + event.type.replace( /^validate/, "" ), + settings = validator.settings; + if ( settings[ eventType ] && !$( this ).is( settings.ignore ) ) { + settings[ eventType ].call( validator, this, event ); + } + } + + $( this.currentForm ) + .on( "focusin.validate focusout.validate keyup.validate", + ":text, [type='password'], [type='file'], select, textarea, [type='number'], [type='search'], " + + "[type='tel'], [type='url'], [type='email'], [type='datetime'], [type='date'], [type='month'], " + + "[type='week'], [type='time'], [type='datetime-local'], [type='range'], [type='color'], " + + "[type='radio'], [type='checkbox'], [contenteditable]", delegate ) + + // Support: Chrome, oldIE + // "select" is provided as event.target when clicking a option + .on( "click.validate", "select, option, [type='radio'], [type='checkbox']", delegate ); + + if ( this.settings.invalidHandler ) { + $( this.currentForm ).on( "invalid-form.validate", this.settings.invalidHandler ); + } + + // Add aria-required to any Static/Data/Class required fields before first validation + // Screen readers require this attribute to be present before the initial submission http://www.w3.org/TR/WCAG-TECHS/ARIA2.html + $( this.currentForm ).find( "[required], [data-rule-required], .required" ).attr( "aria-required", "true" ); + }, + + // http://jqueryvalidation.org/Validator.form/ + form: function() { + this.checkForm(); + $.extend( this.submitted, this.errorMap ); + this.invalid = $.extend( {}, this.errorMap ); + if ( !this.valid() ) { + $( this.currentForm ).triggerHandler( "invalid-form", [ this ] ); + } + this.showErrors(); + return this.valid(); + }, + + checkForm: function() { + this.prepareForm(); + for ( var i = 0, elements = ( this.currentElements = this.elements() ); elements[ i ]; i++ ) { + this.check( elements[ i ] ); + } + return this.valid(); + }, + + // http://jqueryvalidation.org/Validator.element/ + element: function( element ) { + var cleanElement = this.clean( element ), + checkElement = this.validationTargetFor( cleanElement ), + v = this, + result = true, + rs, group; + + if ( checkElement === undefined ) { + delete this.invalid[ cleanElement.name ]; + } else { + this.prepareElement( checkElement ); + this.currentElements = $( checkElement ); + + // If this element is grouped, then validate all group elements already + // containing a value + group = this.groups[ checkElement.name ]; + if ( group ) { + $.each( this.groups, function( name, testgroup ) { + if ( testgroup === group && name !== checkElement.name ) { + cleanElement = v.validationTargetFor( v.clean( v.findByName( name ) ) ); + if ( cleanElement && cleanElement.name in v.invalid ) { + v.currentElements.push( cleanElement ); + result = result && v.check( cleanElement ); + } + } + } ); + } + + rs = this.check( checkElement ) !== false; + result = result && rs; + if ( rs ) { + this.invalid[ checkElement.name ] = false; + } else { + this.invalid[ checkElement.name ] = true; + } + + if ( !this.numberOfInvalids() ) { + + // Hide error containers on last error + this.toHide = this.toHide.add( this.containers ); + } + this.showErrors(); + + // Add aria-invalid status for screen readers + $( element ).attr( "aria-invalid", !rs ); + } + + return result; + }, + + // http://jqueryvalidation.org/Validator.showErrors/ + showErrors: function( errors ) { + if ( errors ) { + var validator = this; + + // Add items to error list and map + $.extend( this.errorMap, errors ); + this.errorList = $.map( this.errorMap, function( message, name ) { + return { + message: message, + element: validator.findByName( name )[ 0 ] + }; + } ); + + // Remove items from success list + this.successList = $.grep( this.successList, function( element ) { + return !( element.name in errors ); + } ); + } + if ( this.settings.showErrors ) { + this.settings.showErrors.call( this, this.errorMap, this.errorList ); + } else { + this.defaultShowErrors(); + } + }, + + // http://jqueryvalidation.org/Validator.resetForm/ + resetForm: function() { + if ( $.fn.resetForm ) { + $( this.currentForm ).resetForm(); + } + this.invalid = {}; + this.submitted = {}; + this.prepareForm(); + this.hideErrors(); + var elements = this.elements() + .removeData( "previousValue" ) + .removeAttr( "aria-invalid" ); + + this.resetElements( elements ); + }, + + resetElements: function( elements ) { + var i; + + if ( this.settings.unhighlight ) { + for ( i = 0; elements[ i ]; i++ ) { + this.settings.unhighlight.call( this, elements[ i ], + this.settings.errorClass, "" ); + this.findByName( elements[ i ].name ).removeClass( this.settings.validClass ); + } + } else { + elements + .removeClass( this.settings.errorClass ) + .removeClass( this.settings.validClass ); + } + }, + + numberOfInvalids: function() { + return this.objectLength( this.invalid ); + }, + + objectLength: function( obj ) { + /* jshint unused: false */ + var count = 0, + i; + for ( i in obj ) { + if ( obj[ i ] ) { + count++; + } + } + return count; + }, + + hideErrors: function() { + this.hideThese( this.toHide ); + }, + + hideThese: function( errors ) { + errors.not( this.containers ).text( "" ); + this.addWrapper( errors ).hide(); + }, + + valid: function() { + return this.size() === 0; + }, + + size: function() { + return this.errorList.length; + }, + + focusInvalid: function() { + if ( this.settings.focusInvalid ) { + try { + $( this.findLastActive() || this.errorList.length && this.errorList[ 0 ].element || [] ) + .filter( ":visible" ) + .focus() + + // Manually trigger focusin event; without it, focusin handler isn't called, findLastActive won't have anything to find + .trigger( "focusin" ); + } catch ( e ) { + + // Ignore IE throwing errors when focusing hidden elements + } + } + }, + + findLastActive: function() { + var lastActive = this.lastActive; + return lastActive && $.grep( this.errorList, function( n ) { + return n.element.name === lastActive.name; + } ).length === 1 && lastActive; + }, + + elements: function() { + var validator = this, + rulesCache = {}; + + // Select all valid inputs inside the form (no submit or reset buttons) + return $( this.currentForm ) + .find( "input, select, textarea, [contenteditable]" ) + .not( ":submit, :reset, :image, :disabled" ) + .not( this.settings.ignore ) + .filter( function() { + var name = this.name || $( this ).attr( "name" ); // For contenteditable + if ( !name && validator.settings.debug && window.console ) { + console.error( "%o has no name assigned", this ); + } + + // Set form expando on contenteditable + if ( this.hasAttribute( "contenteditable" ) ) { + this.form = $( this ).closest( "form" )[ 0 ]; + } + + // Select only the first element for each name, and only those with rules specified + if ( name in rulesCache || !validator.objectLength( $( this ).rules() ) ) { + return false; + } + + rulesCache[ name ] = true; + return true; + } ); + }, + + clean: function( selector ) { + return $( selector )[ 0 ]; + }, + + errors: function() { + var errorClass = this.settings.errorClass.split( " " ).join( "." ); + return $( this.settings.errorElement + "." + errorClass, this.errorContext ); + }, + + resetInternals: function() { + this.successList = []; + this.errorList = []; + this.errorMap = {}; + this.toShow = $( [] ); + this.toHide = $( [] ); + }, + + reset: function() { + this.resetInternals(); + this.currentElements = $( [] ); + }, + + prepareForm: function() { + this.reset(); + this.toHide = this.errors().add( this.containers ); + }, + + prepareElement: function( element ) { + this.reset(); + this.toHide = this.errorsFor( element ); + }, + + elementValue: function( element ) { + var $element = $( element ), + type = element.type, + val, idx; + + if ( type === "radio" || type === "checkbox" ) { + return this.findByName( element.name ).filter( ":checked" ).val(); + } else if ( type === "number" && typeof element.validity !== "undefined" ) { + return element.validity.badInput ? "NaN" : $element.val(); + } + + if ( element.hasAttribute( "contenteditable" ) ) { + val = $element.text(); + } else { + val = $element.val(); + } + + if ( type === "file" ) { + + // Modern browser (chrome & safari) + if ( val.substr( 0, 12 ) === "C:\\fakepath\\" ) { + return val.substr( 12 ); + } + + // Legacy browsers + // Unix-based path + idx = val.lastIndexOf( "/" ); + if ( idx >= 0 ) { + return val.substr( idx + 1 ); + } + + // Windows-based path + idx = val.lastIndexOf( "\\" ); + if ( idx >= 0 ) { + return val.substr( idx + 1 ); + } + + // Just the file name + return val; + } + + if ( typeof val === "string" ) { + return val.replace( /\r/g, "" ); + } + return val; + }, + + check: function( element ) { + element = this.validationTargetFor( this.clean( element ) ); + + var rules = $( element ).rules(), + rulesCount = $.map( rules, function( n, i ) { + return i; + } ).length, + dependencyMismatch = false, + val = this.elementValue( element ), + result, method, rule; + + // If a normalizer is defined for this element, then + // call it to retreive the changed value instead + // of using the real one. + // Note that `this` in the normalizer is `element`. + if ( typeof rules.normalizer === "function" ) { + val = rules.normalizer.call( element, val ); + + if ( typeof val !== "string" ) { + throw new TypeError( "The normalizer should return a string value." ); + } + + // Delete the normalizer from rules to avoid treating + // it as a pre-defined method. + delete rules.normalizer; + } + + for ( method in rules ) { + rule = { method: method, parameters: rules[ method ] }; + try { + result = $.validator.methods[ method ].call( this, val, element, rule.parameters ); + + // If a method indicates that the field is optional and therefore valid, + // don't mark it as valid when there are no other rules + if ( result === "dependency-mismatch" && rulesCount === 1 ) { + dependencyMismatch = true; + continue; + } + dependencyMismatch = false; + + if ( result === "pending" ) { + this.toHide = this.toHide.not( this.errorsFor( element ) ); + return; + } + + if ( !result ) { + this.formatAndAdd( element, rule ); + return false; + } + } catch ( e ) { + if ( this.settings.debug && window.console ) { + console.log( "Exception occurred when checking element " + element.id + ", check the '" + rule.method + "' method.", e ); + } + if ( e instanceof TypeError ) { + e.message += ". Exception occurred when checking element " + element.id + ", check the '" + rule.method + "' method."; + } + + throw e; + } + } + if ( dependencyMismatch ) { + return; + } + if ( this.objectLength( rules ) ) { + this.successList.push( element ); + } + return true; + }, + + // Return the custom message for the given element and validation method + // specified in the element's HTML5 data attribute + // return the generic message if present and no method specific message is present + customDataMessage: function( element, method ) { + return $( element ).data( "msg" + method.charAt( 0 ).toUpperCase() + + method.substring( 1 ).toLowerCase() ) || $( element ).data( "msg" ); + }, + + // Return the custom message for the given element name and validation method + customMessage: function( name, method ) { + var m = this.settings.messages[ name ]; + return m && ( m.constructor === String ? m : m[ method ] ); + }, + + // Return the first defined argument, allowing empty strings + findDefined: function() { + for ( var i = 0; i < arguments.length; i++ ) { + if ( arguments[ i ] !== undefined ) { + return arguments[ i ]; + } + } + return undefined; + }, + + defaultMessage: function( element, rule ) { + var message = this.findDefined( + this.customMessage( element.name, rule.method ), + this.customDataMessage( element, rule.method ), + + // 'title' is never undefined, so handle empty string as undefined + !this.settings.ignoreTitle && element.title || undefined, + $.validator.messages[ rule.method ], + "Warning: No message defined for " + element.name + "" + ), + theregex = /\$?\{(\d+)\}/g; + if ( typeof message === "function" ) { + message = message.call( this, rule.parameters, element ); + } else if ( theregex.test( message ) ) { + message = $.validator.format( message.replace( theregex, "{$1}" ), rule.parameters ); + } + + return message; + }, + + formatAndAdd: function( element, rule ) { + var message = this.defaultMessage( element, rule ); + + this.errorList.push( { + message: message, + element: element, + method: rule.method + } ); + + this.errorMap[ element.name ] = message; + this.submitted[ element.name ] = message; + }, + + addWrapper: function( toToggle ) { + if ( this.settings.wrapper ) { + toToggle = toToggle.add( toToggle.parent( this.settings.wrapper ) ); + } + return toToggle; + }, + + defaultShowErrors: function() { + var i, elements, error; + for ( i = 0; this.errorList[ i ]; i++ ) { + error = this.errorList[ i ]; + if ( this.settings.highlight ) { + this.settings.highlight.call( this, error.element, this.settings.errorClass, this.settings.validClass ); + } + this.showLabel( error.element, error.message ); + } + if ( this.errorList.length ) { + this.toShow = this.toShow.add( this.containers ); + } + if ( this.settings.success ) { + for ( i = 0; this.successList[ i ]; i++ ) { + this.showLabel( this.successList[ i ] ); + } + } + if ( this.settings.unhighlight ) { + for ( i = 0, elements = this.validElements(); elements[ i ]; i++ ) { + this.settings.unhighlight.call( this, elements[ i ], this.settings.errorClass, this.settings.validClass ); + } + } + this.toHide = this.toHide.not( this.toShow ); + this.hideErrors(); + this.addWrapper( this.toShow ).show(); + }, + + validElements: function() { + return this.currentElements.not( this.invalidElements() ); + }, + + invalidElements: function() { + return $( this.errorList ).map( function() { + return this.element; + } ); + }, + + showLabel: function( element, message ) { + var place, group, errorID, v, + error = this.errorsFor( element ), + elementID = this.idOrName( element ), + describedBy = $( element ).attr( "aria-describedby" ); + + if ( error.length ) { + + // Refresh error/success class + error.removeClass( this.settings.validClass ).addClass( this.settings.errorClass ); + + // Replace message on existing label + error.html( message ); + } else { + + // Create error element + error = $( "<" + this.settings.errorElement + ">" ) + .attr( "id", elementID + "-error" ) + .addClass( this.settings.errorClass ) + .html( message || "" ); + + // Maintain reference to the element to be placed into the DOM + place = error; + if ( this.settings.wrapper ) { + + // Make sure the element is visible, even in IE + // actually showing the wrapped element is handled elsewhere + place = error.hide().show().wrap( "<" + this.settings.wrapper + "/>" ).parent(); + } + if ( this.labelContainer.length ) { + this.labelContainer.append( place ); + } else if ( this.settings.errorPlacement ) { + this.settings.errorPlacement( place, $( element ) ); + } else { + place.insertAfter( element ); + } + + // Link error back to the element + if ( error.is( "label" ) ) { + + // If the error is a label, then associate using 'for' + error.attr( "for", elementID ); + + // If the element is not a child of an associated label, then it's necessary + // to explicitly apply aria-describedby + } else if ( error.parents( "label[for='" + this.escapeCssMeta( elementID ) + "']" ).length === 0 ) { + errorID = error.attr( "id" ); + + // Respect existing non-error aria-describedby + if ( !describedBy ) { + describedBy = errorID; + } else if ( !describedBy.match( new RegExp( "\\b" + this.escapeCssMeta( errorID ) + "\\b" ) ) ) { + + // Add to end of list if not already present + describedBy += " " + errorID; + } + $( element ).attr( "aria-describedby", describedBy ); + + // If this element is grouped, then assign to all elements in the same group + group = this.groups[ element.name ]; + if ( group ) { + v = this; + $.each( v.groups, function( name, testgroup ) { + if ( testgroup === group ) { + $( "[name='" + v.escapeCssMeta( name ) + "']", v.currentForm ) + .attr( "aria-describedby", error.attr( "id" ) ); + } + } ); + } + } + } + if ( !message && this.settings.success ) { + error.text( "" ); + if ( typeof this.settings.success === "string" ) { + error.addClass( this.settings.success ); + } else { + this.settings.success( error, element ); + } + } + this.toShow = this.toShow.add( error ); + }, + + errorsFor: function( element ) { + var name = this.escapeCssMeta( this.idOrName( element ) ), + describer = $( element ).attr( "aria-describedby" ), + selector = "label[for='" + name + "'], label[for='" + name + "'] *"; + + // 'aria-describedby' should directly reference the error element + if ( describer ) { + selector = selector + ", #" + this.escapeCssMeta( describer ) + .replace( /\s+/g, ", #" ); + } + + return this + .errors() + .filter( selector ); + }, + + // See https://api.jquery.com/category/selectors/, for CSS + // meta-characters that should be escaped in order to be used with JQuery + // as a literal part of a name/id or any selector. + escapeCssMeta: function( string ) { + return string.replace( /([\\!"#$%&'()*+,./:;<=>?@\[\]^`{|}~])/g, "\\$1" ); + }, + + idOrName: function( element ) { + return this.groups[ element.name ] || ( this.checkable( element ) ? element.name : element.id || element.name ); + }, + + validationTargetFor: function( element ) { + + // If radio/checkbox, validate first element in group instead + if ( this.checkable( element ) ) { + element = this.findByName( element.name ); + } + + // Always apply ignore filter + return $( element ).not( this.settings.ignore )[ 0 ]; + }, + + checkable: function( element ) { + return ( /radio|checkbox/i ).test( element.type ); + }, + + findByName: function( name ) { + return $( this.currentForm ).find( "[name='" + this.escapeCssMeta( name ) + "']" ); + }, + + getLength: function( value, element ) { + switch ( element.nodeName.toLowerCase() ) { + case "select": + return $( "option:selected", element ).length; + case "input": + if ( this.checkable( element ) ) { + return this.findByName( element.name ).filter( ":checked" ).length; + } + } + return value.length; + }, + + depend: function( param, element ) { + return this.dependTypes[ typeof param ] ? this.dependTypes[ typeof param ]( param, element ) : true; + }, + + dependTypes: { + "boolean": function( param ) { + return param; + }, + "string": function( param, element ) { + return !!$( param, element.form ).length; + }, + "function": function( param, element ) { + return param( element ); + } + }, + + optional: function( element ) { + var val = this.elementValue( element ); + return !$.validator.methods.required.call( this, val, element ) && "dependency-mismatch"; + }, + + startRequest: function( element ) { + if ( !this.pending[ element.name ] ) { + this.pendingRequest++; + $( element ).addClass( this.settings.pendingClass ); + this.pending[ element.name ] = true; + } + }, + + stopRequest: function( element, valid ) { + this.pendingRequest--; + + // Sometimes synchronization fails, make sure pendingRequest is never < 0 + if ( this.pendingRequest < 0 ) { + this.pendingRequest = 0; + } + delete this.pending[ element.name ]; + $( element ).removeClass( this.settings.pendingClass ); + if ( valid && this.pendingRequest === 0 && this.formSubmitted && this.form() ) { + $( this.currentForm ).submit(); + this.formSubmitted = false; + } else if ( !valid && this.pendingRequest === 0 && this.formSubmitted ) { + $( this.currentForm ).triggerHandler( "invalid-form", [ this ] ); + this.formSubmitted = false; + } + }, + + previousValue: function( element, method ) { + return $.data( element, "previousValue" ) || $.data( element, "previousValue", { + old: null, + valid: true, + message: this.defaultMessage( element, { method: method } ) + } ); + }, + + // Cleans up all forms and elements, removes validator-specific events + destroy: function() { + this.resetForm(); + + $( this.currentForm ) + .off( ".validate" ) + .removeData( "validator" ) + .find( ".validate-equalTo-blur" ) + .off( ".validate-equalTo" ) + .removeClass( "validate-equalTo-blur" ); + } + + }, + + classRuleSettings: { + required: { required: true }, + email: { email: true }, + url: { url: true }, + date: { date: true }, + dateISO: { dateISO: true }, + number: { number: true }, + digits: { digits: true }, + creditcard: { creditcard: true } + }, + + addClassRules: function( className, rules ) { + if ( className.constructor === String ) { + this.classRuleSettings[ className ] = rules; + } else { + $.extend( this.classRuleSettings, className ); + } + }, + + classRules: function( element ) { + var rules = {}, + classes = $( element ).attr( "class" ); + + if ( classes ) { + $.each( classes.split( " " ), function() { + if ( this in $.validator.classRuleSettings ) { + $.extend( rules, $.validator.classRuleSettings[ this ] ); + } + } ); + } + return rules; + }, + + normalizeAttributeRule: function( rules, type, method, value ) { + + // Convert the value to a number for number inputs, and for text for backwards compability + // allows type="date" and others to be compared as strings + if ( /min|max|step/.test( method ) && ( type === null || /number|range|text/.test( type ) ) ) { + value = Number( value ); + + // Support Opera Mini, which returns NaN for undefined minlength + if ( isNaN( value ) ) { + value = undefined; + } + } + + if ( value || value === 0 ) { + rules[ method ] = value; + } else if ( type === method && type !== "range" ) { + + // Exception: the jquery validate 'range' method + // does not test for the html5 'range' type + rules[ method ] = true; + } + }, + + attributeRules: function( element ) { + var rules = {}, + $element = $( element ), + type = element.getAttribute( "type" ), + method, value; + + for ( method in $.validator.methods ) { + + // Support for in both html5 and older browsers + if ( method === "required" ) { + value = element.getAttribute( method ); + + // Some browsers return an empty string for the required attribute + // and non-HTML5 browsers might have required="" markup + if ( value === "" ) { + value = true; + } + + // Force non-HTML5 browsers to return bool + value = !!value; + } else { + value = $element.attr( method ); + } + + this.normalizeAttributeRule( rules, type, method, value ); + } + + // 'maxlength' may be returned as -1, 2147483647 ( IE ) and 524288 ( safari ) for text inputs + if ( rules.maxlength && /-1|2147483647|524288/.test( rules.maxlength ) ) { + delete rules.maxlength; + } + + return rules; + }, + + dataRules: function( element ) { + var rules = {}, + $element = $( element ), + type = element.getAttribute( "type" ), + method, value; + + for ( method in $.validator.methods ) { + value = $element.data( "rule" + method.charAt( 0 ).toUpperCase() + method.substring( 1 ).toLowerCase() ); + this.normalizeAttributeRule( rules, type, method, value ); + } + return rules; + }, + + staticRules: function( element ) { + var rules = {}, + validator = $.data( element.form, "validator" ); + + if ( validator.settings.rules ) { + rules = $.validator.normalizeRule( validator.settings.rules[ element.name ] ) || {}; + } + return rules; + }, + + normalizeRules: function( rules, element ) { + + // Handle dependency check + $.each( rules, function( prop, val ) { + + // Ignore rule when param is explicitly false, eg. required:false + if ( val === false ) { + delete rules[ prop ]; + return; + } + if ( val.param || val.depends ) { + var keepRule = true; + switch ( typeof val.depends ) { + case "string": + keepRule = !!$( val.depends, element.form ).length; + break; + case "function": + keepRule = val.depends.call( element, element ); + break; + } + if ( keepRule ) { + rules[ prop ] = val.param !== undefined ? val.param : true; + } else { + $.data( element.form, "validator" ).resetElements( $( element ) ); + delete rules[ prop ]; + } + } + } ); + + // Evaluate parameters + $.each( rules, function( rule, parameter ) { + rules[ rule ] = $.isFunction( parameter ) && rule !== "normalizer" ? parameter( element ) : parameter; + } ); + + // Clean number parameters + $.each( [ "minlength", "maxlength" ], function() { + if ( rules[ this ] ) { + rules[ this ] = Number( rules[ this ] ); + } + } ); + $.each( [ "rangelength", "range" ], function() { + var parts; + if ( rules[ this ] ) { + if ( $.isArray( rules[ this ] ) ) { + rules[ this ] = [ Number( rules[ this ][ 0 ] ), Number( rules[ this ][ 1 ] ) ]; + } else if ( typeof rules[ this ] === "string" ) { + parts = rules[ this ].replace( /[\[\]]/g, "" ).split( /[\s,]+/ ); + rules[ this ] = [ Number( parts[ 0 ] ), Number( parts[ 1 ] ) ]; + } + } + } ); + + if ( $.validator.autoCreateRanges ) { + + // Auto-create ranges + if ( rules.min != null && rules.max != null ) { + rules.range = [ rules.min, rules.max ]; + delete rules.min; + delete rules.max; + } + if ( rules.minlength != null && rules.maxlength != null ) { + rules.rangelength = [ rules.minlength, rules.maxlength ]; + delete rules.minlength; + delete rules.maxlength; + } + } + + return rules; + }, + + // Converts a simple string to a {string: true} rule, e.g., "required" to {required:true} + normalizeRule: function( data ) { + if ( typeof data === "string" ) { + var transformed = {}; + $.each( data.split( /\s/ ), function() { + transformed[ this ] = true; + } ); + data = transformed; + } + return data; + }, + + // http://jqueryvalidation.org/jQuery.validator.addMethod/ + addMethod: function( name, method, message ) { + $.validator.methods[ name ] = method; + $.validator.messages[ name ] = message !== undefined ? message : $.validator.messages[ name ]; + if ( method.length < 3 ) { + $.validator.addClassRules( name, $.validator.normalizeRule( name ) ); + } + }, + + // http://jqueryvalidation.org/jQuery.validator.methods/ + methods: { + + // http://jqueryvalidation.org/required-method/ + required: function( value, element, param ) { + + // Check if dependency is met + if ( !this.depend( param, element ) ) { + return "dependency-mismatch"; + } + if ( element.nodeName.toLowerCase() === "select" ) { + + // Could be an array for select-multiple or a string, both are fine this way + var val = $( element ).val(); + return val && val.length > 0; + } + if ( this.checkable( element ) ) { + return this.getLength( value, element ) > 0; + } + return value.length > 0; + }, + + // http://jqueryvalidation.org/email-method/ + email: function( value, element ) { + + // From https://html.spec.whatwg.org/multipage/forms.html#valid-e-mail-address + // Retrieved 2014-01-14 + // If you have a problem with this implementation, report a bug against the above spec + // Or use custom methods to implement your own email validation + return this.optional( element ) || /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test( value ); + }, + + // http://jqueryvalidation.org/url-method/ + url: function( value, element ) { + + // Copyright (c) 2010-2013 Diego Perini, MIT licensed + // https://gist.github.com/dperini/729294 + // see also https://mathiasbynens.be/demo/url-regex + // modified to allow protocol-relative URLs + return this.optional( element ) || /^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})).?)(?::\d{2,5})?(?:[/?#]\S*)?$/i.test( value ); + }, + + // http://jqueryvalidation.org/date-method/ + date: function( value, element ) { + return this.optional( element ) || !/Invalid|NaN/.test( new Date( value ).toString() ); + }, + + // http://jqueryvalidation.org/dateISO-method/ + dateISO: function( value, element ) { + return this.optional( element ) || /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/.test( value ); + }, + + // http://jqueryvalidation.org/number-method/ + number: function( value, element ) { + return this.optional( element ) || /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test( value ); + }, + + // http://jqueryvalidation.org/digits-method/ + digits: function( value, element ) { + return this.optional( element ) || /^\d+$/.test( value ); + }, + + // http://jqueryvalidation.org/minlength-method/ + minlength: function( value, element, param ) { + var length = $.isArray( value ) ? value.length : this.getLength( value, element ); + return this.optional( element ) || length >= param; + }, + + // http://jqueryvalidation.org/maxlength-method/ + maxlength: function( value, element, param ) { + var length = $.isArray( value ) ? value.length : this.getLength( value, element ); + return this.optional( element ) || length <= param; + }, + + // http://jqueryvalidation.org/rangelength-method/ + rangelength: function( value, element, param ) { + var length = $.isArray( value ) ? value.length : this.getLength( value, element ); + return this.optional( element ) || ( length >= param[ 0 ] && length <= param[ 1 ] ); + }, + + // http://jqueryvalidation.org/min-method/ + min: function( value, element, param ) { + return this.optional( element ) || value >= param; + }, + + // http://jqueryvalidation.org/max-method/ + max: function( value, element, param ) { + return this.optional( element ) || value <= param; + }, + + // http://jqueryvalidation.org/range-method/ + range: function( value, element, param ) { + return this.optional( element ) || ( value >= param[ 0 ] && value <= param[ 1 ] ); + }, + + // http://jqueryvalidation.org/step-method/ + step: function( value, element, param ) { + var type = $( element ).attr( "type" ), + errorMessage = "Step attribute on input type " + type + " is not supported.", + supportedTypes = [ "text", "number", "range" ], + re = new RegExp( "\\b" + type + "\\b" ), + notSupported = type && !re.test( supportedTypes.join() ); + + // Works only for text, number and range input types + // TODO find a way to support input types date, datetime, datetime-local, month, time and week + if ( notSupported ) { + throw new Error( errorMessage ); + } + return this.optional( element ) || ( value % param === 0 ); + }, + + // http://jqueryvalidation.org/equalTo-method/ + equalTo: function( value, element, param ) { + + // Bind to the blur event of the target in order to revalidate whenever the target field is updated + var target = $( param ); + if ( this.settings.onfocusout && target.not( ".validate-equalTo-blur" ).length ) { + target.addClass( "validate-equalTo-blur" ).on( "blur.validate-equalTo", function() { + $( element ).valid(); + } ); + } + return value === target.val(); + }, + + // http://jqueryvalidation.org/remote-method/ + remote: function( value, element, param, method ) { + if ( this.optional( element ) ) { + return "dependency-mismatch"; + } + + method = typeof method === "string" && method || "remote"; + + var previous = this.previousValue( element, method ), + validator, data, optionDataString; + + if ( !this.settings.messages[ element.name ] ) { + this.settings.messages[ element.name ] = {}; + } + previous.originalMessage = previous.originalMessage || this.settings.messages[ element.name ][ method ]; + this.settings.messages[ element.name ][ method ] = previous.message; + + param = typeof param === "string" && { url: param } || param; + optionDataString = $.param( $.extend( { data: value }, param.data ) ); + if ( previous.old === optionDataString ) { + return previous.valid; + } + + previous.old = optionDataString; + validator = this; + this.startRequest( element ); + data = {}; + data[ element.name ] = value; + $.ajax( $.extend( true, { + mode: "abort", + port: "validate" + element.name, + dataType: "json", + data: data, + context: validator.currentForm, + success: function( response ) { + var valid = response === true || response === "true", + errors, message, submitted; + + validator.settings.messages[ element.name ][ method ] = previous.originalMessage; + if ( valid ) { + submitted = validator.formSubmitted; + validator.resetInternals(); + validator.toHide = validator.errorsFor( element ); + validator.formSubmitted = submitted; + validator.successList.push( element ); + validator.invalid[ element.name ] = false; + validator.showErrors(); + } else { + errors = {}; + message = response || validator.defaultMessage( element, { method: method, parameters: value } ); + errors[ element.name ] = previous.message = message; + validator.invalid[ element.name ] = true; + validator.showErrors( errors ); + } + previous.valid = valid; + validator.stopRequest( element, valid ); + } + }, param ) ); + return "pending"; + } + } + +} ); + +// Ajax mode: abort +// usage: $.ajax({ mode: "abort"[, port: "uniqueport"]}); +// if mode:"abort" is used, the previous request on that port (port can be undefined) is aborted via XMLHttpRequest.abort() + +var pendingRequests = {}, + ajax; + +// Use a prefilter if available (1.5+) +if ( $.ajaxPrefilter ) { + $.ajaxPrefilter( function( settings, _, xhr ) { + var port = settings.port; + if ( settings.mode === "abort" ) { + if ( pendingRequests[ port ] ) { + pendingRequests[ port ].abort(); + } + pendingRequests[ port ] = xhr; + } + } ); +} else { + + // Proxy ajax + ajax = $.ajax; + $.ajax = function( settings ) { + var mode = ( "mode" in settings ? settings : $.ajaxSettings ).mode, + port = ( "port" in settings ? settings : $.ajaxSettings ).port; + if ( mode === "abort" ) { + if ( pendingRequests[ port ] ) { + pendingRequests[ port ].abort(); + } + pendingRequests[ port ] = ajax.apply( this, arguments ); + return pendingRequests[ port ]; + } + return ajax.apply( this, arguments ); + }; +} })); \ No newline at end of file diff --git a/vendor/caxy/php-htmldiff/.gitignore b/vendor/caxy/php-htmldiff/.gitignore new file mode 100644 index 0000000..bf51d00 --- /dev/null +++ b/vendor/caxy/php-htmldiff/.gitignore @@ -0,0 +1,5 @@ +composer.lock +vendor/ +/demo/bower_components +/demo/node_modules +.DS_Store diff --git a/vendor/caxy/php-htmldiff/.scrutinizer.yml b/vendor/caxy/php-htmldiff/.scrutinizer.yml new file mode 100644 index 0000000..fa2a078 --- /dev/null +++ b/vendor/caxy/php-htmldiff/.scrutinizer.yml @@ -0,0 +1,133 @@ +imports: + - php +tools: + js_hint: true + php_code_sniffer: true + php_cs_fixer: + config: { level: psr2 } + enabled: true +build: + tests: + override: + - + command: 'vendor/bin/phpunit --coverage-clover=code-coverage-file' + coverage: + file: 'code-coverage-file' + format: 'php-clover' +filter: + excluded_paths: + - tests/* +checks: + php: + uppercase_constants: true + unused_variables: true + unreachable_code: true + unused_methods: true + sql_injection_vulnerabilities: true + spacing_of_function_arguments: true + spacing_around_non_conditional_operators: true + spacing_around_conditional_operators: true + too_many_arguments: true + return_doc_comments: true + require_scope_for_properties: true + require_scope_for_methods: true + require_braces_around_control_structures: true + psr2_control_structure_declaration: true + code_rating: true + duplication: true + variable_existence: true + useless_calls: true + use_statement_alias_conflict: true + unused_properties: true + unused_parameters: true + security_vulnerabilities: true + precedence_mistakes: true + precedence_in_conditions: true + parameter_non_unique: true + no_property_on_interface: true + no_non_implemented_abstract_methods: true + deprecated_code_usage: true + closure_use_not_conflicting: true + closure_use_modifiable: true + avoid_useless_overridden_methods: true + avoid_conflicting_incrementers: true + assignment_of_null_return: true + verify_access_scope_valid: true + symfony_request_injection: true + simplify_boolean_return: true + side_effects_or_types: true + scope_indentation: + spaces_per_level: '4' + return_doc_comment_if_not_inferrable: true + remove_trailing_whitespace: true + remove_php_closing_tag: true + remove_extra_empty_lines: true + psr2_switch_declaration: true + psr2_class_declaration: true + property_assignments: true + properties_in_camelcaps: true + phpunit_assertions: true + php5_style_constructor: true + parameters_in_camelcaps: true + parameter_doc_comments: true + param_doc_comment_if_not_inferrable: true + overriding_private_members: true + one_class_per_file: true + optional_parameters_at_the_end: true + non_commented_empty_catch_block: true + no_unnecessary_if: true + no_unnecessary_function_call_in_for_loop: true + no_space_inside_cast_operator: true + no_space_before_semicolon: true + no_space_around_object_operator: true + no_short_open_tag: true + no_short_method_names: + minimum: '3' + no_goto: true + no_global_keyword: true + no_exit: true + no_eval: true + no_long_variable_names: + maximum: '40' + no_empty_statements: true + no_error_suppression: true + no_else_if_statements: true + no_duplicate_arguments: true + no_debug_code: true + no_commented_out_code: true + missing_arguments: true + method_calls_on_non_object: true + lowercase_php_keywords: true + lowercase_basic_constants: true + instanceof_class_exists: true + function_in_camel_caps: true + fix_use_statements: + remove_unused: true + preserve_multiple: false + preserve_blanklines: false + order_alphabetically: true + fix_identation_4spaces: true + ensure_lower_case_builtin_functions: true + fix_doc_comments: true + avoid_unnecessary_concatenation: true + avoid_entity_manager_injection: true + avoid_closing_tag: true + require_php_tag_first: true + line_length: + max_length: '120' + function_body_start_on_new_line: true + fix_php_opening_tag: true + fix_linefeed: true + classes_in_camel_caps: true + catch_class_exists: true + avoid_tab_indentation: true + avoid_superglobals: true + avoid_multiple_statements_on_same_line: true + avoid_length_functions_in_loops: true + avoid_duplicate_types: true + avoid_corrupting_byteorder_marks: true + argument_type_checks: true + no_underscore_prefix_in_properties: true + no_underscore_prefix_in_methods: true + blank_line_after_namespace_declaration: true + verify_argument_usable_as_reference: true \ No newline at end of file diff --git a/vendor/caxy/php-htmldiff/CHANGELOG.md b/vendor/caxy/php-htmldiff/CHANGELOG.md index b32335d..89c2ab8 100755 --- a/vendor/caxy/php-htmldiff/CHANGELOG.md +++ b/vendor/caxy/php-htmldiff/CHANGELOG.md @@ -1,145 +1,145 @@ -# Change Log - -## [v0.1.1](https://github.com/caxy/php-htmldiff/tree/v0.1.1) (2016-03-16) -[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.1.0...v0.1.1) - -**Features and Enhancements:** - -- Update TableDiff HTMLPurifier Initialization [\#35](https://github.com/caxy/php-htmldiff/pull/35) ([dbergunder](https://github.com/dbergunder)) - -**Miscellaneous:** - -- Update the README and add additional documentation [\#34](https://github.com/caxy/php-htmldiff/pull/34) ([jschroed91](https://github.com/jschroed91)) - -## [0.1.0](https://github.com/caxy/php-htmldiff/tree/0.1.0) (2016-03-10) - -[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.14...0.1.0) - -**Features and Enhancements:** - -- Allow caching of the calculated diffs using a doctrine cache provider [\#33](https://github.com/caxy/php-htmldiff/pull/33) ([jschroed91](https://github.com/jschroed91)) -- Create configuration class for HtmlDiff config options [\#32](https://github.com/caxy/php-htmldiff/pull/32) ([jschroed91](https://github.com/jschroed91)) -- New Feature: Table Diffing [\#31](https://github.com/caxy/php-htmldiff/pull/31) ([jschroed91](https://github.com/jschroed91)) -- Detect link changes to resolve [\#28](https://github.com/caxy/php-htmldiff/issues/28) [\#30](https://github.com/caxy/php-htmldiff/pull/30) ([jschroed91](https://github.com/jschroed91)) -- Setup PHPUnit testsuite with basic functional test and a few test cases [\#26](https://github.com/caxy/php-htmldiff/pull/26) ([jschroed91](https://github.com/jschroed91)) - -## [0.1.0-beta.1](https://github.com/caxy/php-htmldiff/tree/0.1.0-beta.1) (2016-02-26) -[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.14...0.1.0-beta.1) - -**Features and Enhancements:** - -- New Feature: Table Diffing [\#31](https://github.com/caxy/php-htmldiff/pull/31) ([jschroed91](https://github.com/jschroed91)) -- Detect link changes to resolve [\#28](https://github.com/caxy/php-htmldiff/issues/28) [\#30](https://github.com/caxy/php-htmldiff/pull/30) ([jschroed91](https://github.com/jschroed91)) -- Setup PHPUnit testsuite with basic functional test and a few test cases [\#26](https://github.com/caxy/php-htmldiff/pull/26) ([jschroed91](https://github.com/jschroed91)) - -## [0.0.14](https://github.com/caxy/php-htmldiff/tree/0.0.14) (2016-02-03) -[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.13...0.0.14) - -**Fixed bugs:** - -- Fix HtmlDiff matching logic skipping over single word matches [\#25](https://github.com/caxy/php-htmldiff/pull/25) ([jschroed91](https://github.com/jschroed91)) - -## [0.0.13](https://github.com/caxy/php-htmldiff/tree/0.0.13) (2016-01-12) -[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.12...0.0.13) - -**Fixed bugs:** - -- Misc. list diffing updates and fixes [\#24](https://github.com/caxy/php-htmldiff/pull/24) ([jschroed91](https://github.com/jschroed91)) -- Updated list diff class to maintain the tags on lists. [\#23](https://github.com/caxy/php-htmldiff/pull/23) ([adamCaxy](https://github.com/adamCaxy)) - -## [0.0.12](https://github.com/caxy/php-htmldiff/tree/0.0.12) (2015-11-11) -[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.11...0.0.12) - -**Fixed bugs:** - -- feature-list\_diffing-new [\#20](https://github.com/caxy/php-htmldiff/pull/20) ([adamCaxy](https://github.com/adamCaxy)) - -## [0.0.11](https://github.com/caxy/php-htmldiff/tree/0.0.11) (2015-11-06) -[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.10...0.0.11) - -**Features and Enhancements:** - -- Feature list diffing new [\#19](https://github.com/caxy/php-htmldiff/pull/19) ([adamCaxy](https://github.com/adamCaxy)) - -## [0.0.10](https://github.com/caxy/php-htmldiff/tree/0.0.10) (2015-10-21) -[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.9...0.0.10) - -**Fixed bugs:** - -- Fix: Updated code so that null is not given in list formatting. [\#17](https://github.com/caxy/php-htmldiff/pull/17) ([adamCaxy](https://github.com/adamCaxy)) - -## [0.0.9](https://github.com/caxy/php-htmldiff/tree/0.0.9) (2015-10-20) -[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.8...0.0.9) - -**Fixed bugs:** - -- Missed an array\_column in ListDiff. Updated to use ArrayColumn function. [\#16](https://github.com/caxy/php-htmldiff/pull/16) ([jschroed91](https://github.com/jschroed91)) - -## [0.0.8](https://github.com/caxy/php-htmldiff/tree/0.0.8) (2015-10-20) -[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.7...0.0.8) - -**Fixed bugs:** - -- Added update for php versions that do not have array\_column as a function. [\#15](https://github.com/caxy/php-htmldiff/pull/15) ([jschroed91](https://github.com/jschroed91)) - -## [0.0.7](https://github.com/caxy/php-htmldiff/tree/0.0.7) (2015-10-20) -[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.6...0.0.7) - -**Features and Enhancements:** - -- Created ListDiff class to handle diffing of lists. [\#14](https://github.com/caxy/php-htmldiff/pull/14) ([adamCaxy](https://github.com/adamCaxy)) - -## [0.0.6](https://github.com/caxy/php-htmldiff/tree/0.0.6) (2015-09-11) -[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.5...0.0.6) - -**Features and Enhancements:** - -- Feature - html tag isolation [\#12](https://github.com/caxy/php-htmldiff/pull/12) ([jschroed91](https://github.com/jschroed91)) -- ICC-4313 | ICC-4314 | Replace Special HTML Elements with placeholder tokens and update diffing logic [\#11](https://github.com/caxy/php-htmldiff/pull/11) ([usaqlain01](https://github.com/usaqlain01)) - -## [0.0.5](https://github.com/caxy/php-htmldiff/tree/0.0.5) (2015-03-03) -[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.4...0.0.5) - -**Features and Enhancements:** - -- Support derived classes [\#10](https://github.com/caxy/php-htmldiff/pull/10) ([mkalkbrenner](https://github.com/mkalkbrenner)) - -## [0.0.4](https://github.com/caxy/php-htmldiff/tree/0.0.4) (2015-01-09) -[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.3...0.0.4) - -**Fixed bugs:** - -- Check for empty oldText or newText before processing del or ins in processReplaceOperation [\#9](https://github.com/caxy/php-htmldiff/pull/9) ([jschroed91](https://github.com/jschroed91)) - -## [0.0.3](https://github.com/caxy/php-htmldiff/tree/0.0.3) (2015-01-08) -[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.2...0.0.3) - -**Features and Enhancements:** - -- Add option to insert a space between del and ins tags [\#8](https://github.com/caxy/php-htmldiff/pull/8) ([jschroed91](https://github.com/jschroed91)) -- Updated demo to accept input and diff on the fly [\#5](https://github.com/caxy/php-htmldiff/pull/5) ([jschroed91](https://github.com/jschroed91)) - -## [0.0.2](https://github.com/caxy/php-htmldiff/tree/0.0.2) (2014-08-12) -[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.1...0.0.2) - -**Features and Enhancements:** - -- Break out HTML content to individual HTML, CSS, JS files [\#6](https://github.com/caxy/php-htmldiff/pull/6) ([mgersten-caxy](https://github.com/mgersten-caxy)) - -**Fixed bugs:** - -- Fix error caused when passing empty array into setSpecialCaseTags [\#7](https://github.com/caxy/php-htmldiff/pull/7) ([jschroed91](https://github.com/jschroed91)) - -## [0.0.1](https://github.com/caxy/php-htmldiff/tree/0.0.1) (2014-07-31) -**Features and Enhancements:** - -- Added static properties for the default config variables [\#4](https://github.com/caxy/php-htmldiff/pull/4) ([jschroed91](https://github.com/jschroed91)) -- Feature nonpartial word diffing [\#3](https://github.com/caxy/php-htmldiff/pull/3) ([jschroed91](https://github.com/jschroed91)) -- Added option to group together diffed words in output [\#2](https://github.com/caxy/php-htmldiff/pull/2) ([jschroed91](https://github.com/jschroed91)) - - - -\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* - - -\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* +# Change Log + +## [v0.1.1](https://github.com/caxy/php-htmldiff/tree/v0.1.1) (2016-03-16) +[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.1.0...v0.1.1) + +**Features and Enhancements:** + +- Update TableDiff HTMLPurifier Initialization [\#35](https://github.com/caxy/php-htmldiff/pull/35) ([dbergunder](https://github.com/dbergunder)) + +**Miscellaneous:** + +- Update the README and add additional documentation [\#34](https://github.com/caxy/php-htmldiff/pull/34) ([jschroed91](https://github.com/jschroed91)) + +## [0.1.0](https://github.com/caxy/php-htmldiff/tree/0.1.0) (2016-03-10) + +[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.14...0.1.0) + +**Features and Enhancements:** + +- Allow caching of the calculated diffs using a doctrine cache provider [\#33](https://github.com/caxy/php-htmldiff/pull/33) ([jschroed91](https://github.com/jschroed91)) +- Create configuration class for HtmlDiff config options [\#32](https://github.com/caxy/php-htmldiff/pull/32) ([jschroed91](https://github.com/jschroed91)) +- New Feature: Table Diffing [\#31](https://github.com/caxy/php-htmldiff/pull/31) ([jschroed91](https://github.com/jschroed91)) +- Detect link changes to resolve [\#28](https://github.com/caxy/php-htmldiff/issues/28) [\#30](https://github.com/caxy/php-htmldiff/pull/30) ([jschroed91](https://github.com/jschroed91)) +- Setup PHPUnit testsuite with basic functional test and a few test cases [\#26](https://github.com/caxy/php-htmldiff/pull/26) ([jschroed91](https://github.com/jschroed91)) + +## [0.1.0-beta.1](https://github.com/caxy/php-htmldiff/tree/0.1.0-beta.1) (2016-02-26) +[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.14...0.1.0-beta.1) + +**Features and Enhancements:** + +- New Feature: Table Diffing [\#31](https://github.com/caxy/php-htmldiff/pull/31) ([jschroed91](https://github.com/jschroed91)) +- Detect link changes to resolve [\#28](https://github.com/caxy/php-htmldiff/issues/28) [\#30](https://github.com/caxy/php-htmldiff/pull/30) ([jschroed91](https://github.com/jschroed91)) +- Setup PHPUnit testsuite with basic functional test and a few test cases [\#26](https://github.com/caxy/php-htmldiff/pull/26) ([jschroed91](https://github.com/jschroed91)) + +## [0.0.14](https://github.com/caxy/php-htmldiff/tree/0.0.14) (2016-02-03) +[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.13...0.0.14) + +**Fixed bugs:** + +- Fix HtmlDiff matching logic skipping over single word matches [\#25](https://github.com/caxy/php-htmldiff/pull/25) ([jschroed91](https://github.com/jschroed91)) + +## [0.0.13](https://github.com/caxy/php-htmldiff/tree/0.0.13) (2016-01-12) +[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.12...0.0.13) + +**Fixed bugs:** + +- Misc. list diffing updates and fixes [\#24](https://github.com/caxy/php-htmldiff/pull/24) ([jschroed91](https://github.com/jschroed91)) +- Updated list diff class to maintain the tags on lists. [\#23](https://github.com/caxy/php-htmldiff/pull/23) ([adamCaxy](https://github.com/adamCaxy)) + +## [0.0.12](https://github.com/caxy/php-htmldiff/tree/0.0.12) (2015-11-11) +[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.11...0.0.12) + +**Fixed bugs:** + +- feature-list\_diffing-new [\#20](https://github.com/caxy/php-htmldiff/pull/20) ([adamCaxy](https://github.com/adamCaxy)) + +## [0.0.11](https://github.com/caxy/php-htmldiff/tree/0.0.11) (2015-11-06) +[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.10...0.0.11) + +**Features and Enhancements:** + +- Feature list diffing new [\#19](https://github.com/caxy/php-htmldiff/pull/19) ([adamCaxy](https://github.com/adamCaxy)) + +## [0.0.10](https://github.com/caxy/php-htmldiff/tree/0.0.10) (2015-10-21) +[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.9...0.0.10) + +**Fixed bugs:** + +- Fix: Updated code so that null is not given in list formatting. [\#17](https://github.com/caxy/php-htmldiff/pull/17) ([adamCaxy](https://github.com/adamCaxy)) + +## [0.0.9](https://github.com/caxy/php-htmldiff/tree/0.0.9) (2015-10-20) +[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.8...0.0.9) + +**Fixed bugs:** + +- Missed an array\_column in ListDiff. Updated to use ArrayColumn function. [\#16](https://github.com/caxy/php-htmldiff/pull/16) ([jschroed91](https://github.com/jschroed91)) + +## [0.0.8](https://github.com/caxy/php-htmldiff/tree/0.0.8) (2015-10-20) +[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.7...0.0.8) + +**Fixed bugs:** + +- Added update for php versions that do not have array\_column as a function. [\#15](https://github.com/caxy/php-htmldiff/pull/15) ([jschroed91](https://github.com/jschroed91)) + +## [0.0.7](https://github.com/caxy/php-htmldiff/tree/0.0.7) (2015-10-20) +[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.6...0.0.7) + +**Features and Enhancements:** + +- Created ListDiff class to handle diffing of lists. [\#14](https://github.com/caxy/php-htmldiff/pull/14) ([adamCaxy](https://github.com/adamCaxy)) + +## [0.0.6](https://github.com/caxy/php-htmldiff/tree/0.0.6) (2015-09-11) +[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.5...0.0.6) + +**Features and Enhancements:** + +- Feature - html tag isolation [\#12](https://github.com/caxy/php-htmldiff/pull/12) ([jschroed91](https://github.com/jschroed91)) +- ICC-4313 | ICC-4314 | Replace Special HTML Elements with placeholder tokens and update diffing logic [\#11](https://github.com/caxy/php-htmldiff/pull/11) ([usaqlain01](https://github.com/usaqlain01)) + +## [0.0.5](https://github.com/caxy/php-htmldiff/tree/0.0.5) (2015-03-03) +[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.4...0.0.5) + +**Features and Enhancements:** + +- Support derived classes [\#10](https://github.com/caxy/php-htmldiff/pull/10) ([mkalkbrenner](https://github.com/mkalkbrenner)) + +## [0.0.4](https://github.com/caxy/php-htmldiff/tree/0.0.4) (2015-01-09) +[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.3...0.0.4) + +**Fixed bugs:** + +- Check for empty oldText or newText before processing del or ins in processReplaceOperation [\#9](https://github.com/caxy/php-htmldiff/pull/9) ([jschroed91](https://github.com/jschroed91)) + +## [0.0.3](https://github.com/caxy/php-htmldiff/tree/0.0.3) (2015-01-08) +[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.2...0.0.3) + +**Features and Enhancements:** + +- Add option to insert a space between del and ins tags [\#8](https://github.com/caxy/php-htmldiff/pull/8) ([jschroed91](https://github.com/jschroed91)) +- Updated demo to accept input and diff on the fly [\#5](https://github.com/caxy/php-htmldiff/pull/5) ([jschroed91](https://github.com/jschroed91)) + +## [0.0.2](https://github.com/caxy/php-htmldiff/tree/0.0.2) (2014-08-12) +[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.1...0.0.2) + +**Features and Enhancements:** + +- Break out HTML content to individual HTML, CSS, JS files [\#6](https://github.com/caxy/php-htmldiff/pull/6) ([mgersten-caxy](https://github.com/mgersten-caxy)) + +**Fixed bugs:** + +- Fix error caused when passing empty array into setSpecialCaseTags [\#7](https://github.com/caxy/php-htmldiff/pull/7) ([jschroed91](https://github.com/jschroed91)) + +## [0.0.1](https://github.com/caxy/php-htmldiff/tree/0.0.1) (2014-07-31) +**Features and Enhancements:** + +- Added static properties for the default config variables [\#4](https://github.com/caxy/php-htmldiff/pull/4) ([jschroed91](https://github.com/jschroed91)) +- Feature nonpartial word diffing [\#3](https://github.com/caxy/php-htmldiff/pull/3) ([jschroed91](https://github.com/jschroed91)) +- Added option to group together diffed words in output [\#2](https://github.com/caxy/php-htmldiff/pull/2) ([jschroed91](https://github.com/jschroed91)) + + + +\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* + + +\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* diff --git a/vendor/caxy/php-htmldiff/CODE_OF_CONDUCT.md b/vendor/caxy/php-htmldiff/CODE_OF_CONDUCT.md index d957971..b051b52 100755 --- a/vendor/caxy/php-htmldiff/CODE_OF_CONDUCT.md +++ b/vendor/caxy/php-htmldiff/CODE_OF_CONDUCT.md @@ -1,74 +1,74 @@ -# Contributor Covenant Code of Conduct - -## Our Pledge - -In the interest of fostering an open and welcoming environment, we as -contributors and maintainers pledge to making participation in our project and -our community a harassment-free experience for everyone, regardless of age, body -size, disability, ethnicity, gender identity and expression, level of experience, -nationality, personal appearance, race, religion, or sexual identity and -orientation. - -## Our Standards - -Examples of behavior that contributes to creating a positive environment -include: - -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members - -Examples of unacceptable behavior by participants include: - -* The use of sexualized language or imagery and unwelcome sexual attention or -advances -* Trolling, insulting/derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or electronic - address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a - professional setting - -## Our Responsibilities - -Project maintainers are responsible for clarifying the standards of acceptable -behavior and are expected to take appropriate and fair corrective action in -response to any instances of unacceptable behavior. - -Project maintainers have the right and responsibility to remove, edit, or -reject comments, commits, code, wiki edits, issues, and other contributions -that are not aligned to this Code of Conduct, or to ban temporarily or -permanently any contributor for other behaviors that they deem inappropriate, -threatening, offensive, or harmful. - -## Scope - -This Code of Conduct applies both within project spaces and in public spaces -when an individual is representing the project or its community. Examples of -representing a project or community include using an official project e-mail -address, posting via an official social media account, or acting as an appointed -representative at an online or offline event. Representation of a project may be -further defined and clarified by project maintainers. - -## Enforcement - -Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported by contacting the project team at dev@caxy.com. All -complaints will be reviewed and investigated and will result in a response that -is deemed necessary and appropriate to the circumstances. The project team is -obligated to maintain confidentiality with regard to the reporter of an incident. -Further details of specific enforcement policies may be posted separately. - -Project maintainers who do not follow or enforce the Code of Conduct in good -faith may face temporary or permanent repercussions as determined by other -members of the project's leadership. - -## Attribution - -This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, -available at [http://contributor-covenant.org/version/1/4][version] - -[homepage]: http://contributor-covenant.org -[version]: http://contributor-covenant.org/version/1/4/ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of experience, +nationality, personal appearance, race, religion, or sexual identity and +orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or +advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at dev@caxy.com. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ diff --git a/vendor/caxy/php-htmldiff/CONTRIBUTING.md b/vendor/caxy/php-htmldiff/CONTRIBUTING.md index e2afa41..3677a2c 100755 --- a/vendor/caxy/php-htmldiff/CONTRIBUTING.md +++ b/vendor/caxy/php-htmldiff/CONTRIBUTING.md @@ -1,33 +1,33 @@ -Contributing -============ - -First of all, **thank you** for contributing, **you are awesome**! - -Here are a few rules to follow in order to ease code reviews, and discussions before -maintainers accept and merge your work. - -You MUST follow the [PSR-1](http://www.php-fig.org/psr/1/) and -[PSR-2](http://www.php-fig.org/psr/2/). If you don't know about any of them, you -should really read the recommendations. Can't wait? Use the [PHP-CS-Fixer -tool](http://cs.sensiolabs.org/). - -You MUST run the test suite. - -You MUST write (or update) unit tests. - -You SHOULD write documentation. - -Please, write [commit messages that make -sense](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html), -and [rebase your branch](http://git-scm.com/book/en/Git-Branching-Rebasing) -before submitting your Pull Request. - -One may ask you to [squash your -commits](http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html) -too. This is used to "clean" your Pull Request before merging it (we don't want -commits such as `fix tests`, `fix 2`, `fix 3`, etc.). - -Also, while creating your Pull Request on GitHub, you MUST write a description -which gives the context and/or explains why you are creating it. - -Thank you! +Contributing +============ + +First of all, **thank you** for contributing, **you are awesome**! + +Here are a few rules to follow in order to ease code reviews, and discussions before +maintainers accept and merge your work. + +You MUST follow the [PSR-1](http://www.php-fig.org/psr/1/) and +[PSR-2](http://www.php-fig.org/psr/2/). If you don't know about any of them, you +should really read the recommendations. Can't wait? Use the [PHP-CS-Fixer +tool](http://cs.sensiolabs.org/). + +You MUST run the test suite. + +You MUST write (or update) unit tests. + +You SHOULD write documentation. + +Please, write [commit messages that make +sense](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html), +and [rebase your branch](http://git-scm.com/book/en/Git-Branching-Rebasing) +before submitting your Pull Request. + +One may ask you to [squash your +commits](http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html) +too. This is used to "clean" your Pull Request before merging it (we don't want +commits such as `fix tests`, `fix 2`, `fix 3`, etc.). + +Also, while creating your Pull Request on GitHub, you MUST write a description +which gives the context and/or explains why you are creating it. + +Thank you! diff --git a/vendor/caxy/php-htmldiff/LICENSE b/vendor/caxy/php-htmldiff/LICENSE index fdebdd9..6ccd897 100755 --- a/vendor/caxy/php-htmldiff/LICENSE +++ b/vendor/caxy/php-htmldiff/LICENSE @@ -1,130 +1,130 @@ -GNU GENERAL PUBLIC LICENSE - -Version 2, June 1991 - -Copyright (C) 1989, 1991 Free Software Foundation, Inc. -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - -Everyone is permitted to copy and distribute verbatim copies -of this license document, but changing it is not allowed. -Preamble - -The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. - -When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. - -To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. - -For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. - -We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. - -Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. - -Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. - -The precise terms and conditions for copying, distribution and modification follow. - -TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - -0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. - -1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. - -You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. - -2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: - -a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. -b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. -c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) -These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. - -3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: - -a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, -b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, -c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) -The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. - -If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. - -4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. - -5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. - -6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. - -7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. - -This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. - -8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. - -9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. - -10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. - -NO WARRANTY - -11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - -12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - -END OF TERMS AND CONDITIONS - -How to Apply These Terms to Your New Programs - -If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. - -To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. - -one line to give the program's name and an idea of what it does. -Copyright (C) yyyy name of author - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -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. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this when it starts in an interactive mode: - -Gnomovision version 69, Copyright (C) year name of author -Gnomovision comes with ABSOLUTELY NO WARRANTY; for details -type `show w'. This is free software, and you are welcome -to redistribute it under certain conditions; type `show c' -for details. -The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: - -Yoyodyne, Inc., hereby disclaims all copyright -interest in the program `Gnomovision' -(which makes passes at compilers) written -by James Hacker. - -signature of Ty Coon, 1 April 1989 -Ty Coon, President of Vice -This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. +GNU GENERAL PUBLIC LICENSE + +Version 2, June 1991 + +Copyright (C) 1989, 1991 Free Software Foundation, Inc. +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +Everyone is permitted to copy and distribute verbatim copies +of this license document, but changing it is not allowed. +Preamble + +The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. + +When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. + +To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. + +For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. + +We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. + +Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. + +Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. + +The precise terms and conditions for copying, distribution and modification follow. + +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. + +1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. + +You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: + +a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. +b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. +c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) +These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. + +3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: + +a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, +b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, +c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) +The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. + +If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. + +4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. + +5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. + +6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. + +7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. + +This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. + +8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. + +9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. + +10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. + +NO WARRANTY + +11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +END OF TERMS AND CONDITIONS + +How to Apply These Terms to Your New Programs + +If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. + +To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. + +one line to give the program's name and an idea of what it does. +Copyright (C) yyyy name of author + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +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. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this when it starts in an interactive mode: + +Gnomovision version 69, Copyright (C) year name of author +Gnomovision comes with ABSOLUTELY NO WARRANTY; for details +type `show w'. This is free software, and you are welcome +to redistribute it under certain conditions; type `show c' +for details. +The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: + +Yoyodyne, Inc., hereby disclaims all copyright +interest in the program `Gnomovision' +(which makes passes at compilers) written +by James Hacker. + +signature of Ty Coon, 1 April 1989 +Ty Coon, President of Vice +This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. diff --git a/vendor/caxy/php-htmldiff/README.md b/vendor/caxy/php-htmldiff/README.md index ba76a58..ed7ec34 100755 --- a/vendor/caxy/php-htmldiff/README.md +++ b/vendor/caxy/php-htmldiff/README.md @@ -1,201 +1,201 @@ -php-htmldiff -============ - -[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/caxy/php-htmldiff/badges/quality-score.png?b=master)][badge_score] -[![Build Status](https://scrutinizer-ci.com/g/caxy/php-htmldiff/badges/build.png?b=master)][badge_status] -[![Code Coverage](https://scrutinizer-ci.com/g/caxy/php-htmldiff/badges/coverage.png?b=master)][badge_coverage] -[![Packagist](https://img.shields.io/packagist/dt/caxy/php-htmldiff.svg)][badge_packagist] -[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/caxy/php-htmldiff.svg)][badge_resolve] -[![Percentage of issues still open](http://isitmaintained.com/badge/open/caxy/php-htmldiff.svg)][badge_issues] - -php-htmldiff is a library for comparing two HTML files/snippets and highlighting the differences using simple HTML. - -This HTML Diff implementation was forked from [rashid2538/php-htmldiff][upstream] and has been modified with new features, -bug fixes, and enhancements to the original code. - -For more information on these modifications, read the [differences from rashid2538/php-htmldiff][differences] or view the [CHANGELOG][changelog]. - -## Installation - -The recommended way to install php-htmldiff is through [Composer][composer]. -Require the [caxy/php-htmldiff][badge_packagist] package by running following command: - -```sh -composer require caxy/php-htmldiff -``` - -This will resolve the latest stable version. - -Otherwise, install the library and setup the autoloader yourself. - -### Working with Symfony - -If you are using Symfony, you can use the [caxy/HtmlDiffBundle][htmldiffbundle] to make life easy! - -## Usage - -```php -use Caxy\HtmlDiff\HtmlDiff; - -$htmlDiff = new HtmlDiff($oldHtml, $newHtml); -$content = $htmlDiff->build(); -``` - -## Configuration - -The configuration for HtmlDiff is contained in the `Caxy\HtmlDiff\HtmlDiffConfig` class. - -There are two ways to set the configuration: - -1. [Configure an Existing HtmlDiff Object](#configure-an-existing-htmldiff-object) -2. [Create and Use a HtmlDiffConfig Object](#create-and-use-a-htmldiffconfig-object) - -#### Configure an Existing HtmlDiff Object - -When a new `HtmlDiff` object is created, it creates a `HtmlDiffConfig` object with the default configuration. -You can change the configuration using setters on the object: - -```php -use Caxy\HtmlDiff\HtmlDiff; - -// ... - -$htmlDiff = new HtmlDiff($oldHtml, $newHtml); - -// Set some of the configuration options. -$htmlDiff->getConfig() - ->setMatchThreshold(80) - ->setInsertSpaceInReplace(true) -; - -// Calculate the differences using the configuration and get the html diff. -$content = $htmlDiff->build(); - -// ... - -``` - -#### Create and Use a HtmlDiffConfig Object - -You can also set the configuration by creating an instance of -`Caxy\HtmlDiff\HtmlDiffConfig` and using it when creating a new `HtmlDiff` -object using `HtmlDiff::create`. - -This is useful when creating more than one instance of `HtmlDiff`: - -```php -use Caxy\HtmlDiff\HtmlDiff; -use Caxy\HtmlDiff\HtmlDiffConfig; - -// ... - -$config = new HtmlDiffConfig(); -$config - ->setMatchThreshold(95) - ->setInsertSpaceInReplace(true) -; - -// Create an HtmlDiff object with the custom configuration. -$firstHtmlDiff = HtmlDiff::create($oldHtml, $newHtml, $config); -$firstContent = $firstHtmlDiff->build(); - -$secondHtmlDiff = HtmlDiff::create($oldHtml2, $newHtml2, $config); -$secondHtmlDiff->getConfig()->setMatchThreshold(50); - -$secondContent = $secondHtmlDiff->build(); - -// ... -``` - -#### Full Configuration with Defaults: - -```php - -$config = new HtmlDiffConfig(); -$config - // Percentage required for list items to be considered a match. - ->setMatchThreshold(80) - - // Set the encoding of the text to be diffed. - ->setEncoding('UTF-8') - - // If true, a space will be added between the and tags of text that was replaced. - ->setInsertSpaceInReplace(false) - - // Option to disable the new Table Diffing feature and treat tables as regular text. - ->setUseTableDiffing(true) - - // Pass an instance of \Doctrine\Common\Cache\Cache to cache the calculated diffs. - ->setCacheProvider(null) - - // Set the cache directory that HTMLPurifier should use. - ->setPurifierCacheLocation(null) - - // Group consecutive deletions and insertions instead of showing a deletion and insertion for each word individually. - ->setGroupDiffs(true) - - // List of characters to consider part of a single word when in the middle of text. - ->setSpecialCaseChars(array('.', ',', '(', ')', '\'')) - - // List of tags to treat as special case tags. - ->setSpecialCaseTags(array('strong', 'b', 'i', 'big', 'small', 'u', 'sub', 'sup', 'strike', 's', 'p')) - - // List of tags (and their replacement strings) to be diffed in isolation. - ->setIsolatedDiffTags(array( - 'ol' => '[[REPLACE_ORDERED_LIST]]', - 'ul' => '[[REPLACE_UNORDERED_LIST]]', - 'sub' => '[[REPLACE_SUB_SCRIPT]]', - 'sup' => '[[REPLACE_SUPER_SCRIPT]]', - 'dl' => '[[REPLACE_DEFINITION_LIST]]', - 'table' => '[[REPLACE_TABLE]]', - 'strong' => '[[REPLACE_STRONG]]', - 'b' => '[[REPLACE_B]]', - 'em' => '[[REPLACE_EM]]', - 'i' => '[[REPLACE_I]]', - 'a' => '[[REPLACE_A]]', - )) -; - -``` - -## Contributing - -See [CONTRIBUTING][contributing] file. - -## Contributor Code of Conduct - -Please note that this project is released with a [Contributor Code of -Conduct][contributor_covenant]. By participating in this project -you agree to abide by its terms. See [CODE_OF_CONDUCT][code_of_conduct] file. - -## Credits - -* [rashid2538][] for the port to PHP and the base for our project: [rashid2538/php-htmldiff][upstream] -* [willdurand][] for an excellent post on [open sourcing libraries][]. -Much of this documentation is based off of the examples in the post. - -Did we miss anyone? If we did, let us know or put in a pull request! - -## License - -php-htmldiff is available under [GNU General Public License, version 2][gnu]. See the [LICENSE][license] file for details. - -[badge_score]: https://scrutinizer-ci.com/g/caxy/php-htmldiff/?branch=master -[badge_status]: https://scrutinizer-ci.com/g/caxy/php-htmldiff/build-status/master -[badge_coverage]: https://scrutinizer-ci.com/g/caxy/php-htmldiff/?branch=master -[badge_packagist]: https://packagist.org/packages/caxy/php-htmldiff -[badge_resolve]: http://isitmaintained.com/project/caxy/php-htmldiff "Average time to resolve an issue" -[badge_issues]: http://isitmaintained.com/project/caxy/php-htmldiff "Percentage of issues still open" -[upstream]: https://github.com/rashid2538/php-htmldiff -[htmldiffbundle]: https://github.com/caxy/HtmlDiffBundle -[differences]: https://github.com/caxy/php-htmldiff/blob/master/doc/differences.rst -[changelog]: https://github.com/caxy/php-htmldiff/blob/master/CHANGELOG.md -[contributing]: https://github.com/caxy/php-htmldiff/blob/master/CONTRIBUTING.md -[gnu]: http://www.gnu.org/licenses/gpl-2.0.html -[license]: https://github.com/caxy/php-htmldiff/blob/master/LICENSE -[code_of_conduct]: https://github.com/caxy/php-htmldiff/blob/master/CODE_OF_CONDUCT.md -[composer]: http://getcomposer.org/ -[contributor_covenant]: http://contributor-covenant.org/ -[rashid2538]: https://github.com/rashid2538 -[willdurand]: https://github.com/willdurand -[open sourcing libraries]: http://williamdurand.fr/2013/07/04/on-open-sourcing-libraries/ +php-htmldiff +============ + +[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/caxy/php-htmldiff/badges/quality-score.png?b=master)][badge_score] +[![Build Status](https://scrutinizer-ci.com/g/caxy/php-htmldiff/badges/build.png?b=master)][badge_status] +[![Code Coverage](https://scrutinizer-ci.com/g/caxy/php-htmldiff/badges/coverage.png?b=master)][badge_coverage] +[![Packagist](https://img.shields.io/packagist/dt/caxy/php-htmldiff.svg)][badge_packagist] +[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/caxy/php-htmldiff.svg)][badge_resolve] +[![Percentage of issues still open](http://isitmaintained.com/badge/open/caxy/php-htmldiff.svg)][badge_issues] + +php-htmldiff is a library for comparing two HTML files/snippets and highlighting the differences using simple HTML. + +This HTML Diff implementation was forked from [rashid2538/php-htmldiff][upstream] and has been modified with new features, +bug fixes, and enhancements to the original code. + +For more information on these modifications, read the [differences from rashid2538/php-htmldiff][differences] or view the [CHANGELOG][changelog]. + +## Installation + +The recommended way to install php-htmldiff is through [Composer][composer]. +Require the [caxy/php-htmldiff][badge_packagist] package by running following command: + +```sh +composer require caxy/php-htmldiff +``` + +This will resolve the latest stable version. + +Otherwise, install the library and setup the autoloader yourself. + +### Working with Symfony + +If you are using Symfony, you can use the [caxy/HtmlDiffBundle][htmldiffbundle] to make life easy! + +## Usage + +```php +use Caxy\HtmlDiff\HtmlDiff; + +$htmlDiff = new HtmlDiff($oldHtml, $newHtml); +$content = $htmlDiff->build(); +``` + +## Configuration + +The configuration for HtmlDiff is contained in the `Caxy\HtmlDiff\HtmlDiffConfig` class. + +There are two ways to set the configuration: + +1. [Configure an Existing HtmlDiff Object](#configure-an-existing-htmldiff-object) +2. [Create and Use a HtmlDiffConfig Object](#create-and-use-a-htmldiffconfig-object) + +#### Configure an Existing HtmlDiff Object + +When a new `HtmlDiff` object is created, it creates a `HtmlDiffConfig` object with the default configuration. +You can change the configuration using setters on the object: + +```php +use Caxy\HtmlDiff\HtmlDiff; + +// ... + +$htmlDiff = new HtmlDiff($oldHtml, $newHtml); + +// Set some of the configuration options. +$htmlDiff->getConfig() + ->setMatchThreshold(80) + ->setInsertSpaceInReplace(true) +; + +// Calculate the differences using the configuration and get the html diff. +$content = $htmlDiff->build(); + +// ... + +``` + +#### Create and Use a HtmlDiffConfig Object + +You can also set the configuration by creating an instance of +`Caxy\HtmlDiff\HtmlDiffConfig` and using it when creating a new `HtmlDiff` +object using `HtmlDiff::create`. + +This is useful when creating more than one instance of `HtmlDiff`: + +```php +use Caxy\HtmlDiff\HtmlDiff; +use Caxy\HtmlDiff\HtmlDiffConfig; + +// ... + +$config = new HtmlDiffConfig(); +$config + ->setMatchThreshold(95) + ->setInsertSpaceInReplace(true) +; + +// Create an HtmlDiff object with the custom configuration. +$firstHtmlDiff = HtmlDiff::create($oldHtml, $newHtml, $config); +$firstContent = $firstHtmlDiff->build(); + +$secondHtmlDiff = HtmlDiff::create($oldHtml2, $newHtml2, $config); +$secondHtmlDiff->getConfig()->setMatchThreshold(50); + +$secondContent = $secondHtmlDiff->build(); + +// ... +``` + +#### Full Configuration with Defaults: + +```php + +$config = new HtmlDiffConfig(); +$config + // Percentage required for list items to be considered a match. + ->setMatchThreshold(80) + + // Set the encoding of the text to be diffed. + ->setEncoding('UTF-8') + + // If true, a space will be added between the and tags of text that was replaced. + ->setInsertSpaceInReplace(false) + + // Option to disable the new Table Diffing feature and treat tables as regular text. + ->setUseTableDiffing(true) + + // Pass an instance of \Doctrine\Common\Cache\Cache to cache the calculated diffs. + ->setCacheProvider(null) + + // Set the cache directory that HTMLPurifier should use. + ->setPurifierCacheLocation(null) + + // Group consecutive deletions and insertions instead of showing a deletion and insertion for each word individually. + ->setGroupDiffs(true) + + // List of characters to consider part of a single word when in the middle of text. + ->setSpecialCaseChars(array('.', ',', '(', ')', '\'')) + + // List of tags to treat as special case tags. + ->setSpecialCaseTags(array('strong', 'b', 'i', 'big', 'small', 'u', 'sub', 'sup', 'strike', 's', 'p')) + + // List of tags (and their replacement strings) to be diffed in isolation. + ->setIsolatedDiffTags(array( + 'ol' => '[[REPLACE_ORDERED_LIST]]', + 'ul' => '[[REPLACE_UNORDERED_LIST]]', + 'sub' => '[[REPLACE_SUB_SCRIPT]]', + 'sup' => '[[REPLACE_SUPER_SCRIPT]]', + 'dl' => '[[REPLACE_DEFINITION_LIST]]', + 'table' => '[[REPLACE_TABLE]]', + 'strong' => '[[REPLACE_STRONG]]', + 'b' => '[[REPLACE_B]]', + 'em' => '[[REPLACE_EM]]', + 'i' => '[[REPLACE_I]]', + 'a' => '[[REPLACE_A]]', + )) +; + +``` + +## Contributing + +See [CONTRIBUTING][contributing] file. + +## Contributor Code of Conduct + +Please note that this project is released with a [Contributor Code of +Conduct][contributor_covenant]. By participating in this project +you agree to abide by its terms. See [CODE_OF_CONDUCT][code_of_conduct] file. + +## Credits + +* [rashid2538][] for the port to PHP and the base for our project: [rashid2538/php-htmldiff][upstream] +* [willdurand][] for an excellent post on [open sourcing libraries][]. +Much of this documentation is based off of the examples in the post. + +Did we miss anyone? If we did, let us know or put in a pull request! + +## License + +php-htmldiff is available under [GNU General Public License, version 2][gnu]. See the [LICENSE][license] file for details. + +[badge_score]: https://scrutinizer-ci.com/g/caxy/php-htmldiff/?branch=master +[badge_status]: https://scrutinizer-ci.com/g/caxy/php-htmldiff/build-status/master +[badge_coverage]: https://scrutinizer-ci.com/g/caxy/php-htmldiff/?branch=master +[badge_packagist]: https://packagist.org/packages/caxy/php-htmldiff +[badge_resolve]: http://isitmaintained.com/project/caxy/php-htmldiff "Average time to resolve an issue" +[badge_issues]: http://isitmaintained.com/project/caxy/php-htmldiff "Percentage of issues still open" +[upstream]: https://github.com/rashid2538/php-htmldiff +[htmldiffbundle]: https://github.com/caxy/HtmlDiffBundle +[differences]: https://github.com/caxy/php-htmldiff/blob/master/doc/differences.rst +[changelog]: https://github.com/caxy/php-htmldiff/blob/master/CHANGELOG.md +[contributing]: https://github.com/caxy/php-htmldiff/blob/master/CONTRIBUTING.md +[gnu]: http://www.gnu.org/licenses/gpl-2.0.html +[license]: https://github.com/caxy/php-htmldiff/blob/master/LICENSE +[code_of_conduct]: https://github.com/caxy/php-htmldiff/blob/master/CODE_OF_CONDUCT.md +[composer]: http://getcomposer.org/ +[contributor_covenant]: http://contributor-covenant.org/ +[rashid2538]: https://github.com/rashid2538 +[willdurand]: https://github.com/willdurand +[open sourcing libraries]: http://williamdurand.fr/2013/07/04/on-open-sourcing-libraries/ diff --git a/vendor/caxy/php-htmldiff/composer.json b/vendor/caxy/php-htmldiff/composer.json index 4eed6b5..5ef3bf6 100755 --- a/vendor/caxy/php-htmldiff/composer.json +++ b/vendor/caxy/php-htmldiff/composer.json @@ -1,43 +1,43 @@ -{ - "name": "caxy/php-htmldiff", - "type": "library", - "description": "A library for comparing two HTML files/snippets and highlighting the differences using simple HTML.", - "keywords": [ - "diff", - "html" - ], - "homepage": "https://github.com/caxy/php-htmldiff", - "license": "GPL-2.0", - "authors": [ - { - "name": "Josh Schroeder", - "email": "jschroeder@caxy.com", - "homepage": "http://www.caxy.com" - } - ], - "support": { - "issues": "https://github.com/caxy/php-htmldiff/issues" - }, - "require": { - "php": ">=5.3.3", - "ezyang/htmlpurifier": "^4.7" - }, - "require-dev": { - "phpunit/phpunit": "~4.8", - "doctrine/cache": "~1.0" - }, - "suggest": { - "doctrine/cache": "Used for caching the calculated diffs using a Doctrine Cache Provider" - }, - "autoload": { - "psr-0": { "Caxy\\HtmlDiff": "lib/" } - }, - "autoload-dev": { - "psr-4": { "Caxy\\Tests\\": "tests/Caxy/Tests" } - }, - "extra": { - "branch-alias": { - "dev-master": "0.1.x-dev" - } - } -} +{ + "name": "caxy/php-htmldiff", + "type": "library", + "description": "A library for comparing two HTML files/snippets and highlighting the differences using simple HTML.", + "keywords": [ + "diff", + "html" + ], + "homepage": "https://github.com/caxy/php-htmldiff", + "license": "GPL-2.0", + "authors": [ + { + "name": "Josh Schroeder", + "email": "jschroeder@caxy.com", + "homepage": "http://www.caxy.com" + } + ], + "support": { + "issues": "https://github.com/caxy/php-htmldiff/issues" + }, + "require": { + "php": ">=5.3.3", + "ezyang/htmlpurifier": "^4.7" + }, + "require-dev": { + "phpunit/phpunit": "~4.8", + "doctrine/cache": "~1.0" + }, + "suggest": { + "doctrine/cache": "Used for caching the calculated diffs using a Doctrine Cache Provider" + }, + "autoload": { + "psr-0": { "Caxy\\HtmlDiff": "lib/" } + }, + "autoload-dev": { + "psr-4": { "Caxy\\Tests\\": "tests/Caxy/Tests" } + }, + "extra": { + "branch-alias": { + "dev-master": "0.1.x-dev" + } + } +} diff --git a/vendor/caxy/php-htmldiff/demo/README.md b/vendor/caxy/php-htmldiff/demo/README.md index fdb5e52..eb153b1 100755 --- a/vendor/caxy/php-htmldiff/demo/README.md +++ b/vendor/caxy/php-htmldiff/demo/README.md @@ -1 +1 @@ -Just write the code as shown in php file and enjoy. +Just write the code as shown in php file and enjoy. diff --git a/vendor/caxy/php-htmldiff/demo/bower.json b/vendor/caxy/php-htmldiff/demo/bower.json index f471fa5..0425be9 100755 --- a/vendor/caxy/php-htmldiff/demo/bower.json +++ b/vendor/caxy/php-htmldiff/demo/bower.json @@ -1,16 +1,16 @@ -{ - "name": "php-htmldiff-demo", - "dependencies": { - "bootstrap": "v4.0.0-alpha.2", - "angular": "1.5.0", - "clipboard": "^1.5.8", - "font-awesome": "^4.5.0", - "angular-sanitize": "^1.5.0", - "tether": "^1.2.0", - "ng-ckeditor": "^0.2.1", - "ckeditor": "^4.5.7", - "angular-ui": "^0.4.0", - "AngularJS-Toaster": "angularjs-toaster#^1.2.0", - "angular-bootstrap": "^1.1.2" - } -} +{ + "name": "php-htmldiff-demo", + "dependencies": { + "bootstrap": "v4.0.0-alpha.2", + "angular": "1.5.0", + "clipboard": "^1.5.8", + "font-awesome": "^4.5.0", + "angular-sanitize": "^1.5.0", + "tether": "^1.2.0", + "ng-ckeditor": "^0.2.1", + "ckeditor": "^4.5.7", + "angular-ui": "^0.4.0", + "AngularJS-Toaster": "angularjs-toaster#^1.2.0", + "angular-bootstrap": "^1.1.2" + } +} diff --git a/vendor/caxy/php-htmldiff/demo/codes.css b/vendor/caxy/php-htmldiff/demo/codes.css index c9c95a8..55f1736 100755 --- a/vendor/caxy/php-htmldiff/demo/codes.css +++ b/vendor/caxy/php-htmldiff/demo/codes.css @@ -1,276 +1,276 @@ -/* - Document : codes - Created on : Sep 23, 2013, 4:41:58 PM - Author : mgersten - Description: CSS related to I-code specific display -*/ -.diff-list > li.normal, -.diff-list > li.removed, -.diff-list > li.replacement{ - display: table-row; -} -.diff-list > li.normal:before, -.diff-list > li.removed:before, -.diff-list > li.replacement:before{ - width: 15px; - overflow: hidden; - content: counters(section,".") ". "; - display: table-cell; - text-indent: -1em; - padding-left: 1em; -} - -/* overwrite width of :before on ballot pages */ -.ballot-monograph .diff-list > li.normal:before, -.ballot-monograph .diff-list > li.removed:before, -.ballot-monograph .diff-list > li.replacement:before { - width: 30px; -} - -.diff-list > li.normal:before, -li.replacement + li.replacement:before, -.diff-list > li.replacement:first-child:before{ - counter-increment: section; -} -.diff-list > li.removed:before{ - counter-increment: section; - text-decoration: line-through; -} -ol.diff-list li.removed + li.replacement { - counter-increment: none; -} -ol.diff-list li.removed + li.removed + li.replacement { - counter-increment: section -1; -} -ol.diff-list li.removed + li.removed + li.removed + li.replacement { - counter-increment: section -2; -} -ol.diff-list li.removed + li.removed + li.removed + li.removed + li.replacement { - counter-increment: section -3; -} -ol.diff-list li.removed + li.removed + li.removed + li.removed + li.removed + li.replacement { - counter-increment: section -4; -} -ol.diff-list li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.replacement { - counter-increment: section -5; -} -ol.diff-list li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.replacement { - counter-increment: section -6; -} -ol.diff-list li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.replacement { - counter-increment: section -7; -} -ol.diff-list li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.replacement { - counter-increment: section -8; -} -ol.diff-list li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.replacement { - counter-increment: section -9; -} -ol.diff-list li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.replacement{ - counter-increment: section -10; -} -ol.diff-list li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.replacement { - counter-increment: section -11; -} -.diff-list > li.replacement:before, -.diff-list > li.new:before{ - text-decoration: underline; -} -.diff-list > li > div{ - display: inline; -} -.diff-list{ - list-style: none; - counter-reset: section; - display: table; -} -.sectionContent ol, -.revision-container ol{ - list-style: none; - counter-reset: section; -} -.sectionContent ol li, -.revision-container ol li{ - position: relative; - padding: 0 0 0 30px; - color: #000000; - text-indent: 0px; -} -.sectionContent ol ol li, -.revision-container ol ol li{ - padding: 0 0 0 45px; -} -.sectionContent ol ol ol li, -.revision-container ol ol ol li{ - padding: 0 0 0 60px; -} -.sectionContent ol ol ol ol li, -.revision-container ol ol ol ol li{ - padding: 0 0 0 75px; -} -.sectionContent ol ol ol ol ol li, -.revision-container ol ol ol ol ol li{ - padding: 0 0 0 90px; -} -.sectionContent ol ol ol ol ol ol li, -.revision-container ol ol ol ol ol ol li{ - padding: 0 0 0 105px; -} -.sectionContent ol ol ol ol ol ol ol li, -.revision-container ol ol ol ol ol ol ol li{ - padding: 0 0 0 120px; -} -.sectionContent ol ol ol ol ol ol ol ol li, -.revision-container ol ol ol ol ol ol ol ol li{ - padding: 0 0 0 135px; -} -.sectionContent ol ol ol ol ol ol ol ol ol li, -.revision-container ol ol ol ol ol ol ol ol ol li{ - padding: 0 0 0 160px; -} -.sectionContent ol ol ol ol ol ol ol ol ol ol li, -.revision-container ol ol ol ol ol ol ol ol ol ol li{ - padding: 0 0 0 175px; -} -.sectionContent ol li:before, -.revision-container ol li:before{ - counter-increment: section; - content:counters(section, ".") "."; - position: absolute; - left: 0px; -} -li.italic { - font-style: italic; -} - -.sectionTitle { - text-align: center; - margin: 23px 0 15px; -} - -.precontent-title { - margin-bottom: 10px; - display: block; -} - -.secondParagraph { - text-indent: 1em; -} - -.indentedParagraph { - margin-left: 1em; -} - -.outdentOneLevel { - margin-left: -75px; -} - -ol.list-alpha-upper > li:before { - content: counter(section, upper-alpha) "."; -} - -ol.list-alpha-lower > li:before { - content: counter(section, lower-alpha) "."; -} - -ol.list-roman-upper > li:before { - content: counter(section, upper-roman) "."; -} - -ol.list-roman-lower > li:before { - content: counter(section, lower-roman) "."; -} - -ol.list-roman-lower-parentheses > li:before { - content: "(" counter(section, lower-roman) ")"; -} - -ol.list-alpha-lower-parentheses > li:before { - content: "(" counter(section, lower-alpha) ")"; -} - -ol.list-numeric-right-parenthesis > li:before { - content: counter(section) ")"; -} - -.revision-content, -.revision-content p, -.revision-content ol, -.revision-content ul, -.revision-content li, -.revision-content td, -.sectionContent, -.sectionContent p, -.sectionContent ol, -.sectionContent ul, -.sectionContent li, -.sectionContent td, -.revision-notes { - font-family: "Helvetica Neue",Helvetica,Arial,sans-serif !important; - font-size: 14px !important; - font-weight: normal !important; - line-height: 18px !important; - color:#404040 !important; -} - -.revision-content .footnotes p, -.revision-content .footnotes ol, -.revision-content .footnotes ul, -.revision-content .footnotes li, -.revision-content .footnotes td, -.sectionContent .footnotes p, -.sectionContent .footnotes ol, -.sectionContent .footnotes ul, -.sectionContent .footnotes li, -.sectionContent .footnotes td { - font-size: 12px !important; -} -.diff-list ul.exception ol , -.sectionContent ul.exception ol , -.revision-container ul.exception ol{ - list-style: none; - counter-reset: exception-section; - /* Creates a new instance of the section counter with each ol element */ -} -ul.exception, -ul.exception li:before { - list-style: none; - content: none; -} -.diff-list ul.exception ol > li:before, -.sectionContent ul.exception ol > li:before, -.revision-container ul.exception ol > li:before { - counter-increment: exception-section; - content:counters(exception-section, ".") "."; -} -.sectionContent i > sub, -.revision-container i > sub { - font-style: italic; -} -div.print-section a { - text-align: center; - color: #818181; - display: block; - text-decoration: none; - font-size: 0.8em; -} -div.print-section a.disabled { - display: none; -} - -.print-link { - color: #818181; -} -.print-link.disabled { - cursor: text; - text-decoration: none; -} - -/* Hack for generic styles that shouldn't exist in the database */ -.content_bold { - font-weight: bold; -} - -.content_italics { - font-style: italic; -} +/* + Document : codes + Created on : Sep 23, 2013, 4:41:58 PM + Author : mgersten + Description: CSS related to I-code specific display +*/ +.diff-list > li.normal, +.diff-list > li.removed, +.diff-list > li.replacement{ + display: table-row; +} +.diff-list > li.normal:before, +.diff-list > li.removed:before, +.diff-list > li.replacement:before{ + width: 15px; + overflow: hidden; + content: counters(section,".") ". "; + display: table-cell; + text-indent: -1em; + padding-left: 1em; +} + +/* overwrite width of :before on ballot pages */ +.ballot-monograph .diff-list > li.normal:before, +.ballot-monograph .diff-list > li.removed:before, +.ballot-monograph .diff-list > li.replacement:before { + width: 30px; +} + +.diff-list > li.normal:before, +li.replacement + li.replacement:before, +.diff-list > li.replacement:first-child:before{ + counter-increment: section; +} +.diff-list > li.removed:before{ + counter-increment: section; + text-decoration: line-through; +} +ol.diff-list li.removed + li.replacement { + counter-increment: none; +} +ol.diff-list li.removed + li.removed + li.replacement { + counter-increment: section -1; +} +ol.diff-list li.removed + li.removed + li.removed + li.replacement { + counter-increment: section -2; +} +ol.diff-list li.removed + li.removed + li.removed + li.removed + li.replacement { + counter-increment: section -3; +} +ol.diff-list li.removed + li.removed + li.removed + li.removed + li.removed + li.replacement { + counter-increment: section -4; +} +ol.diff-list li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.replacement { + counter-increment: section -5; +} +ol.diff-list li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.replacement { + counter-increment: section -6; +} +ol.diff-list li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.replacement { + counter-increment: section -7; +} +ol.diff-list li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.replacement { + counter-increment: section -8; +} +ol.diff-list li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.replacement { + counter-increment: section -9; +} +ol.diff-list li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.replacement{ + counter-increment: section -10; +} +ol.diff-list li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.removed + li.replacement { + counter-increment: section -11; +} +.diff-list > li.replacement:before, +.diff-list > li.new:before{ + text-decoration: underline; +} +.diff-list > li > div{ + display: inline; +} +.diff-list{ + list-style: none; + counter-reset: section; + display: table; +} +.sectionContent ol, +.revision-container ol{ + list-style: none; + counter-reset: section; +} +.sectionContent ol li, +.revision-container ol li{ + position: relative; + padding: 0 0 0 30px; + color: #000000; + text-indent: 0px; +} +.sectionContent ol ol li, +.revision-container ol ol li{ + padding: 0 0 0 45px; +} +.sectionContent ol ol ol li, +.revision-container ol ol ol li{ + padding: 0 0 0 60px; +} +.sectionContent ol ol ol ol li, +.revision-container ol ol ol ol li{ + padding: 0 0 0 75px; +} +.sectionContent ol ol ol ol ol li, +.revision-container ol ol ol ol ol li{ + padding: 0 0 0 90px; +} +.sectionContent ol ol ol ol ol ol li, +.revision-container ol ol ol ol ol ol li{ + padding: 0 0 0 105px; +} +.sectionContent ol ol ol ol ol ol ol li, +.revision-container ol ol ol ol ol ol ol li{ + padding: 0 0 0 120px; +} +.sectionContent ol ol ol ol ol ol ol ol li, +.revision-container ol ol ol ol ol ol ol ol li{ + padding: 0 0 0 135px; +} +.sectionContent ol ol ol ol ol ol ol ol ol li, +.revision-container ol ol ol ol ol ol ol ol ol li{ + padding: 0 0 0 160px; +} +.sectionContent ol ol ol ol ol ol ol ol ol ol li, +.revision-container ol ol ol ol ol ol ol ol ol ol li{ + padding: 0 0 0 175px; +} +.sectionContent ol li:before, +.revision-container ol li:before{ + counter-increment: section; + content:counters(section, ".") "."; + position: absolute; + left: 0px; +} +li.italic { + font-style: italic; +} + +.sectionTitle { + text-align: center; + margin: 23px 0 15px; +} + +.precontent-title { + margin-bottom: 10px; + display: block; +} + +.secondParagraph { + text-indent: 1em; +} + +.indentedParagraph { + margin-left: 1em; +} + +.outdentOneLevel { + margin-left: -75px; +} + +ol.list-alpha-upper > li:before { + content: counter(section, upper-alpha) "."; +} + +ol.list-alpha-lower > li:before { + content: counter(section, lower-alpha) "."; +} + +ol.list-roman-upper > li:before { + content: counter(section, upper-roman) "."; +} + +ol.list-roman-lower > li:before { + content: counter(section, lower-roman) "."; +} + +ol.list-roman-lower-parentheses > li:before { + content: "(" counter(section, lower-roman) ")"; +} + +ol.list-alpha-lower-parentheses > li:before { + content: "(" counter(section, lower-alpha) ")"; +} + +ol.list-numeric-right-parenthesis > li:before { + content: counter(section) ")"; +} + +.revision-content, +.revision-content p, +.revision-content ol, +.revision-content ul, +.revision-content li, +.revision-content td, +.sectionContent, +.sectionContent p, +.sectionContent ol, +.sectionContent ul, +.sectionContent li, +.sectionContent td, +.revision-notes { + font-family: "Helvetica Neue",Helvetica,Arial,sans-serif !important; + font-size: 14px !important; + font-weight: normal !important; + line-height: 18px !important; + color:#404040 !important; +} + +.revision-content .footnotes p, +.revision-content .footnotes ol, +.revision-content .footnotes ul, +.revision-content .footnotes li, +.revision-content .footnotes td, +.sectionContent .footnotes p, +.sectionContent .footnotes ol, +.sectionContent .footnotes ul, +.sectionContent .footnotes li, +.sectionContent .footnotes td { + font-size: 12px !important; +} +.diff-list ul.exception ol , +.sectionContent ul.exception ol , +.revision-container ul.exception ol{ + list-style: none; + counter-reset: exception-section; + /* Creates a new instance of the section counter with each ol element */ +} +ul.exception, +ul.exception li:before { + list-style: none; + content: none; +} +.diff-list ul.exception ol > li:before, +.sectionContent ul.exception ol > li:before, +.revision-container ul.exception ol > li:before { + counter-increment: exception-section; + content:counters(exception-section, ".") "."; +} +.sectionContent i > sub, +.revision-container i > sub { + font-style: italic; +} +div.print-section a { + text-align: center; + color: #818181; + display: block; + text-decoration: none; + font-size: 0.8em; +} +div.print-section a.disabled { + display: none; +} + +.print-link { + color: #818181; +} +.print-link.disabled { + cursor: text; + text-decoration: none; +} + +/* Hack for generic styles that shouldn't exist in the database */ +.content_bold { + font-weight: bold; +} + +.content_italics { + font-style: italic; +} diff --git a/vendor/caxy/php-htmldiff/demo/demo.controller.js b/vendor/caxy/php-htmldiff/demo/demo.controller.js index 8416b61..ee335e6 100755 --- a/vendor/caxy/php-htmldiff/demo/demo.controller.js +++ b/vendor/caxy/php-htmldiff/demo/demo.controller.js @@ -1,212 +1,212 @@ -(function() { - 'use strict'; - - angular - .module('demo') - .controller('DemoController', DemoController); - - DemoController.$inject = ['$q', '$http', '$sce', '$timeout']; - - function DemoController($q, $http, $sce, $timeout) { - var vm = this; - - vm.demos = []; - vm.updateDelay = 800; - vm.currentTimeout = null; - vm.loading = false; - vm.waiting = false; - vm.diffName = ''; - vm.currentDemo = null; - vm.debugOutput = {}; - vm.matchThreshold = 80; - vm.overrides = []; - vm.legislativeOverride = null; - vm.tableDiffNumber = 1; - vm.tableDiffing = true; - vm.editorOptions = {}; - vm.ckEditorEnabled = true; - - vm.trustHtml = trustHtml; - vm.reset = reset; - vm.update = update; - vm.swapText = swapText; - vm.diffDemo = diffDemo; - vm.diffOverride = diffOverride; - vm.diffTableDemo = diffTableDemo; - vm.updateDemo = updateDemo; - vm.saveNewDemo = saveNewDemo; - vm.toggleCkEditor = toggleCkEditor; - - activate(); - - function activate() { - var promises = [loadDemos(), loadOverrides()]; - return $q.all(promises).then(function() { - - }); - } - - function trustHtml(text) { - return typeof text !== 'undefined' ? $sce.trustAsHtml(text) : ''; - } - - function toggleCkEditor() { - vm.ckEditorEnabled = !vm.ckEditorEnabled; - } - - function reset() { - vm.oldText = ''; - vm.newText = ''; - vm.diff = ''; - vm.loading = false; - vm.waiting = false; - vm.currentDemo = null; - vm.legislativeOverride = null; - if (vm.currentTimeout) { - $timeout.cancel(vm.currentTimeout); - } - } - - function update() { - if (vm.currentTimeout) { - $timeout.cancel(vm.currentTimeout); - } - vm.currentTimeout = $timeout(function () { - getDiff(); - }, vm.updateDelay); - - vm.diff = null; - vm.waiting = true; - } - - function swapText() { - var oldText = vm.oldText; - vm.oldText = vm.newText; - vm.newText = oldText; - - getDiff(); - } - - function diffDemo(index) { - if (typeof index === 'undefined') { - index = 0; - } - - vm.oldText = vm.demos[index]['old']; - vm.newText = vm.demos[index]['new']; - getDiff(); - vm.currentDemo = vm.demos[index]; - vm.legislativeOverride = vm.demos[index].hasOwnProperty('legislativeOverride') ? vm.demos[index]['legislativeOverride'] : null; - } - - function diffOverride(override, index) { - vm.oldText = override.old; - vm.newText = override.new; - vm.legislativeOverride = override.override; - getDiff(); - vm.currentDemo = override; - if (!vm.currentDemo.name) { - vm.currentDemo.name = 'Override Demo ' + (index + 1); - } - vm.currentDemo.isOverride = true; - } - - function diffTableDemo(index) { - loadTableDiff(index) - .then(function(response) { - vm.oldText = response.data.old; - vm.newText = response.data.new; - vm.legislativeOverride = null; - getDiff(); - vm.currentDemo = null; - }) - .catch(function(e) { - console.log(e); - }); - } - - function updateDemo() { - vm.currentDemo.old = vm.oldText; - vm.currentDemo.new = vm.newText; - - return $http.post('save_demo.php', vm.currentDemo) - .then(function (response) { - return response; - }); - } - - function saveNewDemo() { - var newIndex = vm.demos.length + 1; - if (vm.diffName.length === 0) { - vm.diffName = 'DEMO ' + newIndex; - } - - var newDemo = {'old': vm.oldText, 'new': vm.newText, 'name': vm.diffName, 'legislativeOverride': vm.legislativeOverride}; - - vm.demos.push(newDemo); - - return $http.post('save_demo.php', newDemo) - .then(function (response) { - vm.currentDemo = newDemo; - - return vm.currentDemo; - }); - } - - function loadTableDiff(index) { - return $http({ - url: 'load_table_diff.php', - method: 'POST', - data: {index: index}, - header: {'Content-Type': 'application/json; charset=UTF-8'} - }); - } - - function getDiff() { - vm.waiting = false; - vm.loading = true; - vm.diff = null; - $http.post('index.php', { - oldText: vm.oldText, - newText: vm.newText, - matchThreshold: vm.matchThreshold, - tableDiffing: vm.tableDiffing - }) - .then(function (response) { - vm.diff = response.data.hasOwnProperty('diff') ? response.data.diff : response.data; - vm.loading = false; - addDebugOutput(response.data.debug); - }) - .catch(function (response) { - console.error('Gists error', response.status, response.data); - }); - } - - function loadDemos() { - $http.get('demos.json') - .success(function (data) { - vm.demos = data; - }); - } - - function loadOverrides() { - return $http.get('diff.json') - .then(function (response) { - vm.overrides = response.data; - - return vm.overrides; - }); - } - - function addDebugOutput(data) { - angular.forEach(data, function(value, key) { - data[key] = { - messages: value, - isCollapsed: true - }; - }); - - vm.debugOutput = data; - } - } -})(); +(function() { + 'use strict'; + + angular + .module('demo') + .controller('DemoController', DemoController); + + DemoController.$inject = ['$q', '$http', '$sce', '$timeout']; + + function DemoController($q, $http, $sce, $timeout) { + var vm = this; + + vm.demos = []; + vm.updateDelay = 800; + vm.currentTimeout = null; + vm.loading = false; + vm.waiting = false; + vm.diffName = ''; + vm.currentDemo = null; + vm.debugOutput = {}; + vm.matchThreshold = 80; + vm.overrides = []; + vm.legislativeOverride = null; + vm.tableDiffNumber = 1; + vm.tableDiffing = true; + vm.editorOptions = {}; + vm.ckEditorEnabled = true; + + vm.trustHtml = trustHtml; + vm.reset = reset; + vm.update = update; + vm.swapText = swapText; + vm.diffDemo = diffDemo; + vm.diffOverride = diffOverride; + vm.diffTableDemo = diffTableDemo; + vm.updateDemo = updateDemo; + vm.saveNewDemo = saveNewDemo; + vm.toggleCkEditor = toggleCkEditor; + + activate(); + + function activate() { + var promises = [loadDemos(), loadOverrides()]; + return $q.all(promises).then(function() { + + }); + } + + function trustHtml(text) { + return typeof text !== 'undefined' ? $sce.trustAsHtml(text) : ''; + } + + function toggleCkEditor() { + vm.ckEditorEnabled = !vm.ckEditorEnabled; + } + + function reset() { + vm.oldText = ''; + vm.newText = ''; + vm.diff = ''; + vm.loading = false; + vm.waiting = false; + vm.currentDemo = null; + vm.legislativeOverride = null; + if (vm.currentTimeout) { + $timeout.cancel(vm.currentTimeout); + } + } + + function update() { + if (vm.currentTimeout) { + $timeout.cancel(vm.currentTimeout); + } + vm.currentTimeout = $timeout(function () { + getDiff(); + }, vm.updateDelay); + + vm.diff = null; + vm.waiting = true; + } + + function swapText() { + var oldText = vm.oldText; + vm.oldText = vm.newText; + vm.newText = oldText; + + getDiff(); + } + + function diffDemo(index) { + if (typeof index === 'undefined') { + index = 0; + } + + vm.oldText = vm.demos[index]['old']; + vm.newText = vm.demos[index]['new']; + getDiff(); + vm.currentDemo = vm.demos[index]; + vm.legislativeOverride = vm.demos[index].hasOwnProperty('legislativeOverride') ? vm.demos[index]['legislativeOverride'] : null; + } + + function diffOverride(override, index) { + vm.oldText = override.old; + vm.newText = override.new; + vm.legislativeOverride = override.override; + getDiff(); + vm.currentDemo = override; + if (!vm.currentDemo.name) { + vm.currentDemo.name = 'Override Demo ' + (index + 1); + } + vm.currentDemo.isOverride = true; + } + + function diffTableDemo(index) { + loadTableDiff(index) + .then(function(response) { + vm.oldText = response.data.old; + vm.newText = response.data.new; + vm.legislativeOverride = null; + getDiff(); + vm.currentDemo = null; + }) + .catch(function(e) { + console.log(e); + }); + } + + function updateDemo() { + vm.currentDemo.old = vm.oldText; + vm.currentDemo.new = vm.newText; + + return $http.post('save_demo.php', vm.currentDemo) + .then(function (response) { + return response; + }); + } + + function saveNewDemo() { + var newIndex = vm.demos.length + 1; + if (vm.diffName.length === 0) { + vm.diffName = 'DEMO ' + newIndex; + } + + var newDemo = {'old': vm.oldText, 'new': vm.newText, 'name': vm.diffName, 'legislativeOverride': vm.legislativeOverride}; + + vm.demos.push(newDemo); + + return $http.post('save_demo.php', newDemo) + .then(function (response) { + vm.currentDemo = newDemo; + + return vm.currentDemo; + }); + } + + function loadTableDiff(index) { + return $http({ + url: 'load_table_diff.php', + method: 'POST', + data: {index: index}, + header: {'Content-Type': 'application/json; charset=UTF-8'} + }); + } + + function getDiff() { + vm.waiting = false; + vm.loading = true; + vm.diff = null; + $http.post('index.php', { + oldText: vm.oldText, + newText: vm.newText, + matchThreshold: vm.matchThreshold, + tableDiffing: vm.tableDiffing + }) + .then(function (response) { + vm.diff = response.data.hasOwnProperty('diff') ? response.data.diff : response.data; + vm.loading = false; + addDebugOutput(response.data.debug); + }) + .catch(function (response) { + console.error('Gists error', response.status, response.data); + }); + } + + function loadDemos() { + $http.get('demos.json') + .success(function (data) { + vm.demos = data; + }); + } + + function loadOverrides() { + return $http.get('diff.json') + .then(function (response) { + vm.overrides = response.data; + + return vm.overrides; + }); + } + + function addDebugOutput(data) { + angular.forEach(data, function(value, key) { + data[key] = { + messages: value, + isCollapsed: true + }; + }); + + vm.debugOutput = data; + } + } +})(); diff --git a/vendor/caxy/php-htmldiff/demo/demo.html b/vendor/caxy/php-htmldiff/demo/demo.html index 7dd779b..c08c74d 100755 --- a/vendor/caxy/php-htmldiff/demo/demo.html +++ b/vendor/caxy/php-htmldiff/demo/demo.html @@ -1,246 +1,246 @@ - - - - - - - - - - - - - - - - - - - - - - -
- -
-
- - Diff Controls - -
-
-

- Current Demo: {{ vm.currentDemo.name }} - -

-
-
-
-
- -
- -
- -
- - -
-
- - -
-
- - -
-
- - -
-
- - - - -
-
- - -
- - -
- - -
- -
- - - - - -
-
- - - - -
-
-
- - -
-
- -
- -
- -
-
- -
- -
- -
-
-
-
- - -
-
-
- - - -
- Diff Output - - {{ vm.loading ? 'Loading' : 'Waiting' }}... -
-
-
-
-
-
-
-
-
- - -
-
- - - - {{ vm.loading ? 'Loading' : 'Waiting' }}... -
-
-
-
- -
-
-
-
- - -
-
-

Debug Output

-
- -
-
-                            {{ message }}
-                        
-
-
-
-
-

Legislative Override

-
-
-
-
- - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + Diff Controls + +
+
+

+ Current Demo: {{ vm.currentDemo.name }} + +

+
+
+
+
+ +
+ +
+ +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + + + +
+
+ + +
+ + +
+ + +
+ +
+ + + + + +
+
+ + + + +
+
+
+ + +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+
+
+ + +
+
+
+ + + +
+ Diff Output + - {{ vm.loading ? 'Loading' : 'Waiting' }}... +
+
+
+
+
+
+
+
+
+ + +
+
+ + + - {{ vm.loading ? 'Loading' : 'Waiting' }}... +
+
+
+
+ +
+
+
+
+ + +
+
+

Debug Output

+
+ +
+
+                            {{ message }}
+                        
+
+
+
+
+

Legislative Override

+
+
+
+
+ + + + + + + + + + + + + + + + + + + + diff --git a/vendor/caxy/php-htmldiff/demo/demo.module.js b/vendor/caxy/php-htmldiff/demo/demo.module.js index c899d42..5e86ac6 100755 --- a/vendor/caxy/php-htmldiff/demo/demo.module.js +++ b/vendor/caxy/php-htmldiff/demo/demo.module.js @@ -1,9 +1,9 @@ -(function() { - 'use strict'; - - angular.module('demo', [ - 'ngSanitize', - 'ngCkeditor', - 'ui.bootstrap' - ]); -})(); +(function() { + 'use strict'; + + angular.module('demo', [ + 'ngSanitize', + 'ngCkeditor', + 'ui.bootstrap' + ]); +})(); diff --git a/vendor/caxy/php-htmldiff/demo/index.php b/vendor/caxy/php-htmldiff/demo/index.php index 3bb7f08..6cf7489 100755 --- a/vendor/caxy/php-htmldiff/demo/index.php +++ b/vendor/caxy/php-htmldiff/demo/index.php @@ -1,56 +1,56 @@ -setMatchThreshold($data['matchThreshold']); - } - $diff->setUseTableDiffing($useTableDiffing); - $diffOutput = $diff->build(); - $diffOutput = mb_convert_encoding($diffOutput, 'UTF-8'); - - $jsonOutput = json_encode(array('diff' => $diffOutput, 'debug' => $debugOutput)); - - if (false === $jsonOutput) { - throw new \Exception('Failed to encode JSON: '.json_last_error_msg()); - } - - echo $jsonOutput; -} else { - header('Content-Type: text/html'); - echo file_get_contents('demo.html'); -} +setMatchThreshold($data['matchThreshold']); + } + $diff->setUseTableDiffing($useTableDiffing); + $diffOutput = $diff->build(); + $diffOutput = mb_convert_encoding($diffOutput, 'UTF-8'); + + $jsonOutput = json_encode(array('diff' => $diffOutput, 'debug' => $debugOutput)); + + if (false === $jsonOutput) { + throw new \Exception('Failed to encode JSON: '.json_last_error_msg()); + } + + echo $jsonOutput; +} else { + header('Content-Type: text/html'); + echo file_get_contents('demo.html'); +} diff --git a/vendor/caxy/php-htmldiff/demo/load_table_diff.php b/vendor/caxy/php-htmldiff/demo/load_table_diff.php index 3cc6d21..c2180ad 100755 --- a/vendor/caxy/php-htmldiff/demo/load_table_diff.php +++ b/vendor/caxy/php-htmldiff/demo/load_table_diff.php @@ -1,22 +1,22 @@ - $demo) { - if ($demo['name'] === $name) { - $existingDemoIndex = $index; - break; - } -} - -if ($existingDemoIndex !== null) { - $demoStorage[$existingDemoIndex]['old'] = $oldText; - $demoStorage[$existingDemoIndex]['new'] = $newText; -} else { - $demoStorage[] = array( - 'name' => $name, - 'old' => $oldText, - 'new' => $newText, - 'legislativeOverride' => $legislativeOverride, - ); -} - -if (false === file_put_contents($jsonFile, json_encode($demoStorage))) { - throw new \Exception("Unable to save to file: $jsonFile"); -} + $demo) { + if ($demo['name'] === $name) { + $existingDemoIndex = $index; + break; + } +} + +if ($existingDemoIndex !== null) { + $demoStorage[$existingDemoIndex]['old'] = $oldText; + $demoStorage[$existingDemoIndex]['new'] = $newText; +} else { + $demoStorage[] = array( + 'name' => $name, + 'old' => $oldText, + 'new' => $newText, + 'legislativeOverride' => $legislativeOverride, + ); +} + +if (false === file_put_contents($jsonFile, json_encode($demoStorage))) { + throw new \Exception("Unable to save to file: $jsonFile"); +} diff --git a/vendor/caxy/php-htmldiff/doc/differences.rst b/vendor/caxy/php-htmldiff/doc/differences.rst index d5800f0..f0d8266 100755 --- a/vendor/caxy/php-htmldiff/doc/differences.rst +++ b/vendor/caxy/php-htmldiff/doc/differences.rst @@ -1,116 +1,116 @@ -Differences from rashid2538/php-htmldiff -======================================== - -.. contents:: Table of Contents - -Code Styling and Clean-up -------------------------- - -* Added namespaces, split up classes to their own files, some code styling changes - -Enhancements ------------- - -* Allow the specialCaseOpeningTags and specialCaseClosingTags properties to be modified by passing an array into the constructor or using set/add/remove functions -* Updated the demo to accept input and diff via AJAX -* Added static properties for the default config variables - -Bug Fixes ---------- - -* Fixed an index out of range bug (may have been fixed on the original repo since): c9ba1fa_ -* Check for empty oldText or newText before processing del or ins in processReplaceOperation function - -New Features ------------- - -Isolated Diffing of certain HTML elements -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -This is the one of the largest changes from the original repository. - -For more information, see the release notes for tag `0.0.6`_ - -List Diffing -^^^^^^^^^^^^ - -Similar to the Isolated Diffing feature, but specifically for HTML lists. - -More information is to come on this, and there will definitely be some tweaks and configuration options added for this -feature. Currently there is no easy way to enable/disable the feature, so if you're having issues with it I suggest -using the `0.0.6`_ or earlier release. - -Table Diffing -^^^^^^^^^^^^^ - -Similar to the Isolated Diffing and List Diffing features, but specifically for HTML tables. - -More information to come on this soon. - -New option to group together diffed words by not matching on whitespace-only. Option is enabled by default. -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -This was a specific requirement for an application we use this library for. The original library would replace -single words at a time, but enabling this feature will group replacements instead. See example below. - -Old Text:: - - testing some text here and there - -New Text:: - - testing other words here and there - -With $groupDiffs = false (original functionality):: - - testing someother textwords here and there - -With $groupDiffs = true (new feature):: - - testing some textother words here and there - -Change diffing to strike through entire words/numbers if they contain periods or commas within the word -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -This change introduced a new property ``$specialCaseChars``, which defaults to the following characters: ``.`` ``,`` ``(`` ``)`` ``'`` - -This feature can be "disabled" by simply setting the $specialCaseChars to an empty array i.e. ``$diff->setSpecialCaseChars(array())`` - -In the original library, special characters are treated as their own "words" even if they are in the middle of a word. -This causes weird things to happen when diffing numbers that have a comma or a period in the middle of the number. - -For example, diffing ``10,000.50`` against ``11,100.75`` gives you: - -Original Functionality:: - - 1011,000100.5075 - -This is very difficult to read, so the new feature allows you to add ``.`` and ``,`` to the ``$specialCaseChars`` array in order -to get output that looks like:: - - 10,000.5011,100.75 - -Note: It will *not* treat the specialCaseChars as part of the word if it is at the beginning or end of the word, -so normal periods or commas at the end of words will still be diffed like the original. - -Added option to insert a space between ```` and ```` tags. Disabled by default. -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -This was a requirement for one our applications that uses this library. - -New property ``$insertSpaceInReplace`` was added, and setting it to true will simply add a space between -the ```` and ```` tags in replace operations, which was requested for easier reading. - -Enable it by calling ``$diff->setInsertSpaceInReplace(true);`` - -Original Functionality:: - - OldNew - -New Functionality:: - - Old New - -.. _c9ba1fa: https://github.com/caxy/php-htmldiff/commit/c9ba1fab6777cd47427477f8d747293bb01ef1e8 -.. _0.0.6: https://github.com/caxy/php-htmldiff/releases/tag/0.0.6 - +Differences from rashid2538/php-htmldiff +======================================== + +.. contents:: Table of Contents + +Code Styling and Clean-up +------------------------- + +* Added namespaces, split up classes to their own files, some code styling changes + +Enhancements +------------ + +* Allow the specialCaseOpeningTags and specialCaseClosingTags properties to be modified by passing an array into the constructor or using set/add/remove functions +* Updated the demo to accept input and diff via AJAX +* Added static properties for the default config variables + +Bug Fixes +--------- + +* Fixed an index out of range bug (may have been fixed on the original repo since): c9ba1fa_ +* Check for empty oldText or newText before processing del or ins in processReplaceOperation function + +New Features +------------ + +Isolated Diffing of certain HTML elements +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This is the one of the largest changes from the original repository. + +For more information, see the release notes for tag `0.0.6`_ + +List Diffing +^^^^^^^^^^^^ + +Similar to the Isolated Diffing feature, but specifically for HTML lists. + +More information is to come on this, and there will definitely be some tweaks and configuration options added for this +feature. Currently there is no easy way to enable/disable the feature, so if you're having issues with it I suggest +using the `0.0.6`_ or earlier release. + +Table Diffing +^^^^^^^^^^^^^ + +Similar to the Isolated Diffing and List Diffing features, but specifically for HTML tables. + +More information to come on this soon. + +New option to group together diffed words by not matching on whitespace-only. Option is enabled by default. +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This was a specific requirement for an application we use this library for. The original library would replace +single words at a time, but enabling this feature will group replacements instead. See example below. + +Old Text:: + + testing some text here and there + +New Text:: + + testing other words here and there + +With $groupDiffs = false (original functionality):: + + testing someother textwords here and there + +With $groupDiffs = true (new feature):: + + testing some textother words here and there + +Change diffing to strike through entire words/numbers if they contain periods or commas within the word +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This change introduced a new property ``$specialCaseChars``, which defaults to the following characters: ``.`` ``,`` ``(`` ``)`` ``'`` + +This feature can be "disabled" by simply setting the $specialCaseChars to an empty array i.e. ``$diff->setSpecialCaseChars(array())`` + +In the original library, special characters are treated as their own "words" even if they are in the middle of a word. +This causes weird things to happen when diffing numbers that have a comma or a period in the middle of the number. + +For example, diffing ``10,000.50`` against ``11,100.75`` gives you: + +Original Functionality:: + + 1011,000100.5075 + +This is very difficult to read, so the new feature allows you to add ``.`` and ``,`` to the ``$specialCaseChars`` array in order +to get output that looks like:: + + 10,000.5011,100.75 + +Note: It will *not* treat the specialCaseChars as part of the word if it is at the beginning or end of the word, +so normal periods or commas at the end of words will still be diffed like the original. + +Added option to insert a space between ```` and ```` tags. Disabled by default. +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This was a requirement for one our applications that uses this library. + +New property ``$insertSpaceInReplace`` was added, and setting it to true will simply add a space between +the ```` and ```` tags in replace operations, which was requested for easier reading. + +Enable it by calling ``$diff->setInsertSpaceInReplace(true);`` + +Original Functionality:: + + OldNew + +New Functionality:: + + Old New + +.. _c9ba1fa: https://github.com/caxy/php-htmldiff/commit/c9ba1fab6777cd47427477f8d747293bb01ef1e8 +.. _0.0.6: https://github.com/caxy/php-htmldiff/releases/tag/0.0.6 + diff --git a/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/AbstractDiff.php b/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/AbstractDiff.php index dbaac06..ea0ad10 100755 --- a/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/AbstractDiff.php +++ b/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/AbstractDiff.php @@ -1,490 +1,490 @@ -config = HtmlDiffConfig::create()->setEncoding($encoding); - - if ($specialCaseTags !== null) { - $this->config->setSpecialCaseTags($specialCaseTags); - } - - if ($groupDiffs !== null) { - $this->config->setGroupDiffs($groupDiffs); - } - - $this->oldText = $this->purifyHtml(trim($oldText)); - $this->newText = $this->purifyHtml(trim($newText)); - $this->content = ''; - } - - /** - * @return bool|string - */ - abstract public function build(); - - /** - * @return DiffCache|null - */ - protected function getDiffCache() - { - if (!$this->hasDiffCache()) { - return null; - } - - $hash = spl_object_hash($this->getConfig()->getCacheProvider()); - - if (!array_key_exists($hash, $this->diffCaches)) { - $this->diffCaches[$hash] = new DiffCache($this->getConfig()->getCacheProvider()); - } - - return $this->diffCaches[$hash]; - } - - /** - * @return bool - */ - protected function hasDiffCache() - { - return null !== $this->getConfig()->getCacheProvider(); - } - - /** - * @return HtmlDiffConfig - */ - public function getConfig() - { - return $this->config; - } - - /** - * @param HtmlDiffConfig $config - * - * @return AbstractDiff - */ - public function setConfig(HtmlDiffConfig $config) - { - $this->config = $config; - - return $this; - } - - /** - * @return int - * - * @deprecated since 0.1.0 - */ - public function getMatchThreshold() - { - return $this->config->getMatchThreshold(); - } - - /** - * @param int $matchThreshold - * - * @return AbstractDiff - * - * @deprecated since 0.1.0 - */ - public function setMatchThreshold($matchThreshold) - { - $this->config->setMatchThreshold($matchThreshold); - - return $this; - } - - /** - * @param array $chars - * - * @deprecated since 0.1.0 - */ - public function setSpecialCaseChars(array $chars) - { - $this->config->setSpecialCaseChars($chars); - } - - /** - * @return array|null - * - * @deprecated since 0.1.0 - */ - public function getSpecialCaseChars() - { - return $this->config->getSpecialCaseChars(); - } - - /** - * @param string $char - * - * @deprecated since 0.1.0 - */ - public function addSpecialCaseChar($char) - { - $this->config->addSpecialCaseChar($char); - } - - /** - * @param string $char - * - * @deprecated since 0.1.0 - */ - public function removeSpecialCaseChar($char) - { - $this->config->removeSpecialCaseChar($char); - } - - /** - * @param array $tags - * - * @deprecated since 0.1.0 - */ - public function setSpecialCaseTags(array $tags = array()) - { - $this->config->setSpecialCaseChars($tags); - } - - /** - * @param string $tag - * - * @deprecated since 0.1.0 - */ - public function addSpecialCaseTag($tag) - { - $this->config->addSpecialCaseTag($tag); - } - - /** - * @param string $tag - * - * @deprecated since 0.1.0 - */ - public function removeSpecialCaseTag($tag) - { - $this->config->removeSpecialCaseTag($tag); - } - - /** - * @return array|null - * - * @deprecated since 0.1.0 - */ - public function getSpecialCaseTags() - { - return $this->config->getSpecialCaseTags(); - } - - /** - * @return string - */ - public function getOldHtml() - { - return $this->oldText; - } - - /** - * @return string - */ - public function getNewHtml() - { - return $this->newText; - } - - /** - * @return string - */ - public function getDifference() - { - return $this->content; - } - - /** - * @param bool $boolean - * - * @return $this - * - * @deprecated since 0.1.0 - */ - public function setGroupDiffs($boolean) - { - $this->config->setGroupDiffs($boolean); - - return $this; - } - - /** - * @return bool - * - * @deprecated since 0.1.0 - */ - public function isGroupDiffs() - { - return $this->config->isGroupDiffs(); - } - - /** - * @param string $tag - * - * @return string - */ - protected function getOpeningTag($tag) - { - return "/<".$tag."[^>]*/i"; - } - - /** - * @param string $tag - * - * @return string - */ - protected function getClosingTag($tag) - { - return ""; - } - - /** - * @param string $str - * @param string $start - * @param string $end - * - * @return string - */ - protected function getStringBetween($str, $start, $end) - { - $expStr = explode( $start, $str, 2 ); - if ( count( $expStr ) > 1 ) { - $expStr = explode( $end, $expStr[ 1 ] ); - if ( count( $expStr ) > 1 ) { - array_pop( $expStr ); - - return implode( $end, $expStr ); - } - } - - return ''; - } - - /** - * @param string $html - * - * @return string - */ - protected function purifyHtml($html) - { - if ( class_exists( 'Tidy' ) && false ) { - $config = array( 'output-xhtml' => true, 'indent' => false ); - $tidy = new tidy(); - $tidy->parseString( $html, $config, 'utf8' ); - $html = (string) $tidy; - - return $this->getStringBetween( $html, '' ); - } - - return $html; - } - - protected function splitInputsToWords() - { - $this->oldWords = $this->convertHtmlToListOfWords( $this->explode( $this->oldText ) ); - $this->newWords = $this->convertHtmlToListOfWords( $this->explode( $this->newText ) ); - } - - /** - * @param string $text - * - * @return bool - */ - protected function isPartOfWord($text) - { - return ctype_alnum(str_replace($this->config->getSpecialCaseChars(), '', $text)); - } - - /** - * @param array $characterString - * - * @return array - */ - protected function convertHtmlToListOfWords($characterString) - { - $mode = 'character'; - $current_word = ''; - $words = array(); - foreach ($characterString as $i => $character) { - switch ($mode) { - case 'character': - if ( $this->isStartOfTag( $character ) ) { - if ($current_word != '') { - $words[] = $current_word; - } - $current_word = "<"; - $mode = 'tag'; - } elseif (preg_match("/\s/", $character)) { - if ($current_word !== '') { - $words[] = $current_word; - } - $current_word = preg_replace('/\s+/S', ' ', $character); - $mode = 'whitespace'; - } else { - if ( - (ctype_alnum($character) && (strlen($current_word) == 0 || $this->isPartOfWord($current_word))) || - (in_array($character, $this->config->getSpecialCaseChars()) && isset($characterString[$i+1]) && $this->isPartOfWord($characterString[$i+1])) - ) { - $current_word .= $character; - } else { - $words[] = $current_word; - $current_word = $character; - } - } - break; - case 'tag' : - if ( $this->isEndOfTag( $character ) ) { - $current_word .= ">"; - $words[] = $current_word; - $current_word = ""; - - if ( !preg_match('[^\s]', $character ) ) { - $mode = 'whitespace'; - } else { - $mode = 'character'; - } - } else { - $current_word .= $character; - } - break; - case 'whitespace': - if ( $this->isStartOfTag( $character ) ) { - if ($current_word !== '') { - $words[] = $current_word; - } - $current_word = "<"; - $mode = 'tag'; - } elseif ( preg_match( "/\s/", $character ) ) { - $current_word .= $character; - $current_word = preg_replace('/\s+/S', ' ', $current_word); - } else { - if ($current_word != '') { - $words[] = $current_word; - } - $current_word = $character; - $mode = 'character'; - } - break; - default: - break; - } - } - if ($current_word != '') { - $words[] = $current_word; - } - - return $words; - } - - /** - * @param string $val - * - * @return bool - */ - protected function isStartOfTag($val) - { - return $val == "<"; - } - - /** - * @param string $val - * - * @return bool - */ - protected function isEndOfTag($val) - { - return $val == ">"; - } - - /** - * @param string $value - * - * @return bool - */ - protected function isWhiteSpace($value) - { - return !preg_match( '[^\s]', $value ); - } - - /** - * @param string $value - * - * @return array - */ - protected function explode($value) - { - // as suggested by @onassar - return preg_split( '//u', $value ); - } -} +config = HtmlDiffConfig::create()->setEncoding($encoding); + + if ($specialCaseTags !== null) { + $this->config->setSpecialCaseTags($specialCaseTags); + } + + if ($groupDiffs !== null) { + $this->config->setGroupDiffs($groupDiffs); + } + + $this->oldText = $this->purifyHtml(trim($oldText)); + $this->newText = $this->purifyHtml(trim($newText)); + $this->content = ''; + } + + /** + * @return bool|string + */ + abstract public function build(); + + /** + * @return DiffCache|null + */ + protected function getDiffCache() + { + if (!$this->hasDiffCache()) { + return null; + } + + $hash = spl_object_hash($this->getConfig()->getCacheProvider()); + + if (!array_key_exists($hash, $this->diffCaches)) { + $this->diffCaches[$hash] = new DiffCache($this->getConfig()->getCacheProvider()); + } + + return $this->diffCaches[$hash]; + } + + /** + * @return bool + */ + protected function hasDiffCache() + { + return null !== $this->getConfig()->getCacheProvider(); + } + + /** + * @return HtmlDiffConfig + */ + public function getConfig() + { + return $this->config; + } + + /** + * @param HtmlDiffConfig $config + * + * @return AbstractDiff + */ + public function setConfig(HtmlDiffConfig $config) + { + $this->config = $config; + + return $this; + } + + /** + * @return int + * + * @deprecated since 0.1.0 + */ + public function getMatchThreshold() + { + return $this->config->getMatchThreshold(); + } + + /** + * @param int $matchThreshold + * + * @return AbstractDiff + * + * @deprecated since 0.1.0 + */ + public function setMatchThreshold($matchThreshold) + { + $this->config->setMatchThreshold($matchThreshold); + + return $this; + } + + /** + * @param array $chars + * + * @deprecated since 0.1.0 + */ + public function setSpecialCaseChars(array $chars) + { + $this->config->setSpecialCaseChars($chars); + } + + /** + * @return array|null + * + * @deprecated since 0.1.0 + */ + public function getSpecialCaseChars() + { + return $this->config->getSpecialCaseChars(); + } + + /** + * @param string $char + * + * @deprecated since 0.1.0 + */ + public function addSpecialCaseChar($char) + { + $this->config->addSpecialCaseChar($char); + } + + /** + * @param string $char + * + * @deprecated since 0.1.0 + */ + public function removeSpecialCaseChar($char) + { + $this->config->removeSpecialCaseChar($char); + } + + /** + * @param array $tags + * + * @deprecated since 0.1.0 + */ + public function setSpecialCaseTags(array $tags = array()) + { + $this->config->setSpecialCaseChars($tags); + } + + /** + * @param string $tag + * + * @deprecated since 0.1.0 + */ + public function addSpecialCaseTag($tag) + { + $this->config->addSpecialCaseTag($tag); + } + + /** + * @param string $tag + * + * @deprecated since 0.1.0 + */ + public function removeSpecialCaseTag($tag) + { + $this->config->removeSpecialCaseTag($tag); + } + + /** + * @return array|null + * + * @deprecated since 0.1.0 + */ + public function getSpecialCaseTags() + { + return $this->config->getSpecialCaseTags(); + } + + /** + * @return string + */ + public function getOldHtml() + { + return $this->oldText; + } + + /** + * @return string + */ + public function getNewHtml() + { + return $this->newText; + } + + /** + * @return string + */ + public function getDifference() + { + return $this->content; + } + + /** + * @param bool $boolean + * + * @return $this + * + * @deprecated since 0.1.0 + */ + public function setGroupDiffs($boolean) + { + $this->config->setGroupDiffs($boolean); + + return $this; + } + + /** + * @return bool + * + * @deprecated since 0.1.0 + */ + public function isGroupDiffs() + { + return $this->config->isGroupDiffs(); + } + + /** + * @param string $tag + * + * @return string + */ + protected function getOpeningTag($tag) + { + return "/<".$tag."[^>]*/i"; + } + + /** + * @param string $tag + * + * @return string + */ + protected function getClosingTag($tag) + { + return ""; + } + + /** + * @param string $str + * @param string $start + * @param string $end + * + * @return string + */ + protected function getStringBetween($str, $start, $end) + { + $expStr = explode( $start, $str, 2 ); + if ( count( $expStr ) > 1 ) { + $expStr = explode( $end, $expStr[ 1 ] ); + if ( count( $expStr ) > 1 ) { + array_pop( $expStr ); + + return implode( $end, $expStr ); + } + } + + return ''; + } + + /** + * @param string $html + * + * @return string + */ + protected function purifyHtml($html) + { + if ( class_exists( 'Tidy' ) && false ) { + $config = array( 'output-xhtml' => true, 'indent' => false ); + $tidy = new tidy(); + $tidy->parseString( $html, $config, 'utf8' ); + $html = (string) $tidy; + + return $this->getStringBetween( $html, '' ); + } + + return $html; + } + + protected function splitInputsToWords() + { + $this->oldWords = $this->convertHtmlToListOfWords( $this->explode( $this->oldText ) ); + $this->newWords = $this->convertHtmlToListOfWords( $this->explode( $this->newText ) ); + } + + /** + * @param string $text + * + * @return bool + */ + protected function isPartOfWord($text) + { + return ctype_alnum(str_replace($this->config->getSpecialCaseChars(), '', $text)); + } + + /** + * @param array $characterString + * + * @return array + */ + protected function convertHtmlToListOfWords($characterString) + { + $mode = 'character'; + $current_word = ''; + $words = array(); + foreach ($characterString as $i => $character) { + switch ($mode) { + case 'character': + if ( $this->isStartOfTag( $character ) ) { + if ($current_word != '') { + $words[] = $current_word; + } + $current_word = "<"; + $mode = 'tag'; + } elseif (preg_match("/\s/", $character)) { + if ($current_word !== '') { + $words[] = $current_word; + } + $current_word = preg_replace('/\s+/S', ' ', $character); + $mode = 'whitespace'; + } else { + if ( + (ctype_alnum($character) && (strlen($current_word) == 0 || $this->isPartOfWord($current_word))) || + (in_array($character, $this->config->getSpecialCaseChars()) && isset($characterString[$i+1]) && $this->isPartOfWord($characterString[$i+1])) + ) { + $current_word .= $character; + } else { + $words[] = $current_word; + $current_word = $character; + } + } + break; + case 'tag' : + if ( $this->isEndOfTag( $character ) ) { + $current_word .= ">"; + $words[] = $current_word; + $current_word = ""; + + if ( !preg_match('[^\s]', $character ) ) { + $mode = 'whitespace'; + } else { + $mode = 'character'; + } + } else { + $current_word .= $character; + } + break; + case 'whitespace': + if ( $this->isStartOfTag( $character ) ) { + if ($current_word !== '') { + $words[] = $current_word; + } + $current_word = "<"; + $mode = 'tag'; + } elseif ( preg_match( "/\s/", $character ) ) { + $current_word .= $character; + $current_word = preg_replace('/\s+/S', ' ', $current_word); + } else { + if ($current_word != '') { + $words[] = $current_word; + } + $current_word = $character; + $mode = 'character'; + } + break; + default: + break; + } + } + if ($current_word != '') { + $words[] = $current_word; + } + + return $words; + } + + /** + * @param string $val + * + * @return bool + */ + protected function isStartOfTag($val) + { + return $val == "<"; + } + + /** + * @param string $val + * + * @return bool + */ + protected function isEndOfTag($val) + { + return $val == ">"; + } + + /** + * @param string $value + * + * @return bool + */ + protected function isWhiteSpace($value) + { + return !preg_match( '[^\s]', $value ); + } + + /** + * @param string $value + * + * @return array + */ + protected function explode($value) + { + // as suggested by @onassar + return preg_split( '//u', $value ); + } +} diff --git a/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/DiffCache.php b/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/DiffCache.php index 434be0f..e3d6c4f 100755 --- a/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/DiffCache.php +++ b/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/DiffCache.php @@ -1,112 +1,112 @@ -cacheProvider = $cacheProvider; - } - - /** - * @return Cache - */ - public function getCacheProvider() - { - return $this->cacheProvider; - } - - /** - * @param Cache $cacheProvider - * - * @return DiffCache - */ - public function setCacheProvider($cacheProvider) - { - $this->cacheProvider = $cacheProvider; - - return $this; - } - - /** - * @param string $oldText - * @param string $newText - * - * @return bool - */ - public function contains($oldText, $newText) - { - return $this->cacheProvider->contains($this->getHashKey($oldText, $newText)); - } - - /** - * @param string $oldText - * @param string $newText - * - * @return string - */ - public function fetch($oldText, $newText) - { - return $this->cacheProvider->fetch($this->getHashKey($oldText, $newText)); - } - - /** - * @param string $oldText - * @param string $newText - * @param string $data - * @param int $lifeTime - * - * @return bool - */ - public function save($oldText, $newText, $data, $lifeTime = 0) - { - return $this->cacheProvider->save($this->getHashKey($oldText, $newText), $data, $lifeTime); - } - - /** - * @param string $oldText - * @param string $newText - * - * @return bool - */ - public function delete($oldText, $newText) - { - return $this->cacheProvider->delete($this->getHashKey($oldText, $newText)); - } - - /** - * @return array|null - */ - public function getStats() - { - return $this->cacheProvider->getStats(); - } - - /** - * @param string $oldText - * @param string $newText - * - * @return string - */ - protected function getHashKey($oldText, $newText) - { - return sprintf('%s_%s', md5($oldText), md5($newText)); - } -} +cacheProvider = $cacheProvider; + } + + /** + * @return Cache + */ + public function getCacheProvider() + { + return $this->cacheProvider; + } + + /** + * @param Cache $cacheProvider + * + * @return DiffCache + */ + public function setCacheProvider($cacheProvider) + { + $this->cacheProvider = $cacheProvider; + + return $this; + } + + /** + * @param string $oldText + * @param string $newText + * + * @return bool + */ + public function contains($oldText, $newText) + { + return $this->cacheProvider->contains($this->getHashKey($oldText, $newText)); + } + + /** + * @param string $oldText + * @param string $newText + * + * @return string + */ + public function fetch($oldText, $newText) + { + return $this->cacheProvider->fetch($this->getHashKey($oldText, $newText)); + } + + /** + * @param string $oldText + * @param string $newText + * @param string $data + * @param int $lifeTime + * + * @return bool + */ + public function save($oldText, $newText, $data, $lifeTime = 0) + { + return $this->cacheProvider->save($this->getHashKey($oldText, $newText), $data, $lifeTime); + } + + /** + * @param string $oldText + * @param string $newText + * + * @return bool + */ + public function delete($oldText, $newText) + { + return $this->cacheProvider->delete($this->getHashKey($oldText, $newText)); + } + + /** + * @return array|null + */ + public function getStats() + { + return $this->cacheProvider->getStats(); + } + + /** + * @param string $oldText + * @param string $newText + * + * @return string + */ + protected function getHashKey($oldText, $newText) + { + return sprintf('%s_%s', md5($oldText), md5($newText)); + } +} diff --git a/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/HtmlDiff.php b/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/HtmlDiff.php index 11ab295..e8ca2bb 100755 --- a/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/HtmlDiff.php +++ b/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/HtmlDiff.php @@ -1,795 +1,795 @@ -setConfig($config); - } - - return $diff; - } - - /** - * @param $bool - * - * @return $this - * - * @deprecated since 0.1.0 - */ - public function setUseTableDiffing($bool) - { - $this->config->setUseTableDiffing($bool); - - return $this; - } - - /** - * @param boolean $boolean - * @return HtmlDiff - * - * @deprecated since 0.1.0 - */ - public function setInsertSpaceInReplace($boolean) - { - $this->config->setInsertSpaceInReplace($boolean); - - return $this; - } - - /** - * @return boolean - * - * @deprecated since 0.1.0 - */ - public function getInsertSpaceInReplace() - { - return $this->config->isInsertSpaceInReplace(); - } - - /** - * @return string - */ - public function build() - { - if ($this->hasDiffCache() && $this->getDiffCache()->contains($this->oldText, $this->newText)) { - $this->content = $this->getDiffCache()->fetch($this->oldText, $this->newText); - - return $this->content; - } - - $this->splitInputsToWords(); - $this->replaceIsolatedDiffTags(); - $this->indexNewWords(); - - $operations = $this->operations(); - foreach ($operations as $item) { - $this->performOperation( $item ); - } - - if ($this->hasDiffCache()) { - $this->getDiffCache()->save($this->oldText, $this->newText, $this->content); - } - - return $this->content; - } - - protected function indexNewWords() - { - $this->wordIndices = array(); - foreach ($this->newWords as $i => $word) { - if ( $this->isTag( $word ) ) { - $word = $this->stripTagAttributes( $word ); - } - if ( isset( $this->wordIndices[ $word ] ) ) { - $this->wordIndices[ $word ][] = $i; - } else { - $this->wordIndices[ $word ] = array( $i ); - } - } - } - - protected function replaceIsolatedDiffTags() - { - $this->oldIsolatedDiffTags = $this->createIsolatedDiffTagPlaceholders($this->oldWords); - $this->newIsolatedDiffTags = $this->createIsolatedDiffTagPlaceholders($this->newWords); - } - - /** - * @param array $words - * - * @return array - */ - protected function createIsolatedDiffTagPlaceholders(&$words) - { - $openIsolatedDiffTags = 0; - $isolatedDiffTagIndicies = array(); - $isolatedDiffTagStart = 0; - $currentIsolatedDiffTag = null; - foreach ($words as $index => $word) { - $openIsolatedDiffTag = $this->isOpeningIsolatedDiffTag($word, $currentIsolatedDiffTag); - if ($openIsolatedDiffTag) { - if ($openIsolatedDiffTags === 0) { - $isolatedDiffTagStart = $index; - } - $openIsolatedDiffTags++; - $currentIsolatedDiffTag = $openIsolatedDiffTag; - } elseif ($openIsolatedDiffTags > 0 && $this->isClosingIsolatedDiffTag($word, $currentIsolatedDiffTag)) { - $openIsolatedDiffTags--; - if ($openIsolatedDiffTags == 0) { - $isolatedDiffTagIndicies[] = array ('start' => $isolatedDiffTagStart, 'length' => $index - $isolatedDiffTagStart + 1, 'tagType' => $currentIsolatedDiffTag); - $currentIsolatedDiffTag = null; - } - } - } - $isolatedDiffTagScript = array(); - $offset = 0; - foreach ($isolatedDiffTagIndicies as $isolatedDiffTagIndex) { - $start = $isolatedDiffTagIndex['start'] - $offset; - $placeholderString = $this->config->getIsolatedDiffTagPlaceholder($isolatedDiffTagIndex['tagType']); - $isolatedDiffTagScript[$start] = array_splice($words, $start, $isolatedDiffTagIndex['length'], $placeholderString); - $offset += $isolatedDiffTagIndex['length'] - 1; - } - - return $isolatedDiffTagScript; - - } - - /** - * @param string $item - * @param null|string $currentIsolatedDiffTag - * - * @return false|string - */ - protected function isOpeningIsolatedDiffTag($item, $currentIsolatedDiffTag = null) - { - $tagsToMatch = $currentIsolatedDiffTag !== null - ? array($currentIsolatedDiffTag => $this->config->getIsolatedDiffTagPlaceholder($currentIsolatedDiffTag)) - : $this->config->getIsolatedDiffTags(); - foreach ($tagsToMatch as $key => $value) { - if (preg_match("#<".$key."[^>]*>\\s*#iU", $item)) { - return $key; - } - } - - return false; - } - - /** - * @param string $item - * @param null|string $currentIsolatedDiffTag - * - * @return false|string - */ - protected function isClosingIsolatedDiffTag($item, $currentIsolatedDiffTag = null) - { - $tagsToMatch = $currentIsolatedDiffTag !== null - ? array($currentIsolatedDiffTag => $this->config->getIsolatedDiffTagPlaceholder($currentIsolatedDiffTag)) - : $this->config->getIsolatedDiffTags(); - foreach ($tagsToMatch as $key => $value) { - if (preg_match("#]*>\\s*#iU", $item)) { - return $key; - } - } - - return false; - } - - /** - * @param Operation $operation - */ - protected function performOperation($operation) - { - switch ($operation->action) { - case 'equal' : - $this->processEqualOperation( $operation ); - break; - case 'delete' : - $this->processDeleteOperation( $operation, "diffdel" ); - break; - case 'insert' : - $this->processInsertOperation( $operation, "diffins"); - break; - case 'replace': - $this->processReplaceOperation( $operation ); - break; - default: - break; - } - } - - /** - * @param Operation $operation - */ - protected function processReplaceOperation($operation) - { - $this->processDeleteOperation( $operation, "diffmod" ); - $this->processInsertOperation( $operation, "diffmod" ); - } - - /** - * @param Operation $operation - * @param string $cssClass - */ - protected function processInsertOperation($operation, $cssClass) - { - $text = array(); - foreach ($this->newWords as $pos => $s) { - if ($pos >= $operation->startInNew && $pos < $operation->endInNew) { - if ($this->config->isIsolatedDiffTagPlaceholder($s) && isset($this->newIsolatedDiffTags[$pos])) { - foreach ($this->newIsolatedDiffTags[$pos] as $word) { - $text[] = $word; - } - } else { - $text[] = $s; - } - } - } - $this->insertTag( "ins", $cssClass, $text ); - } - - /** - * @param Operation $operation - * @param string $cssClass - */ - protected function processDeleteOperation($operation, $cssClass) - { - $text = array(); - foreach ($this->oldWords as $pos => $s) { - if ($pos >= $operation->startInOld && $pos < $operation->endInOld) { - if ($this->config->isIsolatedDiffTagPlaceholder($s) && isset($this->oldIsolatedDiffTags[$pos])) { - foreach ($this->oldIsolatedDiffTags[$pos] as $word) { - $text[] = $word; - } - } else { - $text[] = $s; - } - } - } - $this->insertTag( "del", $cssClass, $text ); - } - - /** - * @param Operation $operation - * @param int $pos - * @param string $placeholder - * @param bool $stripWrappingTags - * - * @return string - */ - protected function diffIsolatedPlaceholder($operation, $pos, $placeholder, $stripWrappingTags = true) - { - $oldText = implode("", $this->findIsolatedDiffTagsInOld($operation, $pos)); - $newText = implode("", $this->newIsolatedDiffTags[$pos]); - - if ($this->isListPlaceholder($placeholder)) { - return $this->diffList($oldText, $newText); - } elseif ($this->config->isUseTableDiffing() && $this->isTablePlaceholder($placeholder)) { - return $this->diffTables($oldText, $newText); - } elseif ($this->isLinkPlaceholder($placeholder)) { - return $this->diffLinks($oldText, $newText); - } - - return $this->diffElements($oldText, $newText, $stripWrappingTags); - } - - /** - * @param string $oldText - * @param string $newText - * @param bool $stripWrappingTags - * - * @return string - */ - protected function diffElements($oldText, $newText, $stripWrappingTags = true) - { - $wrapStart = ''; - $wrapEnd = ''; - - if ($stripWrappingTags) { - $pattern = '/(^<[^>]+>)|(<\/[^>]+>$)/i'; - $matches = array(); - - if (preg_match_all($pattern, $newText, $matches)) { - $wrapStart = isset($matches[0][0]) ? $matches[0][0] : ''; - $wrapEnd = isset($matches[0][1]) ? $matches[0][1] : ''; - } - $oldText = preg_replace($pattern, '', $oldText); - $newText = preg_replace($pattern, '', $newText); - } - - $diff = HtmlDiff::create($oldText, $newText, $this->config); - - return $wrapStart . $diff->build() . $wrapEnd; - } - - /** - * @param string $oldText - * @param string $newText - * - * @return string - */ - protected function diffList($oldText, $newText) - { - $diff = ListDiffNew::create($oldText, $newText, $this->config); - - return $diff->build(); - } - - /** - * @param string $oldText - * @param string $newText - * - * @return string - */ - protected function diffTables($oldText, $newText) - { - $diff = TableDiff::create($oldText, $newText, $this->config); - - return $diff->build(); - } - - /** - * @param string $oldText - * @param string $newText - * - * @return string - */ - protected function diffLinks($oldText, $newText) - { - $oldHref = $this->getAttributeFromTag($oldText, 'href'); - $newHref = $this->getAttributeFromTag($newText, 'href'); - - if ($oldHref != $newHref) { - return sprintf( - '%s%s', - $this->wrapText($oldText, 'del', 'diffmod diff-href'), - $this->wrapText($newText, 'ins', 'diffmod diff-href') - ); - } - - return $this->diffElements($oldText, $newText); - } - - /** - * @param Operation $operation - */ - protected function processEqualOperation($operation) - { - $result = array(); - foreach ($this->newWords as $pos => $s) { - - if ($pos >= $operation->startInNew && $pos < $operation->endInNew) { - if ($this->config->isIsolatedDiffTagPlaceholder($s) && isset($this->newIsolatedDiffTags[$pos])) { - - $result[] = $this->diffIsolatedPlaceholder($operation, $pos, $s); - } else { - $result[] = $s; - } - } - } - $this->content .= implode( "", $result ); - } - - /** - * @param string $text - * @param string $attribute - * - * @return null|string - */ - protected function getAttributeFromTag($text, $attribute) - { - $matches = array(); - if (preg_match(sprintf('/]*%s=([\'"])(.*)\1[^>]*>/i', $attribute), $text, $matches)) { - return $matches[2]; - } - - return null; - } - - /** - * @param string $text - * - * @return bool - */ - protected function isListPlaceholder($text) - { - return $this->isPlaceholderType($text, array('ol', 'dl', 'ul')); - } - - /** - * @param string $text - * - * @return bool - */ - public function isLinkPlaceholder($text) - { - return $this->isPlaceholderType($text, 'a'); - } - - /** - * @param string $text - * @param array|string $types - * @param bool $strict - * - * @return bool - */ - protected function isPlaceholderType($text, $types, $strict = true) - { - if (!is_array($types)) { - $types = array($types); - } - - $criteria = array(); - foreach ($types as $type) { - if ($this->config->isIsolatedDiffTag($type)) { - $criteria[] = $this->config->getIsolatedDiffTagPlaceholder($type); - } else { - $criteria[] = $type; - } - } - - return in_array($text, $criteria, $strict); - } - - /** - * @param string $text - * - * @return bool - */ - protected function isTablePlaceholder($text) - { - return $this->isPlaceholderType($text, 'table'); - } - - /** - * @param Operation $operation - * @param int $posInNew - * - * @return array - */ - protected function findIsolatedDiffTagsInOld($operation, $posInNew) - { - $offset = $posInNew - $operation->startInNew; - - return $this->oldIsolatedDiffTags[$operation->startInOld + $offset]; - } - - /** - * @param string $tag - * @param string $cssClass - * @param array $words - */ - protected function insertTag($tag, $cssClass, &$words) - { - while (true) { - if ( count( $words ) == 0 ) { - break; - } - - $nonTags = $this->extractConsecutiveWords( $words, 'noTag' ); - - $specialCaseTagInjection = ''; - $specialCaseTagInjectionIsBefore = false; - - if ( count( $nonTags ) != 0 ) { - $text = $this->wrapText( implode( "", $nonTags ), $tag, $cssClass ); - $this->content .= $text; - } else { - $firstOrDefault = false; - foreach ($this->config->getSpecialCaseOpeningTags() as $x) { - if ( preg_match( $x, $words[ 0 ] ) ) { - $firstOrDefault = $x; - break; - } - } - if ($firstOrDefault) { - $specialCaseTagInjection = ''; - if ($tag == "del") { - unset( $words[ 0 ] ); - } - } elseif ( array_search( $words[ 0 ], $this->config->getSpecialCaseClosingTags()) !== false ) { - $specialCaseTagInjection = ""; - $specialCaseTagInjectionIsBefore = true; - if ($tag == "del") { - unset( $words[ 0 ] ); - } - } - } - if ( count( $words ) == 0 && count( $specialCaseTagInjection ) == 0 ) { - break; - } - if ($specialCaseTagInjectionIsBefore) { - $this->content .= $specialCaseTagInjection . implode( "", $this->extractConsecutiveWords( $words, 'tag' ) ); - } else { - $workTag = $this->extractConsecutiveWords( $words, 'tag' ); - if ( isset( $workTag[ 0 ] ) && $this->isOpeningTag( $workTag[ 0 ] ) && !$this->isClosingTag( $workTag[ 0 ] ) ) { - if ( strpos( $workTag[ 0 ], 'class=' ) ) { - $workTag[ 0 ] = str_replace( 'class="', 'class="diffmod ', $workTag[ 0 ] ); - $workTag[ 0 ] = str_replace( "class='", 'class="diffmod ', $workTag[ 0 ] ); - } else { - $workTag[ 0 ] = str_replace( ">", ' class="diffmod">', $workTag[ 0 ] ); - } - } - $this->content .= implode( "", $workTag ) . $specialCaseTagInjection; - } - } - } - - /** - * @param string $word - * @param string $condition - * - * @return bool - */ - protected function checkCondition($word, $condition) - { - return $condition == 'tag' ? $this->isTag( $word ) : !$this->isTag( $word ); - } - - /** - * @param string $text - * @param string $tagName - * @param string $cssClass - * - * @return string - */ - protected function wrapText($text, $tagName, $cssClass) - { - return sprintf( '<%1$s class="%2$s">%3$s', $tagName, $cssClass, $text ); - } - - /** - * @param array $words - * @param string $condition - * - * @return array - */ - protected function extractConsecutiveWords(&$words, $condition) - { - $indexOfFirstTag = null; - $words = array_values($words); - foreach ($words as $i => $word) { - if ( !$this->checkCondition( $word, $condition ) ) { - $indexOfFirstTag = $i; - break; - } - } - if ($indexOfFirstTag !== null) { - $items = array(); - foreach ($words as $pos => $s) { - if ($pos >= 0 && $pos < $indexOfFirstTag) { - $items[] = $s; - } - } - if ($indexOfFirstTag > 0) { - array_splice( $words, 0, $indexOfFirstTag ); - } - - return $items; - } else { - $items = array(); - foreach ($words as $pos => $s) { - if ( $pos >= 0 && $pos <= count( $words ) ) { - $items[] = $s; - } - } - array_splice( $words, 0, count( $words ) ); - - return $items; - } - } - - /** - * @param string $item - * - * @return bool - */ - protected function isTag($item) - { - return $this->isOpeningTag( $item ) || $this->isClosingTag( $item ); - } - - /** - * @param string $item - * - * @return bool - */ - protected function isOpeningTag($item) - { - return preg_match( "#<[^>]+>\\s*#iU", $item ); - } - - /** - * @param string $item - * - * @return bool - */ - protected function isClosingTag($item) - { - return preg_match( "#]+>\\s*#iU", $item ); - } - - /** - * @return Operation[] - */ - protected function operations() - { - $positionInOld = 0; - $positionInNew = 0; - $operations = array(); - $matches = $this->matchingBlocks(); - $matches[] = new Match( count( $this->oldWords ), count( $this->newWords ), 0 ); - foreach ($matches as $i => $match) { - $matchStartsAtCurrentPositionInOld = ( $positionInOld == $match->startInOld ); - $matchStartsAtCurrentPositionInNew = ( $positionInNew == $match->startInNew ); - $action = 'none'; - - if ($matchStartsAtCurrentPositionInOld == false && $matchStartsAtCurrentPositionInNew == false) { - $action = 'replace'; - } elseif ($matchStartsAtCurrentPositionInOld == true && $matchStartsAtCurrentPositionInNew == false) { - $action = 'insert'; - } elseif ($matchStartsAtCurrentPositionInOld == false && $matchStartsAtCurrentPositionInNew == true) { - $action = 'delete'; - } else { // This occurs if the first few words are the same in both versions - $action = 'none'; - } - if ($action != 'none') { - $operations[] = new Operation( $action, $positionInOld, $match->startInOld, $positionInNew, $match->startInNew ); - } - if ( count( $match ) != 0 ) { - $operations[] = new Operation( 'equal', $match->startInOld, $match->endInOld(), $match->startInNew, $match->endInNew() ); - } - $positionInOld = $match->endInOld(); - $positionInNew = $match->endInNew(); - } - - return $operations; - } - - /** - * @return Match[] - */ - protected function matchingBlocks() - { - $matchingBlocks = array(); - $this->findMatchingBlocks( 0, count( $this->oldWords ), 0, count( $this->newWords ), $matchingBlocks ); - - return $matchingBlocks; - } - - /** - * @param int $startInOld - * @param int $endInOld - * @param int $startInNew - * @param int $endInNew - * @param array $matchingBlocks - */ - protected function findMatchingBlocks($startInOld, $endInOld, $startInNew, $endInNew, &$matchingBlocks) - { - $match = $this->findMatch( $startInOld, $endInOld, $startInNew, $endInNew ); - if ($match !== null) { - if ($startInOld < $match->startInOld && $startInNew < $match->startInNew) { - $this->findMatchingBlocks( $startInOld, $match->startInOld, $startInNew, $match->startInNew, $matchingBlocks ); - } - $matchingBlocks[] = $match; - if ( $match->endInOld() < $endInOld && $match->endInNew() < $endInNew ) { - $this->findMatchingBlocks( $match->endInOld(), $endInOld, $match->endInNew(), $endInNew, $matchingBlocks ); - } - } - } - - /** - * @param string $word - * - * @return string - */ - protected function stripTagAttributes($word) - { - $word = explode( ' ', trim( $word, '<>' ) ); - - return '<' . $word[ 0 ] . '>'; - } - - /** - * @param int $startInOld - * @param int $endInOld - * @param int $startInNew - * @param int $endInNew - * - * @return Match|null - */ - protected function findMatch($startInOld, $endInOld, $startInNew, $endInNew) - { - $bestMatchInOld = $startInOld; - $bestMatchInNew = $startInNew; - $bestMatchSize = 0; - $matchLengthAt = array(); - for ($indexInOld = $startInOld; $indexInOld < $endInOld; $indexInOld++) { - $newMatchLengthAt = array(); - $index = $this->oldWords[ $indexInOld ]; - if ( $this->isTag( $index ) ) { - $index = $this->stripTagAttributes( $index ); - } - if ( !isset( $this->wordIndices[ $index ] ) ) { - $matchLengthAt = $newMatchLengthAt; - continue; - } - foreach ($this->wordIndices[ $index ] as $indexInNew) { - if ($indexInNew < $startInNew) { - continue; - } - if ($indexInNew >= $endInNew) { - break; - } - $newMatchLength = ( isset( $matchLengthAt[ $indexInNew - 1 ] ) ? $matchLengthAt[ $indexInNew - 1 ] : 0 ) + 1; - $newMatchLengthAt[ $indexInNew ] = $newMatchLength; - if ($newMatchLength > $bestMatchSize || - ( - $this->isGroupDiffs() && - $bestMatchSize > 0 && - preg_match( - '/^\s+$/', - implode('', array_slice($this->oldWords, $bestMatchInOld, $bestMatchSize)) - ) - ) - ) { - $bestMatchInOld = $indexInOld - $newMatchLength + 1; - $bestMatchInNew = $indexInNew - $newMatchLength + 1; - $bestMatchSize = $newMatchLength; - } - } - $matchLengthAt = $newMatchLengthAt; - } - - // Skip match if none found or match consists only of whitespace - if ($bestMatchSize != 0 && - ( - !$this->isGroupDiffs() || - !preg_match('/^\s+$/', implode('', array_slice($this->oldWords, $bestMatchInOld, $bestMatchSize))) - ) - ) { - return new Match($bestMatchInOld, $bestMatchInNew, $bestMatchSize); - } - - return null; - } -} +setConfig($config); + } + + return $diff; + } + + /** + * @param $bool + * + * @return $this + * + * @deprecated since 0.1.0 + */ + public function setUseTableDiffing($bool) + { + $this->config->setUseTableDiffing($bool); + + return $this; + } + + /** + * @param boolean $boolean + * @return HtmlDiff + * + * @deprecated since 0.1.0 + */ + public function setInsertSpaceInReplace($boolean) + { + $this->config->setInsertSpaceInReplace($boolean); + + return $this; + } + + /** + * @return boolean + * + * @deprecated since 0.1.0 + */ + public function getInsertSpaceInReplace() + { + return $this->config->isInsertSpaceInReplace(); + } + + /** + * @return string + */ + public function build() + { + if ($this->hasDiffCache() && $this->getDiffCache()->contains($this->oldText, $this->newText)) { + $this->content = $this->getDiffCache()->fetch($this->oldText, $this->newText); + + return $this->content; + } + + $this->splitInputsToWords(); + $this->replaceIsolatedDiffTags(); + $this->indexNewWords(); + + $operations = $this->operations(); + foreach ($operations as $item) { + $this->performOperation( $item ); + } + + if ($this->hasDiffCache()) { + $this->getDiffCache()->save($this->oldText, $this->newText, $this->content); + } + + return $this->content; + } + + protected function indexNewWords() + { + $this->wordIndices = array(); + foreach ($this->newWords as $i => $word) { + if ( $this->isTag( $word ) ) { + $word = $this->stripTagAttributes( $word ); + } + if ( isset( $this->wordIndices[ $word ] ) ) { + $this->wordIndices[ $word ][] = $i; + } else { + $this->wordIndices[ $word ] = array( $i ); + } + } + } + + protected function replaceIsolatedDiffTags() + { + $this->oldIsolatedDiffTags = $this->createIsolatedDiffTagPlaceholders($this->oldWords); + $this->newIsolatedDiffTags = $this->createIsolatedDiffTagPlaceholders($this->newWords); + } + + /** + * @param array $words + * + * @return array + */ + protected function createIsolatedDiffTagPlaceholders(&$words) + { + $openIsolatedDiffTags = 0; + $isolatedDiffTagIndicies = array(); + $isolatedDiffTagStart = 0; + $currentIsolatedDiffTag = null; + foreach ($words as $index => $word) { + $openIsolatedDiffTag = $this->isOpeningIsolatedDiffTag($word, $currentIsolatedDiffTag); + if ($openIsolatedDiffTag) { + if ($openIsolatedDiffTags === 0) { + $isolatedDiffTagStart = $index; + } + $openIsolatedDiffTags++; + $currentIsolatedDiffTag = $openIsolatedDiffTag; + } elseif ($openIsolatedDiffTags > 0 && $this->isClosingIsolatedDiffTag($word, $currentIsolatedDiffTag)) { + $openIsolatedDiffTags--; + if ($openIsolatedDiffTags == 0) { + $isolatedDiffTagIndicies[] = array ('start' => $isolatedDiffTagStart, 'length' => $index - $isolatedDiffTagStart + 1, 'tagType' => $currentIsolatedDiffTag); + $currentIsolatedDiffTag = null; + } + } + } + $isolatedDiffTagScript = array(); + $offset = 0; + foreach ($isolatedDiffTagIndicies as $isolatedDiffTagIndex) { + $start = $isolatedDiffTagIndex['start'] - $offset; + $placeholderString = $this->config->getIsolatedDiffTagPlaceholder($isolatedDiffTagIndex['tagType']); + $isolatedDiffTagScript[$start] = array_splice($words, $start, $isolatedDiffTagIndex['length'], $placeholderString); + $offset += $isolatedDiffTagIndex['length'] - 1; + } + + return $isolatedDiffTagScript; + + } + + /** + * @param string $item + * @param null|string $currentIsolatedDiffTag + * + * @return false|string + */ + protected function isOpeningIsolatedDiffTag($item, $currentIsolatedDiffTag = null) + { + $tagsToMatch = $currentIsolatedDiffTag !== null + ? array($currentIsolatedDiffTag => $this->config->getIsolatedDiffTagPlaceholder($currentIsolatedDiffTag)) + : $this->config->getIsolatedDiffTags(); + foreach ($tagsToMatch as $key => $value) { + if (preg_match("#<".$key."[^>]*>\\s*#iU", $item)) { + return $key; + } + } + + return false; + } + + /** + * @param string $item + * @param null|string $currentIsolatedDiffTag + * + * @return false|string + */ + protected function isClosingIsolatedDiffTag($item, $currentIsolatedDiffTag = null) + { + $tagsToMatch = $currentIsolatedDiffTag !== null + ? array($currentIsolatedDiffTag => $this->config->getIsolatedDiffTagPlaceholder($currentIsolatedDiffTag)) + : $this->config->getIsolatedDiffTags(); + foreach ($tagsToMatch as $key => $value) { + if (preg_match("#]*>\\s*#iU", $item)) { + return $key; + } + } + + return false; + } + + /** + * @param Operation $operation + */ + protected function performOperation($operation) + { + switch ($operation->action) { + case 'equal' : + $this->processEqualOperation( $operation ); + break; + case 'delete' : + $this->processDeleteOperation( $operation, "diffdel" ); + break; + case 'insert' : + $this->processInsertOperation( $operation, "diffins"); + break; + case 'replace': + $this->processReplaceOperation( $operation ); + break; + default: + break; + } + } + + /** + * @param Operation $operation + */ + protected function processReplaceOperation($operation) + { + $this->processDeleteOperation( $operation, "diffmod" ); + $this->processInsertOperation( $operation, "diffmod" ); + } + + /** + * @param Operation $operation + * @param string $cssClass + */ + protected function processInsertOperation($operation, $cssClass) + { + $text = array(); + foreach ($this->newWords as $pos => $s) { + if ($pos >= $operation->startInNew && $pos < $operation->endInNew) { + if ($this->config->isIsolatedDiffTagPlaceholder($s) && isset($this->newIsolatedDiffTags[$pos])) { + foreach ($this->newIsolatedDiffTags[$pos] as $word) { + $text[] = $word; + } + } else { + $text[] = $s; + } + } + } + $this->insertTag( "ins", $cssClass, $text ); + } + + /** + * @param Operation $operation + * @param string $cssClass + */ + protected function processDeleteOperation($operation, $cssClass) + { + $text = array(); + foreach ($this->oldWords as $pos => $s) { + if ($pos >= $operation->startInOld && $pos < $operation->endInOld) { + if ($this->config->isIsolatedDiffTagPlaceholder($s) && isset($this->oldIsolatedDiffTags[$pos])) { + foreach ($this->oldIsolatedDiffTags[$pos] as $word) { + $text[] = $word; + } + } else { + $text[] = $s; + } + } + } + $this->insertTag( "del", $cssClass, $text ); + } + + /** + * @param Operation $operation + * @param int $pos + * @param string $placeholder + * @param bool $stripWrappingTags + * + * @return string + */ + protected function diffIsolatedPlaceholder($operation, $pos, $placeholder, $stripWrappingTags = true) + { + $oldText = implode("", $this->findIsolatedDiffTagsInOld($operation, $pos)); + $newText = implode("", $this->newIsolatedDiffTags[$pos]); + + if ($this->isListPlaceholder($placeholder)) { + return $this->diffList($oldText, $newText); + } elseif ($this->config->isUseTableDiffing() && $this->isTablePlaceholder($placeholder)) { + return $this->diffTables($oldText, $newText); + } elseif ($this->isLinkPlaceholder($placeholder)) { + return $this->diffLinks($oldText, $newText); + } + + return $this->diffElements($oldText, $newText, $stripWrappingTags); + } + + /** + * @param string $oldText + * @param string $newText + * @param bool $stripWrappingTags + * + * @return string + */ + protected function diffElements($oldText, $newText, $stripWrappingTags = true) + { + $wrapStart = ''; + $wrapEnd = ''; + + if ($stripWrappingTags) { + $pattern = '/(^<[^>]+>)|(<\/[^>]+>$)/i'; + $matches = array(); + + if (preg_match_all($pattern, $newText, $matches)) { + $wrapStart = isset($matches[0][0]) ? $matches[0][0] : ''; + $wrapEnd = isset($matches[0][1]) ? $matches[0][1] : ''; + } + $oldText = preg_replace($pattern, '', $oldText); + $newText = preg_replace($pattern, '', $newText); + } + + $diff = HtmlDiff::create($oldText, $newText, $this->config); + + return $wrapStart . $diff->build() . $wrapEnd; + } + + /** + * @param string $oldText + * @param string $newText + * + * @return string + */ + protected function diffList($oldText, $newText) + { + $diff = ListDiffNew::create($oldText, $newText, $this->config); + + return $diff->build(); + } + + /** + * @param string $oldText + * @param string $newText + * + * @return string + */ + protected function diffTables($oldText, $newText) + { + $diff = TableDiff::create($oldText, $newText, $this->config); + + return $diff->build(); + } + + /** + * @param string $oldText + * @param string $newText + * + * @return string + */ + protected function diffLinks($oldText, $newText) + { + $oldHref = $this->getAttributeFromTag($oldText, 'href'); + $newHref = $this->getAttributeFromTag($newText, 'href'); + + if ($oldHref != $newHref) { + return sprintf( + '%s%s', + $this->wrapText($oldText, 'del', 'diffmod diff-href'), + $this->wrapText($newText, 'ins', 'diffmod diff-href') + ); + } + + return $this->diffElements($oldText, $newText); + } + + /** + * @param Operation $operation + */ + protected function processEqualOperation($operation) + { + $result = array(); + foreach ($this->newWords as $pos => $s) { + + if ($pos >= $operation->startInNew && $pos < $operation->endInNew) { + if ($this->config->isIsolatedDiffTagPlaceholder($s) && isset($this->newIsolatedDiffTags[$pos])) { + + $result[] = $this->diffIsolatedPlaceholder($operation, $pos, $s); + } else { + $result[] = $s; + } + } + } + $this->content .= implode( "", $result ); + } + + /** + * @param string $text + * @param string $attribute + * + * @return null|string + */ + protected function getAttributeFromTag($text, $attribute) + { + $matches = array(); + if (preg_match(sprintf('/]*%s=([\'"])(.*)\1[^>]*>/i', $attribute), $text, $matches)) { + return $matches[2]; + } + + return null; + } + + /** + * @param string $text + * + * @return bool + */ + protected function isListPlaceholder($text) + { + return $this->isPlaceholderType($text, array('ol', 'dl', 'ul')); + } + + /** + * @param string $text + * + * @return bool + */ + public function isLinkPlaceholder($text) + { + return $this->isPlaceholderType($text, 'a'); + } + + /** + * @param string $text + * @param array|string $types + * @param bool $strict + * + * @return bool + */ + protected function isPlaceholderType($text, $types, $strict = true) + { + if (!is_array($types)) { + $types = array($types); + } + + $criteria = array(); + foreach ($types as $type) { + if ($this->config->isIsolatedDiffTag($type)) { + $criteria[] = $this->config->getIsolatedDiffTagPlaceholder($type); + } else { + $criteria[] = $type; + } + } + + return in_array($text, $criteria, $strict); + } + + /** + * @param string $text + * + * @return bool + */ + protected function isTablePlaceholder($text) + { + return $this->isPlaceholderType($text, 'table'); + } + + /** + * @param Operation $operation + * @param int $posInNew + * + * @return array + */ + protected function findIsolatedDiffTagsInOld($operation, $posInNew) + { + $offset = $posInNew - $operation->startInNew; + + return $this->oldIsolatedDiffTags[$operation->startInOld + $offset]; + } + + /** + * @param string $tag + * @param string $cssClass + * @param array $words + */ + protected function insertTag($tag, $cssClass, &$words) + { + while (true) { + if ( count( $words ) == 0 ) { + break; + } + + $nonTags = $this->extractConsecutiveWords( $words, 'noTag' ); + + $specialCaseTagInjection = ''; + $specialCaseTagInjectionIsBefore = false; + + if ( count( $nonTags ) != 0 ) { + $text = $this->wrapText( implode( "", $nonTags ), $tag, $cssClass ); + $this->content .= $text; + } else { + $firstOrDefault = false; + foreach ($this->config->getSpecialCaseOpeningTags() as $x) { + if ( preg_match( $x, $words[ 0 ] ) ) { + $firstOrDefault = $x; + break; + } + } + if ($firstOrDefault) { + $specialCaseTagInjection = ''; + if ($tag == "del") { + unset( $words[ 0 ] ); + } + } elseif ( array_search( $words[ 0 ], $this->config->getSpecialCaseClosingTags()) !== false ) { + $specialCaseTagInjection = ""; + $specialCaseTagInjectionIsBefore = true; + if ($tag == "del") { + unset( $words[ 0 ] ); + } + } + } + if ( count( $words ) == 0 && count( $specialCaseTagInjection ) == 0 ) { + break; + } + if ($specialCaseTagInjectionIsBefore) { + $this->content .= $specialCaseTagInjection . implode( "", $this->extractConsecutiveWords( $words, 'tag' ) ); + } else { + $workTag = $this->extractConsecutiveWords( $words, 'tag' ); + if ( isset( $workTag[ 0 ] ) && $this->isOpeningTag( $workTag[ 0 ] ) && !$this->isClosingTag( $workTag[ 0 ] ) ) { + if ( strpos( $workTag[ 0 ], 'class=' ) ) { + $workTag[ 0 ] = str_replace( 'class="', 'class="diffmod ', $workTag[ 0 ] ); + $workTag[ 0 ] = str_replace( "class='", 'class="diffmod ', $workTag[ 0 ] ); + } else { + $workTag[ 0 ] = str_replace( ">", ' class="diffmod">', $workTag[ 0 ] ); + } + } + $this->content .= implode( "", $workTag ) . $specialCaseTagInjection; + } + } + } + + /** + * @param string $word + * @param string $condition + * + * @return bool + */ + protected function checkCondition($word, $condition) + { + return $condition == 'tag' ? $this->isTag( $word ) : !$this->isTag( $word ); + } + + /** + * @param string $text + * @param string $tagName + * @param string $cssClass + * + * @return string + */ + protected function wrapText($text, $tagName, $cssClass) + { + return sprintf( '<%1$s class="%2$s">%3$s', $tagName, $cssClass, $text ); + } + + /** + * @param array $words + * @param string $condition + * + * @return array + */ + protected function extractConsecutiveWords(&$words, $condition) + { + $indexOfFirstTag = null; + $words = array_values($words); + foreach ($words as $i => $word) { + if ( !$this->checkCondition( $word, $condition ) ) { + $indexOfFirstTag = $i; + break; + } + } + if ($indexOfFirstTag !== null) { + $items = array(); + foreach ($words as $pos => $s) { + if ($pos >= 0 && $pos < $indexOfFirstTag) { + $items[] = $s; + } + } + if ($indexOfFirstTag > 0) { + array_splice( $words, 0, $indexOfFirstTag ); + } + + return $items; + } else { + $items = array(); + foreach ($words as $pos => $s) { + if ( $pos >= 0 && $pos <= count( $words ) ) { + $items[] = $s; + } + } + array_splice( $words, 0, count( $words ) ); + + return $items; + } + } + + /** + * @param string $item + * + * @return bool + */ + protected function isTag($item) + { + return $this->isOpeningTag( $item ) || $this->isClosingTag( $item ); + } + + /** + * @param string $item + * + * @return bool + */ + protected function isOpeningTag($item) + { + return preg_match( "#<[^>]+>\\s*#iU", $item ); + } + + /** + * @param string $item + * + * @return bool + */ + protected function isClosingTag($item) + { + return preg_match( "#]+>\\s*#iU", $item ); + } + + /** + * @return Operation[] + */ + protected function operations() + { + $positionInOld = 0; + $positionInNew = 0; + $operations = array(); + $matches = $this->matchingBlocks(); + $matches[] = new Match( count( $this->oldWords ), count( $this->newWords ), 0 ); + foreach ($matches as $i => $match) { + $matchStartsAtCurrentPositionInOld = ( $positionInOld == $match->startInOld ); + $matchStartsAtCurrentPositionInNew = ( $positionInNew == $match->startInNew ); + $action = 'none'; + + if ($matchStartsAtCurrentPositionInOld == false && $matchStartsAtCurrentPositionInNew == false) { + $action = 'replace'; + } elseif ($matchStartsAtCurrentPositionInOld == true && $matchStartsAtCurrentPositionInNew == false) { + $action = 'insert'; + } elseif ($matchStartsAtCurrentPositionInOld == false && $matchStartsAtCurrentPositionInNew == true) { + $action = 'delete'; + } else { // This occurs if the first few words are the same in both versions + $action = 'none'; + } + if ($action != 'none') { + $operations[] = new Operation( $action, $positionInOld, $match->startInOld, $positionInNew, $match->startInNew ); + } + if ( count( $match ) != 0 ) { + $operations[] = new Operation( 'equal', $match->startInOld, $match->endInOld(), $match->startInNew, $match->endInNew() ); + } + $positionInOld = $match->endInOld(); + $positionInNew = $match->endInNew(); + } + + return $operations; + } + + /** + * @return Match[] + */ + protected function matchingBlocks() + { + $matchingBlocks = array(); + $this->findMatchingBlocks( 0, count( $this->oldWords ), 0, count( $this->newWords ), $matchingBlocks ); + + return $matchingBlocks; + } + + /** + * @param int $startInOld + * @param int $endInOld + * @param int $startInNew + * @param int $endInNew + * @param array $matchingBlocks + */ + protected function findMatchingBlocks($startInOld, $endInOld, $startInNew, $endInNew, &$matchingBlocks) + { + $match = $this->findMatch( $startInOld, $endInOld, $startInNew, $endInNew ); + if ($match !== null) { + if ($startInOld < $match->startInOld && $startInNew < $match->startInNew) { + $this->findMatchingBlocks( $startInOld, $match->startInOld, $startInNew, $match->startInNew, $matchingBlocks ); + } + $matchingBlocks[] = $match; + if ( $match->endInOld() < $endInOld && $match->endInNew() < $endInNew ) { + $this->findMatchingBlocks( $match->endInOld(), $endInOld, $match->endInNew(), $endInNew, $matchingBlocks ); + } + } + } + + /** + * @param string $word + * + * @return string + */ + protected function stripTagAttributes($word) + { + $word = explode( ' ', trim( $word, '<>' ) ); + + return '<' . $word[ 0 ] . '>'; + } + + /** + * @param int $startInOld + * @param int $endInOld + * @param int $startInNew + * @param int $endInNew + * + * @return Match|null + */ + protected function findMatch($startInOld, $endInOld, $startInNew, $endInNew) + { + $bestMatchInOld = $startInOld; + $bestMatchInNew = $startInNew; + $bestMatchSize = 0; + $matchLengthAt = array(); + for ($indexInOld = $startInOld; $indexInOld < $endInOld; $indexInOld++) { + $newMatchLengthAt = array(); + $index = $this->oldWords[ $indexInOld ]; + if ( $this->isTag( $index ) ) { + $index = $this->stripTagAttributes( $index ); + } + if ( !isset( $this->wordIndices[ $index ] ) ) { + $matchLengthAt = $newMatchLengthAt; + continue; + } + foreach ($this->wordIndices[ $index ] as $indexInNew) { + if ($indexInNew < $startInNew) { + continue; + } + if ($indexInNew >= $endInNew) { + break; + } + $newMatchLength = ( isset( $matchLengthAt[ $indexInNew - 1 ] ) ? $matchLengthAt[ $indexInNew - 1 ] : 0 ) + 1; + $newMatchLengthAt[ $indexInNew ] = $newMatchLength; + if ($newMatchLength > $bestMatchSize || + ( + $this->isGroupDiffs() && + $bestMatchSize > 0 && + preg_match( + '/^\s+$/', + implode('', array_slice($this->oldWords, $bestMatchInOld, $bestMatchSize)) + ) + ) + ) { + $bestMatchInOld = $indexInOld - $newMatchLength + 1; + $bestMatchInNew = $indexInNew - $newMatchLength + 1; + $bestMatchSize = $newMatchLength; + } + } + $matchLengthAt = $newMatchLengthAt; + } + + // Skip match if none found or match consists only of whitespace + if ($bestMatchSize != 0 && + ( + !$this->isGroupDiffs() || + !preg_match('/^\s+$/', implode('', array_slice($this->oldWords, $bestMatchInOld, $bestMatchSize))) + ) + ) { + return new Match($bestMatchInOld, $bestMatchInNew, $bestMatchSize); + } + + return null; + } +} diff --git a/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/HtmlDiffConfig.php b/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/HtmlDiffConfig.php index 928bf9c..8f16aef 100755 --- a/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/HtmlDiffConfig.php +++ b/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/HtmlDiffConfig.php @@ -1,488 +1,488 @@ - '[[REPLACE_ORDERED_LIST]]', - 'ul' => '[[REPLACE_UNORDERED_LIST]]', - 'sub' => '[[REPLACE_SUB_SCRIPT]]', - 'sup' => '[[REPLACE_SUPER_SCRIPT]]', - 'dl' => '[[REPLACE_DEFINITION_LIST]]', - 'table' => '[[REPLACE_TABLE]]', - 'strong' => '[[REPLACE_STRONG]]', - 'b' => '[[REPLACE_B]]', - 'em' => '[[REPLACE_EM]]', - 'i' => '[[REPLACE_I]]', - 'a' => '[[REPLACE_A]]', - ); - - /** - * @var int - */ - protected $matchThreshold = 80; - /** - * @var array - */ - protected $specialCaseOpeningTags = array(); - /** - * @var array - */ - protected $specialCaseClosingTags = array(); - - /** - * @var bool - */ - protected $useTableDiffing = true; - - /** - * @var null|\Doctrine\Common\Cache\Cache - */ - protected $cacheProvider; - - /** - * @var null|string - */ - protected $purifierCacheLocation = null; - - /** - * @return HtmlDiffConfig - */ - public static function create() - { - return new self(); - } - - /** - * HtmlDiffConfig constructor. - */ - public function __construct() - { - $this->setSpecialCaseTags($this->specialCaseTags); - } - - /** - * @return int - */ - public function getMatchThreshold() - { - return $this->matchThreshold; - } - - /** - * @param int $matchThreshold - * - * @return AbstractDiff - */ - public function setMatchThreshold($matchThreshold) - { - $this->matchThreshold = $matchThreshold; - - return $this; - } - - /** - * @param array $chars - */ - public function setSpecialCaseChars(array $chars) - { - $this->specialCaseChars = $chars; - } - - /** - * @return array|null - */ - public function getSpecialCaseChars() - { - return $this->specialCaseChars; - } - - /** - * @param string $char - * - * @return $this - */ - public function addSpecialCaseChar($char) - { - if (!in_array($char, $this->specialCaseChars)) { - $this->specialCaseChars[] = $char; - } - - return $this; - } - - /** - * @param string $char - * - * @return $this - */ - public function removeSpecialCaseChar($char) - { - $key = array_search($char, $this->specialCaseChars); - if ($key !== false) { - unset($this->specialCaseChars[$key]); - } - - return $this; - } - - /** - * @param array $tags - * - * @return $this - */ - public function setSpecialCaseTags(array $tags = array()) - { - $this->specialCaseTags = $tags; - $this->specialCaseOpeningTags = array(); - $this->specialCaseClosingTags = array(); - - foreach ($this->specialCaseTags as $tag) { - $this->addSpecialCaseTag($tag); - } - - return $this; - } - - /** - * @param string $tag - * - * @return $this - */ - public function addSpecialCaseTag($tag) - { - if (!in_array($tag, $this->specialCaseTags)) { - $this->specialCaseTags[] = $tag; - } - - $opening = $this->getOpeningTag($tag); - $closing = $this->getClosingTag($tag); - - if (!in_array($opening, $this->specialCaseOpeningTags)) { - $this->specialCaseOpeningTags[] = $opening; - } - if (!in_array($closing, $this->specialCaseClosingTags)) { - $this->specialCaseClosingTags[] = $closing; - } - - return $this; - } - - /** - * @param string $tag - * - * @return $this - */ - public function removeSpecialCaseTag($tag) - { - if (($key = array_search($tag, $this->specialCaseTags)) !== false) { - unset($this->specialCaseTags[$key]); - - $opening = $this->getOpeningTag($tag); - $closing = $this->getClosingTag($tag); - - if (($key = array_search($opening, $this->specialCaseOpeningTags)) !== false) { - unset($this->specialCaseOpeningTags[$key]); - } - if (($key = array_search($closing, $this->specialCaseClosingTags)) !== false) { - unset($this->specialCaseClosingTags[$key]); - } - } - - return $this; - } - - /** - * @return array|null - */ - public function getSpecialCaseTags() - { - return $this->specialCaseTags; - } - - - /** - * @return boolean - */ - public function isGroupDiffs() - { - return $this->groupDiffs; - } - - /** - * @param boolean $groupDiffs - * - * @return HtmlDiffConfig - */ - public function setGroupDiffs($groupDiffs) - { - $this->groupDiffs = $groupDiffs; - - return $this; - } - - /** - * @return string - */ - public function getEncoding() - { - return $this->encoding; - } - - /** - * @param string $encoding - * - * @return HtmlDiffConfig - */ - public function setEncoding($encoding) - { - $this->encoding = $encoding; - - return $this; - } - - /** - * @return boolean - */ - public function isInsertSpaceInReplace() - { - return $this->insertSpaceInReplace; - } - - /** - * @param boolean $insertSpaceInReplace - * - * @return HtmlDiffConfig - */ - public function setInsertSpaceInReplace($insertSpaceInReplace) - { - $this->insertSpaceInReplace = $insertSpaceInReplace; - - return $this; - } - - /** - * @return array - */ - public function getIsolatedDiffTags() - { - return $this->isolatedDiffTags; - } - - /** - * @param array $isolatedDiffTags - * - * @return HtmlDiffConfig - */ - public function setIsolatedDiffTags($isolatedDiffTags) - { - $this->isolatedDiffTags = $isolatedDiffTags; - - return $this; - } - - /** - * @param string $tag - * @param null|string $placeholder - * - * @return $this - */ - public function addIsolatedDiffTag($tag, $placeholder = null) - { - if (null === $placeholder) { - $placeholder = sprintf('[[REPLACE_%s]]', strtoupper($tag)); - } - - if ($this->isIsolatedDiffTag($tag) && $this->isolatedDiffTags[$tag] !== $placeholder) { - throw new \InvalidArgumentException( - sprintf('Isolated diff tag "%s" already exists using a different placeholder', $tag) - ); - } - - $matchingKey = array_search($placeholder, $this->isolatedDiffTags, true); - if (false !== $matchingKey && $matchingKey !== $tag) { - throw new \InvalidArgumentException( - sprintf('Placeholder already being used for a different tag "%s"', $tag) - ); - } - - if (!array_key_exists($tag, $this->isolatedDiffTags)) { - $this->isolatedDiffTags[$tag] = $placeholder; - } - - return $this; - } - - /** - * @param string $tag - * - * @return $this - */ - public function removeIsolatedDiffTag($tag) - { - if ($this->isIsolatedDiffTag($tag)) { - unset($this->isolatedDiffTags[$tag]); - } - - return $this; - } - - /** - * @param string $tag - * - * @return bool - */ - public function isIsolatedDiffTag($tag) - { - return array_key_exists($tag, $this->isolatedDiffTags); - } - - /** - * @param string $text - * - * @return bool - */ - public function isIsolatedDiffTagPlaceholder($text) - { - return in_array($text, $this->isolatedDiffTags, true); - } - - /** - * @param string $tag - * - * @return null|string - */ - public function getIsolatedDiffTagPlaceholder($tag) - { - return $this->isIsolatedDiffTag($tag) ? $this->isolatedDiffTags[$tag] : null; - } - - /** - * @return array - */ - public function getSpecialCaseOpeningTags() - { - return $this->specialCaseOpeningTags; - } - - /** - * @return array - */ - public function getSpecialCaseClosingTags() - { - return $this->specialCaseClosingTags; - } - - /** - * @return boolean - */ - public function isUseTableDiffing() - { - return $this->useTableDiffing; - } - - /** - * @param boolean $useTableDiffing - * - * @return HtmlDiffConfig - */ - public function setUseTableDiffing($useTableDiffing) - { - $this->useTableDiffing = $useTableDiffing; - - return $this; - } - - /** - * @param null|\Doctrine\Common\Cache\Cache $cacheProvider - * - * @return $this - */ - public function setCacheProvider(\Doctrine\Common\Cache\Cache $cacheProvider = null) - { - $this->cacheProvider = $cacheProvider; - - return $this; - } - - /** - * @return null|\Doctrine\Common\Cache\Cache - */ - public function getCacheProvider() - { - return $this->cacheProvider; - } - - /** - * @param null|string - * - * @return $this - */ - public function setPurifierCacheLocation($purifierCacheLocation = null) - { - $this->purifierCacheLocation = $purifierCacheLocation; - - return $this; - } - - /** - * @return null|string - */ - public function getPurifierCacheLocation() - { - return $this->purifierCacheLocation; - } - - /** - * @param string $tag - * - * @return string - */ - protected function getOpeningTag($tag) - { - return "/<".$tag."[^>]*/i"; - } - - /** - * @param string $tag - * - * @return string - */ - protected function getClosingTag($tag) - { - return ""; - } -} + '[[REPLACE_ORDERED_LIST]]', + 'ul' => '[[REPLACE_UNORDERED_LIST]]', + 'sub' => '[[REPLACE_SUB_SCRIPT]]', + 'sup' => '[[REPLACE_SUPER_SCRIPT]]', + 'dl' => '[[REPLACE_DEFINITION_LIST]]', + 'table' => '[[REPLACE_TABLE]]', + 'strong' => '[[REPLACE_STRONG]]', + 'b' => '[[REPLACE_B]]', + 'em' => '[[REPLACE_EM]]', + 'i' => '[[REPLACE_I]]', + 'a' => '[[REPLACE_A]]', + ); + + /** + * @var int + */ + protected $matchThreshold = 80; + /** + * @var array + */ + protected $specialCaseOpeningTags = array(); + /** + * @var array + */ + protected $specialCaseClosingTags = array(); + + /** + * @var bool + */ + protected $useTableDiffing = true; + + /** + * @var null|\Doctrine\Common\Cache\Cache + */ + protected $cacheProvider; + + /** + * @var null|string + */ + protected $purifierCacheLocation = null; + + /** + * @return HtmlDiffConfig + */ + public static function create() + { + return new self(); + } + + /** + * HtmlDiffConfig constructor. + */ + public function __construct() + { + $this->setSpecialCaseTags($this->specialCaseTags); + } + + /** + * @return int + */ + public function getMatchThreshold() + { + return $this->matchThreshold; + } + + /** + * @param int $matchThreshold + * + * @return AbstractDiff + */ + public function setMatchThreshold($matchThreshold) + { + $this->matchThreshold = $matchThreshold; + + return $this; + } + + /** + * @param array $chars + */ + public function setSpecialCaseChars(array $chars) + { + $this->specialCaseChars = $chars; + } + + /** + * @return array|null + */ + public function getSpecialCaseChars() + { + return $this->specialCaseChars; + } + + /** + * @param string $char + * + * @return $this + */ + public function addSpecialCaseChar($char) + { + if (!in_array($char, $this->specialCaseChars)) { + $this->specialCaseChars[] = $char; + } + + return $this; + } + + /** + * @param string $char + * + * @return $this + */ + public function removeSpecialCaseChar($char) + { + $key = array_search($char, $this->specialCaseChars); + if ($key !== false) { + unset($this->specialCaseChars[$key]); + } + + return $this; + } + + /** + * @param array $tags + * + * @return $this + */ + public function setSpecialCaseTags(array $tags = array()) + { + $this->specialCaseTags = $tags; + $this->specialCaseOpeningTags = array(); + $this->specialCaseClosingTags = array(); + + foreach ($this->specialCaseTags as $tag) { + $this->addSpecialCaseTag($tag); + } + + return $this; + } + + /** + * @param string $tag + * + * @return $this + */ + public function addSpecialCaseTag($tag) + { + if (!in_array($tag, $this->specialCaseTags)) { + $this->specialCaseTags[] = $tag; + } + + $opening = $this->getOpeningTag($tag); + $closing = $this->getClosingTag($tag); + + if (!in_array($opening, $this->specialCaseOpeningTags)) { + $this->specialCaseOpeningTags[] = $opening; + } + if (!in_array($closing, $this->specialCaseClosingTags)) { + $this->specialCaseClosingTags[] = $closing; + } + + return $this; + } + + /** + * @param string $tag + * + * @return $this + */ + public function removeSpecialCaseTag($tag) + { + if (($key = array_search($tag, $this->specialCaseTags)) !== false) { + unset($this->specialCaseTags[$key]); + + $opening = $this->getOpeningTag($tag); + $closing = $this->getClosingTag($tag); + + if (($key = array_search($opening, $this->specialCaseOpeningTags)) !== false) { + unset($this->specialCaseOpeningTags[$key]); + } + if (($key = array_search($closing, $this->specialCaseClosingTags)) !== false) { + unset($this->specialCaseClosingTags[$key]); + } + } + + return $this; + } + + /** + * @return array|null + */ + public function getSpecialCaseTags() + { + return $this->specialCaseTags; + } + + + /** + * @return boolean + */ + public function isGroupDiffs() + { + return $this->groupDiffs; + } + + /** + * @param boolean $groupDiffs + * + * @return HtmlDiffConfig + */ + public function setGroupDiffs($groupDiffs) + { + $this->groupDiffs = $groupDiffs; + + return $this; + } + + /** + * @return string + */ + public function getEncoding() + { + return $this->encoding; + } + + /** + * @param string $encoding + * + * @return HtmlDiffConfig + */ + public function setEncoding($encoding) + { + $this->encoding = $encoding; + + return $this; + } + + /** + * @return boolean + */ + public function isInsertSpaceInReplace() + { + return $this->insertSpaceInReplace; + } + + /** + * @param boolean $insertSpaceInReplace + * + * @return HtmlDiffConfig + */ + public function setInsertSpaceInReplace($insertSpaceInReplace) + { + $this->insertSpaceInReplace = $insertSpaceInReplace; + + return $this; + } + + /** + * @return array + */ + public function getIsolatedDiffTags() + { + return $this->isolatedDiffTags; + } + + /** + * @param array $isolatedDiffTags + * + * @return HtmlDiffConfig + */ + public function setIsolatedDiffTags($isolatedDiffTags) + { + $this->isolatedDiffTags = $isolatedDiffTags; + + return $this; + } + + /** + * @param string $tag + * @param null|string $placeholder + * + * @return $this + */ + public function addIsolatedDiffTag($tag, $placeholder = null) + { + if (null === $placeholder) { + $placeholder = sprintf('[[REPLACE_%s]]', strtoupper($tag)); + } + + if ($this->isIsolatedDiffTag($tag) && $this->isolatedDiffTags[$tag] !== $placeholder) { + throw new \InvalidArgumentException( + sprintf('Isolated diff tag "%s" already exists using a different placeholder', $tag) + ); + } + + $matchingKey = array_search($placeholder, $this->isolatedDiffTags, true); + if (false !== $matchingKey && $matchingKey !== $tag) { + throw new \InvalidArgumentException( + sprintf('Placeholder already being used for a different tag "%s"', $tag) + ); + } + + if (!array_key_exists($tag, $this->isolatedDiffTags)) { + $this->isolatedDiffTags[$tag] = $placeholder; + } + + return $this; + } + + /** + * @param string $tag + * + * @return $this + */ + public function removeIsolatedDiffTag($tag) + { + if ($this->isIsolatedDiffTag($tag)) { + unset($this->isolatedDiffTags[$tag]); + } + + return $this; + } + + /** + * @param string $tag + * + * @return bool + */ + public function isIsolatedDiffTag($tag) + { + return array_key_exists($tag, $this->isolatedDiffTags); + } + + /** + * @param string $text + * + * @return bool + */ + public function isIsolatedDiffTagPlaceholder($text) + { + return in_array($text, $this->isolatedDiffTags, true); + } + + /** + * @param string $tag + * + * @return null|string + */ + public function getIsolatedDiffTagPlaceholder($tag) + { + return $this->isIsolatedDiffTag($tag) ? $this->isolatedDiffTags[$tag] : null; + } + + /** + * @return array + */ + public function getSpecialCaseOpeningTags() + { + return $this->specialCaseOpeningTags; + } + + /** + * @return array + */ + public function getSpecialCaseClosingTags() + { + return $this->specialCaseClosingTags; + } + + /** + * @return boolean + */ + public function isUseTableDiffing() + { + return $this->useTableDiffing; + } + + /** + * @param boolean $useTableDiffing + * + * @return HtmlDiffConfig + */ + public function setUseTableDiffing($useTableDiffing) + { + $this->useTableDiffing = $useTableDiffing; + + return $this; + } + + /** + * @param null|\Doctrine\Common\Cache\Cache $cacheProvider + * + * @return $this + */ + public function setCacheProvider(\Doctrine\Common\Cache\Cache $cacheProvider = null) + { + $this->cacheProvider = $cacheProvider; + + return $this; + } + + /** + * @return null|\Doctrine\Common\Cache\Cache + */ + public function getCacheProvider() + { + return $this->cacheProvider; + } + + /** + * @param null|string + * + * @return $this + */ + public function setPurifierCacheLocation($purifierCacheLocation = null) + { + $this->purifierCacheLocation = $purifierCacheLocation; + + return $this; + } + + /** + * @return null|string + */ + public function getPurifierCacheLocation() + { + return $this->purifierCacheLocation; + } + + /** + * @param string $tag + * + * @return string + */ + protected function getOpeningTag($tag) + { + return "/<".$tag."[^>]*/i"; + } + + /** + * @param string $tag + * + * @return string + */ + protected function getClosingTag($tag) + { + return ""; + } +} diff --git a/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/ListDiff.php b/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/ListDiff.php index d6cfd62..b34c083 100755 --- a/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/ListDiff.php +++ b/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/ListDiff.php @@ -1,944 +1,944 @@ - '[[REPLACE_ORDERED_LIST]]', - 'ul' => '[[REPLACE_UNORDERED_LIST]]', - 'dl' => '[[REPLACE_DEFINITION_LIST]]', - ); - - /** - * List (li) placeholder. - * @var string - */ - protected static $listPlaceHolder = "[[REPLACE_LIST_ITEM]]"; - - /** - * Holds the type of list this is ol, ul, dl. - * @var string - */ - protected $listType; - - /** - * Used to hold what type of list the old list is. - * @var string - */ - protected $oldListType; - - /** - * Used to hold what type of list the new list is. - * @var string - */ - protected $newListType; - - /** - * Hold the old/new content of the content of the list. - * @var array - */ - protected $list; - - /** - * Contains the old/new child lists content within this list. - * @var array - */ - protected $childLists; - - /** - * Contains the old/new text strings that match - * @var array - */ - protected $textMatches; - - /** - * Contains the indexed start positions of each list within word string. - * @var array - */ - protected $listsIndex; - - /** - * Array that holds the index of all content outside of the array. Format is array(index => content). - * @var array - */ - protected $contentIndex = array(); - - /** - * Holds the order and data on each list/content block within this list. - * @var array - */ - protected $diffOrderIndex = array(); - - /** - * This is the opening ol,ul,dl ist tag. - * @var string - */ - protected $oldParentTag; - - /** - * This is the opening ol,ul,dl ist tag. - * @var string - */ - protected $newParentTag; - - /** - * We're using the same functions as the parent in build() to get us to the point of - * manipulating the data within this class. - * - * @return string - */ - public function build() - { - // Use the parent functions to get the data we need organized. - $this->splitInputsToWords(); - $this->replaceIsolatedDiffTags(); - $this->indexNewWords(); - // Now use the custom functions in this class to use the data and generate our diff. - $this->diffListContent(); - - return $this->content; - } - - /** - * Calls to the actual custom functions of this class, to diff list content. - */ - protected function diffListContent() - { - /* Format the list we're focusing on. - * There will always be one list, though passed as an array with one item. - * Format this to only have the list contents, outside of the array. - */ - $this->formatThisListContent(); - - /* Build an index of content outside of list tags. - */ - $this->indexContent(); - - /* In cases where we're dealing with nested lists, - * make sure we use placeholders to replace the nested lists - */ - $this->replaceListIsolatedDiffTags(); - - /* Build a list of matches we can reference when we diff the contents of the lists. - * This is needed so that we each NEW list node is matched against the best possible OLD list node/ - * It helps us determine whether the list was added, removed, or changed. - */ - $this->matchAndCompareLists(); - - /* Go through the list of matches, content, and diff each. - * Any nested lists would be sent to parent's diffList function, which creates a new listDiff class. - */ - $this->diff(); - } - - /** - * This function is used to populate both contentIndex and diffOrderIndex arrays for use in the diff function. - */ - protected function indexContent() - { - $this->contentIndex = array(); - $this->diffOrderIndex = array('new' => array(), 'old' => array()); - foreach ($this->list as $type => $list) { - - $this->contentIndex[$type] = array(); - $depth = 0; - $parentList = 0; - $position = 0; - $newBlock = true; - $listCount = 0; - $contentCount = 0; - foreach ($list as $key => $word) { - if (!$parentList && $this->isOpeningListTag($word)) { - $depth++; - - $this->diffOrderIndex[$type][] = array('type' => 'list', 'position' => $listCount, 'index' => $key); - $listCount++; - continue; - } - - if (!$parentList && $this->isClosingListTag($word)) { - $depth--; - - if ($depth == 0) { - $newBlock = true; - } - continue; - } - - if ($this->isOpeningIsolatedDiffTag($word)) { - $parentList++; - } - - if ($this->isClosingIsolatedDiffTag($word)) { - $parentList--; - } - - if ($depth == 0) { - if ($newBlock && !array_key_exists($contentCount, $this->contentIndex[$type])) { - $this->diffOrderIndex[$type][] = array('type' => 'content', 'position' => $contentCount, 'index' => $key); - - $position = $contentCount; - $this->contentIndex[$type][$position] = ''; - $contentCount++; - } - - $this->contentIndex[$type][$position] .= $word; - } - - $newBlock = false; - } - } - } - - /* - * This function is used to remove the wrapped ul, ol, or dl characters from this list - * and sets the listType as ul, ol, or dl, so that we can use it later. - * $list is being set here as well, as an array with the old and new version of this list content. - */ - protected function formatThisListContent() - { - $formatArray = array( - array('type' => 'old', 'array' => $this->oldIsolatedDiffTags), - array('type' => 'new', 'array' => $this->newIsolatedDiffTags) - ); - - foreach ($formatArray as $item) { - $values = array_values($item['array']); - $this->list[$item['type']] = count($values) - ? $this->formatList($values[0], $item['type']) - : array(); - } - - $this->listType = $this->newListType ?: $this->oldListType; - } - - /** - * - * @param array $arrayData - * @param string $index - * @return array - */ - protected function formatList(array $arrayData, $index = 'old') - { - $openingTag = $this->getAndStripTag($arrayData[0]); - $closingTag = $this->getAndStripTag($arrayData[count($arrayData) - 1]); - - if (array_key_exists($openingTag, $this->isolatedDiffTags) && - array_key_exists($closingTag, $this->isolatedDiffTags) - ) { - if ($index == 'new' && $this->isOpeningTag($arrayData[0])) { - $this->newParentTag = $arrayData[0]; - $this->newListType = $this->getAndStripTag($arrayData[0]); - } - - if ($index == 'old' && $this->isOpeningTag($arrayData[0])) { - $this->oldParentTag = $arrayData[0]; - $this->oldListType = $this->getAndStripTag($arrayData[0]); - } - - array_shift($arrayData); - array_pop($arrayData); - } - - return $arrayData; - } - - /** - * @param string $tag - * @return string - */ - protected function getAndStripTag($tag) - { - $content = explode(' ', preg_replace("/[^A-Za-z0-9 ]/", '', $tag)); - return $content[0]; - } - - protected function matchAndCompareLists() - { - /** - * Build the an array (childLists) to hold the contents of the list nodes within this list. - * This only holds the content of each list node. - */ - $this->buildChildLists(); - - /** - * Index the list, starting positions, so that we can refer back to it later. - * This is used to see where one list node starts and another ends. - */ - $this->indexLists(); - - /** - * Compare the lists and build $textMatches array with the matches. - * Each match is an array of "new" and "old" keys, with the id of the list it matches to. - * Whenever there is no match (in cases where a new list item was added or removed), null is used instead of the id. - */ - $this->compareChildLists(); - } - - /** - * Creates matches for lists. - */ - protected function compareChildLists() - { - $this->createNewOldMatches($this->childLists, $this->textMatches, 'content'); - } - - /** - * Abstracted function used to match items in an array. - * This is used primarily for populating lists matches. - * - * @param array $listArray - * @param array $resultArray - * @param string|null $column - */ - protected function createNewOldMatches(&$listArray, &$resultArray, $column = null) - { - // Always compare the new against the old. - // Compare each new string against each old string. - $bestMatchPercentages = array(); - - foreach ($listArray['new'] as $thisKey => $thisList) { - $bestMatchPercentages[$thisKey] = array(); - foreach ($listArray['old'] as $thatKey => $thatList) { - // Save the percent amount each new list content compares against the old list content. - similar_text( - $column ? $thisList[$column] : $thisList, - $column ? $thatList[$column] : $thatList, - $percentage - ); - - $bestMatchPercentages[$thisKey][] = $percentage; - } - } - - // Sort each array by value, highest percent to lowest percent. - foreach ($bestMatchPercentages as &$thisMatch) { - arsort($thisMatch); - } - - // Build matches. - $matches = array(); - $taken = array(); - $takenItems = array(); - $absoluteMatch = 100; - foreach ($bestMatchPercentages as $item => $percentages) { - $highestMatch = -1; - $highestMatchKey = -1; - $takeItemKey = -1; - - foreach ($percentages as $key => $percent) { - // Check that the key for the percentage is not already taken and the new percentage is higher. - if (!in_array($key, $taken) && $percent > $highestMatch) { - // If an absolute match, choose this one. - if ($percent == $absoluteMatch) { - $highestMatch = $percent; - $highestMatchKey = $key; - $takenItemKey = $item; - break; - } else { - // Get all the other matces for the same $key - $columns = $this->getArrayColumn($bestMatchPercentages, $key); - $thisBestMatches = array_filter( - $columns, - function ($v) use ($percent) { - return $v > $percent; - } - ); - - arsort($thisBestMatches); - - /** - * If the list item does not meet the threshold, it will not be considered a match. - */ - if ($percent >= self::$listMatchThreshold) { - // If no greater amounts, use this one. - if (!count($thisBestMatches)) { - $highestMatch = $percent; - $highestMatchKey = $key; - $takenItemKey = $item; - break; - } - - // Loop through, comparing only the items that have not already been added. - foreach ($thisBestMatches as $k => $v) { - if (in_array($k, $takenItems)) { - $highestMatch = $percent; - $highestMatchKey = $key; - $takenItemKey = $item; - break(2); - } - } - } - } - } - } - - $matches[] = array('new' => $item, 'old' => $highestMatchKey > -1 ? $highestMatchKey : null); - if ($highestMatchKey > -1) { - $taken[] = $highestMatchKey; - $takenItems[] = $takenItemKey; - } - } - - - - /* Checking for removed items. Basically, if a list item from the old lists is removed - * it will not be accounted for, and will disappear in the results altogether. - * Loop through all the old lists, any that has not been added, will be added as: - * array( new => null, old => oldItemId ) - */ - $matchColumns = $this->getArrayColumn($matches, 'old'); - foreach ($listArray['old'] as $thisKey => $thisList) { - if (!in_array($thisKey, $matchColumns)) { - $matches[] = array('new' => null, 'old' => $thisKey); - } - } - - // Save the matches. - $resultArray = $matches; - } - - /** - * This fuction is exactly like array_column. This is added for PHP versions that do not support array_column. - * @param array $targetArray - * @param mixed $key - * @return array - */ - protected function getArrayColumn(array $targetArray, $key) - { - $data = array(); - foreach ($targetArray as $item) { - if (array_key_exists($key, $item)) { - $data[] = $item[$key]; - } - } - - return $data; - } - - /** - * Build multidimensional array holding the contents of each list node, old and new. - */ - protected function buildChildLists() - { - $this->childLists['old'] = $this->getListsContent($this->list['old']); - $this->childLists['new'] = $this->getListsContent($this->list['new']); - } - - /** - * Diff the actual contents of the lists against their matched counterpart. - * Build the content of the class. - */ - protected function diff() - { - // Add the opening parent node from listType. So if ol,
    , etc. - $this->content = $this->addListTypeWrapper(); - - $oldIndexCount = 0; - $diffOrderNewKeys = array_keys($this->diffOrderIndex['new']); - foreach ($this->diffOrderIndex['new'] as $key => $index) { - - if ($index['type'] == "list") { - - // Check to see if an old list was deleted. - $oldMatch = $this->getArrayByColumnValue($this->textMatches, 'old', $index['position']); - if ($oldMatch && $oldMatch['new'] === null) { - $newList = ''; - $oldList = $this->getListByMatch($oldMatch, 'old'); - $this->content .= $this->addListElementToContent($newList, $oldList, $oldMatch, $index, 'old'); - } - - $match = $this->getArrayByColumnValue($this->textMatches, 'new', $index['position']); - $newList = $this->childLists['new'][$match['new']]; - $oldList = $this->getListByMatch($match, 'old'); - $this->content .= $this->addListElementToContent($newList, $oldList, $match, $index, 'new'); - } - - if ($index['type'] == 'content') { - $this->content .= $this->addContentElementsToContent($oldIndexCount, $index['position']); - } - - $oldIndexCount++; - - if ($key == $diffOrderNewKeys[count($diffOrderNewKeys) - 1]) { - foreach ($this->diffOrderIndex['old'] as $oldKey => $oldIndex) { - if ($oldKey > $key) { - if ($oldIndex['type'] == 'list') { - $oldMatch = $this->getArrayByColumnValue($this->textMatches, 'old', $oldIndex['position']); - if ($oldMatch && $oldMatch['new'] === null) { - $newList = ''; - $oldList = $this->getListByMatch($oldMatch, 'old'); - $this->content .= $this->addListElementToContent($newList, $oldList, $oldMatch, $oldIndex, 'old'); - } - } else { - $this->content .= $this->addContentElementsToContent($oldKey); - } - } - } - } - } - - // Add the closing parent node from listType. So if ol,
, etc. - $this->content .= $this->addListTypeWrapper(false); - } - - /** - * - * @param string $newList - * @param string $oldList - * @param array $match - * @param array $index - * @return string - */ - protected function addListElementToContent($newList, $oldList, array $match, array $index, $type) - { - $content = $this->list[$type][$index['index']]; - $content .= $this->processPlaceholders( - $this->diffElements( - $this->convertListContentArrayToString($oldList), - $this->convertListContentArrayToString($newList), - false - ), - $match - ); - $content .= ""; - return $content; - } - - /** - * - * @param integer $oldIndexCount - * @param null|integer $newPosition - * @return string - */ - protected function addContentElementsToContent($oldIndexCount, $newPosition = null) - { - $newContent = $newPosition && array_key_exists($newPosition, $this->contentIndex['new']) - ? $this->contentIndex['new'][$newPosition] - : ''; - - $oldDiffOrderIndexMatch = array_key_exists($oldIndexCount, $this->diffOrderIndex['old']) - ? $this->diffOrderIndex['old'][$oldIndexCount] - : ''; - - $oldContent = $oldDiffOrderIndexMatch && array_key_exists($oldDiffOrderIndexMatch['position'], $this->contentIndex['old']) - ? $this->contentIndex['old'][$oldDiffOrderIndexMatch['position']] - : ''; - - $diffObject = new HtmlDiff($oldContent, $newContent); - $content = $diffObject->build(); - return $content; - } - - /** - * - * @param array $match - * @param string $type - * @return array|string - */ - protected function getListByMatch(array $match, $type = 'new') - { - return array_key_exists($match[$type], $this->childLists[$type]) - ? $this->childLists[$type][$match[$type]] - : ''; - } - - /** - * This function replaces array_column function in PHP for older versions of php. - * - * @param array $parentArray - * @param string $column - * @param mixed $value - * @param boolean $allMatches - * @return array|boolean - */ - protected function getArrayByColumnValue($parentArray, $column, $value, $allMatches = false) - { - $returnArray = array(); - foreach ($parentArray as $array) { - if (array_key_exists($column, $array) && $array[$column] == $value) { - if ($allMatches) { - $returnArray[] = $array; - } else { - return $array; - } - } - } - - return $allMatches ? $returnArray : false; - } - - /** - * Converts the list (li) content arrays to string. - * - * @param array $listContentArray - * @return string - */ - protected function convertListContentArrayToString($listContentArray) - { - if (!is_array($listContentArray)) { - return $listContentArray; - } - - $content = array(); - - $words = explode(" ", $listContentArray['content']); - $nestedListCount = 0; - foreach ($words as $word) { - $match = $word == self::$listPlaceHolder; - - $content[] = $match - ? "
  • " . $this->convertListContentArrayToString($listContentArray['kids'][$nestedListCount]) . "
  • " - : $word; - - if ($match) { - $nestedListCount++; - } - } - - return implode(" ", $content); - } - - /** - * Return the contents of each list node. - * Process any placeholders for nested lists. - * - * @param string $text - * @param array $matches - * @return string - */ - protected function processPlaceholders($text, array $matches) - { - // Prepare return - $returnText = array(); - // Save the contents of all list nodes, new and old. - $contentVault = array( - 'old' => $this->getListContent('old', $matches), - 'new' => $this->getListContent('new', $matches) - ); - - $count = 0; - // Loop through the text checking for placeholders. If a nested list is found, create a new ListDiff object for it. - foreach (explode(' ', $text) as $word) { - $preContent = $this->checkWordForDiffTag($this->stripNewLine($word)); - - if (in_array( - is_array($preContent) ? $preContent[1] : $preContent, - $this->isolatedDiffTags - ) - ) { - $oldText = array_key_exists($count, $contentVault['old']) ? implode('', $contentVault['old'][$count]) : ''; - $newText = array_key_exists($count, $contentVault['new']) ? implode('', $contentVault['new'][$count]) : ''; - $content = $this->diffList($oldText, $newText); - $count++; - } else { - $content = $preContent; - } - - $returnText[] = is_array($preContent) ? $preContent[0] . $content . $preContent[2] : $content; - } - // Return the result. - return implode(' ', $returnText); - } - - /** - * Checks to see if a diff tag is in string. - * - * @param string $word - * @return string - */ - protected function checkWordForDiffTag($word) - { - foreach ($this->isolatedDiffTags as $diffTag) { - if (strpos($word, $diffTag) > -1) { - $position = strpos($word, $diffTag); - $length = strlen($diffTag); - $result = array( - substr($word, 0, $position), - $diffTag, - substr($word, ($position + $length)) - ); - - return $result; - } - } - - return $word; - } - - /** - * Used to remove new lines. - * - * @param string $text - * @return string - */ - protected function stripNewLine($text) - { - return trim(preg_replace('/\s\s+/', ' ', $text)); - } - - /** - * Grab the list content using the listsIndex array. - * - * @param string $indexKey - * @param array $matches - * @return array - */ - protected function getListContent($indexKey = 'new', array $matches) - { - $bucket = array(); - - if (isset($matches[$indexKey]) && $matches[$indexKey] !== null) { - $start = $this->listsIndex[$indexKey][$matches[$indexKey]]; - $stop = $this->findEndForIndex($this->list[$indexKey], $start); - - for ($x = $start; $x <= $stop; $x++) { - - if (in_array($this->list[$indexKey][$x], $this->isolatedDiffTags)) { - $bucket[] = $this->listIsolatedDiffTags[$indexKey][$x]; - } - } - } - - return $bucket; - } - - /** - * Finds the end of list within its index. - * - * @param array $index - * @param integer $start - * @return integer - */ - protected function findEndForIndex(array $index, $start) - { - $array = array_splice($index, $start); - $count = 0; - foreach ($array as $key => $item) { - if ($this->isOpeningListTag($item)) { - $count++; - } - - if ($this->isClosingListTag($item)) { - $count--; - if ($count === 0) { - return $start + $key; - } - } - } - - return $start + count($array); - } - - /** - * indexLists - * - * Index the list, starting positions, so that we can refer back to it later. - * This is used to see where one list node starts and another ends. - */ - protected function indexLists() - { - $this->listsIndex = array(); - $count = 0; - foreach ($this->list as $type => $list) { - $this->listsIndex[$type] = array(); - - foreach ($list as $key => $listItem) { - if ($this->isOpeningListTag($listItem)) { - $count++; - if ($count === 1) { - $this->listsIndex[$type][] = $key; - } - } - - if ($this->isClosingListTag($listItem)) { - $count--; - } - } - } - } - - /** - * Adds the opening or closing list html element, based on listType. - * - * @param boolean $opening - * @return string - */ - protected function addListTypeWrapper($opening = true) - { - - if ($opening) { - return $this->newParentTag ?: $this->oldParentTag; - } else { - return "<" . (!$opening ? "/" : '') . $this->listType . ">"; - } - } - - /** - * Replace nested list with placeholders. - */ - public function replaceListIsolatedDiffTags() - { - $this->listIsolatedDiffTags['old'] = $this->createIsolatedDiffTagPlaceholders($this->list['old']); - $this->listIsolatedDiffTags['new'] = $this->createIsolatedDiffTagPlaceholders($this->list['new']); - } - - /** - * Grab the contents of a list node. - * - * @param array $contentArray - * @param boolean $stripTags - * @return array - */ - protected function getListsContent(array $contentArray, $stripTags = true) - { - $lematches = array(); - $arrayDepth = 0; - $nestedCount = array(); - foreach ($contentArray as $index => $word) { - - if ($this->isOpeningListTag($word)) { - $arrayDepth++; - if (!array_key_exists($arrayDepth, $nestedCount)) { - $nestedCount[$arrayDepth] = 1; - } else { - $nestedCount[$arrayDepth]++; - } - continue; - } - - if ($this->isClosingListTag($word)) { - $arrayDepth--; - continue; - } - - if ($arrayDepth > 0) { - $this->addStringToArrayByDepth($word, $lematches, $arrayDepth, 1, $nestedCount); - } - } - - return $lematches; - } - - /** - * This function helps build the list content array of a list. - * If a list has another list within it, the inner list is replaced with the list placeholder and the inner list - * content becomes a child of the parent list. - * This goes recursively down. - * - * @param string $word - * @param array $array - * @param integer $targetDepth - * @param integer $thisDepth - * @param array $nestedCount - */ - protected function addStringToArrayByDepth($word, array &$array, $targetDepth, $thisDepth, array $nestedCount) - { - // determine what depth we're at - if ($targetDepth == $thisDepth) { - // decide on what to do at this level - - if (array_key_exists('content', $array)) { - $array['content'] .= $word; - } else { - // if we're on depth 1, add content - if ($nestedCount[$targetDepth] > count($array)) { - $array[] = array('content' => '', 'kids' => array()); - } - - $array[count($array) - 1]['content'] .= $word; - } - - } else { - - // create first kid if not exist - $newArray = array('content' => '', 'kids' => array()); - - if (array_key_exists('kids', $array)) { - if ($nestedCount[$targetDepth] > count($array['kids'])) { - $array['kids'][] = $newArray; - $array['content'] .= self::$listPlaceHolder; - } - - // continue to the next depth - $thisDepth++; - - // get last kid and send to next depth - - $this->addStringToArrayByDepth( - $word, - $array['kids'][count($array['kids']) - 1], - $targetDepth, - $thisDepth, - $nestedCount - ); - - } else { - - if ($nestedCount[$targetDepth] > count($array[count($array) - 1]['kids'])) { - $array[count($array) - 1]['kids'][] = $newArray; - $array[count($array) - 1]['content'] .= self::$listPlaceHolder; - } - // continue to the next depth - $thisDepth++; - - // get last kid and send to next depth - - $this->addStringToArrayByDepth( - $word, - $array[count($array) - 1]['kids'][count($array[count($array) - 1]['kids']) - 1], - $targetDepth, - $thisDepth, - $nestedCount - ); - } - } - } - - /** - * Checks if text is opening list tag. - * - * @param string $item - * @return boolean - */ - protected function isOpeningListTag($item) - { - if (preg_match("#]*>\\s*#iU", $item)) { - return true; - } - - return false; - } - - /** - * Check if text is closing list tag. - * - * @param string $item - * @return boolean - */ - protected function isClosingListTag($item) - { - if (preg_match("#]*>\\s*#iU", $item)) { - return true; - } - - return false; - } -} + '[[REPLACE_ORDERED_LIST]]', + 'ul' => '[[REPLACE_UNORDERED_LIST]]', + 'dl' => '[[REPLACE_DEFINITION_LIST]]', + ); + + /** + * List (li) placeholder. + * @var string + */ + protected static $listPlaceHolder = "[[REPLACE_LIST_ITEM]]"; + + /** + * Holds the type of list this is ol, ul, dl. + * @var string + */ + protected $listType; + + /** + * Used to hold what type of list the old list is. + * @var string + */ + protected $oldListType; + + /** + * Used to hold what type of list the new list is. + * @var string + */ + protected $newListType; + + /** + * Hold the old/new content of the content of the list. + * @var array + */ + protected $list; + + /** + * Contains the old/new child lists content within this list. + * @var array + */ + protected $childLists; + + /** + * Contains the old/new text strings that match + * @var array + */ + protected $textMatches; + + /** + * Contains the indexed start positions of each list within word string. + * @var array + */ + protected $listsIndex; + + /** + * Array that holds the index of all content outside of the array. Format is array(index => content). + * @var array + */ + protected $contentIndex = array(); + + /** + * Holds the order and data on each list/content block within this list. + * @var array + */ + protected $diffOrderIndex = array(); + + /** + * This is the opening ol,ul,dl ist tag. + * @var string + */ + protected $oldParentTag; + + /** + * This is the opening ol,ul,dl ist tag. + * @var string + */ + protected $newParentTag; + + /** + * We're using the same functions as the parent in build() to get us to the point of + * manipulating the data within this class. + * + * @return string + */ + public function build() + { + // Use the parent functions to get the data we need organized. + $this->splitInputsToWords(); + $this->replaceIsolatedDiffTags(); + $this->indexNewWords(); + // Now use the custom functions in this class to use the data and generate our diff. + $this->diffListContent(); + + return $this->content; + } + + /** + * Calls to the actual custom functions of this class, to diff list content. + */ + protected function diffListContent() + { + /* Format the list we're focusing on. + * There will always be one list, though passed as an array with one item. + * Format this to only have the list contents, outside of the array. + */ + $this->formatThisListContent(); + + /* Build an index of content outside of list tags. + */ + $this->indexContent(); + + /* In cases where we're dealing with nested lists, + * make sure we use placeholders to replace the nested lists + */ + $this->replaceListIsolatedDiffTags(); + + /* Build a list of matches we can reference when we diff the contents of the lists. + * This is needed so that we each NEW list node is matched against the best possible OLD list node/ + * It helps us determine whether the list was added, removed, or changed. + */ + $this->matchAndCompareLists(); + + /* Go through the list of matches, content, and diff each. + * Any nested lists would be sent to parent's diffList function, which creates a new listDiff class. + */ + $this->diff(); + } + + /** + * This function is used to populate both contentIndex and diffOrderIndex arrays for use in the diff function. + */ + protected function indexContent() + { + $this->contentIndex = array(); + $this->diffOrderIndex = array('new' => array(), 'old' => array()); + foreach ($this->list as $type => $list) { + + $this->contentIndex[$type] = array(); + $depth = 0; + $parentList = 0; + $position = 0; + $newBlock = true; + $listCount = 0; + $contentCount = 0; + foreach ($list as $key => $word) { + if (!$parentList && $this->isOpeningListTag($word)) { + $depth++; + + $this->diffOrderIndex[$type][] = array('type' => 'list', 'position' => $listCount, 'index' => $key); + $listCount++; + continue; + } + + if (!$parentList && $this->isClosingListTag($word)) { + $depth--; + + if ($depth == 0) { + $newBlock = true; + } + continue; + } + + if ($this->isOpeningIsolatedDiffTag($word)) { + $parentList++; + } + + if ($this->isClosingIsolatedDiffTag($word)) { + $parentList--; + } + + if ($depth == 0) { + if ($newBlock && !array_key_exists($contentCount, $this->contentIndex[$type])) { + $this->diffOrderIndex[$type][] = array('type' => 'content', 'position' => $contentCount, 'index' => $key); + + $position = $contentCount; + $this->contentIndex[$type][$position] = ''; + $contentCount++; + } + + $this->contentIndex[$type][$position] .= $word; + } + + $newBlock = false; + } + } + } + + /* + * This function is used to remove the wrapped ul, ol, or dl characters from this list + * and sets the listType as ul, ol, or dl, so that we can use it later. + * $list is being set here as well, as an array with the old and new version of this list content. + */ + protected function formatThisListContent() + { + $formatArray = array( + array('type' => 'old', 'array' => $this->oldIsolatedDiffTags), + array('type' => 'new', 'array' => $this->newIsolatedDiffTags) + ); + + foreach ($formatArray as $item) { + $values = array_values($item['array']); + $this->list[$item['type']] = count($values) + ? $this->formatList($values[0], $item['type']) + : array(); + } + + $this->listType = $this->newListType ?: $this->oldListType; + } + + /** + * + * @param array $arrayData + * @param string $index + * @return array + */ + protected function formatList(array $arrayData, $index = 'old') + { + $openingTag = $this->getAndStripTag($arrayData[0]); + $closingTag = $this->getAndStripTag($arrayData[count($arrayData) - 1]); + + if (array_key_exists($openingTag, $this->isolatedDiffTags) && + array_key_exists($closingTag, $this->isolatedDiffTags) + ) { + if ($index == 'new' && $this->isOpeningTag($arrayData[0])) { + $this->newParentTag = $arrayData[0]; + $this->newListType = $this->getAndStripTag($arrayData[0]); + } + + if ($index == 'old' && $this->isOpeningTag($arrayData[0])) { + $this->oldParentTag = $arrayData[0]; + $this->oldListType = $this->getAndStripTag($arrayData[0]); + } + + array_shift($arrayData); + array_pop($arrayData); + } + + return $arrayData; + } + + /** + * @param string $tag + * @return string + */ + protected function getAndStripTag($tag) + { + $content = explode(' ', preg_replace("/[^A-Za-z0-9 ]/", '', $tag)); + return $content[0]; + } + + protected function matchAndCompareLists() + { + /** + * Build the an array (childLists) to hold the contents of the list nodes within this list. + * This only holds the content of each list node. + */ + $this->buildChildLists(); + + /** + * Index the list, starting positions, so that we can refer back to it later. + * This is used to see where one list node starts and another ends. + */ + $this->indexLists(); + + /** + * Compare the lists and build $textMatches array with the matches. + * Each match is an array of "new" and "old" keys, with the id of the list it matches to. + * Whenever there is no match (in cases where a new list item was added or removed), null is used instead of the id. + */ + $this->compareChildLists(); + } + + /** + * Creates matches for lists. + */ + protected function compareChildLists() + { + $this->createNewOldMatches($this->childLists, $this->textMatches, 'content'); + } + + /** + * Abstracted function used to match items in an array. + * This is used primarily for populating lists matches. + * + * @param array $listArray + * @param array $resultArray + * @param string|null $column + */ + protected function createNewOldMatches(&$listArray, &$resultArray, $column = null) + { + // Always compare the new against the old. + // Compare each new string against each old string. + $bestMatchPercentages = array(); + + foreach ($listArray['new'] as $thisKey => $thisList) { + $bestMatchPercentages[$thisKey] = array(); + foreach ($listArray['old'] as $thatKey => $thatList) { + // Save the percent amount each new list content compares against the old list content. + similar_text( + $column ? $thisList[$column] : $thisList, + $column ? $thatList[$column] : $thatList, + $percentage + ); + + $bestMatchPercentages[$thisKey][] = $percentage; + } + } + + // Sort each array by value, highest percent to lowest percent. + foreach ($bestMatchPercentages as &$thisMatch) { + arsort($thisMatch); + } + + // Build matches. + $matches = array(); + $taken = array(); + $takenItems = array(); + $absoluteMatch = 100; + foreach ($bestMatchPercentages as $item => $percentages) { + $highestMatch = -1; + $highestMatchKey = -1; + $takeItemKey = -1; + + foreach ($percentages as $key => $percent) { + // Check that the key for the percentage is not already taken and the new percentage is higher. + if (!in_array($key, $taken) && $percent > $highestMatch) { + // If an absolute match, choose this one. + if ($percent == $absoluteMatch) { + $highestMatch = $percent; + $highestMatchKey = $key; + $takenItemKey = $item; + break; + } else { + // Get all the other matces for the same $key + $columns = $this->getArrayColumn($bestMatchPercentages, $key); + $thisBestMatches = array_filter( + $columns, + function ($v) use ($percent) { + return $v > $percent; + } + ); + + arsort($thisBestMatches); + + /** + * If the list item does not meet the threshold, it will not be considered a match. + */ + if ($percent >= self::$listMatchThreshold) { + // If no greater amounts, use this one. + if (!count($thisBestMatches)) { + $highestMatch = $percent; + $highestMatchKey = $key; + $takenItemKey = $item; + break; + } + + // Loop through, comparing only the items that have not already been added. + foreach ($thisBestMatches as $k => $v) { + if (in_array($k, $takenItems)) { + $highestMatch = $percent; + $highestMatchKey = $key; + $takenItemKey = $item; + break(2); + } + } + } + } + } + } + + $matches[] = array('new' => $item, 'old' => $highestMatchKey > -1 ? $highestMatchKey : null); + if ($highestMatchKey > -1) { + $taken[] = $highestMatchKey; + $takenItems[] = $takenItemKey; + } + } + + + + /* Checking for removed items. Basically, if a list item from the old lists is removed + * it will not be accounted for, and will disappear in the results altogether. + * Loop through all the old lists, any that has not been added, will be added as: + * array( new => null, old => oldItemId ) + */ + $matchColumns = $this->getArrayColumn($matches, 'old'); + foreach ($listArray['old'] as $thisKey => $thisList) { + if (!in_array($thisKey, $matchColumns)) { + $matches[] = array('new' => null, 'old' => $thisKey); + } + } + + // Save the matches. + $resultArray = $matches; + } + + /** + * This fuction is exactly like array_column. This is added for PHP versions that do not support array_column. + * @param array $targetArray + * @param mixed $key + * @return array + */ + protected function getArrayColumn(array $targetArray, $key) + { + $data = array(); + foreach ($targetArray as $item) { + if (array_key_exists($key, $item)) { + $data[] = $item[$key]; + } + } + + return $data; + } + + /** + * Build multidimensional array holding the contents of each list node, old and new. + */ + protected function buildChildLists() + { + $this->childLists['old'] = $this->getListsContent($this->list['old']); + $this->childLists['new'] = $this->getListsContent($this->list['new']); + } + + /** + * Diff the actual contents of the lists against their matched counterpart. + * Build the content of the class. + */ + protected function diff() + { + // Add the opening parent node from listType. So if ol,
      , etc. + $this->content = $this->addListTypeWrapper(); + + $oldIndexCount = 0; + $diffOrderNewKeys = array_keys($this->diffOrderIndex['new']); + foreach ($this->diffOrderIndex['new'] as $key => $index) { + + if ($index['type'] == "list") { + + // Check to see if an old list was deleted. + $oldMatch = $this->getArrayByColumnValue($this->textMatches, 'old', $index['position']); + if ($oldMatch && $oldMatch['new'] === null) { + $newList = ''; + $oldList = $this->getListByMatch($oldMatch, 'old'); + $this->content .= $this->addListElementToContent($newList, $oldList, $oldMatch, $index, 'old'); + } + + $match = $this->getArrayByColumnValue($this->textMatches, 'new', $index['position']); + $newList = $this->childLists['new'][$match['new']]; + $oldList = $this->getListByMatch($match, 'old'); + $this->content .= $this->addListElementToContent($newList, $oldList, $match, $index, 'new'); + } + + if ($index['type'] == 'content') { + $this->content .= $this->addContentElementsToContent($oldIndexCount, $index['position']); + } + + $oldIndexCount++; + + if ($key == $diffOrderNewKeys[count($diffOrderNewKeys) - 1]) { + foreach ($this->diffOrderIndex['old'] as $oldKey => $oldIndex) { + if ($oldKey > $key) { + if ($oldIndex['type'] == 'list') { + $oldMatch = $this->getArrayByColumnValue($this->textMatches, 'old', $oldIndex['position']); + if ($oldMatch && $oldMatch['new'] === null) { + $newList = ''; + $oldList = $this->getListByMatch($oldMatch, 'old'); + $this->content .= $this->addListElementToContent($newList, $oldList, $oldMatch, $oldIndex, 'old'); + } + } else { + $this->content .= $this->addContentElementsToContent($oldKey); + } + } + } + } + } + + // Add the closing parent node from listType. So if ol,
    , etc. + $this->content .= $this->addListTypeWrapper(false); + } + + /** + * + * @param string $newList + * @param string $oldList + * @param array $match + * @param array $index + * @return string + */ + protected function addListElementToContent($newList, $oldList, array $match, array $index, $type) + { + $content = $this->list[$type][$index['index']]; + $content .= $this->processPlaceholders( + $this->diffElements( + $this->convertListContentArrayToString($oldList), + $this->convertListContentArrayToString($newList), + false + ), + $match + ); + $content .= ""; + return $content; + } + + /** + * + * @param integer $oldIndexCount + * @param null|integer $newPosition + * @return string + */ + protected function addContentElementsToContent($oldIndexCount, $newPosition = null) + { + $newContent = $newPosition && array_key_exists($newPosition, $this->contentIndex['new']) + ? $this->contentIndex['new'][$newPosition] + : ''; + + $oldDiffOrderIndexMatch = array_key_exists($oldIndexCount, $this->diffOrderIndex['old']) + ? $this->diffOrderIndex['old'][$oldIndexCount] + : ''; + + $oldContent = $oldDiffOrderIndexMatch && array_key_exists($oldDiffOrderIndexMatch['position'], $this->contentIndex['old']) + ? $this->contentIndex['old'][$oldDiffOrderIndexMatch['position']] + : ''; + + $diffObject = new HtmlDiff($oldContent, $newContent); + $content = $diffObject->build(); + return $content; + } + + /** + * + * @param array $match + * @param string $type + * @return array|string + */ + protected function getListByMatch(array $match, $type = 'new') + { + return array_key_exists($match[$type], $this->childLists[$type]) + ? $this->childLists[$type][$match[$type]] + : ''; + } + + /** + * This function replaces array_column function in PHP for older versions of php. + * + * @param array $parentArray + * @param string $column + * @param mixed $value + * @param boolean $allMatches + * @return array|boolean + */ + protected function getArrayByColumnValue($parentArray, $column, $value, $allMatches = false) + { + $returnArray = array(); + foreach ($parentArray as $array) { + if (array_key_exists($column, $array) && $array[$column] == $value) { + if ($allMatches) { + $returnArray[] = $array; + } else { + return $array; + } + } + } + + return $allMatches ? $returnArray : false; + } + + /** + * Converts the list (li) content arrays to string. + * + * @param array $listContentArray + * @return string + */ + protected function convertListContentArrayToString($listContentArray) + { + if (!is_array($listContentArray)) { + return $listContentArray; + } + + $content = array(); + + $words = explode(" ", $listContentArray['content']); + $nestedListCount = 0; + foreach ($words as $word) { + $match = $word == self::$listPlaceHolder; + + $content[] = $match + ? "
  • " . $this->convertListContentArrayToString($listContentArray['kids'][$nestedListCount]) . "
  • " + : $word; + + if ($match) { + $nestedListCount++; + } + } + + return implode(" ", $content); + } + + /** + * Return the contents of each list node. + * Process any placeholders for nested lists. + * + * @param string $text + * @param array $matches + * @return string + */ + protected function processPlaceholders($text, array $matches) + { + // Prepare return + $returnText = array(); + // Save the contents of all list nodes, new and old. + $contentVault = array( + 'old' => $this->getListContent('old', $matches), + 'new' => $this->getListContent('new', $matches) + ); + + $count = 0; + // Loop through the text checking for placeholders. If a nested list is found, create a new ListDiff object for it. + foreach (explode(' ', $text) as $word) { + $preContent = $this->checkWordForDiffTag($this->stripNewLine($word)); + + if (in_array( + is_array($preContent) ? $preContent[1] : $preContent, + $this->isolatedDiffTags + ) + ) { + $oldText = array_key_exists($count, $contentVault['old']) ? implode('', $contentVault['old'][$count]) : ''; + $newText = array_key_exists($count, $contentVault['new']) ? implode('', $contentVault['new'][$count]) : ''; + $content = $this->diffList($oldText, $newText); + $count++; + } else { + $content = $preContent; + } + + $returnText[] = is_array($preContent) ? $preContent[0] . $content . $preContent[2] : $content; + } + // Return the result. + return implode(' ', $returnText); + } + + /** + * Checks to see if a diff tag is in string. + * + * @param string $word + * @return string + */ + protected function checkWordForDiffTag($word) + { + foreach ($this->isolatedDiffTags as $diffTag) { + if (strpos($word, $diffTag) > -1) { + $position = strpos($word, $diffTag); + $length = strlen($diffTag); + $result = array( + substr($word, 0, $position), + $diffTag, + substr($word, ($position + $length)) + ); + + return $result; + } + } + + return $word; + } + + /** + * Used to remove new lines. + * + * @param string $text + * @return string + */ + protected function stripNewLine($text) + { + return trim(preg_replace('/\s\s+/', ' ', $text)); + } + + /** + * Grab the list content using the listsIndex array. + * + * @param string $indexKey + * @param array $matches + * @return array + */ + protected function getListContent($indexKey = 'new', array $matches) + { + $bucket = array(); + + if (isset($matches[$indexKey]) && $matches[$indexKey] !== null) { + $start = $this->listsIndex[$indexKey][$matches[$indexKey]]; + $stop = $this->findEndForIndex($this->list[$indexKey], $start); + + for ($x = $start; $x <= $stop; $x++) { + + if (in_array($this->list[$indexKey][$x], $this->isolatedDiffTags)) { + $bucket[] = $this->listIsolatedDiffTags[$indexKey][$x]; + } + } + } + + return $bucket; + } + + /** + * Finds the end of list within its index. + * + * @param array $index + * @param integer $start + * @return integer + */ + protected function findEndForIndex(array $index, $start) + { + $array = array_splice($index, $start); + $count = 0; + foreach ($array as $key => $item) { + if ($this->isOpeningListTag($item)) { + $count++; + } + + if ($this->isClosingListTag($item)) { + $count--; + if ($count === 0) { + return $start + $key; + } + } + } + + return $start + count($array); + } + + /** + * indexLists + * + * Index the list, starting positions, so that we can refer back to it later. + * This is used to see where one list node starts and another ends. + */ + protected function indexLists() + { + $this->listsIndex = array(); + $count = 0; + foreach ($this->list as $type => $list) { + $this->listsIndex[$type] = array(); + + foreach ($list as $key => $listItem) { + if ($this->isOpeningListTag($listItem)) { + $count++; + if ($count === 1) { + $this->listsIndex[$type][] = $key; + } + } + + if ($this->isClosingListTag($listItem)) { + $count--; + } + } + } + } + + /** + * Adds the opening or closing list html element, based on listType. + * + * @param boolean $opening + * @return string + */ + protected function addListTypeWrapper($opening = true) + { + + if ($opening) { + return $this->newParentTag ?: $this->oldParentTag; + } else { + return "<" . (!$opening ? "/" : '') . $this->listType . ">"; + } + } + + /** + * Replace nested list with placeholders. + */ + public function replaceListIsolatedDiffTags() + { + $this->listIsolatedDiffTags['old'] = $this->createIsolatedDiffTagPlaceholders($this->list['old']); + $this->listIsolatedDiffTags['new'] = $this->createIsolatedDiffTagPlaceholders($this->list['new']); + } + + /** + * Grab the contents of a list node. + * + * @param array $contentArray + * @param boolean $stripTags + * @return array + */ + protected function getListsContent(array $contentArray, $stripTags = true) + { + $lematches = array(); + $arrayDepth = 0; + $nestedCount = array(); + foreach ($contentArray as $index => $word) { + + if ($this->isOpeningListTag($word)) { + $arrayDepth++; + if (!array_key_exists($arrayDepth, $nestedCount)) { + $nestedCount[$arrayDepth] = 1; + } else { + $nestedCount[$arrayDepth]++; + } + continue; + } + + if ($this->isClosingListTag($word)) { + $arrayDepth--; + continue; + } + + if ($arrayDepth > 0) { + $this->addStringToArrayByDepth($word, $lematches, $arrayDepth, 1, $nestedCount); + } + } + + return $lematches; + } + + /** + * This function helps build the list content array of a list. + * If a list has another list within it, the inner list is replaced with the list placeholder and the inner list + * content becomes a child of the parent list. + * This goes recursively down. + * + * @param string $word + * @param array $array + * @param integer $targetDepth + * @param integer $thisDepth + * @param array $nestedCount + */ + protected function addStringToArrayByDepth($word, array &$array, $targetDepth, $thisDepth, array $nestedCount) + { + // determine what depth we're at + if ($targetDepth == $thisDepth) { + // decide on what to do at this level + + if (array_key_exists('content', $array)) { + $array['content'] .= $word; + } else { + // if we're on depth 1, add content + if ($nestedCount[$targetDepth] > count($array)) { + $array[] = array('content' => '', 'kids' => array()); + } + + $array[count($array) - 1]['content'] .= $word; + } + + } else { + + // create first kid if not exist + $newArray = array('content' => '', 'kids' => array()); + + if (array_key_exists('kids', $array)) { + if ($nestedCount[$targetDepth] > count($array['kids'])) { + $array['kids'][] = $newArray; + $array['content'] .= self::$listPlaceHolder; + } + + // continue to the next depth + $thisDepth++; + + // get last kid and send to next depth + + $this->addStringToArrayByDepth( + $word, + $array['kids'][count($array['kids']) - 1], + $targetDepth, + $thisDepth, + $nestedCount + ); + + } else { + + if ($nestedCount[$targetDepth] > count($array[count($array) - 1]['kids'])) { + $array[count($array) - 1]['kids'][] = $newArray; + $array[count($array) - 1]['content'] .= self::$listPlaceHolder; + } + // continue to the next depth + $thisDepth++; + + // get last kid and send to next depth + + $this->addStringToArrayByDepth( + $word, + $array[count($array) - 1]['kids'][count($array[count($array) - 1]['kids']) - 1], + $targetDepth, + $thisDepth, + $nestedCount + ); + } + } + } + + /** + * Checks if text is opening list tag. + * + * @param string $item + * @return boolean + */ + protected function isOpeningListTag($item) + { + if (preg_match("#]*>\\s*#iU", $item)) { + return true; + } + + return false; + } + + /** + * Check if text is closing list tag. + * + * @param string $item + * @return boolean + */ + protected function isClosingListTag($item) + { + if (preg_match("#]*>\\s*#iU", $item)) { + return true; + } + + return false; + } +} diff --git a/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/ListDiff/DiffList.php b/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/ListDiff/DiffList.php index 1d6ee52..bed9eb8 100755 --- a/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/ListDiff/DiffList.php +++ b/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/ListDiff/DiffList.php @@ -1,102 +1,102 @@ -listType = $listType; - $this->startTag = $startTag; - $this->endTag = $endTag; - $this->listItems = $listItems; - $this->attributes = $attributes; - } - - /** - * @return mixed - */ - public function getListType() - { - return $this->listType; - } - - /** - * @param mixed $listType - * - * @return DiffList - */ - public function setListType($listType) - { - $this->listType = $listType; - - return $this; - } - - /** - * @return mixed - */ - public function getStartTag() - { - return $this->startTag; - } - - public function getStartTagWithDiffClass($class = 'diff-list') - { - return str_replace('>', ' class="'.$class.'">', $this->startTag); - } - - /** - * @param mixed $startTag - */ - public function setStartTag($startTag) - { - $this->startTag = $startTag; - } - - /** - * @return mixed - */ - public function getEndTag() - { - return $this->endTag; - } - - /** - * @param mixed $endTag - */ - public function setEndTag($endTag) - { - $this->endTag = $endTag; - } - - /** - * @return mixed - */ - public function getListItems() - { - return $this->listItems; - } - - /** - * @param mixed $listItems - * - * @return DiffList - */ - public function setListItems($listItems) - { - $this->listItems = $listItems; - - return $this; - } +listType = $listType; + $this->startTag = $startTag; + $this->endTag = $endTag; + $this->listItems = $listItems; + $this->attributes = $attributes; + } + + /** + * @return mixed + */ + public function getListType() + { + return $this->listType; + } + + /** + * @param mixed $listType + * + * @return DiffList + */ + public function setListType($listType) + { + $this->listType = $listType; + + return $this; + } + + /** + * @return mixed + */ + public function getStartTag() + { + return $this->startTag; + } + + public function getStartTagWithDiffClass($class = 'diff-list') + { + return str_replace('>', ' class="'.$class.'">', $this->startTag); + } + + /** + * @param mixed $startTag + */ + public function setStartTag($startTag) + { + $this->startTag = $startTag; + } + + /** + * @return mixed + */ + public function getEndTag() + { + return $this->endTag; + } + + /** + * @param mixed $endTag + */ + public function setEndTag($endTag) + { + $this->endTag = $endTag; + } + + /** + * @return mixed + */ + public function getListItems() + { + return $this->listItems; + } + + /** + * @param mixed $listItems + * + * @return DiffList + */ + public function setListItems($listItems) + { + $this->listItems = $listItems; + + return $this; + } } \ No newline at end of file diff --git a/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/ListDiff/DiffListItem.php b/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/ListDiff/DiffListItem.php index b4440ca..da7272f 100755 --- a/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/ListDiff/DiffListItem.php +++ b/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/ListDiff/DiffListItem.php @@ -1,124 +1,124 @@ -text = $text; - $this->attributes = $attributes; - $this->startTag = $startTag; - $this->endTag = $endTag; - } - - /** - * @return array - */ - public function getAttributes() - { - return $this->attributes; - } - - /** - * @param array $attributes - * - * @return DiffListItem - */ - public function setAttributes($attributes) - { - $this->attributes = $attributes; - - return $this; - } - - /** - * @return mixed - */ - public function getText() - { - return $this->text; - } - - /** - * @param mixed $text - * - * @return DiffListItem - */ - public function setText($text) - { - $this->text = $text; - - return $this; - } - - /** - * @return mixed - */ - public function getStartTag() - { - return $this->startTag; - } - - public function getStartTagWithDiffClass($class = 'normal') - { - return str_replace('>', ' class="'.$class.'">', $this->startTag); - } - - /** - * @param mixed $startTag - * - * @return DiffListItem - */ - public function setStartTag($startTag) - { - $this->startTag = $startTag; - - return $this; - } - - /** - * @return mixed - */ - public function getEndTag() - { - return $this->endTag; - } - - /** - * @param mixed $endTag - * - * @return DiffListItem - */ - public function setEndTag($endTag) - { - $this->endTag = $endTag; - - return $this; - } - - public function getHtml($class = 'normal', $wrapTag = null) - { - $startWrap = $wrapTag ? sprintf('<%s>', $wrapTag) : ''; - $endWrap = $wrapTag ? sprintf('', $wrapTag) : ''; - return sprintf('%s%s%s%s%s', $this->getStartTagWithDiffClass($class), $startWrap, $this->getInnerHtml(), $endWrap, $this->endTag); - } - - public function getInnerHtml() - { - return implode('', $this->text); - } - - public function __toString() - { - return $this->getHtml(); - } +text = $text; + $this->attributes = $attributes; + $this->startTag = $startTag; + $this->endTag = $endTag; + } + + /** + * @return array + */ + public function getAttributes() + { + return $this->attributes; + } + + /** + * @param array $attributes + * + * @return DiffListItem + */ + public function setAttributes($attributes) + { + $this->attributes = $attributes; + + return $this; + } + + /** + * @return mixed + */ + public function getText() + { + return $this->text; + } + + /** + * @param mixed $text + * + * @return DiffListItem + */ + public function setText($text) + { + $this->text = $text; + + return $this; + } + + /** + * @return mixed + */ + public function getStartTag() + { + return $this->startTag; + } + + public function getStartTagWithDiffClass($class = 'normal') + { + return str_replace('>', ' class="'.$class.'">', $this->startTag); + } + + /** + * @param mixed $startTag + * + * @return DiffListItem + */ + public function setStartTag($startTag) + { + $this->startTag = $startTag; + + return $this; + } + + /** + * @return mixed + */ + public function getEndTag() + { + return $this->endTag; + } + + /** + * @param mixed $endTag + * + * @return DiffListItem + */ + public function setEndTag($endTag) + { + $this->endTag = $endTag; + + return $this; + } + + public function getHtml($class = 'normal', $wrapTag = null) + { + $startWrap = $wrapTag ? sprintf('<%s>', $wrapTag) : ''; + $endWrap = $wrapTag ? sprintf('', $wrapTag) : ''; + return sprintf('%s%s%s%s%s', $this->getStartTagWithDiffClass($class), $startWrap, $this->getInnerHtml(), $endWrap, $this->endTag); + } + + public function getInnerHtml() + { + return implode('', $this->text); + } + + public function __toString() + { + return $this->getHtml(); + } } \ No newline at end of file diff --git a/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/ListDiffNew.php b/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/ListDiffNew.php index 7ee2a1f..96e45e4 100755 --- a/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/ListDiffNew.php +++ b/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/ListDiffNew.php @@ -1,280 +1,280 @@ -setConfig($config); - } - - return $diff; - } - - public function build() - { - if ($this->hasDiffCache() && $this->getDiffCache()->contains($this->oldText, $this->newText)) { - $this->content = $this->getDiffCache()->fetch($this->oldText, $this->newText); - - return $this->content; - } - - $this->splitInputsToWords(); - - $this->content = $this->diffLists( - $this->buildDiffList($this->oldWords), - $this->buildDiffList($this->newWords) - ); - - if ($this->hasDiffCache()) { - $this->getDiffCache()->save($this->oldText, $this->newText, $this->content); - } - - return $this->content; - } - - protected function diffLists(DiffList $oldList, DiffList $newList) - { - $oldMatchData = array(); - $newMatchData = array(); - $oldListIndices = array(); - $newListIndices = array(); - $oldListItems = array(); - $newListItems = array(); - - foreach ($oldList->getListItems() as $oldIndex => $oldListItem) { - if ($oldListItem instanceof DiffListItem) { - $oldListItems[$oldIndex] = $oldListItem; - - $oldListIndices[] = $oldIndex; - $oldMatchData[$oldIndex] = array(); - - // Get match percentages - foreach ($newList->getListItems() as $newIndex => $newListItem) { - if ($newListItem instanceof DiffListItem) { - if (!in_array($newListItem, $newListItems)) { - $newListItems[$newIndex] = $newListItem; - } - if (!in_array($newIndex, $newListIndices)) { - $newListIndices[] = $newIndex; - } - if (!array_key_exists($newIndex, $newMatchData)) { - $newMatchData[$newIndex] = array(); - } - - $oldText = implode('', $oldListItem->getText()); - $newText = implode('', $newListItem->getText()); - - // similar_text - $percentage = null; - similar_text($oldText, $newText, $percentage); - - $oldMatchData[$oldIndex][$newIndex] = $percentage; - $newMatchData[$newIndex][$oldIndex] = $percentage; - } - } - } - } - - $currentIndexInOld = 0; - $currentIndexInNew = 0; - $oldCount = count($oldListIndices); - $newCount = count($newListIndices); - $difference = max($oldCount, $newCount) - min($oldCount, $newCount); - - $diffOutput = ''; - - foreach ($newList->getListItems() as $newIndex => $newListItem) { - if ($newListItem instanceof DiffListItem) { - $operation = null; - - $oldListIndex = array_key_exists($currentIndexInOld, $oldListIndices) ? $oldListIndices[$currentIndexInOld] : null; - $class = 'normal'; - - if (null !== $oldListIndex && array_key_exists($oldListIndex, $oldMatchData)) { - // Check percentage matches of upcoming list items in old. - $matchPercentage = $oldMatchData[$oldListIndex][$newIndex]; - - // does the old list item match better? - $otherMatchBetter = false; - foreach ($oldMatchData[$oldListIndex] as $index => $percentage) { - if ($index > $newIndex && $percentage > $matchPercentage) { - $otherMatchBetter = $index; - } - } - - if (false !== $otherMatchBetter && $newCount > $oldCount && $difference > 0) { - $diffOutput .= sprintf('%s', $newListItem->getHtml('normal new', 'ins')); - $currentIndexInNew++; - $difference--; - - continue; - } - - $nextOldListIndex = array_key_exists($currentIndexInOld + 1, $oldListIndices) ? $oldListIndices[$currentIndexInOld + 1] : null; - - $replacement = false; - - if ($nextOldListIndex !== null && $oldMatchData[$nextOldListIndex][$newIndex] > $matchPercentage && $oldMatchData[$nextOldListIndex][$newIndex] > $this->config->getMatchThreshold()) { - // Following list item in old is better match, use that. - $diffOutput .= sprintf('%s', $oldListItems[$oldListIndex]->getHtml('removed', 'del')); - - $currentIndexInOld++; - $oldListIndex = $nextOldListIndex; - $matchPercentage = $oldMatchData[$oldListIndex]; - $replacement = true; - } - - if ($matchPercentage > $this->config->getMatchThreshold() || $currentIndexInNew === $currentIndexInOld) { - // Diff the two lists. - $htmlDiff = HtmlDiff::create( - $oldListItems[$oldListIndex]->getInnerHtml(), - $newListItem->getInnerHtml(), - $this->config - ); - $diffContent = $htmlDiff->build(); - - $diffOutput .= sprintf('%s%s%s', $newListItem->getStartTagWithDiffClass($replacement ? 'replacement' : 'normal'), $diffContent, $newListItem->getEndTag()); - - } else { - $diffOutput .= sprintf('%s', $oldListItems[$oldListIndex]->getHtml('removed', 'del')); - $diffOutput .= sprintf('%s', $newListItem->getHtml('replacement', 'ins')); - } - $currentIndexInOld++; - } else { - $diffOutput .= sprintf('%s', $newListItem->getHtml('normal new', 'ins')); - } - - $currentIndexInNew++; - } - } - - // Output any additional list items - while (array_key_exists($currentIndexInOld, $oldListIndices)) { - $oldListIndex = $oldListIndices[$currentIndexInOld]; - $diffOutput .= sprintf('%s', $oldListItems[$oldListIndex]->getHtml('removed', 'del')); - $currentIndexInOld++; - } - - return sprintf('%s%s%s', $newList->getStartTagWithDiffClass(), $diffOutput, $newList->getEndTag()); - } - - protected function buildDiffList($words) - { - $listType = null; - $listStartTag = null; - $listEndTag = null; - $attributes = array(); - $openLists = 0; - $openListItems = 0; - $list = array(); - $currentListItem = null; - $listItemType = null; - $listItemStart = null; - $listItemEnd = null; - - foreach ($words as $i => $word) { - if ($this->isOpeningListTag($word, $listType)) { - if ($openLists > 0) { - if ($openListItems > 0) { - $currentListItem[] = $word; - } else { - $list[] = $word; - } - } else { - $listType = substr($word, 1, 2); - $listStartTag = $word; - } - - $openLists++; - } elseif ($this->isClosingListTag($word, $listType)) { - if ($openLists > 1) { - if ($openListItems > 0) { - $currentListItem[] = $word; - } else { - $list[] = $word; - } - } else { - $listEndTag = $word; - } - - $openLists--; - } elseif ($this->isOpeningListItemTag($word, $listItemType)) { - if ($openListItems === 0) { - // New top-level list item - $currentListItem = array(); - $listItemType = substr($word, 1, 2); - $listItemStart = $word; - } else { - $currentListItem[] = $word; - } - - $openListItems++; - } elseif ($this->isClosingListItemTag($word, $listItemType)) { - if ($openListItems === 1) { - $listItemEnd = $word; - $listItem = new DiffListItem($currentListItem, array(), $listItemStart, $listItemEnd); - $list[] = $listItem; - $currentListItem = null; - } else { - $currentListItem[] = $word; - } - - $openListItems--; - } else { - if ($openListItems > 0) { - $currentListItem[] = $word; - } else { - $list[] = $word; - } - } - } - - $diffList = new DiffList($listType, $listStartTag, $listEndTag, $list, $attributes); - - return $diffList; - } - - protected function isOpeningListTag($word, $type = null) - { - $filter = $type !== null ? array('<' . $type) : array('setConfig($config); + } + + return $diff; + } + + public function build() + { + if ($this->hasDiffCache() && $this->getDiffCache()->contains($this->oldText, $this->newText)) { + $this->content = $this->getDiffCache()->fetch($this->oldText, $this->newText); + + return $this->content; + } + + $this->splitInputsToWords(); + + $this->content = $this->diffLists( + $this->buildDiffList($this->oldWords), + $this->buildDiffList($this->newWords) + ); + + if ($this->hasDiffCache()) { + $this->getDiffCache()->save($this->oldText, $this->newText, $this->content); + } + + return $this->content; + } + + protected function diffLists(DiffList $oldList, DiffList $newList) + { + $oldMatchData = array(); + $newMatchData = array(); + $oldListIndices = array(); + $newListIndices = array(); + $oldListItems = array(); + $newListItems = array(); + + foreach ($oldList->getListItems() as $oldIndex => $oldListItem) { + if ($oldListItem instanceof DiffListItem) { + $oldListItems[$oldIndex] = $oldListItem; + + $oldListIndices[] = $oldIndex; + $oldMatchData[$oldIndex] = array(); + + // Get match percentages + foreach ($newList->getListItems() as $newIndex => $newListItem) { + if ($newListItem instanceof DiffListItem) { + if (!in_array($newListItem, $newListItems)) { + $newListItems[$newIndex] = $newListItem; + } + if (!in_array($newIndex, $newListIndices)) { + $newListIndices[] = $newIndex; + } + if (!array_key_exists($newIndex, $newMatchData)) { + $newMatchData[$newIndex] = array(); + } + + $oldText = implode('', $oldListItem->getText()); + $newText = implode('', $newListItem->getText()); + + // similar_text + $percentage = null; + similar_text($oldText, $newText, $percentage); + + $oldMatchData[$oldIndex][$newIndex] = $percentage; + $newMatchData[$newIndex][$oldIndex] = $percentage; + } + } + } + } + + $currentIndexInOld = 0; + $currentIndexInNew = 0; + $oldCount = count($oldListIndices); + $newCount = count($newListIndices); + $difference = max($oldCount, $newCount) - min($oldCount, $newCount); + + $diffOutput = ''; + + foreach ($newList->getListItems() as $newIndex => $newListItem) { + if ($newListItem instanceof DiffListItem) { + $operation = null; + + $oldListIndex = array_key_exists($currentIndexInOld, $oldListIndices) ? $oldListIndices[$currentIndexInOld] : null; + $class = 'normal'; + + if (null !== $oldListIndex && array_key_exists($oldListIndex, $oldMatchData)) { + // Check percentage matches of upcoming list items in old. + $matchPercentage = $oldMatchData[$oldListIndex][$newIndex]; + + // does the old list item match better? + $otherMatchBetter = false; + foreach ($oldMatchData[$oldListIndex] as $index => $percentage) { + if ($index > $newIndex && $percentage > $matchPercentage) { + $otherMatchBetter = $index; + } + } + + if (false !== $otherMatchBetter && $newCount > $oldCount && $difference > 0) { + $diffOutput .= sprintf('%s', $newListItem->getHtml('normal new', 'ins')); + $currentIndexInNew++; + $difference--; + + continue; + } + + $nextOldListIndex = array_key_exists($currentIndexInOld + 1, $oldListIndices) ? $oldListIndices[$currentIndexInOld + 1] : null; + + $replacement = false; + + if ($nextOldListIndex !== null && $oldMatchData[$nextOldListIndex][$newIndex] > $matchPercentage && $oldMatchData[$nextOldListIndex][$newIndex] > $this->config->getMatchThreshold()) { + // Following list item in old is better match, use that. + $diffOutput .= sprintf('%s', $oldListItems[$oldListIndex]->getHtml('removed', 'del')); + + $currentIndexInOld++; + $oldListIndex = $nextOldListIndex; + $matchPercentage = $oldMatchData[$oldListIndex]; + $replacement = true; + } + + if ($matchPercentage > $this->config->getMatchThreshold() || $currentIndexInNew === $currentIndexInOld) { + // Diff the two lists. + $htmlDiff = HtmlDiff::create( + $oldListItems[$oldListIndex]->getInnerHtml(), + $newListItem->getInnerHtml(), + $this->config + ); + $diffContent = $htmlDiff->build(); + + $diffOutput .= sprintf('%s%s%s', $newListItem->getStartTagWithDiffClass($replacement ? 'replacement' : 'normal'), $diffContent, $newListItem->getEndTag()); + + } else { + $diffOutput .= sprintf('%s', $oldListItems[$oldListIndex]->getHtml('removed', 'del')); + $diffOutput .= sprintf('%s', $newListItem->getHtml('replacement', 'ins')); + } + $currentIndexInOld++; + } else { + $diffOutput .= sprintf('%s', $newListItem->getHtml('normal new', 'ins')); + } + + $currentIndexInNew++; + } + } + + // Output any additional list items + while (array_key_exists($currentIndexInOld, $oldListIndices)) { + $oldListIndex = $oldListIndices[$currentIndexInOld]; + $diffOutput .= sprintf('%s', $oldListItems[$oldListIndex]->getHtml('removed', 'del')); + $currentIndexInOld++; + } + + return sprintf('%s%s%s', $newList->getStartTagWithDiffClass(), $diffOutput, $newList->getEndTag()); + } + + protected function buildDiffList($words) + { + $listType = null; + $listStartTag = null; + $listEndTag = null; + $attributes = array(); + $openLists = 0; + $openListItems = 0; + $list = array(); + $currentListItem = null; + $listItemType = null; + $listItemStart = null; + $listItemEnd = null; + + foreach ($words as $i => $word) { + if ($this->isOpeningListTag($word, $listType)) { + if ($openLists > 0) { + if ($openListItems > 0) { + $currentListItem[] = $word; + } else { + $list[] = $word; + } + } else { + $listType = substr($word, 1, 2); + $listStartTag = $word; + } + + $openLists++; + } elseif ($this->isClosingListTag($word, $listType)) { + if ($openLists > 1) { + if ($openListItems > 0) { + $currentListItem[] = $word; + } else { + $list[] = $word; + } + } else { + $listEndTag = $word; + } + + $openLists--; + } elseif ($this->isOpeningListItemTag($word, $listItemType)) { + if ($openListItems === 0) { + // New top-level list item + $currentListItem = array(); + $listItemType = substr($word, 1, 2); + $listItemStart = $word; + } else { + $currentListItem[] = $word; + } + + $openListItems++; + } elseif ($this->isClosingListItemTag($word, $listItemType)) { + if ($openListItems === 1) { + $listItemEnd = $word; + $listItem = new DiffListItem($currentListItem, array(), $listItemStart, $listItemEnd); + $list[] = $listItem; + $currentListItem = null; + } else { + $currentListItem[] = $word; + } + + $openListItems--; + } else { + if ($openListItems > 0) { + $currentListItem[] = $word; + } else { + $list[] = $word; + } + } + } + + $diffList = new DiffList($listType, $listStartTag, $listEndTag, $list, $attributes); + + return $diffList; + } + + protected function isOpeningListTag($word, $type = null) + { + $filter = $type !== null ? array('<' . $type) : array('startInOld = $startInOld; - $this->startInNew = $startInNew; - $this->size = $size; - } - - public function endInOld() - { - return $this->startInOld + $this->size; - } - - public function endInNew() - { - return $this->startInNew + $this->size; - } -} +startInOld = $startInOld; + $this->startInNew = $startInNew; + $this->size = $size; + } + + public function endInOld() + { + return $this->startInOld + $this->size; + } + + public function endInNew() + { + return $this->startInNew + $this->size; + } +} diff --git a/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Operation.php b/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Operation.php index 28400a5..b2276a7 100755 --- a/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Operation.php +++ b/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Operation.php @@ -1,21 +1,21 @@ -action = $action; - $this->startInOld = $startInOld; - $this->endInOld = $endInOld; - $this->startInNew = $startInNew; - $this->endInNew = $endInNew; - } -} +action = $action; + $this->startInOld = $startInOld; + $this->endInOld = $endInOld; + $this->startInNew = $startInNew; + $this->endInNew = $endInNew; + } +} diff --git a/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/AbstractTableElement.php b/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/AbstractTableElement.php index 20dca33..0520e67 100755 --- a/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/AbstractTableElement.php +++ b/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/AbstractTableElement.php @@ -1,94 +1,94 @@ -domNode = $domNode; - } - - /** - * @return \DOMElement - */ - public function getDomNode() - { - return $this->domNode; - } - - /** - * @param \DOMElement $domNode - * - * @return $this - */ - public function setDomNode(\DOMElement $domNode) - { - $this->domNode = $domNode; - - return $this; - } - - /** - * @return string - */ - public function getInnerHtml() - { - $innerHtml = ''; - - if ($this->domNode) { - foreach ($this->domNode->childNodes as $child) { - $innerHtml .= static::htmlFromNode($child); - } - } - - return $innerHtml; - } - - /** - * @param string $name - * - * @return string - */ - public function getAttribute($name) - { - return $this->domNode->getAttribute($name); - } - - /** - * @param \DOMDocument $domDocument - * - * @return \DOMElement - */ - public function cloneNode(\DOMDocument $domDocument) - { - return $domDocument->importNode($this->getDomNode()->cloneNode(false), false); - } - - /** - * @param \DOMElement $node - * - * @return string - */ - public static function htmlFromNode($node) - { - $domDocument = new \DOMDocument(); - $newNode = $domDocument->importNode($node, true); - $domDocument->appendChild($newNode); - return trim($domDocument->saveHTML()); - } -} +domNode = $domNode; + } + + /** + * @return \DOMElement + */ + public function getDomNode() + { + return $this->domNode; + } + + /** + * @param \DOMElement $domNode + * + * @return $this + */ + public function setDomNode(\DOMElement $domNode) + { + $this->domNode = $domNode; + + return $this; + } + + /** + * @return string + */ + public function getInnerHtml() + { + $innerHtml = ''; + + if ($this->domNode) { + foreach ($this->domNode->childNodes as $child) { + $innerHtml .= static::htmlFromNode($child); + } + } + + return $innerHtml; + } + + /** + * @param string $name + * + * @return string + */ + public function getAttribute($name) + { + return $this->domNode->getAttribute($name); + } + + /** + * @param \DOMDocument $domDocument + * + * @return \DOMElement + */ + public function cloneNode(\DOMDocument $domDocument) + { + return $domDocument->importNode($this->getDomNode()->cloneNode(false), false); + } + + /** + * @param \DOMElement $node + * + * @return string + */ + public static function htmlFromNode($node) + { + $domDocument = new \DOMDocument(); + $newNode = $domDocument->importNode($node, true); + $domDocument->appendChild($newNode); + return trim($domDocument->saveHTML()); + } +} diff --git a/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/DiffRowPosition.php b/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/DiffRowPosition.php index 952e3a3..71b43e4 100755 --- a/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/DiffRowPosition.php +++ b/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/DiffRowPosition.php @@ -1,268 +1,268 @@ -indexInOld = $indexInOld; - $this->indexInNew = $indexInNew; - $this->columnInOld = $columnInOld; - $this->columnInNew = $columnInNew; - } - - /** - * @return int - */ - public function getIndexInOld() - { - return $this->indexInOld; - } - - /** - * @param int $indexInOld - * - * @return DiffRowPosition - */ - public function setIndexInOld($indexInOld) - { - $this->indexInOld = $indexInOld; - - return $this; - } - - /** - * @return int - */ - public function getIndexInNew() - { - return $this->indexInNew; - } - - /** - * @param int $indexInNew - * - * @return DiffRowPosition - */ - public function setIndexInNew($indexInNew) - { - $this->indexInNew = $indexInNew; - - return $this; - } - - /** - * @return int - */ - public function getColumnInOld() - { - return $this->columnInOld; - } - - /** - * @param int $columnInOld - * - * @return DiffRowPosition - */ - public function setColumnInOld($columnInOld) - { - $this->columnInOld = $columnInOld; - - return $this; - } - - /** - * @return int - */ - public function getColumnInNew() - { - return $this->columnInNew; - } - - /** - * @param int $columnInNew - * - * @return DiffRowPosition - */ - public function setColumnInNew($columnInNew) - { - $this->columnInNew = $columnInNew; - - return $this; - } - - /** - * @param int $increment - * - * @return int - */ - public function incrementColumnInNew($increment = 1) - { - $this->columnInNew += $increment; - - return $this->columnInNew; - } - - /** - * @param int $increment - * - * @return int - */ - public function incrementColumnInOld($increment = 1) - { - $this->columnInOld += $increment; - - return $this->columnInOld; - } - - /** - * @param int $increment - * - * @return int - */ - public function incrementIndexInNew($increment = 1) - { - $this->indexInNew += $increment; - - return $this->indexInNew; - } - - /** - * @param int $increment - * - * @return int - */ - public function incrementIndexInOld($increment = 1) - { - $this->indexInOld += $increment; - - return $this->indexInOld; - } - - /** - * @param string $type - * @param int $increment - * - * @return int - */ - public function incrementIndex($type, $increment = 1) - { - if ($type === 'new') { - return $this->incrementIndexInNew($increment); - } - - return $this->incrementIndexInOld($increment); - } - - /** - * @param string $type - * @param int $increment - * - * @return int - */ - public function incrementColumn($type, $increment = 1) - { - if ($type === 'new') { - return $this->incrementColumnInNew($increment); - } - - return $this->incrementColumnInOld($increment); - } - - /** - * @param string $type - * - * @return bool - */ - public function isColumnLessThanOther($type) - { - if ($type === 'new') { - return $this->getColumnInNew() < $this->getColumnInOld(); - } - - return $this->getColumnInOld() < $this->getColumnInNew(); - } - - /** - * @param string $type - * - * @return int - */ - public function getColumn($type) - { - if ($type === 'new') { - return $this->getColumnInNew(); - } - - return $this->getColumnInOld(); - } - - /** - * @param string $type - * - * @return int - */ - public function getIndex($type) - { - if ($type === 'new') { - return $this->getIndexInNew(); - } - - return $this->getIndexInOld(); - } - - /** - * @return bool - */ - public function areColumnsEqual() - { - return $this->getColumnInOld() === $this->getColumnInNew(); - } - - /** - * @return null|string - */ - public function getLesserColumnType() - { - if ($this->isColumnLessThanOther('new')) { - return 'new'; - } elseif ($this->isColumnLessThanOther('old')) { - return 'old'; - } - - return null; - } -} +indexInOld = $indexInOld; + $this->indexInNew = $indexInNew; + $this->columnInOld = $columnInOld; + $this->columnInNew = $columnInNew; + } + + /** + * @return int + */ + public function getIndexInOld() + { + return $this->indexInOld; + } + + /** + * @param int $indexInOld + * + * @return DiffRowPosition + */ + public function setIndexInOld($indexInOld) + { + $this->indexInOld = $indexInOld; + + return $this; + } + + /** + * @return int + */ + public function getIndexInNew() + { + return $this->indexInNew; + } + + /** + * @param int $indexInNew + * + * @return DiffRowPosition + */ + public function setIndexInNew($indexInNew) + { + $this->indexInNew = $indexInNew; + + return $this; + } + + /** + * @return int + */ + public function getColumnInOld() + { + return $this->columnInOld; + } + + /** + * @param int $columnInOld + * + * @return DiffRowPosition + */ + public function setColumnInOld($columnInOld) + { + $this->columnInOld = $columnInOld; + + return $this; + } + + /** + * @return int + */ + public function getColumnInNew() + { + return $this->columnInNew; + } + + /** + * @param int $columnInNew + * + * @return DiffRowPosition + */ + public function setColumnInNew($columnInNew) + { + $this->columnInNew = $columnInNew; + + return $this; + } + + /** + * @param int $increment + * + * @return int + */ + public function incrementColumnInNew($increment = 1) + { + $this->columnInNew += $increment; + + return $this->columnInNew; + } + + /** + * @param int $increment + * + * @return int + */ + public function incrementColumnInOld($increment = 1) + { + $this->columnInOld += $increment; + + return $this->columnInOld; + } + + /** + * @param int $increment + * + * @return int + */ + public function incrementIndexInNew($increment = 1) + { + $this->indexInNew += $increment; + + return $this->indexInNew; + } + + /** + * @param int $increment + * + * @return int + */ + public function incrementIndexInOld($increment = 1) + { + $this->indexInOld += $increment; + + return $this->indexInOld; + } + + /** + * @param string $type + * @param int $increment + * + * @return int + */ + public function incrementIndex($type, $increment = 1) + { + if ($type === 'new') { + return $this->incrementIndexInNew($increment); + } + + return $this->incrementIndexInOld($increment); + } + + /** + * @param string $type + * @param int $increment + * + * @return int + */ + public function incrementColumn($type, $increment = 1) + { + if ($type === 'new') { + return $this->incrementColumnInNew($increment); + } + + return $this->incrementColumnInOld($increment); + } + + /** + * @param string $type + * + * @return bool + */ + public function isColumnLessThanOther($type) + { + if ($type === 'new') { + return $this->getColumnInNew() < $this->getColumnInOld(); + } + + return $this->getColumnInOld() < $this->getColumnInNew(); + } + + /** + * @param string $type + * + * @return int + */ + public function getColumn($type) + { + if ($type === 'new') { + return $this->getColumnInNew(); + } + + return $this->getColumnInOld(); + } + + /** + * @param string $type + * + * @return int + */ + public function getIndex($type) + { + if ($type === 'new') { + return $this->getIndexInNew(); + } + + return $this->getIndexInOld(); + } + + /** + * @return bool + */ + public function areColumnsEqual() + { + return $this->getColumnInOld() === $this->getColumnInNew(); + } + + /** + * @return null|string + */ + public function getLesserColumnType() + { + if ($this->isColumnLessThanOther('new')) { + return 'new'; + } elseif ($this->isColumnLessThanOther('old')) { + return 'old'; + } + + return null; + } +} diff --git a/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/RowMatch.php b/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/RowMatch.php index 6a57e3d..db92a23 100755 --- a/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/RowMatch.php +++ b/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/RowMatch.php @@ -1,133 +1,133 @@ -startInNew = $startInNew; - $this->startInOld = $startInOld; - $this->endInNew = $endInNew; - $this->endInOld = $endInOld; - $this->percentage = $percentage; - } - - /** - * @return int - */ - public function getStartInNew() - { - return $this->startInNew; - } - - /** - * @param int $startInNew - * - * @return RowMatch - */ - public function setStartInNew($startInNew) - { - $this->startInNew = $startInNew; - - return $this; - } - - /** - * @return int - */ - public function getStartInOld() - { - return $this->startInOld; - } - - /** - * @param int $startInOld - * - * @return RowMatch - */ - public function setStartInOld($startInOld) - { - $this->startInOld = $startInOld; - - return $this; - } - - /** - * @return int - */ - public function getEndInNew() - { - return $this->endInNew; - } - - /** - * @param int $endInNew - * - * @return RowMatch - */ - public function setEndInNew($endInNew) - { - $this->endInNew = $endInNew; - - return $this; - } - - /** - * @return int - */ - public function getEndInOld() - { - return $this->endInOld; - } - - /** - * @param int $endInOld - * - * @return RowMatch - */ - public function setEndInOld($endInOld) - { - $this->endInOld = $endInOld; - - return $this; - } -} +startInNew = $startInNew; + $this->startInOld = $startInOld; + $this->endInNew = $endInNew; + $this->endInOld = $endInOld; + $this->percentage = $percentage; + } + + /** + * @return int + */ + public function getStartInNew() + { + return $this->startInNew; + } + + /** + * @param int $startInNew + * + * @return RowMatch + */ + public function setStartInNew($startInNew) + { + $this->startInNew = $startInNew; + + return $this; + } + + /** + * @return int + */ + public function getStartInOld() + { + return $this->startInOld; + } + + /** + * @param int $startInOld + * + * @return RowMatch + */ + public function setStartInOld($startInOld) + { + $this->startInOld = $startInOld; + + return $this; + } + + /** + * @return int + */ + public function getEndInNew() + { + return $this->endInNew; + } + + /** + * @param int $endInNew + * + * @return RowMatch + */ + public function setEndInNew($endInNew) + { + $this->endInNew = $endInNew; + + return $this; + } + + /** + * @return int + */ + public function getEndInOld() + { + return $this->endInOld; + } + + /** + * @param int $endInOld + * + * @return RowMatch + */ + public function setEndInOld($endInOld) + { + $this->endInOld = $endInOld; + + return $this; + } +} diff --git a/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/Table.php b/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/Table.php index 4605682..4ab8ff2 100755 --- a/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/Table.php +++ b/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/Table.php @@ -1,161 +1,161 @@ -rows; - } - - /** - * @param TableRow $row - */ - public function addRow(TableRow $row) - { - $this->rows[] = $row; - - if (!$row->getTable()) { - $row->setTable($this); - } - } - - /** - * @param TableRow $row - */ - public function removeRow(TableRow $row) - { - $key = array_search($row, $this->rows, true); - - if ($key !== false) { - unset($this->rows[$key]); - if ($row->getTable()) { - $row->setTable(null); - } - } - } - - /** - * @param int $index - * - * @return null|TableRow - */ - public function getRow($index) - { - return isset($this->rows[$index]) ? $this->rows[$index] : null; - } - - /** - * @param TableRow[] $rows - * @param null|int $position - */ - public function insertRows($rows, $position = null) - { - if ($position === null) { - $this->rows = array_merge($this->rows, $rows); - } else { - array_splice($this->rows, $position, 0, $rows); - } - } - - /** - * @param TablePosition $position - * - * @return null|TableCell - */ - public function getCellByPosition(TablePosition $position) - { - $row = $this->getRow($position->getRow()); - - return $row ? $row->getCell($position->getCell()) : null; - } - - /** - * @param TablePosition $position - * @param int $offset - * - * @return TablePosition|null - */ - public function getPositionBefore(TablePosition $position, $offset = 1) - { - if ($position->getCell() > ($offset - 1)) { - $newRow = $position->getRow(); - $newCell = $position->getCell() - $offset; - } elseif ($position->getRow() > 0) { - $cellsToMove = $offset; - $newRow = $position->getRow(); - $newCell = $position->getCell(); - - while ($cellsToMove > 0 && $newRow >= 0) { - if ($cellsToMove > $newCell) { - $newRow--; - if ($newRow < 0) { - return null; - } - - $cellsToMove = $cellsToMove - ($newCell + 1); - $cellCount = count($this->getRow($newRow)->getCells()); - $newCell = $cellCount - 1; - } else { - $newCell = $newCell - $cellsToMove; - $cellsToMove -= $newCell; - } - } - } else { - return null; - } - - if ($newRow >= 0 && $newCell >= 0) { - return new TablePosition($newRow, $newCell); - } - - return null; - } - - /** - * @param TablePosition $position - * @param int $offset - * - * @return TablePosition|null - */ - public function getPositionAfter(TablePosition $position, $offset = 1) - { - $cellsToMove = $offset; - $newRow = $position->getRow(); - $newCell = $position->getCell(); - - while ($cellsToMove > 0 && $newRow < count($this->rows)) { - $cellCount = count($this->getRow($newRow)->getCells()); - - $cellsLeft = $cellCount - $newCell - 1; - - if ($cellsToMove > $cellsLeft) { - $newRow++; - $cellsToMove -= $cellsLeft - 1; - $newCell = 0; - } else { - $newCell = $newCell + $cellsToMove; - $cellsToMove -= $cellsLeft; - } - } - - if ($newRow >= 0 && $newCell >= 0) { - return new TablePosition($newRow, $newCell); - } - - return null; - } -} +rows; + } + + /** + * @param TableRow $row + */ + public function addRow(TableRow $row) + { + $this->rows[] = $row; + + if (!$row->getTable()) { + $row->setTable($this); + } + } + + /** + * @param TableRow $row + */ + public function removeRow(TableRow $row) + { + $key = array_search($row, $this->rows, true); + + if ($key !== false) { + unset($this->rows[$key]); + if ($row->getTable()) { + $row->setTable(null); + } + } + } + + /** + * @param int $index + * + * @return null|TableRow + */ + public function getRow($index) + { + return isset($this->rows[$index]) ? $this->rows[$index] : null; + } + + /** + * @param TableRow[] $rows + * @param null|int $position + */ + public function insertRows($rows, $position = null) + { + if ($position === null) { + $this->rows = array_merge($this->rows, $rows); + } else { + array_splice($this->rows, $position, 0, $rows); + } + } + + /** + * @param TablePosition $position + * + * @return null|TableCell + */ + public function getCellByPosition(TablePosition $position) + { + $row = $this->getRow($position->getRow()); + + return $row ? $row->getCell($position->getCell()) : null; + } + + /** + * @param TablePosition $position + * @param int $offset + * + * @return TablePosition|null + */ + public function getPositionBefore(TablePosition $position, $offset = 1) + { + if ($position->getCell() > ($offset - 1)) { + $newRow = $position->getRow(); + $newCell = $position->getCell() - $offset; + } elseif ($position->getRow() > 0) { + $cellsToMove = $offset; + $newRow = $position->getRow(); + $newCell = $position->getCell(); + + while ($cellsToMove > 0 && $newRow >= 0) { + if ($cellsToMove > $newCell) { + $newRow--; + if ($newRow < 0) { + return null; + } + + $cellsToMove = $cellsToMove - ($newCell + 1); + $cellCount = count($this->getRow($newRow)->getCells()); + $newCell = $cellCount - 1; + } else { + $newCell = $newCell - $cellsToMove; + $cellsToMove -= $newCell; + } + } + } else { + return null; + } + + if ($newRow >= 0 && $newCell >= 0) { + return new TablePosition($newRow, $newCell); + } + + return null; + } + + /** + * @param TablePosition $position + * @param int $offset + * + * @return TablePosition|null + */ + public function getPositionAfter(TablePosition $position, $offset = 1) + { + $cellsToMove = $offset; + $newRow = $position->getRow(); + $newCell = $position->getCell(); + + while ($cellsToMove > 0 && $newRow < count($this->rows)) { + $cellCount = count($this->getRow($newRow)->getCells()); + + $cellsLeft = $cellCount - $newCell - 1; + + if ($cellsToMove > $cellsLeft) { + $newRow++; + $cellsToMove -= $cellsLeft - 1; + $newCell = 0; + } else { + $newCell = $newCell + $cellsToMove; + $cellsToMove -= $cellsLeft; + } + } + + if ($newRow >= 0 && $newCell >= 0) { + return new TablePosition($newRow, $newCell); + } + + return null; + } +} diff --git a/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/TableCell.php b/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/TableCell.php index 7bc9cb1..79d69ad 100755 --- a/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/TableCell.php +++ b/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/TableCell.php @@ -1,55 +1,55 @@ -row; - } - - /** - * @param TableRow|null $row - * - * @return $this - */ - public function setRow(TableRow $row = null) - { - $this->row = $row; - - if (null !== $row && !in_array($this, $row->getCells())) { - $row->addCell($this); - } - - return $this; - } - - /** - * @return int - */ - public function getColspan() - { - return (int)$this->getAttribute('colspan') ?: 1; - } - - /** - * @return int - */ - public function getRowspan() - { - return (int)$this->getAttribute('rowspan') ?: 1; - } -} +row; + } + + /** + * @param TableRow|null $row + * + * @return $this + */ + public function setRow(TableRow $row = null) + { + $this->row = $row; + + if (null !== $row && !in_array($this, $row->getCells())) { + $row->addCell($this); + } + + return $this; + } + + /** + * @return int + */ + public function getColspan() + { + return (int)$this->getAttribute('colspan') ?: 1; + } + + /** + * @return int + */ + public function getRowspan() + { + return (int)$this->getAttribute('rowspan') ?: 1; + } +} diff --git a/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/TableDiff.php b/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/TableDiff.php index 9e11891..d9b317d 100755 --- a/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/TableDiff.php +++ b/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/TableDiff.php @@ -1,921 +1,921 @@ -setConfig($config); - - $this->initPurifier($config->getPurifierCacheLocation()); - } - - return $diff; - } - - /** - * TableDiff constructor. - * - * @param string $oldText - * @param string $newText - * @param string $encoding - * @param array|null $specialCaseTags - * @param bool|null $groupDiffs - */ - public function __construct( - $oldText, - $newText, - $encoding = 'UTF-8', - $specialCaseTags = null, - $groupDiffs = null - ) - { - parent::__construct($oldText, $newText, $encoding, $specialCaseTags, $groupDiffs); - - $this->initPurifier(); - } - - /** - * Initializes HTMLPurifier with cache location - * @param null|string $defaultPurifierSerializerCache - * @return void - */ - protected function initPurifier($defaultPurifierSerializerCache = null) - { - $HTMLPurifierConfig = \HTMLPurifier_Config::createDefault(); - // Cache.SerializerPath defaults to Null and sets - // the location to inside the vendor HTMLPurifier library - // under the DefinitionCache/Serializer folder. - if (!is_null($defaultPurifierSerializerCache)) { - $HTMLPurifierConfig->set('Cache.SerializerPath', $defaultPurifierSerializerCache); - } - $this->purifier = new \HTMLPurifier($HTMLPurifierConfig); - } - - /** - * @return string - */ - public function build() - { - if ($this->hasDiffCache() && $this->getDiffCache()->contains($this->oldText, $this->newText)) { - $this->content = $this->getDiffCache()->fetch($this->oldText, $this->newText); - - return $this->content; - } - - $this->buildTableDoms(); - - $this->diffDom = new \DOMDocument(); - - $this->indexCellValues($this->newTable); - - $this->diffTableContent(); - - if ($this->hasDiffCache()) { - $this->getDiffCache()->save($this->oldText, $this->newText, $this->content); - } - - return $this->content; - } - - protected function diffTableContent() - { - $this->diffDom = new \DOMDocument(); - $this->diffTable = $this->newTable->cloneNode($this->diffDom); - $this->diffDom->appendChild($this->diffTable); - - $oldRows = $this->oldTable->getRows(); - $newRows = $this->newTable->getRows(); - - $oldMatchData = array(); - $newMatchData = array(); - - /* @var $oldRow TableRow */ - foreach ($oldRows as $oldIndex => $oldRow) { - $oldMatchData[$oldIndex] = array(); - - // Get match percentages - /* @var $newRow TableRow */ - foreach ($newRows as $newIndex => $newRow) { - if (!array_key_exists($newIndex, $newMatchData)) { - $newMatchData[$newIndex] = array(); - } - - // similar_text - $percentage = $this->getMatchPercentage($oldRow, $newRow, $oldIndex, $newIndex); - - $oldMatchData[$oldIndex][$newIndex] = $percentage; - $newMatchData[$newIndex][$oldIndex] = $percentage; - } - } - - $matches = $this->getRowMatches($oldMatchData, $newMatchData); - $this->diffTableRowsWithMatches($oldRows, $newRows, $matches); - - $this->content = $this->htmlFromNode($this->diffTable); - } - - /** - * @param TableRow[] $oldRows - * @param TableRow[] $newRows - * @param RowMatch[] $matches - */ - protected function diffTableRowsWithMatches($oldRows, $newRows, $matches) - { - $operations = array(); - - $indexInOld = 0; - $indexInNew = 0; - - $oldRowCount = count($oldRows); - $newRowCount = count($newRows); - - $matches[] = new RowMatch($newRowCount, $oldRowCount, $newRowCount, $oldRowCount); - - // build operations - foreach ($matches as $match) { - $matchAtIndexInOld = $indexInOld === $match->getStartInOld(); - $matchAtIndexInNew = $indexInNew === $match->getStartInNew(); - - $action = 'equal'; - - if (!$matchAtIndexInOld && !$matchAtIndexInNew) { - $action = 'replace'; - } elseif ($matchAtIndexInOld && !$matchAtIndexInNew) { - $action = 'insert'; - } elseif (!$matchAtIndexInOld && $matchAtIndexInNew) { - $action = 'delete'; - } - - if ($action !== 'equal') { - $operations[] = new Operation( - $action, - $indexInOld, - $match->getStartInOld(), - $indexInNew, - $match->getStartInNew() - ); - } - - $operations[] = new Operation( - 'equal', - $match->getStartInOld(), - $match->getEndInOld(), - $match->getStartInNew(), - $match->getEndInNew() - ); - - $indexInOld = $match->getEndInOld(); - $indexInNew = $match->getEndInNew(); - } - - $appliedRowSpans = array(); - - // process operations - foreach ($operations as $operation) { - switch ($operation->action) { - case 'equal': - $this->processEqualOperation($operation, $oldRows, $newRows, $appliedRowSpans); - break; - - case 'delete': - $this->processDeleteOperation($operation, $oldRows, $appliedRowSpans); - break; - - case 'insert': - $this->processInsertOperation($operation, $newRows, $appliedRowSpans); - break; - - case 'replace': - $this->processReplaceOperation($operation, $oldRows, $newRows, $appliedRowSpans); - break; - } - } - } - - /** - * @param Operation $operation - * @param array $newRows - * @param array $appliedRowSpans - * @param bool $forceExpansion - */ - protected function processInsertOperation( - Operation $operation, - $newRows, - &$appliedRowSpans, - $forceExpansion = false - ) { - $targetRows = array_slice($newRows, $operation->startInNew, $operation->endInNew - $operation->startInNew); - foreach ($targetRows as $row) { - $this->diffAndAppendRows(null, $row, $appliedRowSpans, $forceExpansion); - } - } - - /** - * @param Operation $operation - * @param array $oldRows - * @param array $appliedRowSpans - * @param bool $forceExpansion - */ - protected function processDeleteOperation( - Operation $operation, - $oldRows, - &$appliedRowSpans, - $forceExpansion = false - ) { - $targetRows = array_slice($oldRows, $operation->startInOld, $operation->endInOld - $operation->startInOld); - foreach ($targetRows as $row) { - $this->diffAndAppendRows($row, null, $appliedRowSpans, $forceExpansion); - } - } - - /** - * @param Operation $operation - * @param array $oldRows - * @param array $newRows - * @param array $appliedRowSpans - */ - protected function processEqualOperation(Operation $operation, $oldRows, $newRows, &$appliedRowSpans) - { - $targetOldRows = array_values( - array_slice($oldRows, $operation->startInOld, $operation->endInOld - $operation->startInOld) - ); - $targetNewRows = array_values( - array_slice($newRows, $operation->startInNew, $operation->endInNew - $operation->startInNew) - ); - - foreach ($targetNewRows as $index => $newRow) { - if (!isset($targetOldRows[$index])) { - continue; - } - - $this->diffAndAppendRows($targetOldRows[$index], $newRow, $appliedRowSpans); - } - } - - /** - * @param Operation $operation - * @param array $oldRows - * @param array $newRows - * @param array $appliedRowSpans - */ - protected function processReplaceOperation(Operation $operation, $oldRows, $newRows, &$appliedRowSpans) - { - $this->processDeleteOperation($operation, $oldRows, $appliedRowSpans, true); - $this->processInsertOperation($operation, $newRows, $appliedRowSpans, true); - } - - /** - * @param array $oldMatchData - * @param array $newMatchData - * - * @return array - */ - protected function getRowMatches($oldMatchData, $newMatchData) - { - $matches = array(); - - $startInOld = 0; - $startInNew = 0; - $endInOld = count($oldMatchData); - $endInNew = count($newMatchData); - - $this->findRowMatches($newMatchData, $startInOld, $endInOld, $startInNew, $endInNew, $matches); - - return $matches; - } - - /** - * @param array $newMatchData - * @param int $startInOld - * @param int $endInOld - * @param int $startInNew - * @param int $endInNew - * @param array $matches - */ - protected function findRowMatches($newMatchData, $startInOld, $endInOld, $startInNew, $endInNew, &$matches) - { - $match = $this->findRowMatch($newMatchData, $startInOld, $endInOld, $startInNew, $endInNew); - if ($match !== null) { - if ($startInOld < $match->getStartInOld() && - $startInNew < $match->getStartInNew() - ) { - $this->findRowMatches( - $newMatchData, - $startInOld, - $match->getStartInOld(), - $startInNew, - $match->getStartInNew(), - $matches - ); - } - - $matches[] = $match; - - if ($match->getEndInOld() < $endInOld && - $match->getEndInNew() < $endInNew - ) { - $this->findRowMatches( - $newMatchData, - $match->getEndInOld(), - $endInOld, - $match->getEndInNew(), - $endInNew, - $matches - ); - } - } - } - - /** - * @param array $newMatchData - * @param int $startInOld - * @param int $endInOld - * @param int $startInNew - * @param int $endInNew - * - * @return RowMatch|null - */ - protected function findRowMatch($newMatchData, $startInOld, $endInOld, $startInNew, $endInNew) - { - $bestMatch = null; - $bestPercentage = 0; - - foreach ($newMatchData as $newIndex => $oldMatches) { - if ($newIndex < $startInNew) { - continue; - } - - if ($newIndex >= $endInNew) { - break; - } - foreach ($oldMatches as $oldIndex => $percentage) { - if ($oldIndex < $startInOld) { - continue; - } - - if ($oldIndex >= $endInOld) { - break; - } - - if ($percentage > $bestPercentage) { - $bestPercentage = $percentage; - $bestMatch = array( - 'oldIndex' => $oldIndex, - 'newIndex' => $newIndex, - 'percentage' => $percentage, - ); - } - } - } - - if ($bestMatch !== null) { - return new RowMatch( - $bestMatch['newIndex'], - $bestMatch['oldIndex'], - $bestMatch['newIndex'] + 1, - $bestMatch['oldIndex'] + 1, - $bestMatch['percentage'] - ); - } - - return null; - } - - /** - * @param TableRow|null $oldRow - * @param TableRow|null $newRow - * @param array $appliedRowSpans - * @param bool $forceExpansion - * - * @return array - */ - protected function diffRows($oldRow, $newRow, array &$appliedRowSpans, $forceExpansion = false) - { - // create tr dom element - $rowToClone = $newRow ?: $oldRow; - /* @var $diffRow \DOMElement */ - $diffRow = $this->diffDom->importNode($rowToClone->getDomNode()->cloneNode(false), false); - - $oldCells = $oldRow ? $oldRow->getCells() : array(); - $newCells = $newRow ? $newRow->getCells() : array(); - - $position = new DiffRowPosition(); - - $extraRow = null; - - /* @var $expandCells \DOMElement[] */ - $expandCells = array(); - /* @var $cellsWithMultipleRows \DOMElement[] */ - $cellsWithMultipleRows = array(); - - $newCellCount = count($newCells); - while ($position->getIndexInNew() < $newCellCount) { - if (!$position->areColumnsEqual()) { - $type = $position->getLesserColumnType(); - if ($type === 'new') { - $row = $newRow; - $targetRow = $extraRow; - } else { - $row = $oldRow; - $targetRow = $diffRow; - } - if ($row && $targetRow && (!$type === 'old' || isset($oldCells[$position->getIndexInOld()]))) { - $this->syncVirtualColumns($row, $position, $cellsWithMultipleRows, $targetRow, $type, true); - - continue; - } - } - - /* @var $newCell TableCell */ - $newCell = $newCells[$position->getIndexInNew()]; - /* @var $oldCell TableCell */ - $oldCell = isset($oldCells[$position->getIndexInOld()]) ? $oldCells[$position->getIndexInOld()] : null; - - if ($oldCell && $newCell->getColspan() != $oldCell->getColspan()) { - if (null === $extraRow) { - /* @var $extraRow \DOMElement */ - $extraRow = $this->diffDom->importNode($rowToClone->getDomNode()->cloneNode(false), false); - } - - if ($oldCell->getColspan() > $newCell->getColspan()) { - $this->diffCellsAndIncrementCounters( - $oldCell, - null, - $cellsWithMultipleRows, - $diffRow, - $position, - true - ); - $this->syncVirtualColumns($newRow, $position, $cellsWithMultipleRows, $extraRow, 'new', true); - } else { - $this->diffCellsAndIncrementCounters( - null, - $newCell, - $cellsWithMultipleRows, - $extraRow, - $position, - true - ); - $this->syncVirtualColumns($oldRow, $position, $cellsWithMultipleRows, $diffRow, 'old', true); - } - } else { - $diffCell = $this->diffCellsAndIncrementCounters( - $oldCell, - $newCell, - $cellsWithMultipleRows, - $diffRow, - $position - ); - $expandCells[] = $diffCell; - } - } - - $oldCellCount = count($oldCells); - while ($position->getIndexInOld() < $oldCellCount) { - $diffCell = $this->diffCellsAndIncrementCounters( - $oldCells[$position->getIndexInOld()], - null, - $cellsWithMultipleRows, - $diffRow, - $position - ); - $expandCells[] = $diffCell; - } - - if ($extraRow) { - foreach ($expandCells as $expandCell) { - $rowspan = $expandCell->getAttribute('rowspan') ?: 1; - $expandCell->setAttribute('rowspan', 1 + $rowspan); - } - } - - if ($extraRow || $forceExpansion) { - foreach ($appliedRowSpans as $rowSpanCells) { - /* @var $rowSpanCells \DOMElement[] */ - foreach ($rowSpanCells as $extendCell) { - $rowspan = $extendCell->getAttribute('rowspan') ?: 1; - $extendCell->setAttribute('rowspan', 1 + $rowspan); - } - } - } - - if (!$forceExpansion) { - array_shift($appliedRowSpans); - $appliedRowSpans = array_values($appliedRowSpans); - } - $appliedRowSpans = array_merge($appliedRowSpans, array_values($cellsWithMultipleRows)); - - return array($diffRow, $extraRow); - } - - /** - * @param TableCell|null $oldCell - * @param TableCell|null $newCell - * - * @return \DOMElement - */ - protected function getNewCellNode(TableCell $oldCell = null, TableCell $newCell = null) - { - // If only one cell exists, use it - if (!$oldCell || !$newCell) { - $clone = $newCell - ? $newCell->getDomNode()->cloneNode(false) - : $oldCell->getDomNode()->cloneNode(false); - } else { - $oldNode = $oldCell->getDomNode(); - $newNode = $newCell->getDomNode(); - - /* @var $clone \DOMElement */ - $clone = $newNode->cloneNode(false); - - $oldRowspan = $oldNode->getAttribute('rowspan') ?: 1; - $oldColspan = $oldNode->getAttribute('colspan') ?: 1; - $newRowspan = $newNode->getAttribute('rowspan') ?: 1; - $newColspan = $newNode->getAttribute('colspan') ?: 1; - - $clone->setAttribute('rowspan', max($oldRowspan, $newRowspan)); - $clone->setAttribute('colspan', max($oldColspan, $newColspan)); - } - - return $this->diffDom->importNode($clone); - } - - /** - * @param TableCell|null $oldCell - * @param TableCell|null $newCell - * @param bool $usingExtraRow - * - * @return \DOMElement - */ - protected function diffCells($oldCell, $newCell, $usingExtraRow = false) - { - $diffCell = $this->getNewCellNode($oldCell, $newCell); - - $oldContent = $oldCell ? $this->getInnerHtml($oldCell->getDomNode()) : ''; - $newContent = $newCell ? $this->getInnerHtml($newCell->getDomNode()) : ''; - - $htmlDiff = HtmlDiff::create( - mb_convert_encoding($oldContent, 'UTF-8', 'HTML-ENTITIES'), - mb_convert_encoding($newContent, 'UTF-8', 'HTML-ENTITIES'), - $this->config - ); - $diff = $htmlDiff->build(); - - $this->setInnerHtml($diffCell, $diff); - - if (null === $newCell) { - $diffCell->setAttribute('class', trim($diffCell->getAttribute('class').' del')); - } - - if (null === $oldCell) { - $diffCell->setAttribute('class', trim($diffCell->getAttribute('class').' ins')); - } - - if ($usingExtraRow) { - $diffCell->setAttribute('class', trim($diffCell->getAttribute('class').' extra-row')); - } - - return $diffCell; - } - - protected function buildTableDoms() - { - $this->oldTable = $this->parseTableStructure($this->oldText); - $this->newTable = $this->parseTableStructure($this->newText); - } - - /** - * @param string $text - * - * @return \DOMDocument - */ - protected function createDocumentWithHtml($text) - { - $dom = new \DOMDocument(); - $dom->loadHTML(mb_convert_encoding( - $this->purifier->purify(mb_convert_encoding($text, $this->config->getEncoding(), mb_detect_encoding($text))), - 'HTML-ENTITIES', - $this->config->getEncoding() - )); - - return $dom; - } - - /** - * @param string $text - * - * @return Table - */ - protected function parseTableStructure($text) - { - $dom = $this->createDocumentWithHtml($text); - - $tableNode = $dom->getElementsByTagName('table')->item(0); - - $table = new Table($tableNode); - - $this->parseTable($table); - - return $table; - } - - /** - * @param Table $table - * @param \DOMNode|null $node - */ - protected function parseTable(Table $table, \DOMNode $node = null) - { - if ($node === null) { - $node = $table->getDomNode(); - } - - if (!$node->childNodes) { - return; - } - - foreach ($node->childNodes as $child) { - if ($child->nodeName === 'tr') { - $row = new TableRow($child); - $table->addRow($row); - - $this->parseTableRow($row); - } else { - $this->parseTable($table, $child); - } - } - } - - /** - * @param TableRow $row - */ - protected function parseTableRow(TableRow $row) - { - $node = $row->getDomNode(); - - foreach ($node->childNodes as $child) { - if (in_array($child->nodeName, array('td', 'th'))) { - $cell = new TableCell($child); - $row->addCell($cell); - } - } - } - - /** - * @param \DOMNode $node - * - * @return string - */ - protected function getInnerHtml($node) - { - $innerHtml = ''; - $children = $node->childNodes; - - foreach ($children as $child) { - $innerHtml .= $this->htmlFromNode($child); - } - - return $innerHtml; - } - - /** - * @param \DOMNode $node - * - * @return string - */ - protected function htmlFromNode($node) - { - $domDocument = new \DOMDocument(); - $newNode = $domDocument->importNode($node, true); - $domDocument->appendChild($newNode); - - return $domDocument->saveHTML(); - } - - /** - * @param \DOMNode $node - * @param string $html - */ - protected function setInnerHtml($node, $html) - { - // DOMDocument::loadHTML does not allow empty strings. - if (strlen($html) === 0) { - $html = ''; - } - - $doc = $this->createDocumentWithHtml($html); - $fragment = $node->ownerDocument->createDocumentFragment(); - $root = $doc->getElementsByTagName('body')->item(0); - foreach ($root->childNodes as $child) { - $fragment->appendChild($node->ownerDocument->importNode($child, true)); - } - - $node->appendChild($fragment); - } - - /** - * @param Table $table - */ - protected function indexCellValues(Table $table) - { - foreach ($table->getRows() as $rowIndex => $row) { - foreach ($row->getCells() as $cellIndex => $cell) { - $value = trim($cell->getDomNode()->textContent); - - if (!isset($this->cellValues[$value])) { - $this->cellValues[$value] = array(); - } - - $this->cellValues[$value][] = new TablePosition($rowIndex, $cellIndex); - } - } - } - - /** - * @param TableRow $tableRow - * @param DiffRowPosition $position - * @param array $cellsWithMultipleRows - * @param \DOMNode $diffRow - * @param string $diffType - * @param bool $usingExtraRow - */ - protected function syncVirtualColumns( - $tableRow, - DiffRowPosition $position, - &$cellsWithMultipleRows, - $diffRow, - $diffType, - $usingExtraRow = false - ) { - $currentCell = $tableRow->getCell($position->getIndex($diffType)); - while ($position->isColumnLessThanOther($diffType) && $currentCell) { - $diffCell = $diffType === 'new' ? $this->diffCells(null, $currentCell, $usingExtraRow) : $this->diffCells( - $currentCell, - null, - $usingExtraRow - ); - // Store cell in appliedRowSpans if spans multiple rows - if ($diffCell->getAttribute('rowspan') > 1) { - $cellsWithMultipleRows[$diffCell->getAttribute('rowspan')][] = $diffCell; - } - $diffRow->appendChild($diffCell); - $position->incrementColumn($diffType, $currentCell->getColspan()); - $currentCell = $tableRow->getCell($position->incrementIndex($diffType)); - } - } - - /** - * @param null|TableCell $oldCell - * @param null|TableCell $newCell - * @param array $cellsWithMultipleRows - * @param \DOMElement $diffRow - * @param DiffRowPosition $position - * @param bool $usingExtraRow - * - * @return \DOMElement - */ - protected function diffCellsAndIncrementCounters( - $oldCell, - $newCell, - &$cellsWithMultipleRows, - $diffRow, - DiffRowPosition $position, - $usingExtraRow = false - ) { - $diffCell = $this->diffCells($oldCell, $newCell, $usingExtraRow); - // Store cell in appliedRowSpans if spans multiple rows - if ($diffCell->getAttribute('rowspan') > 1) { - $cellsWithMultipleRows[$diffCell->getAttribute('rowspan')][] = $diffCell; - } - $diffRow->appendChild($diffCell); - - if ($newCell !== null) { - $position->incrementIndexInNew(); - $position->incrementColumnInNew($newCell->getColspan()); - } - - if ($oldCell !== null) { - $position->incrementIndexInOld(); - $position->incrementColumnInOld($oldCell->getColspan()); - } - - return $diffCell; - } - - /** - * @param TableRow|null $oldRow - * @param TableRow|null $newRow - * @param array $appliedRowSpans - * @param bool $forceExpansion - */ - protected function diffAndAppendRows($oldRow, $newRow, &$appliedRowSpans, $forceExpansion = false) - { - list($rowDom, $extraRow) = $this->diffRows( - $oldRow, - $newRow, - $appliedRowSpans, - $forceExpansion - ); - - $this->diffTable->appendChild($rowDom); - - if ($extraRow) { - $this->diffTable->appendChild($extraRow); - } - } - - /** - * @param TableRow $oldRow - * @param TableRow $newRow - * @param int $oldIndex - * @param int $newIndex - * - * @return float|int - */ - protected function getMatchPercentage(TableRow $oldRow, TableRow $newRow, $oldIndex, $newIndex) - { - $firstCellWeight = 1.5; - $indexDeltaWeight = 0.25 * (abs($oldIndex - $newIndex)); - $thresholdCount = 0; - $minCells = min(count($newRow->getCells()), count($oldRow->getCells())); - $totalCount = ($minCells + $firstCellWeight + $indexDeltaWeight) * 100; - foreach ($newRow->getCells() as $newIndex => $newCell) { - $oldCell = $oldRow->getCell($newIndex); - - if ($oldCell) { - $percentage = null; - similar_text($oldCell->getInnerHtml(), $newCell->getInnerHtml(), $percentage); - - if ($percentage > ($this->config->getMatchThreshold() * 0.50)) { - $increment = $percentage; - if ($newIndex === 0 && $percentage > 95) { - $increment = $increment * $firstCellWeight; - } - $thresholdCount += $increment; - } - } - } - - return ($totalCount > 0) ? ($thresholdCount / $totalCount) : 0; - } -} +setConfig($config); + + $this->initPurifier($config->getPurifierCacheLocation()); + } + + return $diff; + } + + /** + * TableDiff constructor. + * + * @param string $oldText + * @param string $newText + * @param string $encoding + * @param array|null $specialCaseTags + * @param bool|null $groupDiffs + */ + public function __construct( + $oldText, + $newText, + $encoding = 'UTF-8', + $specialCaseTags = null, + $groupDiffs = null + ) + { + parent::__construct($oldText, $newText, $encoding, $specialCaseTags, $groupDiffs); + + $this->initPurifier(); + } + + /** + * Initializes HTMLPurifier with cache location + * @param null|string $defaultPurifierSerializerCache + * @return void + */ + protected function initPurifier($defaultPurifierSerializerCache = null) + { + $HTMLPurifierConfig = \HTMLPurifier_Config::createDefault(); + // Cache.SerializerPath defaults to Null and sets + // the location to inside the vendor HTMLPurifier library + // under the DefinitionCache/Serializer folder. + if (!is_null($defaultPurifierSerializerCache)) { + $HTMLPurifierConfig->set('Cache.SerializerPath', $defaultPurifierSerializerCache); + } + $this->purifier = new \HTMLPurifier($HTMLPurifierConfig); + } + + /** + * @return string + */ + public function build() + { + if ($this->hasDiffCache() && $this->getDiffCache()->contains($this->oldText, $this->newText)) { + $this->content = $this->getDiffCache()->fetch($this->oldText, $this->newText); + + return $this->content; + } + + $this->buildTableDoms(); + + $this->diffDom = new \DOMDocument(); + + $this->indexCellValues($this->newTable); + + $this->diffTableContent(); + + if ($this->hasDiffCache()) { + $this->getDiffCache()->save($this->oldText, $this->newText, $this->content); + } + + return $this->content; + } + + protected function diffTableContent() + { + $this->diffDom = new \DOMDocument(); + $this->diffTable = $this->newTable->cloneNode($this->diffDom); + $this->diffDom->appendChild($this->diffTable); + + $oldRows = $this->oldTable->getRows(); + $newRows = $this->newTable->getRows(); + + $oldMatchData = array(); + $newMatchData = array(); + + /* @var $oldRow TableRow */ + foreach ($oldRows as $oldIndex => $oldRow) { + $oldMatchData[$oldIndex] = array(); + + // Get match percentages + /* @var $newRow TableRow */ + foreach ($newRows as $newIndex => $newRow) { + if (!array_key_exists($newIndex, $newMatchData)) { + $newMatchData[$newIndex] = array(); + } + + // similar_text + $percentage = $this->getMatchPercentage($oldRow, $newRow, $oldIndex, $newIndex); + + $oldMatchData[$oldIndex][$newIndex] = $percentage; + $newMatchData[$newIndex][$oldIndex] = $percentage; + } + } + + $matches = $this->getRowMatches($oldMatchData, $newMatchData); + $this->diffTableRowsWithMatches($oldRows, $newRows, $matches); + + $this->content = $this->htmlFromNode($this->diffTable); + } + + /** + * @param TableRow[] $oldRows + * @param TableRow[] $newRows + * @param RowMatch[] $matches + */ + protected function diffTableRowsWithMatches($oldRows, $newRows, $matches) + { + $operations = array(); + + $indexInOld = 0; + $indexInNew = 0; + + $oldRowCount = count($oldRows); + $newRowCount = count($newRows); + + $matches[] = new RowMatch($newRowCount, $oldRowCount, $newRowCount, $oldRowCount); + + // build operations + foreach ($matches as $match) { + $matchAtIndexInOld = $indexInOld === $match->getStartInOld(); + $matchAtIndexInNew = $indexInNew === $match->getStartInNew(); + + $action = 'equal'; + + if (!$matchAtIndexInOld && !$matchAtIndexInNew) { + $action = 'replace'; + } elseif ($matchAtIndexInOld && !$matchAtIndexInNew) { + $action = 'insert'; + } elseif (!$matchAtIndexInOld && $matchAtIndexInNew) { + $action = 'delete'; + } + + if ($action !== 'equal') { + $operations[] = new Operation( + $action, + $indexInOld, + $match->getStartInOld(), + $indexInNew, + $match->getStartInNew() + ); + } + + $operations[] = new Operation( + 'equal', + $match->getStartInOld(), + $match->getEndInOld(), + $match->getStartInNew(), + $match->getEndInNew() + ); + + $indexInOld = $match->getEndInOld(); + $indexInNew = $match->getEndInNew(); + } + + $appliedRowSpans = array(); + + // process operations + foreach ($operations as $operation) { + switch ($operation->action) { + case 'equal': + $this->processEqualOperation($operation, $oldRows, $newRows, $appliedRowSpans); + break; + + case 'delete': + $this->processDeleteOperation($operation, $oldRows, $appliedRowSpans); + break; + + case 'insert': + $this->processInsertOperation($operation, $newRows, $appliedRowSpans); + break; + + case 'replace': + $this->processReplaceOperation($operation, $oldRows, $newRows, $appliedRowSpans); + break; + } + } + } + + /** + * @param Operation $operation + * @param array $newRows + * @param array $appliedRowSpans + * @param bool $forceExpansion + */ + protected function processInsertOperation( + Operation $operation, + $newRows, + &$appliedRowSpans, + $forceExpansion = false + ) { + $targetRows = array_slice($newRows, $operation->startInNew, $operation->endInNew - $operation->startInNew); + foreach ($targetRows as $row) { + $this->diffAndAppendRows(null, $row, $appliedRowSpans, $forceExpansion); + } + } + + /** + * @param Operation $operation + * @param array $oldRows + * @param array $appliedRowSpans + * @param bool $forceExpansion + */ + protected function processDeleteOperation( + Operation $operation, + $oldRows, + &$appliedRowSpans, + $forceExpansion = false + ) { + $targetRows = array_slice($oldRows, $operation->startInOld, $operation->endInOld - $operation->startInOld); + foreach ($targetRows as $row) { + $this->diffAndAppendRows($row, null, $appliedRowSpans, $forceExpansion); + } + } + + /** + * @param Operation $operation + * @param array $oldRows + * @param array $newRows + * @param array $appliedRowSpans + */ + protected function processEqualOperation(Operation $operation, $oldRows, $newRows, &$appliedRowSpans) + { + $targetOldRows = array_values( + array_slice($oldRows, $operation->startInOld, $operation->endInOld - $operation->startInOld) + ); + $targetNewRows = array_values( + array_slice($newRows, $operation->startInNew, $operation->endInNew - $operation->startInNew) + ); + + foreach ($targetNewRows as $index => $newRow) { + if (!isset($targetOldRows[$index])) { + continue; + } + + $this->diffAndAppendRows($targetOldRows[$index], $newRow, $appliedRowSpans); + } + } + + /** + * @param Operation $operation + * @param array $oldRows + * @param array $newRows + * @param array $appliedRowSpans + */ + protected function processReplaceOperation(Operation $operation, $oldRows, $newRows, &$appliedRowSpans) + { + $this->processDeleteOperation($operation, $oldRows, $appliedRowSpans, true); + $this->processInsertOperation($operation, $newRows, $appliedRowSpans, true); + } + + /** + * @param array $oldMatchData + * @param array $newMatchData + * + * @return array + */ + protected function getRowMatches($oldMatchData, $newMatchData) + { + $matches = array(); + + $startInOld = 0; + $startInNew = 0; + $endInOld = count($oldMatchData); + $endInNew = count($newMatchData); + + $this->findRowMatches($newMatchData, $startInOld, $endInOld, $startInNew, $endInNew, $matches); + + return $matches; + } + + /** + * @param array $newMatchData + * @param int $startInOld + * @param int $endInOld + * @param int $startInNew + * @param int $endInNew + * @param array $matches + */ + protected function findRowMatches($newMatchData, $startInOld, $endInOld, $startInNew, $endInNew, &$matches) + { + $match = $this->findRowMatch($newMatchData, $startInOld, $endInOld, $startInNew, $endInNew); + if ($match !== null) { + if ($startInOld < $match->getStartInOld() && + $startInNew < $match->getStartInNew() + ) { + $this->findRowMatches( + $newMatchData, + $startInOld, + $match->getStartInOld(), + $startInNew, + $match->getStartInNew(), + $matches + ); + } + + $matches[] = $match; + + if ($match->getEndInOld() < $endInOld && + $match->getEndInNew() < $endInNew + ) { + $this->findRowMatches( + $newMatchData, + $match->getEndInOld(), + $endInOld, + $match->getEndInNew(), + $endInNew, + $matches + ); + } + } + } + + /** + * @param array $newMatchData + * @param int $startInOld + * @param int $endInOld + * @param int $startInNew + * @param int $endInNew + * + * @return RowMatch|null + */ + protected function findRowMatch($newMatchData, $startInOld, $endInOld, $startInNew, $endInNew) + { + $bestMatch = null; + $bestPercentage = 0; + + foreach ($newMatchData as $newIndex => $oldMatches) { + if ($newIndex < $startInNew) { + continue; + } + + if ($newIndex >= $endInNew) { + break; + } + foreach ($oldMatches as $oldIndex => $percentage) { + if ($oldIndex < $startInOld) { + continue; + } + + if ($oldIndex >= $endInOld) { + break; + } + + if ($percentage > $bestPercentage) { + $bestPercentage = $percentage; + $bestMatch = array( + 'oldIndex' => $oldIndex, + 'newIndex' => $newIndex, + 'percentage' => $percentage, + ); + } + } + } + + if ($bestMatch !== null) { + return new RowMatch( + $bestMatch['newIndex'], + $bestMatch['oldIndex'], + $bestMatch['newIndex'] + 1, + $bestMatch['oldIndex'] + 1, + $bestMatch['percentage'] + ); + } + + return null; + } + + /** + * @param TableRow|null $oldRow + * @param TableRow|null $newRow + * @param array $appliedRowSpans + * @param bool $forceExpansion + * + * @return array + */ + protected function diffRows($oldRow, $newRow, array &$appliedRowSpans, $forceExpansion = false) + { + // create tr dom element + $rowToClone = $newRow ?: $oldRow; + /* @var $diffRow \DOMElement */ + $diffRow = $this->diffDom->importNode($rowToClone->getDomNode()->cloneNode(false), false); + + $oldCells = $oldRow ? $oldRow->getCells() : array(); + $newCells = $newRow ? $newRow->getCells() : array(); + + $position = new DiffRowPosition(); + + $extraRow = null; + + /* @var $expandCells \DOMElement[] */ + $expandCells = array(); + /* @var $cellsWithMultipleRows \DOMElement[] */ + $cellsWithMultipleRows = array(); + + $newCellCount = count($newCells); + while ($position->getIndexInNew() < $newCellCount) { + if (!$position->areColumnsEqual()) { + $type = $position->getLesserColumnType(); + if ($type === 'new') { + $row = $newRow; + $targetRow = $extraRow; + } else { + $row = $oldRow; + $targetRow = $diffRow; + } + if ($row && $targetRow && (!$type === 'old' || isset($oldCells[$position->getIndexInOld()]))) { + $this->syncVirtualColumns($row, $position, $cellsWithMultipleRows, $targetRow, $type, true); + + continue; + } + } + + /* @var $newCell TableCell */ + $newCell = $newCells[$position->getIndexInNew()]; + /* @var $oldCell TableCell */ + $oldCell = isset($oldCells[$position->getIndexInOld()]) ? $oldCells[$position->getIndexInOld()] : null; + + if ($oldCell && $newCell->getColspan() != $oldCell->getColspan()) { + if (null === $extraRow) { + /* @var $extraRow \DOMElement */ + $extraRow = $this->diffDom->importNode($rowToClone->getDomNode()->cloneNode(false), false); + } + + if ($oldCell->getColspan() > $newCell->getColspan()) { + $this->diffCellsAndIncrementCounters( + $oldCell, + null, + $cellsWithMultipleRows, + $diffRow, + $position, + true + ); + $this->syncVirtualColumns($newRow, $position, $cellsWithMultipleRows, $extraRow, 'new', true); + } else { + $this->diffCellsAndIncrementCounters( + null, + $newCell, + $cellsWithMultipleRows, + $extraRow, + $position, + true + ); + $this->syncVirtualColumns($oldRow, $position, $cellsWithMultipleRows, $diffRow, 'old', true); + } + } else { + $diffCell = $this->diffCellsAndIncrementCounters( + $oldCell, + $newCell, + $cellsWithMultipleRows, + $diffRow, + $position + ); + $expandCells[] = $diffCell; + } + } + + $oldCellCount = count($oldCells); + while ($position->getIndexInOld() < $oldCellCount) { + $diffCell = $this->diffCellsAndIncrementCounters( + $oldCells[$position->getIndexInOld()], + null, + $cellsWithMultipleRows, + $diffRow, + $position + ); + $expandCells[] = $diffCell; + } + + if ($extraRow) { + foreach ($expandCells as $expandCell) { + $rowspan = $expandCell->getAttribute('rowspan') ?: 1; + $expandCell->setAttribute('rowspan', 1 + $rowspan); + } + } + + if ($extraRow || $forceExpansion) { + foreach ($appliedRowSpans as $rowSpanCells) { + /* @var $rowSpanCells \DOMElement[] */ + foreach ($rowSpanCells as $extendCell) { + $rowspan = $extendCell->getAttribute('rowspan') ?: 1; + $extendCell->setAttribute('rowspan', 1 + $rowspan); + } + } + } + + if (!$forceExpansion) { + array_shift($appliedRowSpans); + $appliedRowSpans = array_values($appliedRowSpans); + } + $appliedRowSpans = array_merge($appliedRowSpans, array_values($cellsWithMultipleRows)); + + return array($diffRow, $extraRow); + } + + /** + * @param TableCell|null $oldCell + * @param TableCell|null $newCell + * + * @return \DOMElement + */ + protected function getNewCellNode(TableCell $oldCell = null, TableCell $newCell = null) + { + // If only one cell exists, use it + if (!$oldCell || !$newCell) { + $clone = $newCell + ? $newCell->getDomNode()->cloneNode(false) + : $oldCell->getDomNode()->cloneNode(false); + } else { + $oldNode = $oldCell->getDomNode(); + $newNode = $newCell->getDomNode(); + + /* @var $clone \DOMElement */ + $clone = $newNode->cloneNode(false); + + $oldRowspan = $oldNode->getAttribute('rowspan') ?: 1; + $oldColspan = $oldNode->getAttribute('colspan') ?: 1; + $newRowspan = $newNode->getAttribute('rowspan') ?: 1; + $newColspan = $newNode->getAttribute('colspan') ?: 1; + + $clone->setAttribute('rowspan', max($oldRowspan, $newRowspan)); + $clone->setAttribute('colspan', max($oldColspan, $newColspan)); + } + + return $this->diffDom->importNode($clone); + } + + /** + * @param TableCell|null $oldCell + * @param TableCell|null $newCell + * @param bool $usingExtraRow + * + * @return \DOMElement + */ + protected function diffCells($oldCell, $newCell, $usingExtraRow = false) + { + $diffCell = $this->getNewCellNode($oldCell, $newCell); + + $oldContent = $oldCell ? $this->getInnerHtml($oldCell->getDomNode()) : ''; + $newContent = $newCell ? $this->getInnerHtml($newCell->getDomNode()) : ''; + + $htmlDiff = HtmlDiff::create( + mb_convert_encoding($oldContent, 'UTF-8', 'HTML-ENTITIES'), + mb_convert_encoding($newContent, 'UTF-8', 'HTML-ENTITIES'), + $this->config + ); + $diff = $htmlDiff->build(); + + $this->setInnerHtml($diffCell, $diff); + + if (null === $newCell) { + $diffCell->setAttribute('class', trim($diffCell->getAttribute('class').' del')); + } + + if (null === $oldCell) { + $diffCell->setAttribute('class', trim($diffCell->getAttribute('class').' ins')); + } + + if ($usingExtraRow) { + $diffCell->setAttribute('class', trim($diffCell->getAttribute('class').' extra-row')); + } + + return $diffCell; + } + + protected function buildTableDoms() + { + $this->oldTable = $this->parseTableStructure($this->oldText); + $this->newTable = $this->parseTableStructure($this->newText); + } + + /** + * @param string $text + * + * @return \DOMDocument + */ + protected function createDocumentWithHtml($text) + { + $dom = new \DOMDocument(); + $dom->loadHTML(mb_convert_encoding( + $this->purifier->purify(mb_convert_encoding($text, $this->config->getEncoding(), mb_detect_encoding($text))), + 'HTML-ENTITIES', + $this->config->getEncoding() + )); + + return $dom; + } + + /** + * @param string $text + * + * @return Table + */ + protected function parseTableStructure($text) + { + $dom = $this->createDocumentWithHtml($text); + + $tableNode = $dom->getElementsByTagName('table')->item(0); + + $table = new Table($tableNode); + + $this->parseTable($table); + + return $table; + } + + /** + * @param Table $table + * @param \DOMNode|null $node + */ + protected function parseTable(Table $table, \DOMNode $node = null) + { + if ($node === null) { + $node = $table->getDomNode(); + } + + if (!$node->childNodes) { + return; + } + + foreach ($node->childNodes as $child) { + if ($child->nodeName === 'tr') { + $row = new TableRow($child); + $table->addRow($row); + + $this->parseTableRow($row); + } else { + $this->parseTable($table, $child); + } + } + } + + /** + * @param TableRow $row + */ + protected function parseTableRow(TableRow $row) + { + $node = $row->getDomNode(); + + foreach ($node->childNodes as $child) { + if (in_array($child->nodeName, array('td', 'th'))) { + $cell = new TableCell($child); + $row->addCell($cell); + } + } + } + + /** + * @param \DOMNode $node + * + * @return string + */ + protected function getInnerHtml($node) + { + $innerHtml = ''; + $children = $node->childNodes; + + foreach ($children as $child) { + $innerHtml .= $this->htmlFromNode($child); + } + + return $innerHtml; + } + + /** + * @param \DOMNode $node + * + * @return string + */ + protected function htmlFromNode($node) + { + $domDocument = new \DOMDocument(); + $newNode = $domDocument->importNode($node, true); + $domDocument->appendChild($newNode); + + return $domDocument->saveHTML(); + } + + /** + * @param \DOMNode $node + * @param string $html + */ + protected function setInnerHtml($node, $html) + { + // DOMDocument::loadHTML does not allow empty strings. + if (strlen($html) === 0) { + $html = ''; + } + + $doc = $this->createDocumentWithHtml($html); + $fragment = $node->ownerDocument->createDocumentFragment(); + $root = $doc->getElementsByTagName('body')->item(0); + foreach ($root->childNodes as $child) { + $fragment->appendChild($node->ownerDocument->importNode($child, true)); + } + + $node->appendChild($fragment); + } + + /** + * @param Table $table + */ + protected function indexCellValues(Table $table) + { + foreach ($table->getRows() as $rowIndex => $row) { + foreach ($row->getCells() as $cellIndex => $cell) { + $value = trim($cell->getDomNode()->textContent); + + if (!isset($this->cellValues[$value])) { + $this->cellValues[$value] = array(); + } + + $this->cellValues[$value][] = new TablePosition($rowIndex, $cellIndex); + } + } + } + + /** + * @param TableRow $tableRow + * @param DiffRowPosition $position + * @param array $cellsWithMultipleRows + * @param \DOMNode $diffRow + * @param string $diffType + * @param bool $usingExtraRow + */ + protected function syncVirtualColumns( + $tableRow, + DiffRowPosition $position, + &$cellsWithMultipleRows, + $diffRow, + $diffType, + $usingExtraRow = false + ) { + $currentCell = $tableRow->getCell($position->getIndex($diffType)); + while ($position->isColumnLessThanOther($diffType) && $currentCell) { + $diffCell = $diffType === 'new' ? $this->diffCells(null, $currentCell, $usingExtraRow) : $this->diffCells( + $currentCell, + null, + $usingExtraRow + ); + // Store cell in appliedRowSpans if spans multiple rows + if ($diffCell->getAttribute('rowspan') > 1) { + $cellsWithMultipleRows[$diffCell->getAttribute('rowspan')][] = $diffCell; + } + $diffRow->appendChild($diffCell); + $position->incrementColumn($diffType, $currentCell->getColspan()); + $currentCell = $tableRow->getCell($position->incrementIndex($diffType)); + } + } + + /** + * @param null|TableCell $oldCell + * @param null|TableCell $newCell + * @param array $cellsWithMultipleRows + * @param \DOMElement $diffRow + * @param DiffRowPosition $position + * @param bool $usingExtraRow + * + * @return \DOMElement + */ + protected function diffCellsAndIncrementCounters( + $oldCell, + $newCell, + &$cellsWithMultipleRows, + $diffRow, + DiffRowPosition $position, + $usingExtraRow = false + ) { + $diffCell = $this->diffCells($oldCell, $newCell, $usingExtraRow); + // Store cell in appliedRowSpans if spans multiple rows + if ($diffCell->getAttribute('rowspan') > 1) { + $cellsWithMultipleRows[$diffCell->getAttribute('rowspan')][] = $diffCell; + } + $diffRow->appendChild($diffCell); + + if ($newCell !== null) { + $position->incrementIndexInNew(); + $position->incrementColumnInNew($newCell->getColspan()); + } + + if ($oldCell !== null) { + $position->incrementIndexInOld(); + $position->incrementColumnInOld($oldCell->getColspan()); + } + + return $diffCell; + } + + /** + * @param TableRow|null $oldRow + * @param TableRow|null $newRow + * @param array $appliedRowSpans + * @param bool $forceExpansion + */ + protected function diffAndAppendRows($oldRow, $newRow, &$appliedRowSpans, $forceExpansion = false) + { + list($rowDom, $extraRow) = $this->diffRows( + $oldRow, + $newRow, + $appliedRowSpans, + $forceExpansion + ); + + $this->diffTable->appendChild($rowDom); + + if ($extraRow) { + $this->diffTable->appendChild($extraRow); + } + } + + /** + * @param TableRow $oldRow + * @param TableRow $newRow + * @param int $oldIndex + * @param int $newIndex + * + * @return float|int + */ + protected function getMatchPercentage(TableRow $oldRow, TableRow $newRow, $oldIndex, $newIndex) + { + $firstCellWeight = 1.5; + $indexDeltaWeight = 0.25 * (abs($oldIndex - $newIndex)); + $thresholdCount = 0; + $minCells = min(count($newRow->getCells()), count($oldRow->getCells())); + $totalCount = ($minCells + $firstCellWeight + $indexDeltaWeight) * 100; + foreach ($newRow->getCells() as $newIndex => $newCell) { + $oldCell = $oldRow->getCell($newIndex); + + if ($oldCell) { + $percentage = null; + similar_text($oldCell->getInnerHtml(), $newCell->getInnerHtml(), $percentage); + + if ($percentage > ($this->config->getMatchThreshold() * 0.50)) { + $increment = $percentage; + if ($newIndex === 0 && $percentage > 95) { + $increment = $increment * $firstCellWeight; + } + $thresholdCount += $increment; + } + } + } + + return ($totalCount > 0) ? ($thresholdCount / $totalCount) : 0; + } +} diff --git a/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/TableMatch.php b/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/TableMatch.php index 763fa79..8e2871b 100755 --- a/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/TableMatch.php +++ b/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/TableMatch.php @@ -1,75 +1,75 @@ -startInOld = $startInOld; - $this->startInNew = $startInNew; - $this->endInOld = $endInOld; - $this->endInNew = $endInNew; - } - - /** - * @return int - */ - public function getStartInOld() - { - return $this->startInOld; - } - - /** - * @return int - */ - public function getStartInNew() - { - return $this->startInNew; - } - - /** - * @return int - */ - public function getEndInOld() - { - return $this->endInOld; - } - - /** - * @return int - */ - public function getEndInNew() - { - return $this->endInNew; - } -} +startInOld = $startInOld; + $this->startInNew = $startInNew; + $this->endInOld = $endInOld; + $this->endInNew = $endInNew; + } + + /** + * @return int + */ + public function getStartInOld() + { + return $this->startInOld; + } + + /** + * @return int + */ + public function getStartInNew() + { + return $this->startInNew; + } + + /** + * @return int + */ + public function getEndInOld() + { + return $this->endInOld; + } + + /** + * @return int + */ + public function getEndInNew() + { + return $this->endInNew; + } +} diff --git a/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/TablePosition.php b/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/TablePosition.php index 8f647bf..4820597 100755 --- a/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/TablePosition.php +++ b/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/TablePosition.php @@ -1,70 +1,70 @@ -row = $row; - $this->cell = $cell; - } - - /** - * @return int - */ - public function getRow() - { - return $this->row; - } - - /** - * @return int - */ - public function getCell() - { - return $this->cell; - } - - /** - * @return string - */ - public function __toString() - { - return $this->row.':'.$this->cell; - } - - /** - * @param TablePosition $a - * @param TablePosition $b - * - * @return int - */ - public static function compare($a, $b) - { - if ($a->getRow() == $b->getRow()) { - return $a->getCell() - $b->getCell(); - } - - return $a->getRow() - $b->getRow(); - } -} +row = $row; + $this->cell = $cell; + } + + /** + * @return int + */ + public function getRow() + { + return $this->row; + } + + /** + * @return int + */ + public function getCell() + { + return $this->cell; + } + + /** + * @return string + */ + public function __toString() + { + return $this->row.':'.$this->cell; + } + + /** + * @param TablePosition $a + * @param TablePosition $b + * + * @return int + */ + public static function compare($a, $b) + { + if ($a->getRow() == $b->getRow()) { + return $a->getCell() - $b->getCell(); + } + + return $a->getRow() - $b->getRow(); + } +} diff --git a/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/TableRow.php b/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/TableRow.php index a41969e..e55cdbf 100755 --- a/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/TableRow.php +++ b/vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/TableRow.php @@ -1,106 +1,106 @@ -table; - } - - /** - * @param Table|null $table - * - * @return $this - */ - public function setTable(Table $table = null) - { - $this->table = $table; - - if ($table && !in_array($this, $table->getRows())) { - $table->addRow($this); - } - - return $this; - } - - /** - * @return TableCell[] - */ - public function getCells() - { - return $this->cells; - } - - /** - * @param TableCell $cell - * - * @return $this - */ - public function addCell(TableCell $cell) - { - $this->cells[] = $cell; - - if (!$cell->getRow()) { - $cell->setRow($this); - } - - return $this; - } - - /** - * @param TableCell $cell - */ - public function removeCell(TableCell $cell) - { - $key = array_search($cell, $this->cells, true); - - if ($key !== false) { - unset($this->cells[$key]); - if ($cell->getRow()) { - $cell->setRow(null); - } - } - } - - /** - * @param int $index - * - * @return TableCell|null - */ - public function getCell($index) - { - return isset($this->cells[$index]) ? $this->cells[$index] : null; - } - - /** - * @param TableCell[] $cells - * @param null|int $position - */ - public function insertCells($cells, $position = null) - { - if ($position === null) { - $this->cells = array_merge($this->cells, $cells); - } else { - array_splice($this->cells, $position, 0, $cells); - } - } -} +table; + } + + /** + * @param Table|null $table + * + * @return $this + */ + public function setTable(Table $table = null) + { + $this->table = $table; + + if ($table && !in_array($this, $table->getRows())) { + $table->addRow($this); + } + + return $this; + } + + /** + * @return TableCell[] + */ + public function getCells() + { + return $this->cells; + } + + /** + * @param TableCell $cell + * + * @return $this + */ + public function addCell(TableCell $cell) + { + $this->cells[] = $cell; + + if (!$cell->getRow()) { + $cell->setRow($this); + } + + return $this; + } + + /** + * @param TableCell $cell + */ + public function removeCell(TableCell $cell) + { + $key = array_search($cell, $this->cells, true); + + if ($key !== false) { + unset($this->cells[$key]); + if ($cell->getRow()) { + $cell->setRow(null); + } + } + } + + /** + * @param int $index + * + * @return TableCell|null + */ + public function getCell($index) + { + return isset($this->cells[$index]) ? $this->cells[$index] : null; + } + + /** + * @param TableCell[] $cells + * @param null|int $position + */ + public function insertCells($cells, $position = null) + { + if ($position === null) { + $this->cells = array_merge($this->cells, $cells); + } else { + array_splice($this->cells, $position, 0, $cells); + } + } +} diff --git a/vendor/caxy/php-htmldiff/phpunit.xml.dist b/vendor/caxy/php-htmldiff/phpunit.xml.dist index bf4f505..28e0e8d 100755 --- a/vendor/caxy/php-htmldiff/phpunit.xml.dist +++ b/vendor/caxy/php-htmldiff/phpunit.xml.dist @@ -1,26 +1,26 @@ - - - - - - ./tests/Caxy/Tests/HtmlDiff - - - - - - ./lib - - - - + + + + + + ./tests/Caxy/Tests/HtmlDiff + + + + + + ./lib + + + + diff --git a/vendor/caxy/php-htmldiff/tests/Caxy/Tests/HtmlDiff/Functional/HtmlDiffFunctionalTest.php b/vendor/caxy/php-htmldiff/tests/Caxy/Tests/HtmlDiff/Functional/HtmlDiffFunctionalTest.php index e6cb3d2..8347143 100755 --- a/vendor/caxy/php-htmldiff/tests/Caxy/Tests/HtmlDiff/Functional/HtmlDiffFunctionalTest.php +++ b/vendor/caxy/php-htmldiff/tests/Caxy/Tests/HtmlDiff/Functional/HtmlDiffFunctionalTest.php @@ -1,40 +1,40 @@ -build(); - - static::assertEquals($this->stripExtraWhitespaceAndNewLines($expected), $this->stripExtraWhitespaceAndNewLines($output)); - } - - public function diffContentProvider() - { - return new HtmlFileIterator(__DIR__.'/../../../../fixtures/HtmlDiff'); - } - - protected function stripExtraWhitespaceAndNewLines($text) - { - return trim( - preg_replace( - '/>\s+<', - preg_replace('/\s+/S', " ", preg_replace("/[\n\r]/", '', $text)) - ) - ); - } -} +build(); + + static::assertEquals($this->stripExtraWhitespaceAndNewLines($expected), $this->stripExtraWhitespaceAndNewLines($output)); + } + + public function diffContentProvider() + { + return new HtmlFileIterator(__DIR__.'/../../../../fixtures/HtmlDiff'); + } + + protected function stripExtraWhitespaceAndNewLines($text) + { + return trim( + preg_replace( + '/>\s+<', + preg_replace('/\s+/S', " ", preg_replace("/[\n\r]/", '', $text)) + ) + ); + } +} diff --git a/vendor/caxy/php-htmldiff/tests/Caxy/Tests/HtmlDiff/HtmlFileIterator.php b/vendor/caxy/php-htmldiff/tests/Caxy/Tests/HtmlDiff/HtmlFileIterator.php index 6103b28..5fc7de0 100755 --- a/vendor/caxy/php-htmldiff/tests/Caxy/Tests/HtmlDiff/HtmlFileIterator.php +++ b/vendor/caxy/php-htmldiff/tests/Caxy/Tests/HtmlDiff/HtmlFileIterator.php @@ -1,103 +1,103 @@ -files = glob($directory.DIRECTORY_SEPARATOR."*.html"); - } - - /** - * Return the current element - * @link http://php.net/manual/en/iterator.current.php - * @return mixed Can return any type. - * @since 5.0.0 - */ - public function current() - { - return $this->loadHtmlFile($this->key); - } - - /** - * Move forward to next element - * @link http://php.net/manual/en/iterator.next.php - * @return void Any returned value is ignored. - * @since 5.0.0 - */ - public function next() - { - $this->key++; - } - - /** - * Return the key of the current element - * @link http://php.net/manual/en/iterator.key.php - * @return mixed scalar on success, or null on failure. - * @since 5.0.0 - */ - public function key() - { - return basename($this->files[$this->key]); - } - - /** - * Checks if current position is valid - * @link http://php.net/manual/en/iterator.valid.php - * @return boolean The return value will be casted to boolean and then evaluated. - * Returns true on success or false on failure. - * @since 5.0.0 - */ - public function valid() - { - return isset($this->files[$this->key]); - } - - /** - * Rewind the Iterator to the first element - * @link http://php.net/manual/en/iterator.rewind.php - * @return void Any returned value is ignored. - * @since 5.0.0 - */ - public function rewind() - { - $this->key = 0; - } - - protected function loadHtmlFile($key) - { - $filename = $this->files[$key]; - - if (!isset($this->loadedDiffs[$filename])) { - - $html = file_get_contents($filename); - - $oldText = $this->parseTagContent('oldText', $html); - $newText = $this->parseTagContent('newText', $html); - $expected = $this->parseTagContent('expected', $html); - - if (null === $expected) { - throw new \Exception('HTML fixture content should have an tag.'); - } - - $this->loadedDiffs[$filename] = array($oldText, $newText, $expected); - } - - return $this->loadedDiffs[$filename]; - } - - protected function parseTagContent($tagName, $html) - { - $matches = array(); - if (preg_match(sprintf('/<%s\s*[^>]*>(.*)<\/%s\s*>/is', $tagName, $tagName), $html, $matches)) { - return $matches[1]; - } - - return null; - } -} +files = glob($directory.DIRECTORY_SEPARATOR."*.html"); + } + + /** + * Return the current element + * @link http://php.net/manual/en/iterator.current.php + * @return mixed Can return any type. + * @since 5.0.0 + */ + public function current() + { + return $this->loadHtmlFile($this->key); + } + + /** + * Move forward to next element + * @link http://php.net/manual/en/iterator.next.php + * @return void Any returned value is ignored. + * @since 5.0.0 + */ + public function next() + { + $this->key++; + } + + /** + * Return the key of the current element + * @link http://php.net/manual/en/iterator.key.php + * @return mixed scalar on success, or null on failure. + * @since 5.0.0 + */ + public function key() + { + return basename($this->files[$this->key]); + } + + /** + * Checks if current position is valid + * @link http://php.net/manual/en/iterator.valid.php + * @return boolean The return value will be casted to boolean and then evaluated. + * Returns true on success or false on failure. + * @since 5.0.0 + */ + public function valid() + { + return isset($this->files[$this->key]); + } + + /** + * Rewind the Iterator to the first element + * @link http://php.net/manual/en/iterator.rewind.php + * @return void Any returned value is ignored. + * @since 5.0.0 + */ + public function rewind() + { + $this->key = 0; + } + + protected function loadHtmlFile($key) + { + $filename = $this->files[$key]; + + if (!isset($this->loadedDiffs[$filename])) { + + $html = file_get_contents($filename); + + $oldText = $this->parseTagContent('oldText', $html); + $newText = $this->parseTagContent('newText', $html); + $expected = $this->parseTagContent('expected', $html); + + if (null === $expected) { + throw new \Exception('HTML fixture content should have an tag.'); + } + + $this->loadedDiffs[$filename] = array($oldText, $newText, $expected); + } + + return $this->loadedDiffs[$filename]; + } + + protected function parseTagContent($tagName, $html) + { + $matches = array(); + if (preg_match(sprintf('/<%s\s*[^>]*>(.*)<\/%s\s*>/is', $tagName, $tagName), $html, $matches)) { + return $matches[1]; + } + + return null; + } +} diff --git a/vendor/caxy/php-htmldiff/tests/Caxy/Tests/TestInit.php b/vendor/caxy/php-htmldiff/tests/Caxy/Tests/TestInit.php index 6beb15f..46da910 100755 --- a/vendor/caxy/php-htmldiff/tests/Caxy/Tests/TestInit.php +++ b/vendor/caxy/php-htmldiff/tests/Caxy/Tests/TestInit.php @@ -1,14 +1,14 @@ - -Compliance with this section requires that the provisions identified in Sections R401 through R404 labeled as "mandatory" and Section R403.5.3 be met. The building thermal envelope shall be greater than or equal to levels of efficiency and Solar Heat Gain Coefficient in Table 402.1.1 or 402.1.3 of the 2009 International Energy Conservation Code.
    • Exception: Supply and return ducts not completely inside the building thermal envelope shall be insulated to a minimum of R-6.
    - - - -

    Compliance with this section requires that the provisions identified in Sections R401 through R404 labeled as "mandatory" and Section R403.5.3 shall be met. Fenestration U-factor and SHGC shall not exceed the maximum values for the climate zone set forth in Table R402.1.2. The remaining components of the building thermal envelope shall comply with either the minimum R-values or maximum U-factors for the climate zones specified in Table R402.1.2 and R402.1.4.

    -
    • Exception: Supply and return ducts not completely inside the building thermal envelope shall be insulated to a minimum of R-6.
    • -
    -
    - - -

    Compliance with this section requires that the provisions identified in Sections R401 through R404 labeled as "mandatory" and Section R403.5.3 shall be met. Fenestration U-factor and SHGC shall not exceed the maximum values for the climate zone set forth in Table R402.1.2. The remaining components of the building thermal envelope shall be greater thancomply with either the minimum R-values or equal to levels of efficiency and Solar Heat Gain Coefficientmaximum U-factors for the climate zones specified in Table 402.1.1 or 402.1.3 of the 2009 International Energy Conservation CodeR402.1.2 and R402.1.4.

    • Exception: Supply and return ducts not completely inside the building thermal envelope shall be insulated to a minimum of R-6.
    -
    + +Compliance with this section requires that the provisions identified in Sections R401 through R404 labeled as "mandatory" and Section R403.5.3 be met. The building thermal envelope shall be greater than or equal to levels of efficiency and Solar Heat Gain Coefficient in Table 402.1.1 or 402.1.3 of the 2009 International Energy Conservation Code.
    • Exception: Supply and return ducts not completely inside the building thermal envelope shall be insulated to a minimum of R-6.
    +
    + + +

    Compliance with this section requires that the provisions identified in Sections R401 through R404 labeled as "mandatory" and Section R403.5.3 shall be met. Fenestration U-factor and SHGC shall not exceed the maximum values for the climate zone set forth in Table R402.1.2. The remaining components of the building thermal envelope shall comply with either the minimum R-values or maximum U-factors for the climate zones specified in Table R402.1.2 and R402.1.4.

    +
    • Exception: Supply and return ducts not completely inside the building thermal envelope shall be insulated to a minimum of R-6.
    • +
    +
    + + +

    Compliance with this section requires that the provisions identified in Sections R401 through R404 labeled as "mandatory" and Section R403.5.3 shall be met. Fenestration U-factor and SHGC shall not exceed the maximum values for the climate zone set forth in Table R402.1.2. The remaining components of the building thermal envelope shall be greater thancomply with either the minimum R-values or equal to levels of efficiency and Solar Heat Gain Coefficientmaximum U-factors for the climate zones specified in Table 402.1.1 or 402.1.3 of the 2009 International Energy Conservation CodeR402.1.2 and R402.1.4.

    • Exception: Supply and return ducts not completely inside the building thermal envelope shall be insulated to a minimum of R-6.
    +
    diff --git a/vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/first-and-last.html b/vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/first-and-last.html index bc94992..0a4aa0a 100755 --- a/vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/first-and-last.html +++ b/vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/first-and-last.html @@ -1,39 +1,39 @@ - -
      -
    1. - Etiam feugiat lorem non metus. Nullam accumsan lorem in dui. -
    2. - -
    3. - Praesent ac sem eget est egestas volutpat. Nulla neque dolor, sagittis eget, iaculis quis, molestie non, velit. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Integer ante arcu, accumsan a, consectetuer eget, posuere ut, mauris. Aenean massa. -
    4. - -
    5. - Vestibulum suscipit nulla quis orci. Integer ante arcu, accumsan a, consectetuer eget, posuere ut, mauris. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. -
    6. - -
    7. - Suspendisse non nisl sit amet velit hendrerit rutrum. Aenean massa. Curabitur ullamcorper ultricies nisi. Praesent vestibulum dapibus nibh. In dui magna, posuere eget, vestibulum et, tempor auctor, justo. -
    8. -
    -
    - - -
      -
    1. - Suspendisse non nisl sit amet velit hendrerit rutrum. Aenean massa. Curabitur ullamcorper ultricies nisi. Praesent vestibulum dapibus nibh. In dui magna, posuere eget, vestibulum et, tempor auctor, justo. -
    2. - -
    3. - Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. -
    4. - -
    5. - Duis lobortis massa imperdiet quam. Donec sodales sagittis magna. Nam ipsum risus, rutrum vitae, vestibulum eu, molestie vel, lacus. Suspendisse eu ligula. Morbi nec metus. -
    6. -
    -
    - - -
    1. Etiam feugiat loremSuspendisse non metusnisl sit amet velit hendrerit rutrum. Nullam accumsan lorem inAenean massa. Curabitur ullamcorper ultricies nisi. Praesent vestibulum dapibus nibh. In dui magna, posuere eget, vestibulum et, tempor auctor, justo.
    2. Praesent ac sem eget est egestas volutpat. Nulla neque dolorDonec pede justo, sagittisfringilla vel, aliquet nec, vulputate eget, iaculis quis, molestie non, velitarcu. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Integer ante arcu, accumsan a, consectetuer eget, posuere ut, mauris. Aenean massa.
    3. Vestibulum suscipit nulla quis orciDuis lobortis massa imperdiet quam. Integer ante arcuDonec sodales sagittis magna. Nam ipsum risus, accumsan arutrum vitae, consectetuer egetvestibulum eu, posuere utmolestie vel, maurislacus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeosSuspendisse eu ligula. Morbi nec metus.
    4. Suspendisse non nisl sit amet velit hendrerit rutrum. Aenean massa. Curabitur ullamcorper ultricies nisi. Praesent vestibulum dapibus nibh. In dui magna, posuere eget, vestibulum et, tempor auctor, justo.
    + +
      +
    1. + Etiam feugiat lorem non metus. Nullam accumsan lorem in dui. +
    2. + +
    3. + Praesent ac sem eget est egestas volutpat. Nulla neque dolor, sagittis eget, iaculis quis, molestie non, velit. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Integer ante arcu, accumsan a, consectetuer eget, posuere ut, mauris. Aenean massa. +
    4. + +
    5. + Vestibulum suscipit nulla quis orci. Integer ante arcu, accumsan a, consectetuer eget, posuere ut, mauris. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. +
    6. + +
    7. + Suspendisse non nisl sit amet velit hendrerit rutrum. Aenean massa. Curabitur ullamcorper ultricies nisi. Praesent vestibulum dapibus nibh. In dui magna, posuere eget, vestibulum et, tempor auctor, justo. +
    8. +
    +
    + + +
      +
    1. + Suspendisse non nisl sit amet velit hendrerit rutrum. Aenean massa. Curabitur ullamcorper ultricies nisi. Praesent vestibulum dapibus nibh. In dui magna, posuere eget, vestibulum et, tempor auctor, justo. +
    2. + +
    3. + Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. +
    4. + +
    5. + Duis lobortis massa imperdiet quam. Donec sodales sagittis magna. Nam ipsum risus, rutrum vitae, vestibulum eu, molestie vel, lacus. Suspendisse eu ligula. Morbi nec metus. +
    6. +
    +
    + + +
    1. Etiam feugiat loremSuspendisse non metusnisl sit amet velit hendrerit rutrum. Nullam accumsan lorem inAenean massa. Curabitur ullamcorper ultricies nisi. Praesent vestibulum dapibus nibh. In dui magna, posuere eget, vestibulum et, tempor auctor, justo.
    2. Praesent ac sem eget est egestas volutpat. Nulla neque dolorDonec pede justo, sagittisfringilla vel, aliquet nec, vulputate eget, iaculis quis, molestie non, velitarcu. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Integer ante arcu, accumsan a, consectetuer eget, posuere ut, mauris. Aenean massa.
    3. Vestibulum suscipit nulla quis orciDuis lobortis massa imperdiet quam. Integer ante arcuDonec sodales sagittis magna. Nam ipsum risus, accumsan arutrum vitae, consectetuer egetvestibulum eu, posuere utmolestie vel, maurislacus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeosSuspendisse eu ligula. Morbi nec metus.
    4. Suspendisse non nisl sit amet velit hendrerit rutrum. Aenean massa. Curabitur ullamcorper ultricies nisi. Praesent vestibulum dapibus nibh. In dui magna, posuere eget, vestibulum et, tempor auctor, justo.
    \ No newline at end of file diff --git a/vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/issue-28-link-changes.html b/vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/issue-28-link-changes.html index 80eb083..9448d03 100755 --- a/vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/issue-28-link-changes.html +++ b/vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/issue-28-link-changes.html @@ -1,15 +1,15 @@ - -Testing Link Changes -And when the link stays the same - - - -Testing Link Changes -And when the link stays the same - - - -Testing Link ChangesLink Changes - And when the link stays the same - - + +Testing Link Changes +And when the link stays the same + + + +Testing Link Changes +And when the link stays the same + + + +Testing Link ChangesLink Changes + And when the link stays the same + + diff --git a/vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/new-paragraph-and-list.html b/vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/new-paragraph-and-list.html index c2fdd30..5bc5c34 100755 --- a/vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/new-paragraph-and-list.html +++ b/vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/new-paragraph-and-list.html @@ -1,20 +1,20 @@ - -Corridors shall be fire-resistance rated in accordance with Table 1020.1. The corridor walls required to be fire-resistance rated shall comply with Section 708 for fire partitions.
    • Exceptions:
      1. A fire-resistance rating is not required for corridors in an occupancy in Group E where each room that is used for instruction has not less than one door opening directly to the exterior and rooms for assembly purposes have not less than one-half of the required means of egress doors opening directly to the exterior. Exterior doors specified in this exception are required to be at ground level.
      2. A fire-resistance rating is not required for corridors contained within a dwelling unit or sleeping unit in an occupancy in Groups I-1 and R.
      3. A fire-resistance rating is not required for corridors in open parking garages.
      4. A fire-resistance rating is not required for corridors in an occupancy in Group B that is a space requiring only a single means of egress complying with Section 1006.2.
      5. Corridors adjacent to the exterior walls of buildings shall be permitted to have unprotected openings on unrated exterior walls where unrated walls are permitted by Table 602 and unprotected openings are permitted by Table 705.8.
    -
    - - -Corridors shall be fire-resistance rated in accordance with Table 1020.1. The corridor walls required to be fire-resistance rated shall comply with Section 708 for fire partitions.

    In addition, corridors in buildings of Types IIB, IIIB, and VB construction and assigned Risk Categories III and IV in Table 1604.5, other than Group I, shall have a fire resistance rating of not less than 1 hour where such buildings are any of the following:

    1. Assigned a Seismic Design Category C or D in Table 1613.3.5(1).
    2. -
    3. Located in a flood hazard area established in accordance with Section 1612.3.
    4. -
    5. Located in a hurricane-prone regions.
    6. -
    • Exceptions:
      1. A fire-resistance rating is not required for corridors in an occupancy in Group E where each room that is used for instruction has not less than one door opening directly to the exterior and rooms for assembly purposes have not less than one-half of the required means of egress doors opening directly to the exterior. Exterior doors specified in this exception are required to be at ground level.
      2. -
      3. A fire-resistance rating is not required for corridors contained within a dwelling unit or sleeping unit in an occupancy in Groups I-1 and R.
      4. -
      5. A fire-resistance rating is not required for corridors in open parking garages.
      6. -
      7. A fire-resistance rating is not required for corridors in an occupancy in Group B that is a space requiring only a single means of egress complying with Section 1006.2.
      8. -
      9. Corridors adjacent to the exterior walls of buildings shall be permitted to have unprotected openings on unrated exterior walls where unrated walls are permitted by Table 602 and unprotected openings are permitted by Table 705.8.
      10. -
    • -
    -
    - - -CorridorsCorridors shall be fire-resistance rated in accordance with Table 1020.1. The corridorcorridor walls required to be fire-resistance rated shall comply with Section 708 for fire partitionsfire partitions.
    • Exceptions:
      1. A fire-resistance rating is not required for corridors in an occupancy in Group E where each room that is used for instruction has not less than one door opening directly to the exterior and rooms for assembly purposes have not less than one-half of the required means of egress doors opening directly to the exterior. Exterior doors specified in this exception are required to be at ground level.
      2. A fire-resistance rating is not required for corridors contained within a dwelling unit or sleeping unit in an occupancy in Groups I-1 and R.
      3. A fire-resistance rating is not required for corridors in open parking garages.
      4. A fire-resistance rating is not required for corridors in an occupancy in Group B that is a space requiring only a single means of egress complying with Section 1006.2.
      5. Corridors adjacent to the exterior walls of buildings shall be permitted to have unprotected openings on unrated exterior walls where unrated walls are permitted by Table 602 and unprotected openings are permitted by Table 705.8.


    In addition, corridors in buildings of Types IIB, IIIB, and VB construction and assigned Risk Categories III and IV in Table 1604.5, other than Group I, shall have a fire resistance rating of not less than 1 hour where such buildings are any of the following:

    1. Assigned a Seismic Design Category C or D in Table 1613.3.5(1).
    2. Located in a flood hazard area established in accordance with Section 1612.3.
    3. Located in a hurricane-prone regions.
    • Exceptions:
      1. A fire-resistance rating is not required for corridors in an occupancy in Group E where each room that is used for instruction has not less than one door opening directly to the exterior and rooms for assembly purposes have not less than one-half of the required means of egress doors opening directly to the exterior. Exterior doors specified in this exception are required to be at ground level.
      2. A fire-resistance rating is not required for corridors contained within a dwelling unit or sleeping unit in an occupancy in Groups I-1 and R.
      3. A fire-resistance rating is not required for corridors in open parking garages.
      4. A fire-resistance rating is not required for corridors in an occupancy in Group B that is a space requiring only a single means of egress complying with Section 1006.2.
      5. Corridors adjacent to the exterior walls of buildings shall be permitted to have unprotected openings on unrated exterior walls where unrated walls are permitted by Table 602 and unprotected openings are permitted by Table 705.8.
    -
    + +Corridors shall be fire-resistance rated in accordance with Table 1020.1. The corridor walls required to be fire-resistance rated shall comply with Section 708 for fire partitions.
    • Exceptions:
      1. A fire-resistance rating is not required for corridors in an occupancy in Group E where each room that is used for instruction has not less than one door opening directly to the exterior and rooms for assembly purposes have not less than one-half of the required means of egress doors opening directly to the exterior. Exterior doors specified in this exception are required to be at ground level.
      2. A fire-resistance rating is not required for corridors contained within a dwelling unit or sleeping unit in an occupancy in Groups I-1 and R.
      3. A fire-resistance rating is not required for corridors in open parking garages.
      4. A fire-resistance rating is not required for corridors in an occupancy in Group B that is a space requiring only a single means of egress complying with Section 1006.2.
      5. Corridors adjacent to the exterior walls of buildings shall be permitted to have unprotected openings on unrated exterior walls where unrated walls are permitted by Table 602 and unprotected openings are permitted by Table 705.8.
    +
    + + +Corridors shall be fire-resistance rated in accordance with Table 1020.1. The corridor walls required to be fire-resistance rated shall comply with Section 708 for fire partitions.

    In addition, corridors in buildings of Types IIB, IIIB, and VB construction and assigned Risk Categories III and IV in Table 1604.5, other than Group I, shall have a fire resistance rating of not less than 1 hour where such buildings are any of the following:

    1. Assigned a Seismic Design Category C or D in Table 1613.3.5(1).
    2. +
    3. Located in a flood hazard area established in accordance with Section 1612.3.
    4. +
    5. Located in a hurricane-prone regions.
    6. +
    • Exceptions:
      1. A fire-resistance rating is not required for corridors in an occupancy in Group E where each room that is used for instruction has not less than one door opening directly to the exterior and rooms for assembly purposes have not less than one-half of the required means of egress doors opening directly to the exterior. Exterior doors specified in this exception are required to be at ground level.
      2. +
      3. A fire-resistance rating is not required for corridors contained within a dwelling unit or sleeping unit in an occupancy in Groups I-1 and R.
      4. +
      5. A fire-resistance rating is not required for corridors in open parking garages.
      6. +
      7. A fire-resistance rating is not required for corridors in an occupancy in Group B that is a space requiring only a single means of egress complying with Section 1006.2.
      8. +
      9. Corridors adjacent to the exterior walls of buildings shall be permitted to have unprotected openings on unrated exterior walls where unrated walls are permitted by Table 602 and unprotected openings are permitted by Table 705.8.
      10. +
    • +
    +
    + + +CorridorsCorridors shall be fire-resistance rated in accordance with Table 1020.1. The corridorcorridor walls required to be fire-resistance rated shall comply with Section 708 for fire partitionsfire partitions.
    • Exceptions:
      1. A fire-resistance rating is not required for corridors in an occupancy in Group E where each room that is used for instruction has not less than one door opening directly to the exterior and rooms for assembly purposes have not less than one-half of the required means of egress doors opening directly to the exterior. Exterior doors specified in this exception are required to be at ground level.
      2. A fire-resistance rating is not required for corridors contained within a dwelling unit or sleeping unit in an occupancy in Groups I-1 and R.
      3. A fire-resistance rating is not required for corridors in open parking garages.
      4. A fire-resistance rating is not required for corridors in an occupancy in Group B that is a space requiring only a single means of egress complying with Section 1006.2.
      5. Corridors adjacent to the exterior walls of buildings shall be permitted to have unprotected openings on unrated exterior walls where unrated walls are permitted by Table 602 and unprotected openings are permitted by Table 705.8.


    In addition, corridors in buildings of Types IIB, IIIB, and VB construction and assigned Risk Categories III and IV in Table 1604.5, other than Group I, shall have a fire resistance rating of not less than 1 hour where such buildings are any of the following:

    1. Assigned a Seismic Design Category C or D in Table 1613.3.5(1).
    2. Located in a flood hazard area established in accordance with Section 1612.3.
    3. Located in a hurricane-prone regions.
    • Exceptions:
      1. A fire-resistance rating is not required for corridors in an occupancy in Group E where each room that is used for instruction has not less than one door opening directly to the exterior and rooms for assembly purposes have not less than one-half of the required means of egress doors opening directly to the exterior. Exterior doors specified in this exception are required to be at ground level.
      2. A fire-resistance rating is not required for corridors contained within a dwelling unit or sleeping unit in an occupancy in Groups I-1 and R.
      3. A fire-resistance rating is not required for corridors in open parking garages.
      4. A fire-resistance rating is not required for corridors in an occupancy in Group B that is a space requiring only a single means of egress complying with Section 1006.2.
      5. Corridors adjacent to the exterior walls of buildings shall be permitted to have unprotected openings on unrated exterior walls where unrated walls are permitted by Table 602 and unprotected openings are permitted by Table 705.8.
    +
    diff --git a/vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/override-2.html b/vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/override-2.html index 41e7fe2..6081543 100755 --- a/vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/override-2.html +++ b/vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/override-2.html @@ -1,18 +1,18 @@ - -

    Air handling equipment and HVAC equipment shall be designed and installed to limit the amount of airflow that bypasses the air filters and shall comply with the following:

    -
    1. Channels, racks and other filter retaining constructions that do not seal tightly to the filter frame by means of a friction fit shall be provided with a means to seal the filter frame to the filter retaining construction.
    2. -
    3. Where standard size filters are installed in banks of multiple filters, gaskets shall seal the gap between the frames of adjacent filters. As an alternative to gaskets, the frames of adjacent filters shall be compressed by means of spring elements that are built into the filter retaining construction.
    4. -
    5. Channels, racks and other filter retaining constructions shall be sealed to the duct or housing of the HVAC equipment served by the filters.
    6. -
    7. Filter access doors in ducts and HVAC equipment shall be designed to limit the amount of airflow that bypasses the filters.
    8. -
    9. Field or shop fabricated spacers shall not be installed for the purpose of replacing the intended size filter with a smaller size filter.
    10. -
    11. Gaskets and seals shall be provided with access for repair, maintenance and replacement.
    12. -
    -
    - - -

    Air handling equipment and HVAC equipment shall be designed and installed to limit the amount of airflow that bypasses the air filters. Filter access doors in ducts and HVAC equipment shall be designed to limit the amount of airflow that bypasses the filters. Channels, racks and other filter retaining constructions shall be sealed to the duct or housing of the HVAC equipment served by the filters. Field or shop fabricated spacers shall not be installed for the purpose of replacing the intended size filter with a smaller size filter.

    -
    - - -

    Air handling equipment and HVAC equipment shall be designed and installed to limit the amount of airflow that bypasses the air filters. Filter access doors in ducts and HVAC equipment shall complybe designed to limit the amount of airflow that bypasses the filters. Channels, racks and other filter retaining constructions shall be sealed to the duct or housing of the HVAC equipment served by the filters. Field or shop fabricated spacers shall not be installed for the purpose of replacing the intended size filter with the following: a smaller size filter.

    1. Channels, racks and other filter retaining constructions that do not seal tightly to the filter frame by means of a friction fit shall be provided with a means to seal the filter frame to the filter retaining construction.
    2. Where standard size filters are installed in banks of multiple filters, gaskets shall seal the gap between the frames of adjacent filters. As an alternative to gaskets, the frames of adjacent filters shall be compressed by means of spring elements that are built into the filter retaining construction.
    3. Channels, racks and other filter retaining constructions shall be sealed to the duct or housing of the HVAC equipment served by the filters.
    4. Filter access doors in ducts and HVAC equipment shall be designed to limit the amount of airflow that bypasses the filters.
    5. Field or shop fabricated spacers shall not be installed for the purpose of replacing the intended size filter with a smaller size filter.
    6. Gaskets and seals shall be provided with access for repair, maintenance and replacement.
    -
    + +

    Air handling equipment and HVAC equipment shall be designed and installed to limit the amount of airflow that bypasses the air filters and shall comply with the following:

    +
    1. Channels, racks and other filter retaining constructions that do not seal tightly to the filter frame by means of a friction fit shall be provided with a means to seal the filter frame to the filter retaining construction.
    2. +
    3. Where standard size filters are installed in banks of multiple filters, gaskets shall seal the gap between the frames of adjacent filters. As an alternative to gaskets, the frames of adjacent filters shall be compressed by means of spring elements that are built into the filter retaining construction.
    4. +
    5. Channels, racks and other filter retaining constructions shall be sealed to the duct or housing of the HVAC equipment served by the filters.
    6. +
    7. Filter access doors in ducts and HVAC equipment shall be designed to limit the amount of airflow that bypasses the filters.
    8. +
    9. Field or shop fabricated spacers shall not be installed for the purpose of replacing the intended size filter with a smaller size filter.
    10. +
    11. Gaskets and seals shall be provided with access for repair, maintenance and replacement.
    12. +
    +
    + + +

    Air handling equipment and HVAC equipment shall be designed and installed to limit the amount of airflow that bypasses the air filters. Filter access doors in ducts and HVAC equipment shall be designed to limit the amount of airflow that bypasses the filters. Channels, racks and other filter retaining constructions shall be sealed to the duct or housing of the HVAC equipment served by the filters. Field or shop fabricated spacers shall not be installed for the purpose of replacing the intended size filter with a smaller size filter.

    +
    + + +

    Air handling equipment and HVAC equipment shall be designed and installed to limit the amount of airflow that bypasses the air filters. Filter access doors in ducts and HVAC equipment shall complybe designed to limit the amount of airflow that bypasses the filters. Channels, racks and other filter retaining constructions shall be sealed to the duct or housing of the HVAC equipment served by the filters. Field or shop fabricated spacers shall not be installed for the purpose of replacing the intended size filter with the following: a smaller size filter.

    1. Channels, racks and other filter retaining constructions that do not seal tightly to the filter frame by means of a friction fit shall be provided with a means to seal the filter frame to the filter retaining construction.
    2. Where standard size filters are installed in banks of multiple filters, gaskets shall seal the gap between the frames of adjacent filters. As an alternative to gaskets, the frames of adjacent filters shall be compressed by means of spring elements that are built into the filter retaining construction.
    3. Channels, racks and other filter retaining constructions shall be sealed to the duct or housing of the HVAC equipment served by the filters.
    4. Filter access doors in ducts and HVAC equipment shall be designed to limit the amount of airflow that bypasses the filters.
    5. Field or shop fabricated spacers shall not be installed for the purpose of replacing the intended size filter with a smaller size filter.
    6. Gaskets and seals shall be provided with access for repair, maintenance and replacement.
    +
    diff --git a/vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/override-3.html b/vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/override-3.html index 5498c9b..8fa3973 100755 --- a/vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/override-3.html +++ b/vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/override-3.html @@ -1,29 +1,29 @@ - -
    The path of egress travel to an exit shall not pass through more than one adjacent story.
    -
    -
    Exception: The path of egress travel to an exit shall be permitted to pass through more than one adjacent story in any of the following:
    -
    1. In Group R-1, R-2 or R-3 occupancies, exit access stairways and ramps connecting four stories or less serving and contained within an individual dwelling unit or sleeping unit or live/work unit.
    2. -
    3. Exit access stairways serving and contained within a Group R-3 congregate residence or a Group R-4 facility.
    4. -
    5. Exit access stairways and ramps in open parking garages that serve only the parking garage.
    6. -
    7. Exit access stairways and ramps serving open-air assembly seating complying with the exit access travel distance requirements of Section 1029.7.
    8. -
    9. Exit access stairways and ramps between the balcony, gallery or press box and the main assembly floor in occupancies such as theaters, places of religious worship, auditoriums and sports facilities.
    10. -
    -
    - - -
    The path of egress travel to an exit shall not pass through more than one adjacent story.
    -
    -
    Exception: The path of egress travel to an exit shall be permitted to pass through more than one adjacent story in any of the following:
    -
    1. In Group R-1, R-2 or R-3 occupancies, exit access stairways and ramps connecting four stories or less serving and contained within an individual dwelling unit or sleeping unit or live/work unit.
    2. -
    3. Exit access stairways serving and contained within a Group R-3 congregate residence or a Group R-4 facility.
    4. -
    5. Exit access stairways and ramps in open parking garages that serve only the parking garage.
    6. -
    7. Exit access stairways and ramps in buildings equipped throughout with an automatic sprinkler system in accordance with Section 903.3.1.1, where the area of the vertical opening between stories does not exceed twice the horizontal projected area of the stairway or ramp and the opening is protected by a draft curtain and closely spaced sprinklers in accordance with NFPA 13. In other than Group B and M occupancies, this provision is limited to openings that do not connect more than four stories.
    8. -
    9. Exit access stairways and ramps within an atrium complying with the provisions of Section 404.
    10. -
    11. Exit access stairways and ramps serving open-air assembly seating complying with the exit access travel distance requirements of Section 1029.7.
    12. -
    13. Exit access stairways and ramps between the balcony, gallery or press box and the main assembly floor in occupancies such as theaters, places of religious worship, auditoriums and sports facilities.
    14. -
    -
    - - -
    The path of egress travel to an exit shall not pass through more than one adjacent story.
    Exception: The path of egress travel to an exit shall be permitted to pass through more than one adjacent story in any of the following:
    1. In Group R-1, R-2 or R-3 occupancies, exit access stairways and ramps connecting four stories or less serving and contained within an individual dwelling unit or sleeping unit or live/work unit.
    2. Exit access stairways serving and contained within a Group R-3 congregate residence or a Group R-4 facility.
    3. Exit access stairways and ramps in open parking garages that serve only the parking garage.
    4. Exit access stairways and ramps in buildings equipped throughout with an automatic sprinkler system in accordance with Section 903.3.1.1, where the area of the vertical opening between stories does not exceed twice the horizontal projected area of the stairway or ramp and the opening is protected by a draft curtain and closely spaced sprinklers in accordance with NFPA 13. In other than Group B and M occupancies, this provision is limited to openings that do not connect more than four stories.
    5. Exit access stairways and ramps within an atrium complying with the provisions of Section 404.
    6. Exit access stairways and ramps serving open-air assembly seating complying with the exit access travel distance requirements of Section 1029.7.
    7. Exit access stairways and ramps between the balcony, gallery or press box and the main assembly floor in occupancies such as theaters, places of religious worship, auditoriums and sports facilities.
    + +
    The path of egress travel to an exit shall not pass through more than one adjacent story.
    +
    +
    Exception: The path of egress travel to an exit shall be permitted to pass through more than one adjacent story in any of the following:
    +
    1. In Group R-1, R-2 or R-3 occupancies, exit access stairways and ramps connecting four stories or less serving and contained within an individual dwelling unit or sleeping unit or live/work unit.
    2. +
    3. Exit access stairways serving and contained within a Group R-3 congregate residence or a Group R-4 facility.
    4. +
    5. Exit access stairways and ramps in open parking garages that serve only the parking garage.
    6. +
    7. Exit access stairways and ramps serving open-air assembly seating complying with the exit access travel distance requirements of Section 1029.7.
    8. +
    9. Exit access stairways and ramps between the balcony, gallery or press box and the main assembly floor in occupancies such as theaters, places of religious worship, auditoriums and sports facilities.
    10. +
    +
    + + +
    The path of egress travel to an exit shall not pass through more than one adjacent story.
    +
    +
    Exception: The path of egress travel to an exit shall be permitted to pass through more than one adjacent story in any of the following:
    +
    1. In Group R-1, R-2 or R-3 occupancies, exit access stairways and ramps connecting four stories or less serving and contained within an individual dwelling unit or sleeping unit or live/work unit.
    2. +
    3. Exit access stairways serving and contained within a Group R-3 congregate residence or a Group R-4 facility.
    4. +
    5. Exit access stairways and ramps in open parking garages that serve only the parking garage.
    6. +
    7. Exit access stairways and ramps in buildings equipped throughout with an automatic sprinkler system in accordance with Section 903.3.1.1, where the area of the vertical opening between stories does not exceed twice the horizontal projected area of the stairway or ramp and the opening is protected by a draft curtain and closely spaced sprinklers in accordance with NFPA 13. In other than Group B and M occupancies, this provision is limited to openings that do not connect more than four stories.
    8. +
    9. Exit access stairways and ramps within an atrium complying with the provisions of Section 404.
    10. +
    11. Exit access stairways and ramps serving open-air assembly seating complying with the exit access travel distance requirements of Section 1029.7.
    12. +
    13. Exit access stairways and ramps between the balcony, gallery or press box and the main assembly floor in occupancies such as theaters, places of religious worship, auditoriums and sports facilities.
    14. +
    +
    + + +
    The path of egress travel to an exit shall not pass through more than one adjacent story.
    Exception: The path of egress travel to an exit shall be permitted to pass through more than one adjacent story in any of the following:
    1. In Group R-1, R-2 or R-3 occupancies, exit access stairways and ramps connecting four stories or less serving and contained within an individual dwelling unit or sleeping unit or live/work unit.
    2. Exit access stairways serving and contained within a Group R-3 congregate residence or a Group R-4 facility.
    3. Exit access stairways and ramps in open parking garages that serve only the parking garage.
    4. Exit access stairways and ramps in buildings equipped throughout with an automatic sprinkler system in accordance with Section 903.3.1.1, where the area of the vertical opening between stories does not exceed twice the horizontal projected area of the stairway or ramp and the opening is protected by a draft curtain and closely spaced sprinklers in accordance with NFPA 13. In other than Group B and M occupancies, this provision is limited to openings that do not connect more than four stories.
    5. Exit access stairways and ramps within an atrium complying with the provisions of Section 404.
    6. Exit access stairways and ramps serving open-air assembly seating complying with the exit access travel distance requirements of Section 1029.7.
    7. Exit access stairways and ramps between the balcony, gallery or press box and the main assembly floor in occupancies such as theaters, places of religious worship, auditoriums and sports facilities.
    \ No newline at end of file diff --git a/vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/override-4.html b/vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/override-4.html index 7cdc7dc..544d037 100755 --- a/vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/override-4.html +++ b/vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/override-4.html @@ -1,28 +1,28 @@ - - Corridors shall be fire-resistance rated in accordance with Table 1020.1. The corridor walls required to be fire-resistance rated shall comply with Section 708 for fire partitions.

    In addition, corridors in buildings of Types IIB, IIIB, and VB construction and assigned Risk Categories III and IV in Table 1604.5, other than Group I, shall have a fire resistance rating of not less than 1 hour where such buildings are any of the following:

    1. Assigned a Seismic Design Category C or D in Table 1613.3.5(1).
    2. -
    3. Located in a flood hazard area established in accordance with Section 1612.3.
    4. -
    5. Located in a hurricane-prone regions.
    6. -
    • Exceptions:
      1. A fire-resistance rating is not required for corridors in an occupancy in Group E where each room that is used for instruction has not less than one door opening directly to the exterior and rooms for assembly purposes have not less than one-half of the required means of egress doors opening directly to the exterior. Exterior doors specified in this exception are required to be at ground level.
      2. -
      3. A fire-resistance rating is not required for corridors contained within a dwelling unit or sleeping unit in an occupancy in Groups I-1 and R.
      4. -
      5. A fire-resistance rating is not required for corridors in open parking garages.
      6. -
      7. A fire-resistance rating is not required for corridors in an occupancy in Group B that is a space requiring only a single means of egress complying with Section 1006.2.
      8. -
      9. Corridors adjacent to the exterior walls of buildings shall be permitted to have unprotected openings on unrated exterior walls where unrated walls are permitted by Table 602 and unprotected openings are permitted by Table 705.8.
      10. -
    • -
    -
    - - - Corridors shall be fire-resistance rated in accordance with Table 1020.1 and where applicable in Section 1020.1.1. The corridor walls required to be fire-resistance rated shall comply with Section 708 for fire partitions.
    • Exceptions:
    • -
    • -
      1. A fire-resistance rating is not required for corridors in an occupancy in Group E where each room that is used for instruction has not less than one door opening directly to the exterior and rooms for assembly purposes have not less than one-half of the required means of egress doors opening directly to the exterior. Exterior doors specified in this exception are required to be at ground level.
      2. -
      3. A fire-resistance rating is not required for corridors contained within a dwelling unit or sleeping unit in an occupancy in Groups I-1 and R.
      4. -
      5. A fire-resistance rating is not required for corridors in open parking garages.
      6. -
      7. A fire-resistance rating is not required for corridors in an occupancy in Group B that is a space requiring only a single means of egress complying with Section 1006.2.
      8. -
      9. Corridors adjacent to the exterior walls of buildings shall be permitted to have unprotected openings on unrated exterior walls where unrated walls are permitted by Table 602 and unprotected openings are permitted by Table 705.8.
      10. -
    • -
    -
    - - -Corridors shall be fire-resistance rated in accordance with Table 1020.1 and where applicable in Section 1020.1.1. The corridor walls required to be fire-resistance rated shall comply with Section 708 for fire partitions.

    In addition, corridors in buildings of Types IIB, IIIB, and VB construction and assigned Risk Categories III and IV in Table 1604.5, other than Group I, shall have a fire resistance rating of not less than 1 hour where such buildings are any of the following:

    1. Assigned a Seismic Design Category C or D in Table 1613.3.5(1).
    2. Located in a flood hazard area established in accordance with Section 1612.3.
    3. Located in a hurricane-prone regions.
    • Exceptions:
      1. A fire-resistance rating is not required for corridors in an occupancy in Group E where each room that is used for instruction has not less than one door opening directly to the exterior and rooms for assembly purposes have not less than one-half of the required means of egress doors opening directly to the exterior. Exterior doors specified in this exception are required to be at ground level.
      2. A fire-resistance rating is not required for corridors contained within a dwelling unit or sleeping unit in an occupancy in Groups I-1 and R.
      3. A fire-resistance rating is not required for corridors in open parking garages.
      4. A fire-resistance rating is not required for corridors in an occupancy in Group B that is a space requiring only a single means of egress complying with Section 1006.2.
      5. Corridors adjacent to the exterior walls of buildings shall be permitted to have unprotected openings on unrated exterior walls where unrated walls are permitted by Table 602 and unprotected openings are permitted by Table 705.8.
    -
    + + Corridors shall be fire-resistance rated in accordance with Table 1020.1. The corridor walls required to be fire-resistance rated shall comply with Section 708 for fire partitions.

    In addition, corridors in buildings of Types IIB, IIIB, and VB construction and assigned Risk Categories III and IV in Table 1604.5, other than Group I, shall have a fire resistance rating of not less than 1 hour where such buildings are any of the following:

    1. Assigned a Seismic Design Category C or D in Table 1613.3.5(1).
    2. +
    3. Located in a flood hazard area established in accordance with Section 1612.3.
    4. +
    5. Located in a hurricane-prone regions.
    6. +
    • Exceptions:
      1. A fire-resistance rating is not required for corridors in an occupancy in Group E where each room that is used for instruction has not less than one door opening directly to the exterior and rooms for assembly purposes have not less than one-half of the required means of egress doors opening directly to the exterior. Exterior doors specified in this exception are required to be at ground level.
      2. +
      3. A fire-resistance rating is not required for corridors contained within a dwelling unit or sleeping unit in an occupancy in Groups I-1 and R.
      4. +
      5. A fire-resistance rating is not required for corridors in open parking garages.
      6. +
      7. A fire-resistance rating is not required for corridors in an occupancy in Group B that is a space requiring only a single means of egress complying with Section 1006.2.
      8. +
      9. Corridors adjacent to the exterior walls of buildings shall be permitted to have unprotected openings on unrated exterior walls where unrated walls are permitted by Table 602 and unprotected openings are permitted by Table 705.8.
      10. +
    • +
    +
    + + + Corridors shall be fire-resistance rated in accordance with Table 1020.1 and where applicable in Section 1020.1.1. The corridor walls required to be fire-resistance rated shall comply with Section 708 for fire partitions.
    • Exceptions:
    • +
    • +
      1. A fire-resistance rating is not required for corridors in an occupancy in Group E where each room that is used for instruction has not less than one door opening directly to the exterior and rooms for assembly purposes have not less than one-half of the required means of egress doors opening directly to the exterior. Exterior doors specified in this exception are required to be at ground level.
      2. +
      3. A fire-resistance rating is not required for corridors contained within a dwelling unit or sleeping unit in an occupancy in Groups I-1 and R.
      4. +
      5. A fire-resistance rating is not required for corridors in open parking garages.
      6. +
      7. A fire-resistance rating is not required for corridors in an occupancy in Group B that is a space requiring only a single means of egress complying with Section 1006.2.
      8. +
      9. Corridors adjacent to the exterior walls of buildings shall be permitted to have unprotected openings on unrated exterior walls where unrated walls are permitted by Table 602 and unprotected openings are permitted by Table 705.8.
      10. +
    • +
    +
    + + +Corridors shall be fire-resistance rated in accordance with Table 1020.1 and where applicable in Section 1020.1.1. The corridor walls required to be fire-resistance rated shall comply with Section 708 for fire partitions.

    In addition, corridors in buildings of Types IIB, IIIB, and VB construction and assigned Risk Categories III and IV in Table 1604.5, other than Group I, shall have a fire resistance rating of not less than 1 hour where such buildings are any of the following:

    1. Assigned a Seismic Design Category C or D in Table 1613.3.5(1).
    2. Located in a flood hazard area established in accordance with Section 1612.3.
    3. Located in a hurricane-prone regions.
    • Exceptions:
      1. A fire-resistance rating is not required for corridors in an occupancy in Group E where each room that is used for instruction has not less than one door opening directly to the exterior and rooms for assembly purposes have not less than one-half of the required means of egress doors opening directly to the exterior. Exterior doors specified in this exception are required to be at ground level.
      2. A fire-resistance rating is not required for corridors contained within a dwelling unit or sleeping unit in an occupancy in Groups I-1 and R.
      3. A fire-resistance rating is not required for corridors in open parking garages.
      4. A fire-resistance rating is not required for corridors in an occupancy in Group B that is a space requiring only a single means of egress complying with Section 1006.2.
      5. Corridors adjacent to the exterior walls of buildings shall be permitted to have unprotected openings on unrated exterior walls where unrated walls are permitted by Table 602 and unprotected openings are permitted by Table 705.8.
    +
    diff --git a/vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/override-5.html b/vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/override-5.html index c2f1407..fe16ae1 100755 --- a/vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/override-5.html +++ b/vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/override-5.html @@ -1,31 +1,31 @@ - -

    In addition to the means of egress required by this chapter, provisions shall be made for emergency escape and rescue openings in Group R occupancies. Basements and sleeping rooms below the fourth story above grade plane shall have at least one exterior emergency escape and rescue opening in accordance with this section. Where basements contain one or more sleeping rooms, emergency escape and rescue openings shall be required in each sleeping room, but shall not be required in adjoining areas of the basement. Such openings shall open directly into a public way or to a yard or court that opens to a public way.

    -
    • Exceptions:
      1. Groups R-1 and R-2 occupancies are not required to provide emergency and escape openings where they comply with all of the following:
        1. Each story has access to two or more means of egress.
        2. -
        3. The building is constructed of Type I, Type II, Type IIIA or Type IV construction.
        4. -
        5. The building is equipped throughout with an approved automatic sprinkler system in accordance with Sections 903.3.1.1 or 903.3.3.2.
        6. -
      2. -
      3. The emergency escape and rescue opening is permitted to open onto a balcony within an atrium in accordance with the requirements of Section 404, provided the balcony provides access to an exit and the dwelling unit or sleeping unit has a means of egress that is not open to the atrium.
      4. -
      5. Basements with a ceiling height of less than 80 inches (2032 mm) shall not be required to have emergency escape and rescue openings.
      6. -
      7. Emergency escape and rescue openings are not required from basements or sleeping rooms that have an exit door or exit access door that opens directly into a public way or to a yard, court or exterior exit balcony that opens to a public way.
      8. -
      9. Basements without habitable spaces and having not more than 200 square feet (18.6 m2) in floor area shall not be required to have emergency escape and rescue openings.
      10. -
    • -
    -
    - - -

    In addition to the means of egress required by this chapter, emergency escape and rescue openings shall be provided in the following occupancies:

    -
    1. Group R-1 and R-2 occupancies.
    -
    2. Group R-1 and R-2 occupancies located on stories with one exit or access to one exit where permitted by Tables 1006.3.2(1) and 1006.3.2(2).
    -
    3. Group R-3 occupancies.
    -


    Basements and sleeping rooms below the fourth story above grade plane shall have at least one exterior emergency escape and rescue opening in accordance with this section. Where basements contain one or more sleeping rooms, emergency escape and rescue openings shall be required in each sleeping room, but shall not be required in adjoining areas of the basement. Such openings shall open directly into a public way or to a yard or court that opens to a public way.

    -
    • Exceptions:
      1. Emergency escape and rescue opening are not required from Group R-1 and R-2 occupancies where each story has access to at least two exits or access to exits and the building is equipped throughout with an automatic sprinkler system in accordance with Section 903.3.1.1.
      2. -
      3. Basements with a ceiling height of less than 80 inches (2032 mm) shall not be required to have emergency escape and rescue openings.
      4. -
      5. Emergency escape and rescue openings are not required from basements or sleeping rooms that have an exit door or exit access door that opens directly into a public way or to a yard, court or exterior exit balcony that opens to a public way.
      6. -
      7. Basements without habitable spaces and having not more than 200 square feet (18.6 m2) in floor area shall not be required to have emergency escape and rescue openings.
      8. -
    • -
    -
    - - -

    In addition to the means of egress required by this chapter, provisions emergency escape and rescue openings shall be made for emergency escape and rescue openingsprovided in the following occupancies:

    1. Group R-1 and R-2 occupancies. Basements
    2. Group R-1 and R-2 occupancies located on stories with one exit or access to one exit where permitted by Tables 1006.3.2(1) and 1006.3.2(2).
    3. Group R-3 occupancies.


    Basements and sleeping rooms below the fourth story above grade planegrade plane shall have at least one exterior emergency escape and rescue openingemergency escape and rescue opening in accordance with this section. Where basementsbasements contain one or more sleeping rooms, emergency escape and rescue openingsemergency escape and rescue openings shall be required in each sleeping room, but shall not be required in adjoining areas of the basementbasement. Such openings shall open directly into a public waypublic way or to a yard yard or court court that opens to a public waypublic way.

    • Exceptions:
      1. Groups R-1 and R-2 occupancies are not required to provide emergency and escape openings where they comply with all of the following:
        1. Each story has access to two or more means of egress.
        2. The building is constructed of Type I, Type II, Type IIIA or Type IV construction.
        3. The building is equipped throughout with an approved automatic sprinkler system in accordance with Sections 903.3.1.1 or 903.3.3.2.
      2. The emergency escape and rescue opening is permitted to open onto a balcony within an atrium in accordance with the requirements of Section 404, provided the balcony provides access to an exit and the dwelling unit or sleeping unit has a means of egress that is not open to the atrium.
      3. Basements with a ceiling height of less than 80 inches (2032 mm) shall not be required to have emergency escape and rescue openings.
      4. Emergency escape and rescue openings are not required from basements or sleeping rooms that have an exit door or exit access door that opens directly into a public way or to a yard, court or exterior exit balcony that opens to a public way.
      5. Basements without habitable spaces and having not more than 200 square feet (18.6 m2) in floor area shall not be required to have emergency escape and rescue openings.
    • Exceptions:
      1. Emergency escape and rescue opening are not required from Group R-1 and R-2 occupancies where each story has access to at least two exits or access to exits and the building is equipped throughout with an automatic sprinkler system in accordance with Section 903.3.1.1.
      2. Basements with a ceiling height of less than 80 inches (2032 mm) shall not be required to have emergency escape and rescue openings.
      3. Emergency escape and rescue openings are not required from basements or sleeping rooms that have an exit door or exit access door that opens directly into a public way or to a yard, court or exterior exit balcony that opens to a public way.
      4. Basements without habitable spaces and having not more than 200 square feet (18.6 m2) in floor area shall not be required to have emergency escape and rescue openings.
    -
    + +

    In addition to the means of egress required by this chapter, provisions shall be made for emergency escape and rescue openings in Group R occupancies. Basements and sleeping rooms below the fourth story above grade plane shall have at least one exterior emergency escape and rescue opening in accordance with this section. Where basements contain one or more sleeping rooms, emergency escape and rescue openings shall be required in each sleeping room, but shall not be required in adjoining areas of the basement. Such openings shall open directly into a public way or to a yard or court that opens to a public way.

    +
    • Exceptions:
      1. Groups R-1 and R-2 occupancies are not required to provide emergency and escape openings where they comply with all of the following:
        1. Each story has access to two or more means of egress.
        2. +
        3. The building is constructed of Type I, Type II, Type IIIA or Type IV construction.
        4. +
        5. The building is equipped throughout with an approved automatic sprinkler system in accordance with Sections 903.3.1.1 or 903.3.3.2.
        6. +
      2. +
      3. The emergency escape and rescue opening is permitted to open onto a balcony within an atrium in accordance with the requirements of Section 404, provided the balcony provides access to an exit and the dwelling unit or sleeping unit has a means of egress that is not open to the atrium.
      4. +
      5. Basements with a ceiling height of less than 80 inches (2032 mm) shall not be required to have emergency escape and rescue openings.
      6. +
      7. Emergency escape and rescue openings are not required from basements or sleeping rooms that have an exit door or exit access door that opens directly into a public way or to a yard, court or exterior exit balcony that opens to a public way.
      8. +
      9. Basements without habitable spaces and having not more than 200 square feet (18.6 m2) in floor area shall not be required to have emergency escape and rescue openings.
      10. +
    • +
    +
    + + +

    In addition to the means of egress required by this chapter, emergency escape and rescue openings shall be provided in the following occupancies:

    +
    1. Group R-1 and R-2 occupancies.
    +
    2. Group R-1 and R-2 occupancies located on stories with one exit or access to one exit where permitted by Tables 1006.3.2(1) and 1006.3.2(2).
    +
    3. Group R-3 occupancies.
    +


    Basements and sleeping rooms below the fourth story above grade plane shall have at least one exterior emergency escape and rescue opening in accordance with this section. Where basements contain one or more sleeping rooms, emergency escape and rescue openings shall be required in each sleeping room, but shall not be required in adjoining areas of the basement. Such openings shall open directly into a public way or to a yard or court that opens to a public way.

    +
    • Exceptions:
      1. Emergency escape and rescue opening are not required from Group R-1 and R-2 occupancies where each story has access to at least two exits or access to exits and the building is equipped throughout with an automatic sprinkler system in accordance with Section 903.3.1.1.
      2. +
      3. Basements with a ceiling height of less than 80 inches (2032 mm) shall not be required to have emergency escape and rescue openings.
      4. +
      5. Emergency escape and rescue openings are not required from basements or sleeping rooms that have an exit door or exit access door that opens directly into a public way or to a yard, court or exterior exit balcony that opens to a public way.
      6. +
      7. Basements without habitable spaces and having not more than 200 square feet (18.6 m2) in floor area shall not be required to have emergency escape and rescue openings.
      8. +
    • +
    +
    + + +

    In addition to the means of egress required by this chapter, provisions emergency escape and rescue openings shall be made for emergency escape and rescue openingsprovided in the following occupancies:

    1. Group R-1 and R-2 occupancies. Basements
    2. Group R-1 and R-2 occupancies located on stories with one exit or access to one exit where permitted by Tables 1006.3.2(1) and 1006.3.2(2).
    3. Group R-3 occupancies.


    Basements and sleeping rooms below the fourth story above grade planegrade plane shall have at least one exterior emergency escape and rescue openingemergency escape and rescue opening in accordance with this section. Where basementsbasements contain one or more sleeping rooms, emergency escape and rescue openingsemergency escape and rescue openings shall be required in each sleeping room, but shall not be required in adjoining areas of the basementbasement. Such openings shall open directly into a public waypublic way or to a yard yard or court court that opens to a public waypublic way.

    • Exceptions:
      1. Groups R-1 and R-2 occupancies are not required to provide emergency and escape openings where they comply with all of the following:
        1. Each story has access to two or more means of egress.
        2. The building is constructed of Type I, Type II, Type IIIA or Type IV construction.
        3. The building is equipped throughout with an approved automatic sprinkler system in accordance with Sections 903.3.1.1 or 903.3.3.2.
      2. The emergency escape and rescue opening is permitted to open onto a balcony within an atrium in accordance with the requirements of Section 404, provided the balcony provides access to an exit and the dwelling unit or sleeping unit has a means of egress that is not open to the atrium.
      3. Basements with a ceiling height of less than 80 inches (2032 mm) shall not be required to have emergency escape and rescue openings.
      4. Emergency escape and rescue openings are not required from basements or sleeping rooms that have an exit door or exit access door that opens directly into a public way or to a yard, court or exterior exit balcony that opens to a public way.
      5. Basements without habitable spaces and having not more than 200 square feet (18.6 m2) in floor area shall not be required to have emergency escape and rescue openings.
    • Exceptions:
      1. Emergency escape and rescue opening are not required from Group R-1 and R-2 occupancies where each story has access to at least two exits or access to exits and the building is equipped throughout with an automatic sprinkler system in accordance with Section 903.3.1.1.
      2. Basements with a ceiling height of less than 80 inches (2032 mm) shall not be required to have emergency escape and rescue openings.
      3. Emergency escape and rescue openings are not required from basements or sleeping rooms that have an exit door or exit access door that opens directly into a public way or to a yard, court or exterior exit balcony that opens to a public way.
      4. Basements without habitable spaces and having not more than 200 square feet (18.6 m2) in floor area shall not be required to have emergency escape and rescue openings.
    +
    diff --git a/vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/override-6.html b/vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/override-6.html index 860e4d8..d691ab2 100755 --- a/vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/override-6.html +++ b/vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/override-6.html @@ -1,42 +1,42 @@ - -

    Return air openings for heating, ventilation and air-conditioning systems shall comply with all of the following:

    -
    1. Openings shall not be located less than 10 feet (3048 mm) measured in any direction from an open combustion chamber or draft hood of another appliance located in the same room or space.
    2. -
    3. Return air shall not be taken from a hazardous or insanitary location or a refrigeration room as defined in this code.
    4. -
    5. The amount of return air taken from any room or space shall be not greater than the flow rate of supply air delivered to such room or space.
    6. -
    7. Return and transfer openings shall be sized in accordance with the appliance or equipment manufacturer's installation instructions, ACCA Manual D or the design of the registered design professional.
    8. -
    9. Return air taken from one dwelling unit shall not be discharged into another dwelling unit.
    10. -
    11. Taking return air from a crawl space shall not be accomplished through a direct connection to the return side of a forced air furnace. Transfer openings in the crawl space enclosure shall not be prohibited.
    12. -
    13. Return air shall not be taken from a closet, bathroom, toilet room, kitchen, garage, boiler room, furnace room or unconditioned attic. -
      • Exceptions: -
        1. Taking return air from a kitchen is not prohibited where such return air openings serve the kitchen and are located not less than 10 feet (3048 mm) from the cooking appliances.
        2. -
        3. Dedicated forced air systems serving only the garage shall not be prohibited from obtaining return air from the garage
        4. -
      • -
    14. -
    15. Return air shall not be taken from indoor swimming pool enclosures and associated deck areas. -
      • Exceptions: -
        1. Where the air from such spaces is dehumidified in accordance with Sections 403.2.1 Item #2.
        2. -
        3. Dedicated HVAC systems serving only such spaces.
        4. -
      • -
    16. -
    -
    - - -

    Return air openings for heating, ventilation and air-conditioning systems shall comply with all of the following:

    -
    1. Openings shall not be located less than 10 feet (3048 mm) measured in any direction from an open combustion chamber or draft hood of another appliance located in the same room or space.
    2. -
    3. Return air shall not be taken from a hazardous or insanitary location or a refrigeration room as defined in this code.
    4. -
    5. The amount of return air taken from any room or space shall be not greater than the flow rate of supply air delivered to such room or space.
    6. -
    7. Return and transfer openings shall be sized in accordance with the appliance or equipment manufacturer's installation instructions, ACCA Manual D or the design of the registered design professional.
    8. -
    9. Return air taken from one dwelling unit shall not be discharged into another dwelling unit.
    10. -
    11. Taking return air from a crawl space shall not be accomplished through a direct connection to the return side of a forced air furnace. Transfer openings in the crawl space enclosure shall not be prohibited.
    12. -
    13. Return air shall not be taken from a closet, bathroom, toilet room, kitchen, garage, boiler room, furnace room, indoor swimming pool enclosure and associated deck area, or unconditioned attic.
    14. -
    • Exceptions:
    • -
    1. Taking return air from a kitchen is not prohibited where such return air openings serve the kitchen and are located not less than 10 feet (3048 mm) from the cooking appliances.
    2. -
    3. Dedicated forced air systems serving only the garage shall not be prohibited from obtaining return air from the garage
    4. -
    5. Dedicated HVAC systems serving indoor swimming pool enclosures and associated deck areas shall not be prohibited from obtaining return air from such swimming pool enclosures and associated deck areas
    6. -
    -
    - - -

    Return air openings for heating, ventilation and air-conditioning systems shall comply with all of the following:

    1. Openings shall not be located less than 10 feet (3048 mm) measured in any direction from an open combustion chamber or draft hood of another appliance located in the same room or space.
    2. Return air shall not be taken from a hazardous or insanitary location or a refrigeration room as defined in this code.
    3. The amount of return air taken from any room or space shall be not greater than the flow rate of supply air delivered to such room or space.
    4. Return and transfer openings shall be sized in accordance with the appliance or equipment manufacturer's installation instructions, ACCA Manual D or the design of the registered design professional.
    5. Return air taken from one dwelling unit shall not be discharged into another dwelling unit.
    6. Taking return air from a crawl space shall not be accomplished through a direct connection to the return side of a forced air furnace. Transfer openings in the crawl space enclosure shall not be prohibited.
    7. Return air shall not be taken from a closet, bathroom, toilet room, kitchen, garage, boiler room, furnace room, indoor swimming pool enclosure and associated deck area, or unconditioned attic.
      • Exceptions:
        1. Taking return air from a kitchen is not prohibited where such return air openings serve the kitchen and are located not less than 10 feet (3048 mm) from the cooking appliances.
        2. Dedicated forced air systems serving only the garage shall not be prohibited from obtaining return air from the garage
    8. Return air shall not be taken from indoor swimming pool enclosures and associated deck areas.
      • Exceptions:
        1. Where the air from such spaces is dehumidified in accordance with Sections 403.2.1 Item #2.
        2. Dedicated HVAC systems serving only such spaces.
    • Exceptions:
    1. Taking return air from a kitchen is not prohibited where such return air openings serve the kitchen and are located not less than 10 feet (3048 mm) from the cooking appliances.
    2. Dedicated forced air systems serving only the garage shall not be prohibited from obtaining return air from the garage
    3. Dedicated HVAC systems serving indoor swimming pool enclosures and associated deck areas shall not be prohibited from obtaining return air from such swimming pool enclosures and associated deck areas
    -
    + +

    Return air openings for heating, ventilation and air-conditioning systems shall comply with all of the following:

    +
    1. Openings shall not be located less than 10 feet (3048 mm) measured in any direction from an open combustion chamber or draft hood of another appliance located in the same room or space.
    2. +
    3. Return air shall not be taken from a hazardous or insanitary location or a refrigeration room as defined in this code.
    4. +
    5. The amount of return air taken from any room or space shall be not greater than the flow rate of supply air delivered to such room or space.
    6. +
    7. Return and transfer openings shall be sized in accordance with the appliance or equipment manufacturer's installation instructions, ACCA Manual D or the design of the registered design professional.
    8. +
    9. Return air taken from one dwelling unit shall not be discharged into another dwelling unit.
    10. +
    11. Taking return air from a crawl space shall not be accomplished through a direct connection to the return side of a forced air furnace. Transfer openings in the crawl space enclosure shall not be prohibited.
    12. +
    13. Return air shall not be taken from a closet, bathroom, toilet room, kitchen, garage, boiler room, furnace room or unconditioned attic. +
      • Exceptions: +
        1. Taking return air from a kitchen is not prohibited where such return air openings serve the kitchen and are located not less than 10 feet (3048 mm) from the cooking appliances.
        2. +
        3. Dedicated forced air systems serving only the garage shall not be prohibited from obtaining return air from the garage
        4. +
      • +
    14. +
    15. Return air shall not be taken from indoor swimming pool enclosures and associated deck areas. +
      • Exceptions: +
        1. Where the air from such spaces is dehumidified in accordance with Sections 403.2.1 Item #2.
        2. +
        3. Dedicated HVAC systems serving only such spaces.
        4. +
      • +
    16. +
    +
    + + +

    Return air openings for heating, ventilation and air-conditioning systems shall comply with all of the following:

    +
    1. Openings shall not be located less than 10 feet (3048 mm) measured in any direction from an open combustion chamber or draft hood of another appliance located in the same room or space.
    2. +
    3. Return air shall not be taken from a hazardous or insanitary location or a refrigeration room as defined in this code.
    4. +
    5. The amount of return air taken from any room or space shall be not greater than the flow rate of supply air delivered to such room or space.
    6. +
    7. Return and transfer openings shall be sized in accordance with the appliance or equipment manufacturer's installation instructions, ACCA Manual D or the design of the registered design professional.
    8. +
    9. Return air taken from one dwelling unit shall not be discharged into another dwelling unit.
    10. +
    11. Taking return air from a crawl space shall not be accomplished through a direct connection to the return side of a forced air furnace. Transfer openings in the crawl space enclosure shall not be prohibited.
    12. +
    13. Return air shall not be taken from a closet, bathroom, toilet room, kitchen, garage, boiler room, furnace room, indoor swimming pool enclosure and associated deck area, or unconditioned attic.
    14. +
    • Exceptions:
    • +
    1. Taking return air from a kitchen is not prohibited where such return air openings serve the kitchen and are located not less than 10 feet (3048 mm) from the cooking appliances.
    2. +
    3. Dedicated forced air systems serving only the garage shall not be prohibited from obtaining return air from the garage
    4. +
    5. Dedicated HVAC systems serving indoor swimming pool enclosures and associated deck areas shall not be prohibited from obtaining return air from such swimming pool enclosures and associated deck areas
    6. +
    +
    + + +

    Return air openings for heating, ventilation and air-conditioning systems shall comply with all of the following:

    1. Openings shall not be located less than 10 feet (3048 mm) measured in any direction from an open combustion chamber or draft hood of another appliance located in the same room or space.
    2. Return air shall not be taken from a hazardous or insanitary location or a refrigeration room as defined in this code.
    3. The amount of return air taken from any room or space shall be not greater than the flow rate of supply air delivered to such room or space.
    4. Return and transfer openings shall be sized in accordance with the appliance or equipment manufacturer's installation instructions, ACCA Manual D or the design of the registered design professional.
    5. Return air taken from one dwelling unit shall not be discharged into another dwelling unit.
    6. Taking return air from a crawl space shall not be accomplished through a direct connection to the return side of a forced air furnace. Transfer openings in the crawl space enclosure shall not be prohibited.
    7. Return air shall not be taken from a closet, bathroom, toilet room, kitchen, garage, boiler room, furnace room, indoor swimming pool enclosure and associated deck area, or unconditioned attic.
      • Exceptions:
        1. Taking return air from a kitchen is not prohibited where such return air openings serve the kitchen and are located not less than 10 feet (3048 mm) from the cooking appliances.
        2. Dedicated forced air systems serving only the garage shall not be prohibited from obtaining return air from the garage
    8. Return air shall not be taken from indoor swimming pool enclosures and associated deck areas.
      • Exceptions:
        1. Where the air from such spaces is dehumidified in accordance with Sections 403.2.1 Item #2.
        2. Dedicated HVAC systems serving only such spaces.
    • Exceptions:
    1. Taking return air from a kitchen is not prohibited where such return air openings serve the kitchen and are located not less than 10 feet (3048 mm) from the cooking appliances.
    2. Dedicated forced air systems serving only the garage shall not be prohibited from obtaining return air from the garage
    3. Dedicated HVAC systems serving indoor swimming pool enclosures and associated deck areas shall not be prohibited from obtaining return air from such swimming pool enclosures and associated deck areas
    +
    diff --git a/vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/override-8.html b/vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/override-8.html index acde4a9..0fd7577 100755 --- a/vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/override-8.html +++ b/vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/override-8.html @@ -1,11 +1,11 @@ - -

    The manufacturer of PEX tubing shall have marked the outside of the tubing with the thermoplastic material designation code in accordance with ASTM F876. The designation code shall consist of the abbreviation "PEX" followed by four digits. The first digit shall represent a chlorine resistance rating as established by testing in accordance with ASTM F876.

    -
    - - -

    For PEX tubing complying with ASTM F876, the first digit folllowing "PEX" as marked on the tubing exterior shall be an indicator of the maximum service temperatures for which the PEX tubing can be used. The maximum service temperatures shall be as follows:

    1. Digit “0”: 73⁰F (23⁰C).

    2. Digit “1”: For not more that 25% of the time, greater than 73⁰F (23⁰C) and not exceeding140⁰F (60⁰C). For the remainder of the time, not greater than 73⁰F (23⁰C).

    3. Digit “3”: For not more that 50% of the time, greater than 73⁰F (23⁰C) and not exceeding 140⁰F (60⁰C). For the remainder of the time, not greater than 73⁰F (23⁰C).

    4. Digit “5”: 140⁰F (60⁰C).


    -
    - - -

    The manufacturer ofFor PEX tubing shall have marked the outside of the tubing with the thermoplastic material designation code in accordancecomplying with ASTM F876. The designation code, the first digit folllowing "PEX" as marked on the tubing exterior shall consistbe an indicator of the abbreviation "maximum service temperatures for which the PEX" followed by four digits tubing can be used. The first digitmaximum service temperatures shall represent a chlorine resistance ratingbe as established by testing in accordance with ASTM F876follows:

    1. Digit “0”: 73⁰F (23⁰C).

    2. Digit “1”: For not more that 25% of the time, greater than 73⁰F (23⁰C) and not exceeding140⁰F (60⁰C). For the remainder of the time, not greater than 73⁰F (23⁰C).

    3. Digit “3”: For not more that 50% of the time, greater than 73⁰F (23⁰C) and not exceeding 140⁰F (60⁰C). For the remainder of the time, not greater than 73⁰F (23⁰C).

    4. Digit “5”: 140⁰F (60⁰C).


    -
    + +

    The manufacturer of PEX tubing shall have marked the outside of the tubing with the thermoplastic material designation code in accordance with ASTM F876. The designation code shall consist of the abbreviation "PEX" followed by four digits. The first digit shall represent a chlorine resistance rating as established by testing in accordance with ASTM F876.

    +
    + + +

    For PEX tubing complying with ASTM F876, the first digit folllowing "PEX" as marked on the tubing exterior shall be an indicator of the maximum service temperatures for which the PEX tubing can be used. The maximum service temperatures shall be as follows:

    1. Digit “0”: 73⁰F (23⁰C).

    2. Digit “1”: For not more that 25% of the time, greater than 73⁰F (23⁰C) and not exceeding140⁰F (60⁰C). For the remainder of the time, not greater than 73⁰F (23⁰C).

    3. Digit “3”: For not more that 50% of the time, greater than 73⁰F (23⁰C) and not exceeding 140⁰F (60⁰C). For the remainder of the time, not greater than 73⁰F (23⁰C).

    4. Digit “5”: 140⁰F (60⁰C).


    +
    + + +

    The manufacturer ofFor PEX tubing shall have marked the outside of the tubing with the thermoplastic material designation code in accordancecomplying with ASTM F876. The designation code, the first digit folllowing "PEX" as marked on the tubing exterior shall consistbe an indicator of the abbreviation "maximum service temperatures for which the PEX" followed by four digits tubing can be used. The first digitmaximum service temperatures shall represent a chlorine resistance ratingbe as established by testing in accordance with ASTM F876follows:

    1. Digit “0”: 73⁰F (23⁰C).

    2. Digit “1”: For not more that 25% of the time, greater than 73⁰F (23⁰C) and not exceeding140⁰F (60⁰C). For the remainder of the time, not greater than 73⁰F (23⁰C).

    3. Digit “3”: For not more that 50% of the time, greater than 73⁰F (23⁰C) and not exceeding 140⁰F (60⁰C). For the remainder of the time, not greater than 73⁰F (23⁰C).

    4. Digit “5”: 140⁰F (60⁰C).


    +
    diff --git a/vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/override-9.html b/vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/override-9.html index ec88c13..b066bbe 100755 --- a/vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/override-9.html +++ b/vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/override-9.html @@ -1,11 +1,11 @@ - - Existing buildings that undergo a change of group or occupancy shall comply with this section.
    • Exception: Type B dwelling or sleeping units required by Section 1107 of the International Building Code are not required to be provided in existing buildings and facilities undergoing a change of occupancy in conjunction with alterations where the work area is 50 percent or less of the aggregate area of the building.
    -
    - - - Where existing buildings undergo a change of group or occupancy any alterations shall comply with Sections 410.6, 410.7 and 410.8 as applicable. - - - -Existing buildings that Where existing buildings undergo a change of group or occupancy any alterations shall comply with this sectionSections 410.6, 410.7 and 410.8 as applicable.
    • Exception: Type B dwelling or sleeping units required by Section 1107 of the International Building Code are not required to be provided in existing buildings and facilities undergoing a change of occupancy in conjunction with alterations where the work area is 50 percent or less of the aggregate area of the building.
    -
    + + Existing buildings that undergo a change of group or occupancy shall comply with this section.
    • Exception: Type B dwelling or sleeping units required by Section 1107 of the International Building Code are not required to be provided in existing buildings and facilities undergoing a change of occupancy in conjunction with alterations where the work area is 50 percent or less of the aggregate area of the building.
    +
    + + + Where existing buildings undergo a change of group or occupancy any alterations shall comply with Sections 410.6, 410.7 and 410.8 as applicable. + + + +Existing buildings that Where existing buildings undergo a change of group or occupancy any alterations shall comply with this sectionSections 410.6, 410.7 and 410.8 as applicable.
    • Exception: Type B dwelling or sleeping units required by Section 1107 of the International Building Code are not required to be provided in existing buildings and facilities undergoing a change of occupancy in conjunction with alterations where the work area is 50 percent or less of the aggregate area of the building.
    +
    diff --git a/vendor/ezyang/htmlpurifier/CREDITS b/vendor/ezyang/htmlpurifier/CREDITS index d0cc45a..7921b45 100755 --- a/vendor/ezyang/htmlpurifier/CREDITS +++ b/vendor/ezyang/htmlpurifier/CREDITS @@ -1,9 +1,9 @@ - -CREDITS - -Almost everything written by Edward Z. Yang (Ambush Commander). Lots of thanks -to the DevNetwork Community for their help (see docs/ref-devnetwork.html for -more details), Feyd especially (namely IPv6 and optimization). Thanks to RSnake -for letting me package his fantastic XSS cheatsheet for a smoketest. - - vim: et sw=4 sts=4 + +CREDITS + +Almost everything written by Edward Z. Yang (Ambush Commander). Lots of thanks +to the DevNetwork Community for their help (see docs/ref-devnetwork.html for +more details), Feyd especially (namely IPv6 and optimization). Thanks to RSnake +for letting me package his fantastic XSS cheatsheet for a smoketest. + + vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/INSTALL b/vendor/ezyang/htmlpurifier/INSTALL index 9fbb28e..677c04a 100755 --- a/vendor/ezyang/htmlpurifier/INSTALL +++ b/vendor/ezyang/htmlpurifier/INSTALL @@ -1,374 +1,374 @@ - -Install - How to install HTML Purifier - -HTML Purifier is designed to run out of the box, so actually using the -library is extremely easy. (Although... if you were looking for a -step-by-step installation GUI, you've downloaded the wrong software!) - -While the impatient can get going immediately with some of the sample -code at the bottom of this library, it's well worth reading this entire -document--most of the other documentation assumes that you are familiar -with these contents. - - ---------------------------------------------------------------------------- -1. Compatibility - -HTML Purifier is PHP 5 only, and is actively tested from PHP 5.0.5 and -up. It has no core dependencies with other libraries. PHP -4 support was deprecated on December 31, 2007 with HTML Purifier 3.0.0. -HTML Purifier is not compatible with zend.ze1_compatibility_mode. - -These optional extensions can enhance the capabilities of HTML Purifier: - - * iconv : Converts text to and from non-UTF-8 encodings - * bcmath : Used for unit conversion and imagecrash protection - * tidy : Used for pretty-printing HTML - -These optional libraries can enhance the capabilities of HTML Purifier: - - * CSSTidy : Clean CSS stylesheets using %Core.ExtractStyleBlocks - * Net_IDNA2 (PEAR) : IRI support using %Core.EnableIDNA - ---------------------------------------------------------------------------- -2. Reconnaissance - -A big plus of HTML Purifier is its inerrant support of standards, so -your web-pages should be standards-compliant. (They should also use -semantic markup, but that's another issue altogether, one HTML Purifier -cannot fix without reading your mind.) - -HTML Purifier can process these doctypes: - -* XHTML 1.0 Transitional (default) -* XHTML 1.0 Strict -* HTML 4.01 Transitional -* HTML 4.01 Strict -* XHTML 1.1 - -...and these character encodings: - -* UTF-8 (default) -* Any encoding iconv supports (with crippled internationalization support) - -These defaults reflect what my choices would be if I were authoring an -HTML document, however, what you choose depends on the nature of your -codebase. If you don't know what doctype you are using, you can determine -the doctype from this identifier at the top of your source code: - - - -...and the character encoding from this code: - - - -If the character encoding declaration is missing, STOP NOW, and -read 'docs/enduser-utf8.html' (web accessible at -http://htmlpurifier.org/docs/enduser-utf8.html). In fact, even if it is -present, read this document anyway, as many websites specify their -document's character encoding incorrectly. - - ---------------------------------------------------------------------------- -3. Including the library - -The procedure is quite simple: - - require_once '/path/to/library/HTMLPurifier.auto.php'; - -This will setup an autoloader, so the library's files are only included -when you use them. - -Only the contents in the library/ folder are necessary, so you can remove -everything else when using HTML Purifier in a production environment. - -If you installed HTML Purifier via PEAR, all you need to do is: - - require_once 'HTMLPurifier.auto.php'; - -Please note that the usual PEAR practice of including just the classes you -want will not work with HTML Purifier's autoloading scheme. - -Advanced users, read on; other users can skip to section 4. - -Autoload compatibility ----------------------- - - HTML Purifier attempts to be as smart as possible when registering an - autoloader, but there are some cases where you will need to change - your own code to accomodate HTML Purifier. These are those cases: - - PHP VERSION IS LESS THAN 5.1.2, AND YOU'VE DEFINED __autoload - Because spl_autoload_register() doesn't exist in early versions - of PHP 5, HTML Purifier has no way of adding itself to the autoload - stack. Modify your __autoload function to test - HTMLPurifier_Bootstrap::autoload($class) - - For example, suppose your autoload function looks like this: - - function __autoload($class) { - require str_replace('_', '/', $class) . '.php'; - return true; - } - - A modified version with HTML Purifier would look like this: - - function __autoload($class) { - if (HTMLPurifier_Bootstrap::autoload($class)) return true; - require str_replace('_', '/', $class) . '.php'; - return true; - } - - Note that there *is* some custom behavior in our autoloader; the - original autoloader in our example would work for 99% of the time, - but would fail when including language files. - - AN __autoload FUNCTION IS DECLARED AFTER OUR AUTOLOADER IS REGISTERED - spl_autoload_register() has the curious behavior of disabling - the existing __autoload() handler. Users need to explicitly - spl_autoload_register('__autoload'). Because we use SPL when it - is available, __autoload() will ALWAYS be disabled. If __autoload() - is declared before HTML Purifier is loaded, this is not a problem: - HTML Purifier will register the function for you. But if it is - declared afterwards, it will mysteriously not work. This - snippet of code (after your autoloader is defined) will fix it: - - spl_autoload_register('__autoload') - - Users should also be on guard if they use a version of PHP previous - to 5.1.2 without an autoloader--HTML Purifier will define __autoload() - for you, which can collide with an autoloader that was added by *you* - later. - - -For better performance ----------------------- - - Opcode caches, which greatly speed up PHP initialization for scripts - with large amounts of code (HTML Purifier included), don't like - autoloaders. We offer an include file that includes all of HTML Purifier's - files in one go in an opcode cache friendly manner: - - // If /path/to/library isn't already in your include path, uncomment - // the below line: - // require '/path/to/library/HTMLPurifier.path.php'; - - require 'HTMLPurifier.includes.php'; - - Optional components still need to be included--you'll know if you try to - use a feature and you get a class doesn't exists error! The autoloader - can be used in conjunction with this approach to catch classes that are - missing. Simply add this afterwards: - - require 'HTMLPurifier.autoload.php'; - -Standalone version ------------------- - - HTML Purifier has a standalone distribution; you can also generate - a standalone file from the full version by running the script - maintenance/generate-standalone.php . The standalone version has the - benefit of having most of its code in one file, so parsing is much - faster and the library is easier to manage. - - If HTMLPurifier.standalone.php exists in the library directory, you - can use it like this: - - require '/path/to/HTMLPurifier.standalone.php'; - - This is equivalent to including HTMLPurifier.includes.php, except that - the contents of standalone/ will be added to your path. To override this - behavior, specify a new HTMLPURIFIER_PREFIX where standalone files can - be found (usually, this will be one directory up, the "true" library - directory in full distributions). Don't forget to set your path too! - - The autoloader can be added to the end to ensure the classes are - loaded when necessary; otherwise you can manually include them. - To use the autoloader, use this: - - require 'HTMLPurifier.autoload.php'; - -For advanced users ------------------- - - HTMLPurifier.auto.php performs a number of operations that can be done - individually. These are: - - HTMLPurifier.path.php - Puts /path/to/library in the include path. For high performance, - this should be done in php.ini. - - HTMLPurifier.autoload.php - Registers our autoload handler HTMLPurifier_Bootstrap::autoload($class). - - You can do these operations by yourself--in fact, you must modify your own - autoload handler if you are using a version of PHP earlier than PHP 5.1.2 - (See "Autoload compatibility" above). - - ---------------------------------------------------------------------------- -4. Configuration - -HTML Purifier is designed to run out-of-the-box, but occasionally HTML -Purifier needs to be told what to do. If you answer no to any of these -questions, read on; otherwise, you can skip to the next section (or, if you're -into configuring things just for the heck of it, skip to 4.3). - -* Am I using UTF-8? -* Am I using XHTML 1.0 Transitional? - -If you answered no to any of these questions, instantiate a configuration -object and read on: - - $config = HTMLPurifier_Config::createDefault(); - - -4.1. Setting a different character encoding - -You really shouldn't use any other encoding except UTF-8, especially if you -plan to support multilingual websites (read section three for more details). -However, switching to UTF-8 is not always immediately feasible, so we can -adapt. - -HTML Purifier uses iconv to support other character encodings, as such, -any encoding that iconv supports -HTML Purifier supports with this code: - - $config->set('Core.Encoding', /* put your encoding here */); - -An example usage for Latin-1 websites (the most common encoding for English -websites): - - $config->set('Core.Encoding', 'ISO-8859-1'); - -Note that HTML Purifier's support for non-Unicode encodings is crippled by the -fact that any character not supported by that encoding will be silently -dropped, EVEN if it is ampersand escaped. If you want to work around -this, you are welcome to read docs/enduser-utf8.html for a fix, -but please be cognizant of the issues the "solution" creates (for this -reason, I do not include the solution in this document). - - -4.2. Setting a different doctype - -For those of you using HTML 4.01 Transitional, you can disable -XHTML output like this: - - $config->set('HTML.Doctype', 'HTML 4.01 Transitional'); - -Other supported doctypes include: - - * HTML 4.01 Strict - * HTML 4.01 Transitional - * XHTML 1.0 Strict - * XHTML 1.0 Transitional - * XHTML 1.1 - - -4.3. Other settings - -There are more configuration directives which can be read about -here: They're a bit boring, -but they can help out for those of you who like to exert maximum control over -your code. Some of the more interesting ones are configurable at the -demo and are well worth looking into -for your own system. - -For example, you can fine tune allowed elements and attributes, convert -relative URLs to absolute ones, and even autoparagraph input text! These -are, respectively, %HTML.Allowed, %URI.MakeAbsolute and %URI.Base, and -%AutoFormat.AutoParagraph. The %Namespace.Directive naming convention -translates to: - - $config->set('Namespace.Directive', $value); - -E.g. - - $config->set('HTML.Allowed', 'p,b,a[href],i'); - $config->set('URI.Base', 'http://www.example.com'); - $config->set('URI.MakeAbsolute', true); - $config->set('AutoFormat.AutoParagraph', true); - - ---------------------------------------------------------------------------- -5. Caching - -HTML Purifier generates some cache files (generally one or two) to speed up -its execution. For maximum performance, make sure that -library/HTMLPurifier/DefinitionCache/Serializer is writeable by the webserver. - -If you are in the library/ folder of HTML Purifier, you can set the -appropriate permissions using: - - chmod -R 0755 HTMLPurifier/DefinitionCache/Serializer - -If the above command doesn't work, you may need to assign write permissions -to all. This may be necessary if your webserver runs as nobody, but is -not recommended since it means any other user can write files in the -directory. Use: - - chmod -R 0777 HTMLPurifier/DefinitionCache/Serializer - -You can also chmod files via your FTP client; this option -is usually accessible by right clicking the corresponding directory and -then selecting "chmod" or "file permissions". - -Starting with 2.0.1, HTML Purifier will generate friendly error messages -that will tell you exactly what you have to chmod the directory to, if in doubt, -follow its advice. - -If you are unable or unwilling to give write permissions to the cache -directory, you can either disable the cache (and suffer a performance -hit): - - $config->set('Core.DefinitionCache', null); - -Or move the cache directory somewhere else (no trailing slash): - - $config->set('Cache.SerializerPath', '/home/user/absolute/path'); - - ---------------------------------------------------------------------------- -6. Using the code - -The interface is mind-numbingly simple: - - $purifier = new HTMLPurifier($config); - $clean_html = $purifier->purify( $dirty_html ); - -That's it! For more examples, check out docs/examples/ (they aren't very -different though). Also, docs/enduser-slow.html gives advice on what to -do if HTML Purifier is slowing down your application. - - ---------------------------------------------------------------------------- -7. Quick install - -First, make sure library/HTMLPurifier/DefinitionCache/Serializer is -writable by the webserver (see Section 5: Caching above for details). -If your website is in UTF-8 and XHTML Transitional, use this code: - -purify($dirty_html); -?> - -If your website is in a different encoding or doctype, use this code: - -set('Core.Encoding', 'ISO-8859-1'); // replace with your encoding - $config->set('HTML.Doctype', 'HTML 4.01 Transitional'); // replace with your doctype - $purifier = new HTMLPurifier($config); - - $clean_html = $purifier->purify($dirty_html); -?> - - vim: et sw=4 sts=4 + +Install + How to install HTML Purifier + +HTML Purifier is designed to run out of the box, so actually using the +library is extremely easy. (Although... if you were looking for a +step-by-step installation GUI, you've downloaded the wrong software!) + +While the impatient can get going immediately with some of the sample +code at the bottom of this library, it's well worth reading this entire +document--most of the other documentation assumes that you are familiar +with these contents. + + +--------------------------------------------------------------------------- +1. Compatibility + +HTML Purifier is PHP 5 only, and is actively tested from PHP 5.0.5 and +up. It has no core dependencies with other libraries. PHP +4 support was deprecated on December 31, 2007 with HTML Purifier 3.0.0. +HTML Purifier is not compatible with zend.ze1_compatibility_mode. + +These optional extensions can enhance the capabilities of HTML Purifier: + + * iconv : Converts text to and from non-UTF-8 encodings + * bcmath : Used for unit conversion and imagecrash protection + * tidy : Used for pretty-printing HTML + +These optional libraries can enhance the capabilities of HTML Purifier: + + * CSSTidy : Clean CSS stylesheets using %Core.ExtractStyleBlocks + * Net_IDNA2 (PEAR) : IRI support using %Core.EnableIDNA + +--------------------------------------------------------------------------- +2. Reconnaissance + +A big plus of HTML Purifier is its inerrant support of standards, so +your web-pages should be standards-compliant. (They should also use +semantic markup, but that's another issue altogether, one HTML Purifier +cannot fix without reading your mind.) + +HTML Purifier can process these doctypes: + +* XHTML 1.0 Transitional (default) +* XHTML 1.0 Strict +* HTML 4.01 Transitional +* HTML 4.01 Strict +* XHTML 1.1 + +...and these character encodings: + +* UTF-8 (default) +* Any encoding iconv supports (with crippled internationalization support) + +These defaults reflect what my choices would be if I were authoring an +HTML document, however, what you choose depends on the nature of your +codebase. If you don't know what doctype you are using, you can determine +the doctype from this identifier at the top of your source code: + + + +...and the character encoding from this code: + + + +If the character encoding declaration is missing, STOP NOW, and +read 'docs/enduser-utf8.html' (web accessible at +http://htmlpurifier.org/docs/enduser-utf8.html). In fact, even if it is +present, read this document anyway, as many websites specify their +document's character encoding incorrectly. + + +--------------------------------------------------------------------------- +3. Including the library + +The procedure is quite simple: + + require_once '/path/to/library/HTMLPurifier.auto.php'; + +This will setup an autoloader, so the library's files are only included +when you use them. + +Only the contents in the library/ folder are necessary, so you can remove +everything else when using HTML Purifier in a production environment. + +If you installed HTML Purifier via PEAR, all you need to do is: + + require_once 'HTMLPurifier.auto.php'; + +Please note that the usual PEAR practice of including just the classes you +want will not work with HTML Purifier's autoloading scheme. + +Advanced users, read on; other users can skip to section 4. + +Autoload compatibility +---------------------- + + HTML Purifier attempts to be as smart as possible when registering an + autoloader, but there are some cases where you will need to change + your own code to accomodate HTML Purifier. These are those cases: + + PHP VERSION IS LESS THAN 5.1.2, AND YOU'VE DEFINED __autoload + Because spl_autoload_register() doesn't exist in early versions + of PHP 5, HTML Purifier has no way of adding itself to the autoload + stack. Modify your __autoload function to test + HTMLPurifier_Bootstrap::autoload($class) + + For example, suppose your autoload function looks like this: + + function __autoload($class) { + require str_replace('_', '/', $class) . '.php'; + return true; + } + + A modified version with HTML Purifier would look like this: + + function __autoload($class) { + if (HTMLPurifier_Bootstrap::autoload($class)) return true; + require str_replace('_', '/', $class) . '.php'; + return true; + } + + Note that there *is* some custom behavior in our autoloader; the + original autoloader in our example would work for 99% of the time, + but would fail when including language files. + + AN __autoload FUNCTION IS DECLARED AFTER OUR AUTOLOADER IS REGISTERED + spl_autoload_register() has the curious behavior of disabling + the existing __autoload() handler. Users need to explicitly + spl_autoload_register('__autoload'). Because we use SPL when it + is available, __autoload() will ALWAYS be disabled. If __autoload() + is declared before HTML Purifier is loaded, this is not a problem: + HTML Purifier will register the function for you. But if it is + declared afterwards, it will mysteriously not work. This + snippet of code (after your autoloader is defined) will fix it: + + spl_autoload_register('__autoload') + + Users should also be on guard if they use a version of PHP previous + to 5.1.2 without an autoloader--HTML Purifier will define __autoload() + for you, which can collide with an autoloader that was added by *you* + later. + + +For better performance +---------------------- + + Opcode caches, which greatly speed up PHP initialization for scripts + with large amounts of code (HTML Purifier included), don't like + autoloaders. We offer an include file that includes all of HTML Purifier's + files in one go in an opcode cache friendly manner: + + // If /path/to/library isn't already in your include path, uncomment + // the below line: + // require '/path/to/library/HTMLPurifier.path.php'; + + require 'HTMLPurifier.includes.php'; + + Optional components still need to be included--you'll know if you try to + use a feature and you get a class doesn't exists error! The autoloader + can be used in conjunction with this approach to catch classes that are + missing. Simply add this afterwards: + + require 'HTMLPurifier.autoload.php'; + +Standalone version +------------------ + + HTML Purifier has a standalone distribution; you can also generate + a standalone file from the full version by running the script + maintenance/generate-standalone.php . The standalone version has the + benefit of having most of its code in one file, so parsing is much + faster and the library is easier to manage. + + If HTMLPurifier.standalone.php exists in the library directory, you + can use it like this: + + require '/path/to/HTMLPurifier.standalone.php'; + + This is equivalent to including HTMLPurifier.includes.php, except that + the contents of standalone/ will be added to your path. To override this + behavior, specify a new HTMLPURIFIER_PREFIX where standalone files can + be found (usually, this will be one directory up, the "true" library + directory in full distributions). Don't forget to set your path too! + + The autoloader can be added to the end to ensure the classes are + loaded when necessary; otherwise you can manually include them. + To use the autoloader, use this: + + require 'HTMLPurifier.autoload.php'; + +For advanced users +------------------ + + HTMLPurifier.auto.php performs a number of operations that can be done + individually. These are: + + HTMLPurifier.path.php + Puts /path/to/library in the include path. For high performance, + this should be done in php.ini. + + HTMLPurifier.autoload.php + Registers our autoload handler HTMLPurifier_Bootstrap::autoload($class). + + You can do these operations by yourself--in fact, you must modify your own + autoload handler if you are using a version of PHP earlier than PHP 5.1.2 + (See "Autoload compatibility" above). + + +--------------------------------------------------------------------------- +4. Configuration + +HTML Purifier is designed to run out-of-the-box, but occasionally HTML +Purifier needs to be told what to do. If you answer no to any of these +questions, read on; otherwise, you can skip to the next section (or, if you're +into configuring things just for the heck of it, skip to 4.3). + +* Am I using UTF-8? +* Am I using XHTML 1.0 Transitional? + +If you answered no to any of these questions, instantiate a configuration +object and read on: + + $config = HTMLPurifier_Config::createDefault(); + + +4.1. Setting a different character encoding + +You really shouldn't use any other encoding except UTF-8, especially if you +plan to support multilingual websites (read section three for more details). +However, switching to UTF-8 is not always immediately feasible, so we can +adapt. + +HTML Purifier uses iconv to support other character encodings, as such, +any encoding that iconv supports +HTML Purifier supports with this code: + + $config->set('Core.Encoding', /* put your encoding here */); + +An example usage for Latin-1 websites (the most common encoding for English +websites): + + $config->set('Core.Encoding', 'ISO-8859-1'); + +Note that HTML Purifier's support for non-Unicode encodings is crippled by the +fact that any character not supported by that encoding will be silently +dropped, EVEN if it is ampersand escaped. If you want to work around +this, you are welcome to read docs/enduser-utf8.html for a fix, +but please be cognizant of the issues the "solution" creates (for this +reason, I do not include the solution in this document). + + +4.2. Setting a different doctype + +For those of you using HTML 4.01 Transitional, you can disable +XHTML output like this: + + $config->set('HTML.Doctype', 'HTML 4.01 Transitional'); + +Other supported doctypes include: + + * HTML 4.01 Strict + * HTML 4.01 Transitional + * XHTML 1.0 Strict + * XHTML 1.0 Transitional + * XHTML 1.1 + + +4.3. Other settings + +There are more configuration directives which can be read about +here: They're a bit boring, +but they can help out for those of you who like to exert maximum control over +your code. Some of the more interesting ones are configurable at the +demo and are well worth looking into +for your own system. + +For example, you can fine tune allowed elements and attributes, convert +relative URLs to absolute ones, and even autoparagraph input text! These +are, respectively, %HTML.Allowed, %URI.MakeAbsolute and %URI.Base, and +%AutoFormat.AutoParagraph. The %Namespace.Directive naming convention +translates to: + + $config->set('Namespace.Directive', $value); + +E.g. + + $config->set('HTML.Allowed', 'p,b,a[href],i'); + $config->set('URI.Base', 'http://www.example.com'); + $config->set('URI.MakeAbsolute', true); + $config->set('AutoFormat.AutoParagraph', true); + + +--------------------------------------------------------------------------- +5. Caching + +HTML Purifier generates some cache files (generally one or two) to speed up +its execution. For maximum performance, make sure that +library/HTMLPurifier/DefinitionCache/Serializer is writeable by the webserver. + +If you are in the library/ folder of HTML Purifier, you can set the +appropriate permissions using: + + chmod -R 0755 HTMLPurifier/DefinitionCache/Serializer + +If the above command doesn't work, you may need to assign write permissions +to all. This may be necessary if your webserver runs as nobody, but is +not recommended since it means any other user can write files in the +directory. Use: + + chmod -R 0777 HTMLPurifier/DefinitionCache/Serializer + +You can also chmod files via your FTP client; this option +is usually accessible by right clicking the corresponding directory and +then selecting "chmod" or "file permissions". + +Starting with 2.0.1, HTML Purifier will generate friendly error messages +that will tell you exactly what you have to chmod the directory to, if in doubt, +follow its advice. + +If you are unable or unwilling to give write permissions to the cache +directory, you can either disable the cache (and suffer a performance +hit): + + $config->set('Core.DefinitionCache', null); + +Or move the cache directory somewhere else (no trailing slash): + + $config->set('Cache.SerializerPath', '/home/user/absolute/path'); + + +--------------------------------------------------------------------------- +6. Using the code + +The interface is mind-numbingly simple: + + $purifier = new HTMLPurifier($config); + $clean_html = $purifier->purify( $dirty_html ); + +That's it! For more examples, check out docs/examples/ (they aren't very +different though). Also, docs/enduser-slow.html gives advice on what to +do if HTML Purifier is slowing down your application. + + +--------------------------------------------------------------------------- +7. Quick install + +First, make sure library/HTMLPurifier/DefinitionCache/Serializer is +writable by the webserver (see Section 5: Caching above for details). +If your website is in UTF-8 and XHTML Transitional, use this code: + +purify($dirty_html); +?> + +If your website is in a different encoding or doctype, use this code: + +set('Core.Encoding', 'ISO-8859-1'); // replace with your encoding + $config->set('HTML.Doctype', 'HTML 4.01 Transitional'); // replace with your doctype + $purifier = new HTMLPurifier($config); + + $clean_html = $purifier->purify($dirty_html); +?> + + vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/INSTALL.fr.utf8 b/vendor/ezyang/htmlpurifier/INSTALL.fr.utf8 index 8fe2a26..06e628c 100755 --- a/vendor/ezyang/htmlpurifier/INSTALL.fr.utf8 +++ b/vendor/ezyang/htmlpurifier/INSTALL.fr.utf8 @@ -1,60 +1,60 @@ - -Installation - Comment installer HTML Purifier - -Attention : Ce document est encodé en UTF-8, si les lettres avec des accents -ne s'affichent pas, prenez un meilleur éditeur de texte. - -L'installation de HTML Purifier est très simple, parce qu'il n'a pas besoin -de configuration. Pour les utilisateurs impatients, le code se trouve dans le -pied de page, mais je recommande de lire le document. - -1. Compatibilité - -HTML Purifier fonctionne avec PHP 5. PHP 5.0.5 est la dernière version testée. -Il ne dépend pas d'autres librairies. - -Les extensions optionnelles sont iconv (généralement déjà installée) et tidy -(répendue aussi). Si vous utilisez UTF-8 et que vous ne voulez pas l'indentation, -vous pouvez utiliser HTML Purifier sans ces extensions. - - -2. Inclure la librairie - -Quand vous devez l'utilisez, incluez le : - - require_once('/path/to/library/HTMLPurifier.auto.php'); - -Ne pas l'inclure si ce n'est pas nécessaire, car HTML Purifier est lourd. - -HTML Purifier utilise "autoload". Si vous avez défini la fonction __autoload, -vous devez ajouter cette fonction : - - spl_autoload_register('__autoload') - -Plus d'informations dans le document "INSTALL". - -3. Installation rapide - -Si votre site Web est en UTF-8 et XHTML Transitional, utilisez : - -purify($html_a_purifier); -?> - -Sinon, utilisez : - -set('Core', 'Encoding', 'ISO-8859-1'); //Remplacez par votre - encodage - $config->set('Core', 'XHTML', true); //Remplacer par false si HTML 4.01 - $purificateur = new HTMLPurifier($config); - $html_propre = $purificateur->purify($html_a_purifier); -?> - - - vim: et sw=4 sts=4 + +Installation + Comment installer HTML Purifier + +Attention : Ce document est encodé en UTF-8, si les lettres avec des accents +ne s'affichent pas, prenez un meilleur éditeur de texte. + +L'installation de HTML Purifier est très simple, parce qu'il n'a pas besoin +de configuration. Pour les utilisateurs impatients, le code se trouve dans le +pied de page, mais je recommande de lire le document. + +1. Compatibilité + +HTML Purifier fonctionne avec PHP 5. PHP 5.0.5 est la dernière version testée. +Il ne dépend pas d'autres librairies. + +Les extensions optionnelles sont iconv (généralement déjà installée) et tidy +(répendue aussi). Si vous utilisez UTF-8 et que vous ne voulez pas l'indentation, +vous pouvez utiliser HTML Purifier sans ces extensions. + + +2. Inclure la librairie + +Quand vous devez l'utilisez, incluez le : + + require_once('/path/to/library/HTMLPurifier.auto.php'); + +Ne pas l'inclure si ce n'est pas nécessaire, car HTML Purifier est lourd. + +HTML Purifier utilise "autoload". Si vous avez défini la fonction __autoload, +vous devez ajouter cette fonction : + + spl_autoload_register('__autoload') + +Plus d'informations dans le document "INSTALL". + +3. Installation rapide + +Si votre site Web est en UTF-8 et XHTML Transitional, utilisez : + +purify($html_a_purifier); +?> + +Sinon, utilisez : + +set('Core', 'Encoding', 'ISO-8859-1'); //Remplacez par votre + encodage + $config->set('Core', 'XHTML', true); //Remplacer par false si HTML 4.01 + $purificateur = new HTMLPurifier($config); + $html_propre = $purificateur->purify($html_a_purifier); +?> + + + vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/LICENSE b/vendor/ezyang/htmlpurifier/LICENSE index 21ee8fa..8c88a20 100755 --- a/vendor/ezyang/htmlpurifier/LICENSE +++ b/vendor/ezyang/htmlpurifier/LICENSE @@ -1,504 +1,504 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library 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. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! - - vim: et sw=4 sts=4 + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/NEWS b/vendor/ezyang/htmlpurifier/NEWS index b43b00d..a9124af 100755 --- a/vendor/ezyang/htmlpurifier/NEWS +++ b/vendor/ezyang/htmlpurifier/NEWS @@ -1,1094 +1,1094 @@ -NEWS ( CHANGELOG and HISTORY ) HTMLPurifier -||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| - -= KEY ==================== - # Breaks back-compat - ! Feature - - Bugfix - + Sub-comment - . Internal change -========================== - -4.7.0, released 2015-08-04 -# opacity is now considered a "tricky" CSS property rather than a - proprietary one. -! %AutoFormat.RemoveEmpty.Predicate for specifying exactly when - an element should be considered "empty" (maybe preserve if it - has attributes), and modify iframe support so that the iframe - is removed if it is missing a src attribute. Thanks meeva for - reporting. -- Don't truncate upon encountering
    when using DOMLex. Thanks - Myrto Christina for finally convincing me to fix this. -- Update YouTube filter for new code. -- Fix parsing of rgb() values with spaces in them for 'border' - attribute. -- Don't remove foo="" attributes if foo is a boolean attribute. Thanks - valME for reporting. - -4.6.0, released 2013-11-30 -# Secure URI munge hashing algorithm has changed to hash_hmac("sha256", $url, $secret). - Please update any verification scripts you may have. -# URI parsing algorithm was made more strict, so only prefixes which - looks like schemes will actually be schemes. Thanks - Michael Gusev for fixing. -# %Core.EscapeInvalidChildren is no longer supported, and no longer does - anything. -! New directive %Core.AllowHostnameUnderscore which allows underscores - in hostnames. -- Eliminate quadratic behavior in DOMLex by using a proper queue. - Thanks Ole Laursen for noticing this. -- Rewritten MakeWellFormed/FixNesting implementation eliminates quadratic - behavior in the rest of the purificaiton pipeline. Thanks Chedburn - Networks for sponsoring this work. -- Made Linkify URL parser a bit less permissive, so that non-breaking - spaces and commas are not included as part of URL. Thanks nAS for fixing. -- Fix some bad interactions with %HTML.Allowed and injectors. Thanks - David Hirtz for reporting. -- Fix infinite loop in DirectLex. Thanks Ashar Javed (@soaj1664ashar) - for reporting. - -4.5.0, released 2013-02-17 -# Fix bug where stacked attribute transforms clobber each other; - this also means it's no longer possible to override attribute - transforms in later modules. No internal code was using this - but this may break some clients. -# We now use SHA-1 to identify cached definitions, instead of MD5. -! Support display:inline-block -! Support for more white-space CSS values. -! Permit underscores in font families -! Support for page-break-* CSS3 properties when proprietary properties - are enabled. -! New directive %Core.DisableExcludes; can be set to 'true' to turn off - SGML excludes checking. If HTML Purifier is removing too much text - and you don't care about full standards compliance, try setting this to - 'true'. -- Use prepend for SPL autoloading on PHP 5.3 and later. -- Fix bug with nofollow transform when pre-existing rel exists. -- Fix bug where background:url() always gets lower-cased - (but not background-image:url()) -- Fix bug with non lower-case color names in HTML -- Fix bug where data URI validation doesn't remove temporary files. - Thanks Javier Marín Ros for reporting. -- Don't remove certain empty tags on RemoveEmpty. - -4.4.0, released 2012-01-18 -# Removed PEARSax3 handler. -# URI.Munge now munges URIs inside the same host that go from https - to http. Reported by Neike Taika-Tessaro. -# Core.EscapeNonASCIICharacters now always transforms entities to - entities, even if target encoding is UTF-8. -# Tighten up selector validation in ExtractStyleBlocks. - Non-syntactically valid selectors are now rejected, along with - some of the more obscure ones such as attribute selectors, the - :lang pseudoselector, and anything not in CSS2.1. Furthermore, - ID and class selectors now work properly with the relevant - configuration attributes. Also, mute errors when parsing CSS - with CSS Tidy. Reported by Mario Heiderich and Norman Hippert. -! Added support for 'scope' attribute on tables. -! Added %HTML.TargetBlank, which adds target="blank" to all outgoing links. -! Properly handle sub-lists directly nested inside of lists in - a standards compliant way, by moving them into the preceding
  • -! Added %HTML.AllowedComments and %HTML.AllowedCommentsRegexp for - limited allowed comments in untrusted situations. -! Implement iframes, and allow them to be used in untrusted mode with - %HTML.SafeIframe and %URI.SafeIframeRegexp. Thanks Bradley M. Froehle - for submitting an initial version of the patch. -! The Forms module now works properly for transitional doctypes. -! Added support for internationalized domain names. You need the PEAR - Net_IDNA2 module to be in your path; if it is installed, ensure the - class can be loaded and then set %Core.EnableIDNA to true. -- Color keywords are now case insensitive. Thanks Yzmir Ramirez - for reporting. -- Explicitly initialize anonModule variable to null. -- Do not duplicate nofollow if already present. Thanks 178 - for reporting. -- Do not add nofollow if hostname matches our current host. Thanks 178 - for reporting, and Neike Taika-Tessaro for helping diagnose. -- Do not unset parser variable; this fixes intermittent serialization - problems. Thanks Neike Taika-Tessaro for reporting, bill - <10010tiger@gmail.com> for diagnosing. -- Fix iconv truncation bug, where non-UTF-8 target encodings see - output truncated after around 8000 characters. Thanks Jörg Ludwig - for reporting. -- Fix broken table content model for XHTML1.1 (and also earlier - versions, although the W3C validator doesn't catch those violations). - Thanks GlitchMr for reporting. - -4.3.0, released 2011-03-27 -# Fixed broken caching of customized raw definitions, but requires an - API change. The old API still works but will emit a warning, - see http://htmlpurifier.org/docs/enduser-customize.html#optimized - for how to upgrade your code. -# Protect against Internet Explorer innerHTML behavior by specially - treating attributes with backticks but no angled brackets, quotes or - spaces. This constitutes a slight semantic change, which can be - reverted using %Output.FixInnerHTML. Reported by Neike Taika-Tessaro - and Mario Heiderich. -# Protect against cssText/innerHTML by restricting allowed characters - used in fonts further than mandated by the specification and encoding - some extra special characters in URLs. Reported by Neike - Taika-Tessaro and Mario Heiderich. -! Added %HTML.Nofollow to add rel="nofollow" to external links. -! More types of SPL autoloaders allowed on later versions of PHP. -! Implementations for position, top, left, right, bottom, z-index - when %CSS.Trusted is on. -! Add %Cache.SerializerPermissions option for custom serializer - directory/file permissions -! Fix longstanding bug in Flash support for non-IE browsers, and - allow more wmode attributes. -! Add %CSS.AllowedFonts to restrict permissible font names. -- Switch to an iterative traversal of the DOM, which prevents us - from running out of stack space for deeply nested documents. - Thanks Maxim Krizhanovsky for contributing a patch. -- Make removal of conditional IE comments ungreedy; thanks Bernd - for reporting. -- Escape CDATA before removing Internet Explorer comments. -- Fix removal of id attributes under certain conditions by ensuring - armor attributes are preserved when recreating tags. -- Check if schema.ser was corrupted. -- Check if zend.ze1_compatibility_mode is on, and error out if it is. - This safety check is only done for HTMLPurifier.auto.php; if you - are using standalone or the specialized includes files, you're - expected to know what you're doing. -- Stop repeatedly writing the cache file after I'm done customizing a - raw definition. Reported by ajh. -- Switch to using require_once in the Bootstrap to work around bad - interaction with Zend Debugger and APC. Reported by Antonio Parraga. -- Fix URI handling when hostname is missing but scheme is present. - Reported by Neike Taika-Tessaro. -- Fix missing numeric entities on DirectLex; thanks Neike Taika-Tessaro - for reporting. -- Fix harmless notice from indexing into empty string. Thanks Matthijs - Kooijman for reporting. -- Don't autoclose no parent elements are able to support the element - that triggered the autoclose. In particular fixes strange behavior - of stray
  • tags. Thanks pkuliga@gmail.com for reporting and - Neike Taika-Tessaro for debugging assistance. - -4.2.0, released 2010-09-15 -! Added %Core.RemoveProcessingInstructions, which lets you remove - statements. -! Added %URI.DisableResources functionality; the directive originally - did nothing. Thanks David Rothstein for reporting. -! Add documentation about configuration directive types. -! Add %CSS.ForbiddenProperties configuration directive. -! Add %HTML.FlashAllowFullScreen to permit embedded Flash objects - to utilize full-screen mode. -! Add optional support for the file URI scheme, enable - by explicitly setting %URI.AllowedSchemes. -! Add %Core.NormalizeNewlines options to allow turning off newline - normalization. -- Fix improper handling of Internet Explorer conditional comments - by parser. Thanks zmonteca for reporting. -- Fix missing attributes bug when running on Mac Snow Leopard and APC. - Thanks sidepodcast for the fix. -- Warn if an element is allowed, but an attribute it requires is - not allowed. - -4.1.1, released 2010-05-31 -- Fix undefined index warnings in maintenance scripts. -- Fix bug in DirectLex for parsing elements with a single attribute - with entities. -- Rewrite CSS output logic for font-family and url(). Thanks Mario - Heiderich for reporting and Takeshi - Terada for suggesting the fix. -- Emit an error for CollectErrors if a body is extracted -- Fix bug where in background-position for center keyword handling. -- Fix infinite loop when a wrapper element is inserted in a context - where it's not allowed. Thanks Lars for reporting. -- Remove +x bit and shebang from index.php; only supported mode is to - explicitly call it with php. -- Make test script less chatty when log_errors is on. - -4.1.0, released 2010-04-26 -! Support proprietary height attribute on table element -! Support YouTube slideshows that contain /cp/ in their URL. -! Support for data: URI scheme; not enabled by default, add it using - %URI.AllowedSchemes -! Support flashvars when using %HTML.SafeObject and %HTML.SafeEmbed. -! Support for Internet Explorer compatibility with %HTML.SafeObject - using %Output.FlashCompat. -! Handle
        properly, by inserting the necessary
      1. tag. -- Always quote the insides of url(...) in CSS. - -4.0.0, released 2009-07-07 -# APIs for ConfigSchema subsystem have substantially changed. See - docs/dev-config-bcbreaks.txt for details; in essence, anything that - had both namespace and directive now have a single unified key. -# Some configuration directives were renamed, specifically: - %AutoFormatParam.PurifierLinkifyDocURL -> %AutoFormat.PurifierLinkify.DocURL - %FilterParam.ExtractStyleBlocksEscaping -> %Filter.ExtractStyleBlocks.Escaping - %FilterParam.ExtractStyleBlocksScope -> %Filter.ExtractStyleBlocks.Scope - %FilterParam.ExtractStyleBlocksTidyImpl -> %Filter.ExtractStyleBlocks.TidyImpl - As usual, the old directive names will still work, but will throw E_NOTICE - errors. -# The allowed values for class have been relaxed to allow all of CDATA for - doctypes that are not XHTML 1.1 or XHTML 2.0. For old behavior, set - %Attr.ClassUseCDATA to false. -# Instead of appending the content model to an old content model, a blank - element will replace the old content model. You can use #SUPER to get - the old content model. -! More robust support for name="" and id="" -! HTMLPurifier_Config::inherit($config) allows you to inherit one - configuration, and have changes to that configuration be propagated - to all of its children. -! Implement %HTML.Attr.Name.UseCDATA, which relaxes validation rules on - the name attribute when set. Use with care. Thanks Ian Cook for - sponsoring. -! Implement %AutoFormat.RemoveEmpty.RemoveNbsp, which removes empty - tags that contain non-breaking spaces as well other whitespace. You - can also modify which tags should have   maintained with - %AutoFormat.RemoveEmpty.RemoveNbsp.Exceptions. -! Implement %Attr.AllowedClasses, which allows administrators to restrict - classes users can use to a specified finite set of classes, and - %Attr.ForbiddenClasses, which is the logical inverse. -! You can now maintain your own configuration schema directories by - creating a config-schema.php file or passing an extra argument. Check - docs/dev-config-schema.html for more details. -! Added HTMLPurifier_Config->serialize() method, which lets you save away - your configuration in a compact serial file, which you can unserialize - and use directly without having to go through the overhead of setup. -- Fix bug where URIDefinition would not get cleared if it's directives got - changed. -- Fix fatal error in HTMLPurifier_Encoder on certain platforms (probably NetBSD 5.0) -- Fix bug in Linkify autoformatter involving http://foo -- Make %URI.Munge not apply to links that have the same host as your host. -- Prevent stray tag from truncating output, if a second - is present. -. Created script maintenance/rename-config.php for renaming a configuration - directive while maintaining its alias. This script does not change source code. -. Implement namespace locking for definition construction, to prevent - bugs where a directive is used for definition construction but is not - used to construct the cache hash. - -3.3.0, released 2009-02-16 -! Implement CSS property 'overflow' when %CSS.AllowTricky is true. -! Implement generic property list classess -- Fix bug with testEncodingSupportsASCII() algorithm when iconv() implementation - does not do the "right thing" with characters not supported in the output - set. -- Spellcheck UTF-8: The Secret To Character Encoding -- Fix improper removal of the contents of elements with only whitespace. Thanks - Eric Wald for reporting. -- Fix broken test suite in versions of PHP without spl_autoload_register() -- Fix degenerate case with YouTube filter involving double hyphens. - Thanks Pierre Attar for reporting. -- Fix YouTube rendering problem on certain versions of Firefox. -- Fix CSSDefinition Printer problems with decorators -- Add text parameter to unit tests, forces text output -. Add verbose mode to command line test runner, use (--verbose) -. Turn on unit tests for UnitConverter -. Fix missing version number in configuration %Attr.DefaultImageAlt (added 3.2.0) -. Fix newline errors that caused spurious failures when CRLF HTML Purifier was - tested on Linux. -. Removed trailing whitespace from all text files, see - remote-trailing-whitespace.php maintenance script. -. Convert configuration to use property list backend. - -3.2.0, released 2008-10-31 -# Using %Core.CollectErrors forces line number/column tracking on, whereas - previously you could theoretically turn it off. -# HTMLPurifier_Injector->notifyEnd() is formally deprecated. Please - use handleEnd() instead. -! %Output.AttrSort for when you need your attributes in alphabetical order to - deal with a bug in FCKEditor. Requested by frank farmer. -! Enable HTML comments when %HTML.Trusted is on. Requested by Waldo Jaquith. -! Proper support for name attribute. It is now allowed and equivalent to the id - attribute in a and img tags, and is only converted to id when %HTML.TidyLevel - is heavy (for all doctypes). -! %AutoFormat.RemoveEmpty to remove some empty tags from documents. Please don't - use on hand-written HTML. -! Add error-cases for unsupported elements in MakeWellFormed. This enables - the strategy to be used, standalone, on untrusted input. -! %Core.AggressivelyFixLt is on by default. This causes more sensible - processing of left angled brackets in smileys and other whatnot. -! Test scripts now have a 'type' parameter, which lets you say 'htmlpurifier', - 'phpt', 'vtest', etc. in order to only execute those tests. This supercedes - the --only-phpt parameter, although for backwards-compatibility the flag - will still work. -! AutoParagraph auto-formatter will now preserve double-newlines upon output. - Users who are not performing inbound filtering, this may seem a little - useless, but as a bonus, the test suite and handling of edge cases is also - improved. -! Experimental implementation of forms for %HTML.Trusted -! Track column numbers when maintain line numbers is on -! Proprietary 'background' attribute on table-related elements converted into - corresponding CSS. Thanks Fusemail for sponsoring this feature! -! Add forward(), forwardUntilEndToken(), backward() and current() to Injector - supertype. -! HTMLPurifier_Injector->handleEnd() permits modification to end tokens. The - time of operation varies slightly from notifyEnd() as *all* end tokens are - processed by the injector before they are subject to the well-formedness rules. -! %Attr.DefaultImageAlt allows overriding default behavior of setting alt to - basename of image when not present. -! %AutoFormat.DisplayLinkURI neuters tags into plain text URLs. -- Fix two bugs in %URI.MakeAbsolute; one involving empty paths in base URLs, - the other involving an undefined $is_folder error. -- Throw error when %Core.Encoding is set to a spurious value. Previously, - this errored silently and returned false. -- Redirected stderr to stdout for flush error output. -- %URI.DisableExternal will now use the host in %URI.Base if %URI.Host is not - available. -- Do not re-munge URL if the output URL has the same host as the input URL. - Requested by Chris. -- Fix error in documentation regarding %Filter.ExtractStyleBlocks -- Prevent ]]> from triggering %Core.ConvertDocumentToFragment -- Fix bug with inline elements in blockquotes conflicting with strict doctype -- Detect if HTML support is disabled for DOM by checking for loadHTML() method. -- Fix bug where dots and double-dots in absolute URLs without hostname were - not collapsed by URIFilter_MakeAbsolute. -- Fix bug with anonymous modules operating on SafeEmbed or SafeObject elements - by reordering their addition. -- Will now throw exception on many error conditions during lexer creation; also - throw an exception when MaintainLineNumbers is true, but a non-tracksLineNumbers - is being used. -- Detect if domxml extension is loaded, and use DirectLEx accordingly. -- Improve handling of big numbers with floating point arithmetic in UnitConverter. - Reported by David Morton. -. Strategy_MakeWellFormed now operates in-place, saving memory and allowing - for more interesting filter-backtracking -. New HTMLPurifier_Injector->rewind() functionality, allows injectors to rewind - index to reprocess tokens. -. StringHashParser now allows for multiline sections with "empty" content; - previously the section would remain undefined. -. Added --quick option to multitest.php, which tests only the most recent - release for each series. -. Added --distro option to multitest.php, which accepts either 'normal' or - 'standalone'. This supercedes --exclude-normal and --exclude-standalone - -3.1.1, released 2008-06-19 -# %URI.Munge now, by default, does not munge resources (for example, ) - In order to enable this again, please set %URI.MungeResources to true. -! More robust imagecrash protection with height/width CSS with %CSS.MaxImgLength, - and height/width HTML with %HTML.MaxImgLength. -! %URI.MungeSecretKey for secure URI munging. Thanks Chris - for sponsoring this feature. Check out the corresponding documentation - for details. (Att Nightly testers: The API for this feature changed before - the general release. Namely, rename your directives %URI.SecureMungeSecretKey => - %URI.MungeSecretKey and and %URI.SecureMunge => %URI.Munge) -! Implemented post URI filtering. Set member variable $post to true to set - a URIFilter as such. -! Allow modules to define injectors via $info_injector. Injectors are - automatically disabled if injector's needed elements are not found. -! Support for "safe" objects added, use %HTML.SafeObject and %HTML.SafeEmbed. - Thanks Chris for sponsoring. If you've been using ad hoc code from the - forums, PLEASE use this instead. -! Added substitutions for %e, %n, %a and %p in %URI.Munge (in order, - embedded, tag name, attribute name, CSS property name). See %URI.Munge - for more details. Requested by Jochem Blok. -- Disable percent height/width attributes for img. -- AttrValidator operations are now atomic; updates to attributes are not - manifest in token until end of operations. This prevents naughty internal - code from directly modifying CurrentToken when they're not supposed to. - This semantics change was requested by frank farmer. -- Percent encoding checks enabled for URI query and fragment -- Fix stray backslashes in font-family; CSS Unicode character escapes are - now properly resolved (although *only* in font-family). Thanks Takeshi Terada - for reporting. -- Improve parseCDATA algorithm to take into account newline normalization -- Account for browser confusion between Yen character and backslash in - Shift_JIS encoding. This fix generalizes to any other encoding which is not - a strict superset of printable ASCII. Thanks Takeshi Terada for reporting. -- Fix missing configuration parameter in Generator calls. Thanks vs for the - partial patch. -- Improved adherence to Unicode by checking for non-character codepoints. - Thanks Geoffrey Sneddon for reporting. This may result in degraded - performance for extremely large inputs. -- Allow CSS property-value pair ''text-decoration: none''. Thanks Jochem Blok - for reporting. -. Added HTMLPurifier_UnitConverter and HTMLPurifier_Length for convenient - handling of CSS-style lengths. HTMLPurifier_AttrDef_CSS_Length now uses - this class. -. API of HTMLPurifier_AttrDef_CSS_Length changed from __construct($disable_negative) - to __construct($min, $max). __construct(true) is equivalent to - __construct('0'). -. Added HTMLPurifier_AttrDef_Switch class -. Rename HTMLPurifier_HTMLModule_Tidy->construct() to setup() and bubble method - up inheritance hierarchy to HTMLPurifier_HTMLModule. All HTMLModules - get this called with the configuration object. All modules now - use this rather than __construct(), although legacy code using constructors - will still work--the new format, however, lets modules access the - configuration object for HTML namespace dependant tweaks. -. AttrDef_HTML_Pixels now takes a single construction parameter, pixels. -. ConfigSchema data-structure heavily optimized; on average it uses a third - the memory it did previously. The interface has changed accordingly, - consult changes to HTMLPurifier_Config for details. -. Variable parsing types now are magic integers instead of strings -. Added benchmark for ConfigSchema -. HTMLPurifier_Generator requires $config and $context parameters. If you - don't know what they should be, use HTMLPurifier_Config::createDefault() - and new HTMLPurifier_Context(). -. Printers now properly distinguish between output configuration, and - target configuration. This is not applicable to scripts using - the Printers for HTML Purifier related tasks. -. HTML/CSS Printers must be primed with prepareGenerator($gen_config), otherwise - fatal errors will ensue. -. URIFilter->prepare can return false in order to abort loading of the filter -. Factory for AttrDef_URI implemented, URI#embedded to indicate URI that embeds - an external resource. -. %URI.Munge functionality factored out into a post-filter class. -. Added CurrentCSSProperty context variable during CSS validation - -3.1.0, released 2008-05-18 -# Unnecessary references to objects (vestiges of PHP4) removed from method - signatures. The following methods do not need references when assigning from - them and will result in E_STRICT errors if you try: - + HTMLPurifier_Config->get*Definition() [* = HTML, CSS] - + HTMLPurifier_ConfigSchema::instance() - + HTMLPurifier_DefinitionCacheFactory::instance() - + HTMLPurifier_DefinitionCacheFactory->create() - + HTMLPurifier_DoctypeRegistry->register() - + HTMLPurifier_DoctypeRegistry->get() - + HTMLPurifier_HTMLModule->addElement() - + HTMLPurifier_HTMLModule->addBlankElement() - + HTMLPurifier_LanguageFactory::instance() -# Printer_ConfigForm's get*() functions were static-ified -# %HTML.ForbiddenAttributes requires attribute declarations to be in the - form of tag@attr, NOT tag.attr (which will throw an error and won't do - anything). This is for forwards compatibility with XML; you'd do best - to migrate an %HTML.AllowedAttributes directives to this syntax too. -! Allow index to be false for config from form creation -! Added HTMLPurifier::VERSION constant -! Commas, not dashes, used for serializer IDs. This change is forwards-compatible - and allows for version numbers like "3.1.0-dev". -! %HTML.Allowed deals gracefully with whitespace anywhere, anytime! -! HTML Purifier's URI handling is a lot more robust, with much stricter - validation checks and better percent encoding handling. Thanks Gareth Heyes - for indicating security vulnerabilities from lax percent encoding. -! Bootstrap autoloader deals more robustly with classes that don't exist, - preventing class_exists($class, true) from barfing. -- InterchangeBuilder now alphabetizes its lists -- Validation error in configdoc output fixed -- Iconv and other encoding errors muted even with custom error handlers that - do not honor error_reporting -- Add protection against imagecrash attack with CSS height/width -- HTMLPurifier::instance() created for consistency, is equivalent to getInstance() -- Fixed and revamped broken ConfigForm smoketest -- Bug with bool/null fields in Printer_ConfigForm fixed -- Bug with global forbidden attributes fixed -- Improved error messages for allowed and forbidden HTML elements and attributes -- Missing (or null) in configdoc documentation restored -- If DOM throws and exception during parsing with PH5P (occurs in newer versions - of DOM), HTML Purifier punts to DirectLex -- Fatal error with unserialization of ScriptRequired -- Created directories are now chmod'ed properly -- Fixed bug with fallback languages in LanguageFactory -- Standalone testing setup properly with autoload -. Out-of-date documentation revised -. UTF-8 encoding check optimization as suggested by Diego -. HTMLPurifier_Error removed in favor of exceptions -. More copy() function removed; should use clone instead -. More extensive unit tests for HTMLDefinition -. assertPurification moved to central harness -. HTMLPurifier_Generator accepts $config and $context parameters during - instantiation, not runtime -. Double-quotes outside of attribute values are now unescaped - -3.1.0rc1, released 2008-04-22 -# Autoload support added. Internal require_once's removed in favor of an - explicit require list or autoloading. To use HTML Purifier, - you must now either use HTMLPurifier.auto.php - or HTMLPurifier.includes.php; setting the include path and including - HTMLPurifier.php is insufficient--in such cases include HTMLPurifier.autoload.php - as well to register our autoload handler (or modify your autoload function - to check HTMLPurifier_Bootstrap::getPath($class)). You can also use - HTMLPurifier.safe-includes.php for a less performance friendly but more - user-friendly library load. -# HTMLPurifier_ConfigSchema static functions are officially deprecated. Schema - information is stored in the ConfigSchema directory, and the - maintenance/generate-schema-cache.php generates the schema.ser file, which - is now instantiated. Support for userland schema changes coming soon! -# HTMLPurifier_Config will now throw E_USER_NOTICE when you use a directive - alias; to get rid of these errors just modify your configuration to use - the new directive name. -# HTMLPurifier->addFilter is deprecated; built-in filters can now be - enabled using %Filter.$filter_name or by setting your own filters using - %Filter.Custom -# Directive-level safety properties superceded in favor of module-level - safety. Internal method HTMLModule->addElement() has changed, although - the externally visible HTMLDefinition->addElement has *not* changed. -! Extra utility classes for testing and non-library operations can - be found in extras/. Specifically, these are FSTools and ConfigDoc. - You may find a use for these in your own project, but right now they - are highly experimental and volatile. -! Integration with PHPT allows for automated smoketests -! Limited support for proprietary HTML elements, namely , sponsored - by Chris. You can enable them with %HTML.Proprietary if your client - demands them. -! Support for !important CSS cascade modifier. By default, this will be stripped - from CSS, but you can enable it using %CSS.AllowImportant -! Support for display and visibility CSS properties added, set %CSS.AllowTricky - to true to use them. -! HTML Purifier now has its own Exception hierarchy under HTMLPurifier_Exception. - Developer error (not enduser error) can cause these to be triggered. -! Experimental kses() wrapper introduced with HTMLPurifier.kses.php -! Finally %CSS.AllowedProperties for tweaking allowed CSS properties without - mucking around with HTMLPurifier_CSSDefinition -! ConfigDoc output has been enhanced with version and deprecation info. -! %HTML.ForbiddenAttributes and %HTML.ForbiddenElements implemented. -- Autoclose now operates iteratively, i.e.
        now has - both span tags closed. -- Various HTMLPurifier_Config convenience functions now accept another parameter - $schema which defines what HTMLPurifier_ConfigSchema to use besides the - global default. -- Fix bug with trusted script handling in libxml versions later than 2.6.28. -- Fix bug in ExtractStyleBlocks with comments in style tags -- Fix bug in comment parsing for DirectLex -- Flush output now displayed when in command line mode for unit tester -- Fix bug with rgb(0, 1, 2) color syntax with spaces inside shorthand syntax -- HTMLPurifier_HTMLDefinition->addAttribute can now be called multiple times - on the same element without emitting errors. -- Fixed fatal error in PH5P lexer with invalid tag names -. Plugins now get their own changelogs according to project conventions. -. Convert tokens to use instanceof, reducing memory footprint and - improving comparison speed. -. Dry runs now supported in SimpleTest; testing facilities improved -. Bootstrap class added for handling autoloading functionality -. Implemented recursive glob at FSTools->globr -. ConfigSchema now has instance methods for all corresponding define* - static methods. -. A couple of new historical maintenance scripts were added. -. HTMLPurifier/HTMLModule/Tidy/XHTMLAndHTML4.php split into two files -. tests/index.php can now be run from any directory. -. HTMLPurifier_Token subclasses split into seperate files -. HTMLPURIFIER_PREFIX now is defined in Bootstrap.php, NOT HTMLPurifier.php -. HTMLPURIFIER_PREFIX can now be defined outside of HTML Purifier -. New --php=php flag added, allows PHP executable to be specified (command - line only!) -. htmlpurifier_add_test() preferred method to translate test files in to - classes, because it handles PHPT files too. -. Debugger class is deprecated and will be removed soon. -. Command line argument parsing for testing scripts revamped, now --opt value - format is supported. -. Smoketests now cleanup after magic quotes -. Generator now can output comments (however, comments are still stripped - from HTML Purifier output) -. HTMLPurifier_ConfigSchema->validate() deprecated in favor of - HTMLPurifier_VarParser->parse() -. Integers auto-cast into float type by VarParser. -. HTMLPURIFIER_STRICT removed; no validation is performed on runtime, only - during cache generation -. Reordered script calls in maintenance/flush.php -. Command line scripts now honor exit codes -. When --flush fails in unit testers, abort tests and print message -. Improved documentation in docs/dev-flush.html about the maintenance scripts -. copy() methods removed in favor of clone keyword - -3.0.0, released 2008-01-06 -# HTML Purifier is PHP 5 only! The 2.1.x branch will be maintained - until PHP 4 is completely deprecated, but no new features will be added - to it. - + Visibility declarations added - + Constructor methods renamed to __construct() - + PHP4 reference cruft removed (in progress) -! CSS properties are now case-insensitive -! DefinitionCacheFactory now can register new implementations -! New HTMLPurifier_Filter_ExtractStyleBlocks for extracting