Browse Source

Initial code import based on Amine's email 6/28/2016

master
Mahmoud Al-Qudsi 3 years ago
commit
8a81066ae0
100 changed files with 15482 additions and 0 deletions
  1. 135
    0
      bootstrap.php
  2. 178
    0
      css/app.css
  3. 156
    0
      css/editor.css
  4. 230
    0
      css/grid.css
  5. 10
    0
      css/tinymce.css
  6. BIN
      img/approve.png
  7. BIN
      img/clean.png
  8. BIN
      img/contribute.png
  9. BIN
      img/original.png
  10. BIN
      img/reject.png
  11. 204
    0
      inc/approve.php
  12. 152
    0
      inc/editor.php
  13. 48
    0
      inc/mail.php
  14. 89
    0
      inc/mail_templates/admin_submition.html
  15. 84
    0
      inc/mail_templates/visitor_approval.html
  16. 95
    0
      inc/mail_templates/visitor_submition.html
  17. 86
    0
      inc/main.php
  18. 1742
    0
      inc/parser.php
  19. 71
    0
      inc/settings.php
  20. 8
    0
      js/admin.js
  21. 121
    0
      js/approve.js
  22. 41
    0
      js/editor.js
  23. 4
    0
      js/jquery.js
  24. 1532
    0
      js/jquery.validate.js
  25. 7
    0
      vendor/autoload.php
  26. 145
    0
      vendor/caxy/php-htmldiff/CHANGELOG.md
  27. 74
    0
      vendor/caxy/php-htmldiff/CODE_OF_CONDUCT.md
  28. 33
    0
      vendor/caxy/php-htmldiff/CONTRIBUTING.md
  29. 130
    0
      vendor/caxy/php-htmldiff/LICENSE
  30. 201
    0
      vendor/caxy/php-htmldiff/README.md
  31. 43
    0
      vendor/caxy/php-htmldiff/composer.json
  32. 1
    0
      vendor/caxy/php-htmldiff/demo/README.md
  33. 16
    0
      vendor/caxy/php-htmldiff/demo/bower.json
  34. 276
    0
      vendor/caxy/php-htmldiff/demo/codes.css
  35. 212
    0
      vendor/caxy/php-htmldiff/demo/demo.controller.js
  36. 246
    0
      vendor/caxy/php-htmldiff/demo/demo.html
  37. 9
    0
      vendor/caxy/php-htmldiff/demo/demo.module.js
  38. 1
    0
      vendor/caxy/php-htmldiff/demo/demos.json
  39. 1
    0
      vendor/caxy/php-htmldiff/demo/diff.json
  40. 56
    0
      vendor/caxy/php-htmldiff/demo/index.php
  41. 22
    0
      vendor/caxy/php-htmldiff/demo/load_table_diff.php
  42. 46
    0
      vendor/caxy/php-htmldiff/demo/save_demo.php
  43. 1
    0
      vendor/caxy/php-htmldiff/demo/tablediffs.json
  44. 116
    0
      vendor/caxy/php-htmldiff/doc/differences.rst
  45. 490
    0
      vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/AbstractDiff.php
  46. 112
    0
      vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/DiffCache.php
  47. 795
    0
      vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/HtmlDiff.php
  48. 488
    0
      vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/HtmlDiffConfig.php
  49. 944
    0
      vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/ListDiff.php
  50. 102
    0
      vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/ListDiff/DiffList.php
  51. 124
    0
      vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/ListDiff/DiffListItem.php
  52. 280
    0
      vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/ListDiffNew.php
  53. 27
    0
      vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Match.php
  54. 21
    0
      vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Operation.php
  55. 94
    0
      vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/AbstractTableElement.php
  56. 268
    0
      vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/DiffRowPosition.php
  57. 133
    0
      vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/RowMatch.php
  58. 161
    0
      vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/Table.php
  59. 55
    0
      vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/TableCell.php
  60. 921
    0
      vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/TableDiff.php
  61. 75
    0
      vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/TableMatch.php
  62. 70
    0
      vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/TablePosition.php
  63. 106
    0
      vendor/caxy/php-htmldiff/lib/Caxy/HtmlDiff/Table/TableRow.php
  64. 26
    0
      vendor/caxy/php-htmldiff/phpunit.xml.dist
  65. 40
    0
      vendor/caxy/php-htmldiff/tests/Caxy/Tests/HtmlDiff/Functional/HtmlDiffFunctionalTest.php
  66. 103
    0
      vendor/caxy/php-htmldiff/tests/Caxy/Tests/HtmlDiff/HtmlFileIterator.php
  67. 14
    0
      vendor/caxy/php-htmldiff/tests/Caxy/Tests/TestInit.php
  68. 13
    0
      vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/ICC-5136.html
  69. 39
    0
      vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/first-and-last.html
  70. 15
    0
      vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/issue-28-link-changes.html
  71. 20
    0
      vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/new-paragraph-and-list.html
  72. 18
    0
      vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/override-2.html
  73. 29
    0
      vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/override-3.html
  74. 28
    0
      vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/override-4.html
  75. 31
    0
      vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/override-5.html
  76. 42
    0
      vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/override-6.html
  77. 11
    0
      vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/override-8.html
  78. 11
    0
      vendor/caxy/php-htmldiff/tests/fixtures/HtmlDiff/override-9.html
  79. 413
    0
      vendor/composer/ClassLoader.php
  80. 21
    0
      vendor/composer/LICENSE
  81. 9
    0
      vendor/composer/autoload_classmap.php
  82. 10
    0
      vendor/composer/autoload_files.php
  83. 11
    0
      vendor/composer/autoload_namespaces.php
  84. 9
    0
      vendor/composer/autoload_psr4.php
  85. 59
    0
      vendor/composer/autoload_real.php
  86. 105
    0
      vendor/composer/installed.json
  87. 9
    0
      vendor/ezyang/htmlpurifier/CREDITS
  88. 374
    0
      vendor/ezyang/htmlpurifier/INSTALL
  89. 60
    0
      vendor/ezyang/htmlpurifier/INSTALL.fr.utf8
  90. 504
    0
      vendor/ezyang/htmlpurifier/LICENSE
  91. 1094
    0
      vendor/ezyang/htmlpurifier/NEWS
  92. 24
    0
      vendor/ezyang/htmlpurifier/README
  93. 150
    0
      vendor/ezyang/htmlpurifier/TODO
  94. 1
    0
      vendor/ezyang/htmlpurifier/VERSION
  95. 4
    0
      vendor/ezyang/htmlpurifier/WHATSNEW
  96. 20
    0
      vendor/ezyang/htmlpurifier/WYSIWYG
  97. 22
    0
      vendor/ezyang/htmlpurifier/composer.json
  98. 91
    0
      vendor/ezyang/htmlpurifier/extras/ConfigDoc/HTMLXSLTProcessor.php
  99. 164
    0
      vendor/ezyang/htmlpurifier/extras/FSTools.php
  100. 0
    0
      vendor/ezyang/htmlpurifier/extras/FSTools/File.php

+ 135
- 0
bootstrap.php View File

@@ -0,0 +1,135 @@
1
+<?php
2
+/*
3
+Plugin Name: Visitors contributions
4
+Plugin URI: http://codecanyon.net/user/Leavy
5
+Description: A wordpress plugin that gives your visitors the possiblity to develop your website content by submiting new versions to your articles.
6
+Version: 1.07
7
+Author: Leavy
8
+Author URI: http://codecanyon.net/user/Leavy
9
+*/
10
+class visitors_edits{
11
+	public function __construct() {
12
+		register_activation_hook( __FILE__, array($this,'install'));
13
+		add_action( 'admin_menu', array( $this, 'admin_pages' ) );
14
+		add_filter('the_content', array($this,'contentFilter'));
15
+
16
+		add_filter( 'query_vars', array($this,'query_vars') );
17
+		add_action( 'init',array($this,'init'));
18
+		add_action( 'parse_request',array($this,'parse_request'));
19
+
20
+		add_filter( 'mce_buttons', array($this,'tinymce_btns') );
21
+		add_filter( 'mce_external_plugins', array($this,'tinymce_scripts') );
22
+
23
+		add_action('admin_head', array($this,'admin_head') );
24
+		add_action('admin_init', array($this,'admin_init') );
25
+
26
+	}
27
+	public function admin_pages() {
28
+		add_menu_page('Visitors Contributions | Pending reviews','Visitors contributions','read','visitors_edits_main',array($this , 'main'),plugins_url("img/contribute.png",__FILE__),87);
29
+		add_submenu_page(null,"Visitors Contributions | Review","Review a contribution","read",'visitors_edits_approve',array($this,'approve'));
30
+		add_submenu_page("visitors_edits_main","Visitors Contributions | Settings","Settings","read",'visitors_edits_settings',array($this,'settings'));
31
+	}
32
+	public function admin_head(){
33
+		if(isset($_GET["page"]) && ($_GET["page"]==="visitors_edits_approve" || $_GET["page"]==="visitors_edits_main" || $_GET["page"]==="visitors_edits_settings")){
34
+		?>
35
+			<link rel="stylesheet" type="text/css" href="<?php echo plugins_url( '/css/app.css',__FILE__ );?>">
36
+		<?php
37
+		}
38
+	}
39
+	public function admin_init(){
40
+		add_editor_style(plugins_url( './css/tinymce.css',__FILE__ ));
41
+	}
42
+	public function main(){
43
+		require "inc/main.php";
44
+	}
45
+	public function approve(){
46
+		require 'inc/approve.php';
47
+	}
48
+	public function settings(){
49
+		require 'inc/settings.php';
50
+	}
51
+	public function contentFilter($content){
52
+		if(is_single()) {
53
+			$options=get_option( "visitors_edits_options", [
54
+				"propose_edit_link"=>"<p><a href='#post_link#'>Propose an edit</a></p>"
55
+			]);
56
+			global $post;
57
+			$new_content = str_replace("#post_link#", get_site_url().'/'.$post->post_name.'/suggestions', stripcslashes($options["propose_edit_link"]));
58
+			$content .= $new_content;	
59
+		}
60
+		return $content;
61
+	}
62
+	public function install(){
63
+		//General Settings
64
+		delete_option("visitors_edits_options");
65
+		//Database Settings
66
+		global $wpdb;
67
+		$wpdb->show_errors();
68
+
69
+		$charset_collate = $wpdb->get_charset_collate();
70
+		$table_name = $wpdb->prefix . 'visitors_edits';
71
+
72
+		$sql = "CREATE TABLE $table_name (
73
+			edit_id bigint(20) NOT NULL AUTO_INCREMENT,
74
+			edit_time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
75
+			visitor_name text DEFAULT '',
76
+			visitor_email text DEFAULT '',
77
+			visitor_comment longtext DEFAULT '',
78
+			edit_content longtext DEFAULT '',
79
+			post_id bigint(20),
80
+			post_content longtext DEFAULT '',
81
+			UNIQUE KEY (edit_id)
82
+		) $charset_collate;";
83
+
84
+		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
85
+		dbDelta( $sql );
86
+	}
87
+	public function query_vars($query_vars){
88
+		$query_vars[] = 'visitors_edits_post_name';
89
+    	return $query_vars;
90
+	}
91
+	public function init(){
92
+		add_rewrite_rule(
93
+	        '(.*)?/suggestions/?$',
94
+	        'index.php?visitors_edits_post_name=$matches[1]',
95
+	        'top'
96
+	    );
97
+	    flush_rewrite_rules(true);
98
+	}
99
+	public function parse_request($request){
100
+		if( isset( $request->query_vars['visitors_edits_post_name'] ) ):
101
+	        include( plugin_dir_path(__FILE__) . "/inc/editor.php" );
102
+	        exit();
103
+	    endif;
104
+	    return $request;
105
+	}
106
+	public function tinymce_btns($buttons){
107
+		if(isset($_GET["page"]) && $_GET["page"]==="visitors_edits_approve"){
108
+			array_push($buttons,'|','visitors_edits_approve','visitors_edits_reject','visitors_edits_clean');
109
+		}
110
+   		return $buttons;
111
+	}
112
+	public function tinymce_scripts($plugin_array){
113
+		$plugin_array['visitors_edits'] = plugins_url( 'js/approve.js',__FILE__ );
114
+   		return $plugin_array;
115
+	}
116
+	static function scriptUrl($script){
117
+		return plugins_url( 'js/'.$script.'.js',__FILE__);
118
+	}
119
+}
120
+new visitors_edits();
121
+
122
+use Caxy\HtmlDiff\HtmlDiff;
123
+use PHPHtmlParser\Dom;
124
+
125
+function visitors_editsDIFF($oldHtml,$newHtml){
126
+	require "vendor/autoload.php";
127
+	$htmlDiff = new HtmlDiff($oldHtml, $newHtml);
128
+	$htmlDiff->getConfig()->setGroupDiffs(false);
129
+	
130
+	return $htmlDiff->build();
131
+}
132
+function visitors_editsDOM(){
133
+	return new Dom;
134
+}
135
+?>

+ 178
- 0
css/app.css View File

@@ -0,0 +1,178 @@
1
+@import url("https://fonts.googleapis.com/css?family=Roboto:100,400,700");
2
+/* line 3, ../sass/app.scss */
3
+.visitors_edits_no_data {
4
+  text-align: center;
5
+  font-weight: bold;
6
+  font-size: 50px;
7
+  margin-top: 250px;
8
+  opacity: 0.3;
9
+  text-transform: uppercase;
10
+  display: none;
11
+}
12
+
13
+/* line 12, ../sass/app.scss */
14
+.visitors_edits_pending {
15
+  padding: 15px;
16
+}
17
+/* line 14, ../sass/app.scss */
18
+.visitors_edits_pending h1 {
19
+  font-weight: 100;
20
+  font-size: 20px;
21
+}
22
+
23
+/* line 22, ../sass/app.scss */
24
+.visitors_flashMessage {
25
+  margin: 15px;
26
+  background: #fff;
27
+  padding: 10px 15px;
28
+  border-left: 6px solid #089D08;
29
+  color: #089D08;
30
+  font-size: 14px;
31
+  font-weight: 100;
32
+}
33
+/* line 30, ../sass/app.scss */
34
+.visitors_flashMessage.danger {
35
+  color: #F6214E;
36
+  border-color: #F6214E;
37
+}
38
+
39
+/* line 36, ../sass/app.scss */
40
+.visitors_edits_review_editor {
41
+  padding: 15px;
42
+}
43
+/* line 38, ../sass/app.scss */
44
+.visitors_edits_review_editor h1 {
45
+  font-weight: 100;
46
+  font-size: 25px;
47
+  display: inline-block;
48
+  margin-right: 15px;
49
+  margin-bottom: 10px;
50
+}
51
+/* line 45, ../sass/app.scss */
52
+.visitors_edits_review_editor .delete_edit {
53
+  transition-duration: 0.3s;
54
+  color: #F6214E;
55
+  text-decoration: none;
56
+  text-decoration: underline;
57
+  font-style: italic;
58
+  font-style: 12px;
59
+  opacity: 0.6;
60
+}
61
+/* line 53, ../sass/app.scss */
62
+.visitors_edits_review_editor .delete_edit:hover {
63
+  opacity: 1;
64
+}
65
+/* line 57, ../sass/app.scss */
66
+.visitors_edits_review_editor .edit_info, .visitors_edits_review_editor .edit_notify {
67
+  padding-left: 15px;
68
+  font-style: italic;
69
+  opacity: 0.8;
70
+  font-size: 14px;
71
+}
72
+/* line 62, ../sass/app.scss */
73
+.visitors_edits_review_editor .edit_info .mail, .visitors_edits_review_editor .edit_notify .mail {
74
+  opacity: 0.6;
75
+  font-size: 12px;
76
+}
77
+/* line 67, ../sass/app.scss */
78
+.visitors_edits_review_editor .edit_notify {
79
+  margin: 10px 0;
80
+  padding: 0;
81
+}
82
+/* line 70, ../sass/app.scss */
83
+.visitors_edits_review_editor .edit_notify label {
84
+  display: block;
85
+  margin-bottom: 10px;
86
+}
87
+/* line 74, ../sass/app.scss */
88
+.visitors_edits_review_editor .edit_notify #edit_notify_message {
89
+  font-family: "Roboto",sans-serif;
90
+  max-height: 100px;
91
+  min-height: 100px;
92
+  max-width: 100%;
93
+  min-width: 100%;
94
+  line-height: normal;
95
+  border: none;
96
+  border-bottom: 1px solid #DFDFDF;
97
+  font-size: 18px;
98
+  padding: 10px;
99
+  display: none;
100
+}
101
+/* line 85, ../sass/app.scss */
102
+.visitors_edits_review_editor .edit_notify #edit_notify_message:focus {
103
+  outline: none;
104
+  border-bottom-width: 2px;
105
+  border-color: rgba(3, 133, 244, 0.7);
106
+}
107
+/* line 93, ../sass/app.scss */
108
+.visitors_edits_review_editor .controls {
109
+  margin-top: 20px;
110
+}
111
+/* line 96, ../sass/app.scss */
112
+.visitors_edits_review_editor .comment {
113
+  font-size: 14px;
114
+  margin: 0;
115
+  padding: 10px;
116
+  background: #fff;
117
+  border: 1px solid #999;
118
+  font-style: normal;
119
+  opacity: 1;
120
+  color: #000;
121
+}
122
+
123
+/* line 107, ../sass/app.scss */
124
+.visitors_edits_admin {
125
+  font-family: "Roboto",sans-serif;
126
+  width: 70%;
127
+  margin: 50px auto;
128
+  background: #fff;
129
+  border: 1px solid #E2E2E2;
130
+  padding: 20px;
131
+}
132
+/* line 114, ../sass/app.scss */
133
+.visitors_edits_admin h2 {
134
+  font-size: 25px;
135
+  font-weight: 100;
136
+}
137
+/* line 120, ../sass/app.scss */
138
+.visitors_edits_admin .control label {
139
+  display: block;
140
+  font-weight: bold;
141
+  margin: 15px 0 0;
142
+  opacity: 0.9;
143
+  font-size: 13px;
144
+}
145
+/* line 127, ../sass/app.scss */
146
+.visitors_edits_admin .control input[type="text"], .visitors_edits_admin .control .notif_message {
147
+  background: #F3F3F3;
148
+  outline: none;
149
+  padding: 0 10px;
150
+  height: 40px;
151
+  line-height: normal;
152
+  border: none;
153
+  border-bottom: 1px solid #DFDFDF;
154
+  width: 100%;
155
+}
156
+/* line 136, ../sass/app.scss */
157
+.visitors_edits_admin .control input[type="text"]:focus, .visitors_edits_admin .control .notif_message:focus {
158
+  outline: none;
159
+  border-bottom-width: 2px;
160
+  border-color: rgba(3, 133, 244, 0.7);
161
+}
162
+/* line 142, ../sass/app.scss */
163
+.visitors_edits_admin .control .notif_message {
164
+  min-height: 120px;
165
+  max-height: 120px;
166
+  padding: 10px;
167
+  min-width: 100%;
168
+  max-width: 100%;
169
+  line-height: normal;
170
+}
171
+/* line 150, ../sass/app.scss */
172
+.visitors_edits_admin .control input[type="checkbox"] {
173
+  margin-right: 10px;
174
+}
175
+/* line 153, ../sass/app.scss */
176
+.visitors_edits_admin .control .save_btn {
177
+  margin-top: 20px;
178
+}

+ 156
- 0
css/editor.css View File

@@ -0,0 +1,156 @@
1
+@import url("https://fonts.googleapis.com/css?family=Roboto:100,400,700");
2
+/* line 7, ../sass/editor.scss */
3
+body {
4
+  font-family: "Roboto",sans-serif;
5
+  font-size: 18px;
6
+  color: #545454;
7
+  padding: 0;
8
+  margin: 0;
9
+}
10
+
11
+/* line 14, ../sass/editor.scss */
12
+a {
13
+  text-decoration: none;
14
+  color: inherit;
15
+}
16
+
17
+/* line 18, ../sass/editor.scss */
18
+* {
19
+  transition-duration: 0.3s;
20
+  -moz-box-sizing: border-box;
21
+  -webkit-box-sizing: border-box;
22
+  box-sizing: border-box;
23
+}
24
+
25
+/* line 22, ../sass/editor.scss */
26
+.header {
27
+  padding: 20px 60px;
28
+  background: #0385F4;
29
+}
30
+/* line 25, ../sass/editor.scss */
31
+.header .header-title {
32
+  font-size: 50px;
33
+  font-weight: 100;
34
+  color: #fff;
35
+  opacity: 0.5;
36
+}
37
+/* line 31, ../sass/editor.scss */
38
+.header .header-content {
39
+  font-weight: 100;
40
+  color: #fff;
41
+  text-align: right;
42
+  font-size: 14px;
43
+  opacity: 0.7;
44
+}
45
+/* line 37, ../sass/editor.scss */
46
+.header .header-content:hover {
47
+  opacity: 0.9;
48
+}
49
+
50
+/* line 42, ../sass/editor.scss */
51
+.editor_form {
52
+  padding: 20px 40px;
53
+  overflow: hidden;
54
+  width: 100%;
55
+}
56
+/* line 46, ../sass/editor.scss */
57
+.editor_form .editor_field {
58
+  background: #f5f5f5;
59
+  padding: 15px;
60
+}
61
+/* line 50, ../sass/editor.scss */
62
+.editor_form .submit_fields {
63
+  padding: 0 20px;
64
+}
65
+
66
+/* line 55, ../sass/editor.scss */
67
+label {
68
+  display: block;
69
+  margin: 30px 0 10px;
70
+}
71
+
72
+/* line 59, ../sass/editor.scss */
73
+.text_field, .area_field {
74
+  height: 40px;
75
+  line-height: 40px;
76
+  border: none;
77
+  border-bottom: 1px solid #DFDFDF;
78
+  width: 100%;
79
+  font-size: 18px;
80
+}
81
+/* line 66, ../sass/editor.scss */
82
+.text_field:focus, .area_field:focus {
83
+  outline: none;
84
+  border-bottom-width: 2px;
85
+  border-color: rgba(3, 133, 244, 0.7);
86
+}
87
+
88
+/* line 72, ../sass/editor.scss */
89
+.area_field {
90
+  font-family: "Roboto",sans-serif;
91
+  max-height: 100px;
92
+  min-height: 100px;
93
+  max-width: 100%;
94
+  min-width: 100%;
95
+  line-height: normal;
96
+}
97
+
98
+/* line 80, ../sass/editor.scss */
99
+.submit_fields_error {
100
+  line-height: 20px;
101
+  font-style: italic;
102
+  font-size: 12px;
103
+  opacity: 0.8;
104
+  color: #e74c3c;
105
+}
106
+
107
+/* line 87, ../sass/editor.scss */
108
+.btn {
109
+  height: 40px;
110
+  color: #fff;
111
+  line-height: 40px;
112
+  padding: 0 20px;
113
+  text-transform: uppercase;
114
+  background: #0385F4;
115
+  border: 1px solid #0385F4;
116
+  cursor: pointer;
117
+  margin: 20px 0;
118
+}
119
+/* line 97, ../sass/editor.scss */
120
+.btn:hover {
121
+  color: #0385F4;
122
+  background: #fff;
123
+}
124
+
125
+/* line 102, ../sass/editor.scss */
126
+.cb {
127
+  clear: both;
128
+}
129
+
130
+/* line 105, ../sass/editor.scss */
131
+.grey {
132
+  background: #f5f5f5;
133
+}
134
+
135
+/* line 108, ../sass/editor.scss */
136
+.submit_success {
137
+  margin-top: 200px;
138
+  background: #0385F4;
139
+  padding: 30px;
140
+  color: #fff;
141
+}
142
+/* line 113, ../sass/editor.scss */
143
+.submit_success .alert_title {
144
+  font-size: 40px;
145
+  opacity: 0.4;
146
+}
147
+/* line 117, ../sass/editor.scss */
148
+.submit_success .alert_content {
149
+  font-weight: 100;
150
+}
151
+/* line 120, ../sass/editor.scss */
152
+.submit_success .alert_footer {
153
+  opacity: 0.7;
154
+  font-size: 12px;
155
+  font-style: italic;
156
+}

+ 230
- 0
css/grid.css View File

@@ -0,0 +1,230 @@
1
+/* line 2, style.scss */
2
+* {
3
+  -webkit-box-sizing: border-box;
4
+  -moz-box-sizing: border-box;
5
+  box-sizing: border-box;
6
+}
7
+
8
+/* line 3, style.scss */
9
+body {
10
+  margin: 0;
11
+  padding: 0;
12
+  font-family: sans-serif;
13
+}
14
+
15
+/* line 6, _grid.scss */
16
+.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 {
17
+  float: right;
18
+  position: relative;
19
+  min-height: 1px;
20
+  padding: 0 10px;
21
+  /*border: 1px solid rgba(255, 0, 0, 0.5);*/
22
+}
23
+
24
+/* line 16, _grid.scss */
25
+.col-1 {
26
+  width: 8.33333%;
27
+}
28
+
29
+/* line 16, _grid.scss */
30
+.col-2 {
31
+  width: 16.66667%;
32
+}
33
+
34
+/* line 16, _grid.scss */
35
+.col-3 {
36
+  width: 25%;
37
+}
38
+
39
+/* line 16, _grid.scss */
40
+.col-4 {
41
+  width: 33.33333%;
42
+}
43
+
44
+/* line 16, _grid.scss */
45
+.col-5 {
46
+  width: 41.66667%;
47
+}
48
+
49
+/* line 16, _grid.scss */
50
+.col-6 {
51
+  width: 50%;
52
+}
53
+
54
+/* line 16, _grid.scss */
55
+.col-7 {
56
+  width: 58.33333%;
57
+}
58
+
59
+/* line 16, _grid.scss */
60
+.col-8 {
61
+  width: 66.66667%;
62
+}
63
+
64
+/* line 16, _grid.scss */
65
+.col-9 {
66
+  width: 75%;
67
+}
68
+
69
+/* line 16, _grid.scss */
70
+.col-10 {
71
+  width: 83.33333%;
72
+}
73
+
74
+/* line 16, _grid.scss */
75
+.col-11 {
76
+  width: 91.66667%;
77
+}
78
+
79
+/* line 16, _grid.scss */
80
+.col-12 {
81
+  width: 100%;
82
+}
83
+
84
+/* line 23, _grid.scss */
85
+.row {
86
+  margin: 0 -10px;
87
+  overflow: hidden;
88
+  *zoom: 1;
89
+}
90
+
91
+/* line 27, _grid.scss */
92
+.col-center {
93
+  margin: 0 auto;
94
+  float: none;
95
+}
96
+
97
+@media only screen and (min-width: 640px) {
98
+  /* line 30, _grid.scss */
99
+  .col-m-center {
100
+    margin: 0 auto;
101
+    float: none;
102
+  }
103
+
104
+  /* line 32, _grid.scss */
105
+  .col-m-1 {
106
+    width: 8.33333%;
107
+  }
108
+
109
+  /* line 32, _grid.scss */
110
+  .col-m-2 {
111
+    width: 16.66667%;
112
+  }
113
+
114
+  /* line 32, _grid.scss */
115
+  .col-m-3 {
116
+    width: 25%;
117
+  }
118
+
119
+  /* line 32, _grid.scss */
120
+  .col-m-4 {
121
+    width: 33.33333%;
122
+  }
123
+
124
+  /* line 32, _grid.scss */
125
+  .col-m-5 {
126
+    width: 41.66667%;
127
+  }
128
+
129
+  /* line 32, _grid.scss */
130
+  .col-m-6 {
131
+    width: 50%;
132
+  }
133
+
134
+  /* line 32, _grid.scss */
135
+  .col-m-7 {
136
+    width: 58.33333%;
137
+  }
138
+
139
+  /* line 32, _grid.scss */
140
+  .col-m-8 {
141
+    width: 66.66667%;
142
+  }
143
+
144
+  /* line 32, _grid.scss */
145
+  .col-m-9 {
146
+    width: 75%;
147
+  }
148
+
149
+  /* line 32, _grid.scss */
150
+  .col-m-10 {
151
+    width: 83.33333%;
152
+  }
153
+
154
+  /* line 32, _grid.scss */
155
+  .col-m-11 {
156
+    width: 91.66667%;
157
+  }
158
+
159
+  /* line 32, _grid.scss */
160
+  .col-m-12 {
161
+    width: 100%;
162
+  }
163
+}
164
+@media only screen and (min-width: 1024px) {
165
+  /* line 39, _grid.scss */
166
+  .col-l-center {
167
+    margin: 0 auto;
168
+    float: none;
169
+  }
170
+
171
+  /* line 41, _grid.scss */
172
+  .col-l-1 {
173
+    width: 8.33333%;
174
+  }
175
+
176
+  /* line 41, _grid.scss */
177
+  .col-l-2 {
178
+    width: 16.66667%;
179
+  }
180
+
181
+  /* line 41, _grid.scss */
182
+  .col-l-3 {
183
+    width: 25%;
184
+  }
185
+
186
+  /* line 41, _grid.scss */
187
+  .col-l-4 {
188
+    width: 33.33333%;
189
+  }
190
+
191
+  /* line 41, _grid.scss */
192
+  .col-l-5 {
193
+    width: 41.66667%;
194
+  }
195
+
196
+  /* line 41, _grid.scss */
197
+  .col-l-6 {
198
+    width: 50%;
199
+  }
200
+
201
+  /* line 41, _grid.scss */
202
+  .col-l-7 {
203
+    width: 58.33333%;
204
+  }
205
+
206
+  /* line 41, _grid.scss */
207
+  .col-l-8 {
208
+    width: 66.66667%;
209
+  }
210
+
211
+  /* line 41, _grid.scss */
212
+  .col-l-9 {
213
+    width: 75%;
214
+  }
215
+
216
+  /* line 41, _grid.scss */
217
+  .col-l-10 {
218
+    width: 83.33333%;
219
+  }
220
+
221
+  /* line 41, _grid.scss */
222
+  .col-l-11 {
223
+    width: 91.66667%;
224
+  }
225
+
226
+  /* line 41, _grid.scss */
227
+  .col-l-12 {
228
+    width: 100%;
229
+  }
230
+}

+ 10
- 0
css/tinymce.css View File

@@ -0,0 +1,10 @@
1
+ins{
2
+	background: transparent !important;
3
+	color: inherit !important;
4
+}
5
+.diffins{
6
+	background:#4DB1FB !important;
7
+}
8
+.diffmod{
9
+	background:#4DFB74 !important;
10
+}

BIN
img/approve.png View File


BIN
img/clean.png View File


BIN
img/contribute.png View File


BIN
img/original.png View File


BIN
img/reject.png View File


+ 204
- 0
inc/approve.php View File

@@ -0,0 +1,204 @@
1
+<?php 
2
+if(isset($_GET["edit"])){
3
+	global $wpdb;
4
+	$table_name = $wpdb->prefix . 'visitors_edits';
5
+	$edit = $wpdb->get_row("SELECT * FROM ".$table_name." WHERE edit_id=".$_GET["edit"]);
6
+	$edit->edit_content=stripcslashes($edit->edit_content);
7
+	$edit->post=get_post($edit->post_id);
8
+	$options=get_option( "visitors_edits_options", [
9
+		"advanced_merge"=>null
10
+	]);
11
+	//Fix nl
12
+	//$edit->post->post_content=str_replace(["\r\n", "\r", "\n"], "<br/>",$edit->post->post_content);
13
+	//$edit->post_content=str_replace(["\r\n", "\r", "\n"], "<br/>",$edit->post_content);
14
+	//$edit->edit_content=str_replace(["\r\n", "\r", "\n"], "<br/>",$edit->edit_content);
15
+
16
+	$edit->post->post_content=nl2br($edit->post->post_content);
17
+	$edit->post_content=nl2br($edit->post_content);
18
+	$edit->edit_content=nl2br($edit->edit_content);
19
+
20
+	if($options["advanced_merge"]!=null){
21
+		$diff1=visitors_editsDIFF($edit->post_content,$edit->edit_content);
22
+		$conv_diff1=encodeDiff($diff1);
23
+		$diff=visitors_editsDIFF($conv_diff1["html"],$edit->post->post_content);
24
+		$diff=cleanEncodedDiff($diff);
25
+		$diff=decodeDiff($diff,$conv_diff1["codes"]);
26
+	}else{
27
+		$diff=visitors_editsDIFF($edit->post->post_content,$edit->edit_content);
28
+	}
29
+
30
+	$diff=cleanDiff($diff);
31
+	echo '<div style="display:none" id="visitors_edits_diff">'.$diff.'</div>';
32
+
33
+	showEditor($edit);
34
+}else{
35
+	noData("Select a visitor contribution");
36
+	?>
37
+	<script type="text/javascript">
38
+		setTimeout(function(){
39
+			window.location="<?php echo menu_page_url('visitors_edits_main',false);?>";
40
+		},2000)
41
+	</script>
42
+	<?php
43
+}
44
+
45
+function showEditor($edit,$editor_content=""){
46
+	$options=get_option( "visitors_edits_options", [
47
+		"edit_notify_message"=>"Thanks for your contribution to our blog, your contribution was reviewed and approved."
48
+	]);
49
+	?>
50
+	<div class="visitors_edits_review_editor">
51
+		<h1>Review a contribution</h1><a class="delete_edit" href="<?php echo menu_page_url('visitors_edits_main',false);?>&delete=<?php echo $edit->edit_id;?>">Delete this contribution</a>
52
+		<ul class="edit_info">
53
+			<li><a target="_blank" href="<?php echo get_permalink($edit->post->ID);?>">View original post</a></li>
54
+			<li>Author : <?php echo $edit->visitor_name; ?> <span class="mail"><?php echo $edit->visitor_email; ?></span></li>
55
+			<li>Submited on : 
56
+				<?php 
57
+					$creationDate=date_create($edit->edit_time);
58
+         			echo date_format($creationDate,"m/d/Y")." at ".date_format($creationDate,"h:i a");
59
+				?>
60
+			</li>
61
+			<li>Author comment :</li>
62
+			<p class="comment">
63
+				<?php echo stripcslashes($edit->visitor_comment); ?>		
64
+			</p>
65
+		</ul>
66
+		
67
+		<div class="cb"></div>
68
+		<form action="<?php echo menu_page_url('visitors_edits_main',false);?>" method="POST" onsubmit="return editSubmit()">
69
+			<div class="editor">
70
+				<?php 
71
+				wp_editor($editor_content,"diff_editor",[
72
+					"media_buttons"=>false,
73
+					"quicktags"=>false,
74
+					"textarea_name"=>"post_content",
75
+					"tinymce"=>[
76
+						"mode" => "textareas",
77
+						"theme" => "modern"
78
+				    ]
79
+				]); 
80
+				?>
81
+			</div>
82
+			<style>
83
+				.diff_editor ins{
84
+					background: #44B3FD !important;
85
+				}
86
+			</style>
87
+			<div class="controls">
88
+				<input type="hidden" value="<?php echo $edit->visitor_name; ?>" name="visitor_name">
89
+				<input type="hidden" value="<?php echo $edit->visitor_email; ?>" name="visitor_email">
90
+				<input type="hidden" value="<?php echo $edit->edit_id; ?>" name="edit_id">
91
+				<input type="hidden" value="<?php echo $edit->post_id; ?>" name="ID">
92
+
93
+				<div class="edit_notify">
94
+					<label><input type="checkbox" name="notify_visitor" id="edit_notify_activate"> Notify the author.</label>
95
+					<textarea name="admin_message" id="edit_notify_message"><?php echo $options["edit_notify_message"]; ?></textarea>
96
+				</div>
97
+				<button class="button-primary" type="submit">Save changes</button>
98
+			</div>
99
+		</form>
100
+		<script src="<?php echo visitors_edits::scriptUrl('admin');?>"></script>
101
+	</div>
102
+	<?php
103
+}
104
+
105
+function noData($msg){
106
+	?>
107
+	<h1 class="visitors_edits_no_data" style="display:block">
108
+	    <?php echo $msg; ?>
109
+	</h1>
110
+	<?php
111
+}
112
+
113
+function clearTag($tag,$content){
114
+	return preg_replace("#<".$tag.".*?>.*?</".$tag.">#i","", $content);
115
+}
116
+
117
+function addAttrTag($tag,$attr,$content){
118
+	return preg_replace("#<".$tag."(.*?)>#i","<".$tag." ".$attr."='1'$1>", $content);
119
+}
120
+function clearTagName($tag,$content){
121
+	return preg_replace("#</*".$tag.".*?>#i", "", $content);
122
+}
123
+function replaceTag($origin,$replace,$content){
124
+	return preg_replace("#(<(/*)(".$origin.")(.*?)>)#i", '[$2'.$replace.'$4]', $content);
125
+}
126
+function encodeDiff($diff){
127
+	//composer require paquettg/php-html-parser
128
+	require_once "parser.php";
129
+	$html=str_get_html($diff);
130
+	$encoded=[
131
+		"html"=>"",
132
+		"codes"=>[
133
+			"INS"=>[],
134
+			"DEL"=>[]
135
+		]
136
+	];
137
+	$id=0;
138
+	foreach($html->find('ins') as $ins){
139
+    	$encoded["codes"]["INS"][$id]=$ins->outertext;
140
+    	$ins->outertext="%INS".$id."%";
141
+    	$id++;
142
+	}
143
+	$id=0;
144
+	foreach($html->find('del') as $del){
145
+    	$encoded["codes"]["DEL"][$id]=$del->outertext;
146
+    	$del->outertext="%DEL".$id."%";
147
+    	$id++;
148
+	}
149
+	$encoded["html"]=$html->outertext;
150
+	return $encoded;
151
+}
152
+function cleanDiff($content){
153
+	require_once "parser.php";
154
+	$html=str_get_html($content);
155
+	foreach($html->find('ul') as $ul){
156
+		foreach($ul->find("br") as $br){
157
+			$br->outertext="";
158
+		}
159
+	}
160
+	foreach($html->find('ol') as $ol){
161
+		foreach($ol->find("br") as $br){
162
+			$br->outertext="";
163
+		}
164
+	} 
165
+	return $html;
166
+}
167
+function cleanEncodedDiff($content){
168
+	$html=str_get_html($content);
169
+	$delete_next=false;
170
+	$diffs = $html->find('ins, del');
171
+	for ($i=0; $i < count($diffs); $i++) { 
172
+		$diff=$diffs[$i];
173
+		if($delete_next){
174
+			$diff->outertext="";
175
+			$delete_next=false;
176
+			coutinue;
177
+		}else{
178
+			$isSpecial=preg_match("#%(INS|DEL)\d*?%#", $diff->innertext);
179
+			if ($isSpecial){
180
+		    	//is important
181
+		    	if(preg_match("#diffmod#",$diff->outertext)){
182
+		    		$delete_next=true;
183
+		    	}
184
+		    	$diff->outertext=$diff->innertext;
185
+		    }else{
186
+		    	if($diff->tag==="ins"){
187
+		    		$diff->outertext=$diff->innertext;
188
+		    	}else{
189
+		    		$diff->outertext="";
190
+		    	}
191
+		    }
192
+		}
193
+	}
194
+	return $html;
195
+}
196
+function decodeDiff($content,$codes){
197
+	foreach ($codes["INS"] as $id => $code) {
198
+		$content=str_replace("%INS".$id."%", $code, $content);
199
+	}
200
+	foreach ($codes["DEL"] as $id => $code) {
201
+		$content=str_replace("%DEL".$id."%", $code, $content);
202
+	}
203
+	return $content;
204
+}

+ 152
- 0
inc/editor.php View File

@@ -0,0 +1,152 @@
1
+<?php
2
+$post=null;
3
+if(!empty($_POST)){
4
+	global $wpdb;
5
+	$wpdb->show_errors();
6
+	$table_name = $wpdb->prefix . 'visitors_edits';
7
+
8
+	$post_id=$_POST["post_id"];
9
+	$visitor_name=$_POST["visitor_name"];
10
+	$visitor_email=$_POST["visitor_email"];
11
+	$visitor_comment=$_POST["visitor_comment"];
12
+	$edit_content=$_POST["edit_content"];
13
+
14
+	$post = get_post($post_id);
15
+	
16
+	//Check if changed
17
+	if(md5($post->post_content)!==md5(stripcslashes($edit_content))){
18
+		
19
+		$wpdb->insert($table_name,[
20
+			"edit_time"=>date('Y-m-d H:i:s'),
21
+			"visitor_name"=>$visitor_name,
22
+			"visitor_email"=>$visitor_email,
23
+			"visitor_comment"=>$visitor_comment,
24
+			"edit_content"=>$edit_content,
25
+			"post_id"=>$post_id,
26
+			"post_content"=>$post->post_content
27
+		]);
28
+		require "mail.php";
29
+		$options=get_option( "visitors_edits_options", [
30
+			"admin_email"=>"",
31
+			"notify_admin"=>null,
32
+			"visitor_notif_message"=>"Your suggestion was submitted.",
33
+			"admin_notif_message"=>"A new suggestion was submitted."
34
+		]);
35
+		$mail = [
36
+			"post_title"=>$post->post_title,
37
+			"post_url"=>get_permalink($post_id),
38
+			"visitor_name"=>$visitor_name,
39
+			"visitor_email"=>$visitor_email,
40
+			"edit_time"=>date('H:i')." - ".date('d/m/y'),
41
+			"blog_title" => get_bloginfo("name"),
42
+			"visitor_notif_message"=>$options["visitor_notif_message"],
43
+			"admin_notif_message"=>$options["admin_notif_message"]
44
+		];
45
+
46
+		$visitor_submitionMail=new visitors_edits_EMAIL($mail,"visitor_submition");
47
+		$visitor_submitionMail->send($visitor_email);
48
+
49
+		if($options["notify_admin"]!=null){
50
+			$admin_email=$options["admin_email"];
51
+			$admin_submitionMail=new visitors_edits_EMAIL($mail,"admin_submition");
52
+			$admin_submitionMail->send($admin_email);
53
+		}
54
+	}
55
+}else{
56
+	global $wp;
57
+	global $post;
58
+	$post = get_posts([
59
+		"name"=> $wp->query_vars['visitors_edits_post_name'],
60
+		'post_type'   => 'post',
61
+	  	'post_status' => 'publish',
62
+	  	'numberposts' => 1
63
+	]);
64
+	$post=$post[0];
65
+	if($post->post_name!=$wp->query_vars['visitors_edits_post_name']){
66
+		header("Location:".get_site_url());
67
+	}
68
+}
69
+?>
70
+<!DOCTYPE html>
71
+<html xmlns="http://www.w1.org/1998/xhtml" xml:lang="en" lang="en">
72
+<head>
73
+	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
74
+	<link rel="stylesheet" type="text/css" href="<?php echo plugins_url( '/../css/grid.css',__FILE__ );?>">
75
+	<link rel="stylesheet" type="text/css" href="<?php echo plugins_url( '/../css/editor.css',__FILE__ );?>">
76
+	<script src="<?php echo visitors_edits::scriptUrl('jquery');?>"></script>
77
+	<title>Submit an edit</title>
78
+</head>
79
+<body <?php if(!empty($_POST)){echo 'class="grey"';} ?>>
80
+	<?php 
81
+		if(!empty($_POST)){
82
+			confirmSubmit("Edit Submitted!","Thanks for your contribution you will be notified once the edit reviewed.");
83
+		}else{
84
+			showForm();
85
+		}
86
+	?>
87
+</body>
88
+</html>
89
+<?php 
90
+function showForm(){
91
+	global $post;
92
+	?>
93
+	<div class="header">
94
+		<div class="header-title">Submit a contribution</div>
95
+		<p class="header-content">
96
+			<a href="<?php echo  get_permalink($post->ID) ?>">Original post : <?php echo $post->post_title; ?>.</a>
97
+		</p>
98
+	</div>
99
+	<form action="" method="POST" class="editor_form row" id="editor_form" onsubmit="return validateEdit.run()">
100
+		<div class="submit_fields col-12 col-l-4">
101
+			<ul class="submit_fields_error" id="submit_fields_error">
102
+			</ul>
103
+			<label for="name">Name</label>
104
+			<input class="text_field" type="text" name="visitor_name" placeholder="Name" id="name">
105
+			<label for="email">Email</label>
106
+			<input class="text_field" type="email" name="visitor_email" placeholder="Email" id="email">
107
+			<label for="comment">Description</label>
108
+			<textarea class="area_field" type="text" name="visitor_comment" value=" " id="comment">
109
+				
110
+			</textarea>
111
+			<input type="hidden" name="post_id" value="<?php echo $post->ID;?>">
112
+			<input type="hidden" name="post_url" value="<?php echo  get_permalink($post->ID);?>">
113
+			<input type="submit" class="btn" value="Submit for review">
114
+		</div>
115
+		<div class="editor_field col-12 col-l-8">
116
+			<?php
117
+				wp_editor($post->post_content,"edit_content",[
118
+					"media_buttons"=>false,
119
+					"quicktags"=>false,
120
+					"textarea_name"=>"edit_content",
121
+					"tinymce"=>[
122
+						"mode" => "textareas",
123
+						"theme" => "modern"
124
+				    ]
125
+				]);
126
+				_WP_Editors::enqueue_scripts();
127
+				print_footer_scripts();
128
+				_WP_Editors::editor_js();
129
+			?>
130
+		</div>
131
+		<div class="cb"></div>
132
+	</form>
133
+	<script src="<?php echo visitors_edits::scriptUrl('editor');?>"></script>
134
+	<?php
135
+}
136
+function confirmSubmit($title,$message){
137
+	?>
138
+	<div class="submit_success col-10 col-l-6 col-center">
139
+		<strong class="alert_title">
140
+			<?php echo $title;?>
141
+		</strong>
142
+		<p class="alert_content">
143
+			<?php echo $message;?>
144
+		</p>
145
+		<p class="alert_footer">
146
+			<a href="<?php echo $_POST['post_url']?>">Click here to continue back to the post</a>
147
+		</p>
148
+		</div>
149
+	</div>
150
+	<?php
151
+}
152
+?>

+ 48
- 0
inc/mail.php View File

@@ -0,0 +1,48 @@
1
+<?php
2
+class visitors_edits_EMAIL{
3
+	var $subject;
4
+	var $body;
5
+	public function __construct($cpts,$template){
6
+		$template=$this->loadTemplate($template);
7
+		$this->subject=$this->inject($template["subject"],$cpts);
8
+		$this->body=$this->inject($template["body"],$cpts);
9
+	}
10
+	public function send($destination){
11
+
12
+		$options=get_option( "visitors_edits_options", [
13
+			"admin_email"=>"",
14
+			"notify_admin"=>null
15
+		]);
16
+
17
+		$headers= "MIME-Version: 1.0\r\n";
18
+		$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
19
+
20
+		wp_mail($destination, $this->subject, $this->body,$headers);
21
+		/*
22
+		subject : $this->subject
23
+		body : $this->body
24
+		*/
25
+	}
26
+	private function loadTemplate($template){
27
+		ob_start();
28
+		require("mail_templates/".$template.".html");
29
+		$templateHtml=ob_get_clean();
30
+		preg_match("|<subject>(.*)</subject>|",$templateHtml,$subject);
31
+		$templateHtml=preg_replace("|<subject>.*</subject>|","",$templateHtml);
32
+		return [
33
+			"subject"=>$subject[1],
34
+			"body"=>$templateHtml
35
+		];	
36
+	}
37
+	private function inject($str,$body){
38
+		foreach ($body as $key => $value) {
39
+			$str=str_replace("#$key#",$value,$str);
40
+		}
41
+		return $str;
42
+	}
43
+	public function preview(){
44
+		echo $this->subject;
45
+		echo $this->body;
46
+	}
47
+}
48
+?>

+ 89
- 0
inc/mail_templates/admin_submition.html View File

@@ -0,0 +1,89 @@
1
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
+   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+<html xmlns:v="urn:schemas-microsoft-com:vml">
4
+<head>
5
+	<subject>[#blog_title# | Visitors Contributions] - Contribution submited</subject>
6
+	<meta http-equiv="content-type" content="text/html, charset=utf-8">
7
+	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
8
+	<link href='https://fonts.googleapis.com/css?family=Questrial' rel='stylesheet' type='text/css'>
9
+</head>
10
+<body leftmargin="0" rightmargin="0" marginwidth="0" marginheight="0">
11
+	<table bgcolor="#0385F4" width="100%" border="0" cellpadding="0" cellspacing="0">
12
+		<tbody>
13
+			<tr>
14
+				<td>
15
+					<table align="center" width="600" border="0" cellpadding="0" cellspacing="0">
16
+						<tbody>
17
+							<tr><td height="30" style="font-size:30px; line-height:30px">&nbsp;</td></tr>
18
+							<tr>
19
+								<td align="center "style="font-family:'Questrial',Helvetica,sans-serif; text-align:center;font-size:50px;color:#fff;mso-line-height-rule:exactly;line-height:28px">#blog_title#</td>
20
+							</tr>
21
+							<tr><td height="30" style="font-size:30px; line-height:30px">&nbsp;</td></tr>
22
+							<tr>
23
+								<td align="center "style="font-family:'Questrial',Helvetica,sans-serif; text-align:center;font-size:20px;color:#fff;mso-line-height-rule:exactly;line-height:28px">Contribution submited</td>
24
+							</tr>
25
+							<tr><td height="30" style="font-size:30px; line-height:30px">&nbsp;</td></tr>
26
+						</tbody>
27
+					</table>
28
+				</td>
29
+			</tr>
30
+		</tbody>
31
+	</table>
32
+
33
+	<table bgcolor="#E3E3E3" width="100%" border="0" cellpadding="0" cellspacing="0">
34
+		<tbody>
35
+			<tr>
36
+				<td>
37
+					<table align="center" width="600" border="0" cellpadding="0" cellspacing="0">
38
+						<tbody>
39
+							<tr><td height="30" style="font-size:30px; line-height:30px">&nbsp;</td></tr>
40
+							<tr>
41
+								<td align="center "style="font-family:'Questrial',Helvetica,sans-serif; text-align:center;color:#262626;mso-line-height-rule:exactly;line-height:28px">
42
+									#admin_notif_message#
43
+								</td>
44
+							</tr>
45
+							<tr><td height="30" style="font-size:30px; line-height:30px">&nbsp;</td></tr>
46
+							<tr>
47
+								<td align="center "style="font-family:'Questrial',Helvetica,sans-serif; text-align:center;color:#262626;mso-line-height-rule:exactly;line-height:28px">
48
+									Submition details
49
+								</td>
50
+							</tr>
51
+							<tr><td height="30" style="font-size:30px; line-height:30px">&nbsp;</td></tr>
52
+							<tr>
53
+								<td align="center "style="font-family:'Questrial',Helvetica,sans-serif; text-align:center;color:#262626;mso-line-height-rule:exactly;line-height:28px">
54
+									<a href="#post_url#" style="color:#262626">#post_title#</a>
55
+								</td>
56
+							</tr>
57
+							<tr>
58
+								<td align="center "style="font-family:'Questrial',Helvetica,sans-serif; text-align:center;color:#262626;mso-line-height-rule:exactly;line-height:28px">
59
+									Submited on : #edit_time#
60
+								</td>
61
+							</tr>
62
+							<tr>
63
+								<td align="center "style="font-family:'Questrial',Helvetica,sans-serif; text-align:center;color:#262626;mso-line-height-rule:exactly;line-height:28px">
64
+									Author : #visitor_name# (#visitor_email#)
65
+								</td>
66
+							</tr>
67
+							<tr><td height="30" style="font-size:30px; line-height:30px">&nbsp;</td></tr>
68
+							<tr>
69
+								<td align="center "style="font-family:'Questrial',Helvetica,sans-serif; text-align:center;color:#262626;mso-line-height-rule:exactly;line-height:28px">
70
+									<table align="center" bgcolor="#0385F4" width="100" border="0" cellpadding="0" cellspacing="0">
71
+										<tbody><tr><td height="4" style="font-size:4px; line-height:4px">&nbsp;</td></tr></tbody>
72
+									</table>
73
+								</td>
74
+							</tr>
75
+							<tr><td height="30" style="font-size:30px; line-height:30px">&nbsp;</td></tr>
76
+							<tr>
77
+								<td align="center "style="font-family:'Questrial',Helvetica,sans-serif; text-align:center;color:#262626;mso-line-height-rule:exactly;line-height:28px">
78
+									Visitors Contributions
79
+								</td>
80
+							</tr>
81
+							<tr><td height="30" style="font-size:30px; line-height:30px">&nbsp;</td></tr>
82
+						</tbody>
83
+					</table>
84
+				</td>
85
+			</tr>
86
+		</tbody>
87
+	</table>
88
+</body>
89
+</html>

+ 84
- 0
inc/mail_templates/visitor_approval.html View File

@@ -0,0 +1,84 @@
1
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
+   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+<html xmlns:v="urn:schemas-microsoft-com:vml">
4
+<head>
5
+	<subject>[#blog_title#] - Contribution reviewed</subject>
6
+	<meta http-equiv="content-type" content="text/html, charset=utf-8">
7
+	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
8
+	<link href='https://fonts.googleapis.com/css?family=Questrial' rel='stylesheet' type='text/css'>
9
+</head>
10
+<body leftmargin="0" rightmargin="0" marginwidth="0" marginheight="0">
11
+	<table bgcolor="#0385F4" width="100%" border="0" cellpadding="0" cellspacing="0">
12
+		<tbody>
13
+			<tr>
14
+				<td>
15
+					<table align="center" width="600" border="0" cellpadding="0" cellspacing="0">
16
+						<tbody>
17
+							<tr><td height="30" style="font-size:30px; line-height:30px">&nbsp;</td></tr>
18
+							<tr>
19
+								<td align="center "style="font-family:'Questrial',Helvetica,sans-serif; text-align:center;font-size:50px;color:#fff;mso-line-height-rule:exactly;line-height:28px">#blog_title#</td>
20
+							</tr>
21
+							<tr><td height="30" style="font-size:30px; line-height:30px">&nbsp;</td></tr>
22
+							<tr>
23
+								<td align="center "style="font-family:'Questrial',Helvetica,sans-serif; text-align:center;font-size:20px;color:#fff;mso-line-height-rule:exactly;line-height:28px">Contribution approved</td>
24
+							</tr>
25
+							<tr><td height="30" style="font-size:30px; line-height:30px">&nbsp;</td></tr>
26
+						</tbody>
27
+					</table>
28
+				</td>
29
+			</tr>
30
+		</tbody>
31
+	</table>
32
+
33
+	<table bgcolor="#E3E3E3" width="100%" border="0" cellpadding="0" cellspacing="0">
34
+		<tbody>
35
+			<tr>
36
+				<td>
37
+					<table align="center" width="600" border="0" cellpadding="0" cellspacing="0">
38
+						<tbody>
39
+							<tr><td height="30" style="font-size:30px; line-height:30px">&nbsp;</td></tr>
40
+							<tr>
41
+								<td align="center "style="font-family:'Questrial',Helvetica,sans-serif; text-align:center;color:#262626;mso-line-height-rule:exactly;line-height:28px">
42
+									<strong>Dear #visitor_name#</strong>
43
+								</td>
44
+							</tr>
45
+							<tr><td height="30" style="font-size:30px; line-height:30px">&nbsp;</td></tr>
46
+							<tr>
47
+								<td align="center "style="font-family:'Questrial',Helvetica,sans-serif; text-align:center;color:#262626;mso-line-height-rule:exactly;line-height:28px">
48
+									#admin_message#
49
+								</td>
50
+							</tr>
51
+							<tr><td height="30" style="font-size:30px; line-height:30px">&nbsp;</td></tr>
52
+							<tr>
53
+								<td align="center "style="font-family:'Questrial',Helvetica,sans-serif; text-align:center;color:#262626;mso-line-height-rule:exactly;line-height:28px">
54
+									<a href="#post_url#" style="color:#262626">#post_title#</a>
55
+								</td>
56
+							</tr>
57
+							<tr><td height="30" style="font-size:30px; line-height:30px">&nbsp;</td></tr>
58
+							<tr>
59
+								<td align="center "style="font-family:'Questrial',Helvetica,sans-serif; text-align:center;color:#262626;mso-line-height-rule:exactly;line-height:28px">
60
+									<table align="center" bgcolor="#0385F4" width="100" border="0" cellpadding="0" cellspacing="0">
61
+										<tbody><tr><td height="4" style="font-size:4px; line-height:4px">&nbsp;</td></tr></tbody>
62
+									</table>
63
+								</td>
64
+							</tr>
65
+							<tr><td height="30" style="font-size:30px; line-height:30px">&nbsp;</td></tr>
66
+							<tr>
67
+								<td align="center "style="font-family:'Questrial',Helvetica,sans-serif; text-align:center;color:#262626;mso-line-height-rule:exactly;line-height:28px">
68
+									#blog_title# team
69
+								</td>
70
+							</tr>
71
+							<tr>
72
+								<td align="center "style="font-family:'Questrial',Helvetica,sans-serif; text-align:center;color:#262626;mso-line-height-rule:exactly;line-height:28px">
73
+									Regards
74
+								</td>
75
+							</tr>
76
+							<tr><td height="30" style="font-size:30px; line-height:30px">&nbsp;</td></tr>
77
+						</tbody>
78
+					</table>
79
+				</td>
80
+			</tr>
81
+		</tbody>
82
+	</table>
83
+</body>
84
+</html>

+ 95
- 0
inc/mail_templates/visitor_submition.html View File

@@ -0,0 +1,95 @@
1
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
+   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+<html xmlns:v="urn:schemas-microsoft-com:vml">
4
+<head>
5
+	<subject>[#blog_title#] - Contribution submited</subject>
6
+	<meta http-equiv="content-type" content="text/html, charset=utf-8">
7
+	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
8
+	<link href='https://fonts.googleapis.com/css?family=Questrial' rel='stylesheet' type='text/css'>
9
+</head>
10
+<body leftmargin="0" rightmargin="0" marginwidth="0" marginheight="0">
11
+	<table bgcolor="#0385F4" width="100%" border="0" cellpadding="0" cellspacing="0">
12
+		<tbody>
13
+			<tr>
14
+				<td>
15
+					<table align="center" width="600" border="0" cellpadding="0" cellspacing="0">
16
+						<tbody>
17
+							<tr><td height="30" style="font-size:30px; line-height:30px">&nbsp;</td></tr>
18
+							<tr>
19
+								<td align="center "style="font-family:'Questrial',Helvetica,sans-serif; text-align:center;font-size:50px;color:#fff;mso-line-height-rule:exactly;line-height:28px">#blog_title#</td>
20
+							</tr>
21
+							<tr><td height="30" style="font-size:30px; line-height:30px">&nbsp;</td></tr>
22
+							<tr>
23
+								<td align="center "style="font-family:'Questrial',Helvetica,sans-serif; text-align:center;font-size:20px;color:#fff;mso-line-height-rule:exactly;line-height:28px">Contribution submited</td>
24
+							</tr>
25
+							<tr><td height="30" style="font-size:30px; line-height:30px">&nbsp;</td></tr>
26
+						</tbody>
27
+					</table>
28
+				</td>
29
+			</tr>
30
+		</tbody>
31
+	</table>
32
+
33
+	<table bgcolor="#E3E3E3" width="100%" border="0" cellpadding="0" cellspacing="0">
34
+		<tbody>
35
+			<tr>
36
+				<td>
37
+					<table align="center" width="600" border="0" cellpadding="0" cellspacing="0">
38
+						<tbody>
39
+							<tr><td height="30" style="font-size:30px; line-height:30px">&nbsp;</td></tr>
40
+							<tr>
41
+								<td align="center "style="font-family:'Questrial',Helvetica,sans-serif; text-align:center;color:#262626;mso-line-height-rule:exactly;line-height:28px">
42
+									<strong>Dear #visitor_name#</strong>
43
+								</td>
44
+							</tr>
45
+							<tr><td height="30" style="font-size:30px; line-height:30px">&nbsp;</td></tr>
46
+							<tr>
47
+								<td align="center "style="font-family:'Questrial',Helvetica,sans-serif; text-align:center;color:#262626;mso-line-height-rule:exactly;line-height:28px">
48
+									#visitor_notif_message#
49
+								</td>
50
+							</tr>
51
+							<tr><td height="30" style="font-size:30px; line-height:30px">&nbsp;</td></tr>
52
+							<tr>
53
+								<td align="center "style="font-family:'Questrial',Helvetica,sans-serif; text-align:center;color:#262626;mso-line-height-rule:exactly;line-height:28px">
54
+									Submition details
55
+								</td>
56
+							</tr>
57
+							<tr><td height="30" style="font-size:30px; line-height:30px">&nbsp;</td></tr>
58
+							<tr>
59
+								<td align="center "style="font-family:'Questrial',Helvetica,sans-serif; text-align:center;color:#262626;mso-line-height-rule:exactly;line-height:28px">
60
+									<a href="#post_url#" style="color:#262626">#post_title#</a>
61
+								</td>
62
+							</tr>
63
+							<tr>
64
+								<td align="center "style="font-family:'Questrial',Helvetica,sans-serif; text-align:center;color:#262626;mso-line-height-rule:exactly;line-height:28px">
65
+									Submited on : #edit_time#
66
+								</td>
67
+							</tr>
68
+							<tr><td height="30" style="font-size:30px; line-height:30px">&nbsp;</td></tr>
69
+							<tr>
70
+								<td align="center "style="font-family:'Questrial',Helvetica,sans-serif; text-align:center;color:#262626;mso-line-height-rule:exactly;line-height:28px">
71
+									<table align="center" bgcolor="#0385F4" width="100" border="0" cellpadding="0" cellspacing="0">
72
+										<tbody><tr><td height="4" style="font-size:4px; line-height:4px">&nbsp;</td></tr></tbody>
73
+									</table>
74
+								</td>
75
+							</tr>
76
+							<tr><td height="30" style="font-size:30px; line-height:30px">&nbsp;</td></tr>
77
+							<tr>
78
+								<td align="center "style="font-family:'Questrial',Helvetica,sans-serif; text-align:center;color:#262626;mso-line-height-rule:exactly;line-height:28px">
79
+									#blog_title# team
80
+								</td>
81
+							</tr>
82
+							<tr>
83
+								<td align="center "style="font-family:'Questrial',Helvetica,sans-serif; text-align:center;color:#262626;mso-line-height-rule:exactly;line-height:28px">
84
+									Regards
85
+								</td>
86
+							</tr>
87
+							<tr><td height="30" style="font-size:30px; line-height:30px">&nbsp;</td></tr>
88
+						</tbody>
89
+					</table>
90
+				</td>
91
+			</tr>
92
+		</tbody>
93
+	</table>
94
+</body>
95
+</html>

+ 86
- 0
inc/main.php View File

@@ -0,0 +1,86 @@
1
+<?php 
2
+global $wpdb;
3
+$table_name = $wpdb->prefix . 'visitors_edits';
4
+if(isset($_GET["delete"])){
5
+	$wpdb->delete($table_name, array( 'edit_id' => $_GET["delete"] ) );
6
+	flashMessage("The review was deleted","danger");
7
+}
8
+if(!empty($_POST)){
9
+    wp_update_post([
10
+		"ID"=>$_POST["ID"],
11
+		"post_content"=>$_POST["post_content"]
12
+	]);
13
+	$wpdb->delete($table_name, array( 'edit_id' => $_POST["edit_id"] ) );
14
+	flashMessage("The post was updated successfully","");
15
+    //Notify visitor
16
+    if(isset($_POST["notify_visitor"])){
17
+    require 'mail.php';
18
+        $post = get_post($_POST["ID"]);
19
+        $mail = [
20
+            "visitor_name"=>$_POST["visitor_name"],
21
+            "post_title"=>$post->post_title,
22
+            "post_url"=>get_permalink($_POST["ID"]),
23
+            "blog_title" => get_bloginfo("name"),
24
+            "admin_message"=>$_POST["admin_message"]
25
+        ];
26
+        $visitor_submitionMail=new visitors_edits_EMAIL($mail,"visitor_approval");
27
+        $visitor_submitionMail->send($_POST["visitor_email"]);
28
+    }
29
+}
30
+$edits = $wpdb->get_results("SELECT * FROM ".$table_name);
31
+for ($r=0; $r <count($edits); $r++) { 
32
+	$edits[$r]->post=get_post($edits[$r]->post_id);
33
+}
34
+?>
35
+<h1 class="visitors_edits_no_data" <?php if(count($edits)==0){echo 'style="display:block"';}?>>
36
+    Emty pending list
37
+</h1>
38
+<div class="visitors_edits_pending" <?php if(count($edits)==0){echo 'style="display:none"';}?>>
39
+    <h1>Pending reviews (<?php echo count($edits);?>)</h1>
40
+    <table class="widefat pending">
41
+        <thead>
42
+            <tr>
43
+                <th>Post</th>
44
+                <th>Author</th>       
45
+                <th>Author comment</th>
46
+                <th>Date</th>
47
+                <th>Options</th>
48
+            </tr>
49
+        </thead>
50
+        <tbody>
51
+<?php
52
+for ($i=0; $i < count($edits); $i++) { 
53
+	$edit=$edits[$i];
54
+	?>
55
+       <tr>
56
+         <td><?php echo $edit->post->post_title; ?></td>
57
+         <td><?php echo $edit->visitor_name?></td>
58
+         <td>
59
+            <?php echo stripslashes($edit->visitor_comment); ?>
60
+         </td>
61
+         <td><?php
62
+         	$creationDate=date_create($edit->edit_time);
63
+         	echo date_format($creationDate,"m/d/Y")." at ".date_format($creationDate,"h:i a")
64
+         	?></td>
65
+         <td>
66
+         	<a class="button-primary" href="<?php echo menu_page_url('visitors_edits_approve',false);?>&edit=<?php echo $edit->edit_id;?>">Review</a>
67
+    		<a class="button-secondary" href="<?php echo menu_page_url('visitors_edits_main',false);?>&delete=<?php echo $edit->edit_id;?>">Delete</a>
68
+    	</td>
69
+       </tr>
70
+	<?php 
71
+}
72
+?>
73
+        </tbody>
74
+    </table>
75
+</div>
76
+<?php
77
+function flashMessage($msg,$type){
78
+    ?>
79
+    <div class="visitors_flashMessage <?php echo $type ?>">
80
+        <p>
81
+            <?php echo $msg ;?>
82
+        </p>
83
+    </div>
84
+    <?php
85
+}
86
+?>

+ 1742
- 0
inc/parser.php
File diff suppressed because it is too large
View File


+ 71
- 0
inc/settings.php View File

@@ -0,0 +1,71 @@
1
+<?php 
2
+	$options=[];
3
+	if(isset($_POST["save_settings"])){
4
+		$options=[
5
+			"admin_email"=>$_POST["admin_email"],
6
+			"notify_admin"=>$_POST["notify_admin"],
7
+			"advanced_merge"=>$_POST["advanced_merge"],
8
+			"admin_notif_message"=>$_POST["admin_notif_message"],
9
+			"visitor_notif_message"=>$_POST["visitor_notif_message"],
10
+			"edit_notify_message"=>$_POST["edit_notify_message"],
11
+			"propose_edit_link"=>$_POST["propose_edit_link"]
12
+		];
13
+		update_option( "visitors_edits_options", $options );
14
+		flashMessage("Settings saved.","");
15
+	}else{
16
+		$options=get_option( "visitors_edits_options", [
17
+			"admin_email"=>"",
18
+			"notify_admin"=>null,
19
+			"advanced_merge"=>null,
20
+			"visitor_notif_message"=>"Your suggestion was submitted.",
21
+			"admin_notif_message"=>"A new suggestion was submitted.",
22
+			"edit_notify_message"=>"Thanks for your contribution to our blog, your contribution was reviewed and approved.",
23
+			"propose_edit_link"=>"<p><a href='#post_link#'>Propose an edit</a></p>"
24
+		]);
25
+	}
26
+?>
27
+<div class="visitors_edits_admin">
28
+	<h2>Settings</h2>
29
+	<form action="" method="post">
30
+		<div class="control">
31
+			<label>Propose an edit link</label>
32
+			<input type="text" name="propose_edit_link" value="<?php echo stripcslashes($options['propose_edit_link']) ?>">
33
+		</div>
34
+		<div class="control">
35
+			<label>Admin notification message</label>
36
+			<textarea name="admin_notif_message" class="notif_message" value=""><?php echo $options['admin_notif_message'] ?></textarea>
37
+		</div>
38
+		<div class="control">
39
+			<label>Visitor notification message (On Submit)</label>
40
+			<textarea name="visitor_notif_message" class="notif_message" value=""><?php echo $options['visitor_notif_message'] ?></textarea>
41
+		</div>
42
+		<div class="control">
43
+			<label>Visitor notification message (On Review)</label>
44
+			<textarea name="edit_notify_message" class="notif_message" value=""><?php echo $options['edit_notify_message'] ?></textarea>
45
+		</div>
46
+		<div class="control">
47
+			<label>Admin email</label>
48
+			<input type="text" placeholder="Email" name="admin_email" value="<?php echo $options['admin_email'] ?>">
49
+		</div>
50
+		<div class="control">
51
+			<label><input type="checkbox" name="notify_admin" <?php echo (($options['notify_admin']==null) ? "" : "checked")?>>Notify me on new submits.</label>
52
+		</div>
53
+		<div class="control">
54
+			<label><input type="checkbox" name="advanced_merge" <?php echo (($options['advanced_merge']==null) ? "" : "checked")?>>Use deep merging.</label>
55
+		</div>
56
+		<div class="control">
57
+			<input type="submit" class="save_btn button-primary" value="Save settings" name="save_settings">
58
+		</div>
59
+	</form>
60
+</div>
61
+<?php
62
+function flashMessage($msg,$type){
63
+    ?>
64
+    <div class="visitors_flashMessage <?php echo $type ?>">
65
+        <p>
66
+            <?php echo $msg ;?>
67
+        </p>
68
+    </div>
69
+    <?php
70
+}
71
+?>

+ 8
- 0
js/admin.js View File

@@ -0,0 +1,8 @@
1
+var $notification=document.querySelector("#edit_notify_message");
2
+document.querySelector("#edit_notify_activate").addEventListener("change",function(){
3
+    if(this.checked){
4
+        $notification.style.display="block";
5
+    }else{
6
+        $notification.style.display="none";
7
+    }
8
+});

+ 121
- 0
js/approve.js View File

@@ -0,0 +1,121 @@
1
+visitors_edits_tools={
2
+    data:{},
3
+    clearTag:function(content,tag){
4
+        var regexp=RegExp("<"+tag+">.*?<\/"+tag+">", "gi");
5
+        var editedContent=content.replace(regexp,"");
6
+        return editedContent;
7
+    },
8
+    clearTag:function(content,tag){
9
+        var $contentDiv=jQuery("<div/>").html(content);
10
+        $contentDiv.find(tag).each(function(){
11
+            $tag=jQuery(this);
12
+            $tag.remove();
13
+        });
14
+        return $contentDiv.html();
15
+    },
16
+    clearTagName:function(content,tag){
17
+        var $contentDiv=jQuery("<div/>").html(content);
18
+        $contentDiv.find(tag).each(function(){
19
+            $tag=jQuery(this);
20
+            $tag.replaceWith($tag.html());
21
+        });
22
+        return $contentDiv.html();
23
+    },
24
+    clearClassName:function(content,classname){
25
+        var $contentDiv=jQuery("<div/>").html(content);
26
+        $contentDiv.find("."+classname).each(function(){
27
+            $elm=jQuery(this);
28
+            $elm.removeClass(classname);
29
+        });
30
+        return $contentDiv.html();
31
+    },
32
+    clear:function(ed){
33
+        var elt=ed.selection.getNode();
34
+        elt.remove();
35
+    },
36
+    clean:function(ed){
37
+        var elt=ed.selection.getNode();
38
+        var eltContent=elt.outerHTML;
39
+        eltContent=visitors_edits_tools.clearTagName(eltContent,"ins");
40
+        eltContent=visitors_edits_tools.clearTagName(eltContent,"del");
41
+        elt.remove();
42
+        ed.execCommand('mceInsertContent', 0, eltContent);
43
+    }
44
+};
45
+(function($){
46
+	//Create plugin
47
+	tinymce.create('tinymce.plugins.visitors_edits', {
48
+        init : function(ed, url) {
49
+            //Add buttons
50
+            ed.addButton('visitors_edits_approve', {
51
+                title : 'Approve',
52
+                cmd : 'visitors_edits_approve',
53
+                image : url + '/../img/approve.png'
54
+            });
55
+            ed.addButton('visitors_edits_reject', {
56
+                title : 'Reject',
57
+                cmd : 'visitors_edits_reject',
58
+                image : url + '/../img/reject.png',
59
+            });
60
+            ed.addButton('visitors_edits_clean', {
61
+                title : 'Clean All',
62
+                cmd : 'visitors_edits_clean',
63
+                image : url + '/../img/clean.png'
64
+            });
65
+            //Add Commands
66
+            ed.addCommand('visitors_edits_approve', function() {
67
+                var elt=ed.selection.getNode();
68
+                if(elt.tagName.toLowerCase()=="ins"){
69
+                    visitors_edits_tools.clean(ed);
70
+                }
71
+                if(elt.tagName.toLowerCase()=="del"){
72
+                    visitors_edits_tools.clear(ed);
73
+                }
74
+            });
75
+            ed.addCommand('visitors_edits_reject', function() {
76
+            	var elt=ed.selection.getNode();
77
+                if(elt.tagName.toLowerCase()=="del"){
78
+                    visitors_edits_tools.clean(ed);
79
+                }
80
+                if(elt.tagName.toLowerCase()=="ins"){
81
+                    visitors_edits_tools.clear(ed);
82
+                }
83
+            });
84
+            ed.addCommand('visitors_edits_clean',function(){
85
+            	var content=ed.getContent();
86
+            	content=visitors_edits_tools.clearTagName(content,"ins");
87
+            	content=visitors_edits_tools.clearTag(content,"del");
88
+                content=visitors_edits_tools.clearClassName(content,"diffmod");
89
+            	ed.setContent(content);
90
+            });
91
+            //Load content
92
+            setTimeout(function(){
93
+                //Procedce diff Html
94
+                var diffDiv=document.querySelector("#visitors_edits_diff");
95
+                var $diffDiv=jQuery(diffDiv);
96
+                $diffDiv.find("ins").each(function(){
97
+                    var $ins=$(this);
98
+                    if([""," "].indexOf($ins.html())>-1){
99
+                        $ins.remove();
100
+                    }
101
+                });
102
+                ed.setContent($diffDiv.html());
103
+                //Clean content
104
+                var $diffDiv=jQuery("<div/>").html(ed.getContent());
105
+                $diffDiv.find("p").each(function(){
106
+                    var $p=$(this);
107
+                    if(["&nbsp;"].indexOf($p.html())>-1){
108
+                        $p.remove();
109
+                    }
110
+                });
111
+                ed.setContent($diffDiv.html());
112
+            },0);
113
+        },
114
+    });
115
+    // Register plugin
116
+    tinymce.PluginManager.add( 'visitors_edits', tinymce.plugins.visitors_edits );
117
+})(jQuery);
118
+function editSubmit(){
119
+	tinyMCE.activeEditor.execCommand("visitors_edits_clean");
120
+	return true;
121
+}

+ 41
- 0
js/editor.js View File

@@ -0,0 +1,41 @@
1
+var validateEdit={
2
+	container:jQuery("#submit_fields_error"),
3
+	validateRules:{
4
+		name:{
5
+			required:true,
6
+			msg:"Name field required"
7
+		},
8
+		email:{
9
+			required:true,
10
+			msg:"Email field required"
11
+		},
12
+		comment:{
13
+			required:true,
14
+			msg:"Please describe your edit to speed up the approval"
15
+		}
16
+	},
17
+	run:function(){
18
+		var errors=[];
19
+		jQuery.each(this.validateRules, function(id, rule) {
20
+		    var element=jQuery("#"+id);
21
+		    if(rule.required && element.val()===""){
22
+		    	errors.push(id);
23
+		    }
24
+		});
25
+		if(errors.length){
26
+			this.container.html("");
27
+			for (var i = 0; i < errors.length; i++) {
28
+				this.container.append("<li>"+this.validateRules[errors[i]].msg+"</li>")
29
+			}
30
+			return false;
31
+		}else{
32
+			return true;
33
+		}
34
+	},init:function(){
35
+		jQuery.each(this.validateRules, function(id, rule) {
36
+		    var element=jQuery("#"+id);
37
+		    element.val("");
38
+		});
39
+	}
40
+}
41
+validateEdit.init();

+ 4
- 0
js/jquery.js
File diff suppressed because it is too large
View File


+ 1532
- 0
js/jquery.validate.js
File diff suppressed because it is too large
View File


+ 7
- 0
vendor/autoload.php View File

@@ -0,0 +1,7 @@
1
+<?php
2
+
3
+// autoload.php @generated by Composer
4
+
5
+require_once __DIR__ . '/composer' . '/autoload_real.php';
6
+
7
+return ComposerAutoloaderInit8a728e750e2d17f1173f31bda205adec::getLoader();

+ 145
- 0
vendor/caxy/php-htmldiff/CHANGELOG.md View File

@@ -0,0 +1,145 @@
1
+# Change Log
2
+
3
+## [v0.1.1](https://github.com/caxy/php-htmldiff/tree/v0.1.1) (2016-03-16)
4
+[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.1.0...v0.1.1)
5
+
6
+**Features and Enhancements:**
7
+
8
+- Update TableDiff HTMLPurifier Initialization [\#35](https://github.com/caxy/php-htmldiff/pull/35) ([dbergunder](https://github.com/dbergunder))
9
+
10
+**Miscellaneous:**
11
+
12
+- Update the README and add additional documentation [\#34](https://github.com/caxy/php-htmldiff/pull/34) ([jschroed91](https://github.com/jschroed91))
13
+
14
+## [0.1.0](https://github.com/caxy/php-htmldiff/tree/0.1.0) (2016-03-10)
15
+
16
+[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.14...0.1.0)
17
+
18
+**Features and Enhancements:**
19
+
20
+- 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))
21
+- Create configuration class for HtmlDiff config options [\#32](https://github.com/caxy/php-htmldiff/pull/32) ([jschroed91](https://github.com/jschroed91))
22
+- New Feature: Table Diffing [\#31](https://github.com/caxy/php-htmldiff/pull/31) ([jschroed91](https://github.com/jschroed91))
23
+- 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))
24
+- 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))
25
+
26
+## [0.1.0-beta.1](https://github.com/caxy/php-htmldiff/tree/0.1.0-beta.1) (2016-02-26)
27
+[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.14...0.1.0-beta.1)
28
+
29
+**Features and Enhancements:**
30
+
31
+- New Feature: Table Diffing [\#31](https://github.com/caxy/php-htmldiff/pull/31) ([jschroed91](https://github.com/jschroed91))
32
+- 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))
33
+- 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))
34
+
35
+## [0.0.14](https://github.com/caxy/php-htmldiff/tree/0.0.14) (2016-02-03)
36
+[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.13...0.0.14)
37
+
38
+**Fixed bugs:**
39
+
40
+- Fix HtmlDiff matching logic skipping over single word matches [\#25](https://github.com/caxy/php-htmldiff/pull/25) ([jschroed91](https://github.com/jschroed91))
41
+
42
+## [0.0.13](https://github.com/caxy/php-htmldiff/tree/0.0.13) (2016-01-12)
43
+[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.12...0.0.13)
44
+
45
+**Fixed bugs:**
46
+
47
+- Misc. list diffing updates and fixes [\#24](https://github.com/caxy/php-htmldiff/pull/24) ([jschroed91](https://github.com/jschroed91))
48
+- Updated list diff class to maintain the tags on lists. [\#23](https://github.com/caxy/php-htmldiff/pull/23) ([adamCaxy](https://github.com/adamCaxy))
49
+
50
+## [0.0.12](https://github.com/caxy/php-htmldiff/tree/0.0.12) (2015-11-11)
51
+[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.11...0.0.12)
52
+
53
+**Fixed bugs:**
54
+
55
+- feature-list\_diffing-new [\#20](https://github.com/caxy/php-htmldiff/pull/20) ([adamCaxy](https://github.com/adamCaxy))
56
+
57
+## [0.0.11](https://github.com/caxy/php-htmldiff/tree/0.0.11) (2015-11-06)
58
+[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.10...0.0.11)
59
+
60
+**Features and Enhancements:**
61
+
62
+- Feature list diffing new [\#19](https://github.com/caxy/php-htmldiff/pull/19) ([adamCaxy](https://github.com/adamCaxy))
63
+
64
+## [0.0.10](https://github.com/caxy/php-htmldiff/tree/0.0.10) (2015-10-21)
65
+[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.9...0.0.10)
66
+
67
+**Fixed bugs:**
68
+
69
+- 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))
70
+
71
+## [0.0.9](https://github.com/caxy/php-htmldiff/tree/0.0.9) (2015-10-20)
72
+[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.8...0.0.9)
73
+
74
+**Fixed bugs:**
75
+
76
+- 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))
77
+
78
+## [0.0.8](https://github.com/caxy/php-htmldiff/tree/0.0.8) (2015-10-20)
79
+[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.7...0.0.8)
80
+
81
+**Fixed bugs:**
82
+
83
+- 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))
84
+
85
+## [0.0.7](https://github.com/caxy/php-htmldiff/tree/0.0.7) (2015-10-20)
86
+[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.6...0.0.7)
87
+
88
+**Features and Enhancements:**
89
+
90
+- Created ListDiff class to handle diffing of lists. [\#14](https://github.com/caxy/php-htmldiff/pull/14) ([adamCaxy](https://github.com/adamCaxy))
91
+
92
+## [0.0.6](https://github.com/caxy/php-htmldiff/tree/0.0.6) (2015-09-11)
93
+[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.5...0.0.6)
94
+
95
+**Features and Enhancements:**
96
+
97
+- Feature - html tag isolation [\#12](https://github.com/caxy/php-htmldiff/pull/12) ([jschroed91](https://github.com/jschroed91))
98
+- 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))
99
+
100
+## [0.0.5](https://github.com/caxy/php-htmldiff/tree/0.0.5) (2015-03-03)
101
+[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.4...0.0.5)
102
+
103
+**Features and Enhancements:**
104
+
105
+- Support derived classes [\#10](https://github.com/caxy/php-htmldiff/pull/10) ([mkalkbrenner](https://github.com/mkalkbrenner))
106
+
107
+## [0.0.4](https://github.com/caxy/php-htmldiff/tree/0.0.4) (2015-01-09)
108
+[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.3...0.0.4)
109
+
110
+**Fixed bugs:**
111
+
112
+- 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))
113
+
114
+## [0.0.3](https://github.com/caxy/php-htmldiff/tree/0.0.3) (2015-01-08)
115
+[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.2...0.0.3)
116
+
117
+**Features and Enhancements:**
118
+
119
+- 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))
120
+- Updated demo to accept input and diff on the fly [\#5](https://github.com/caxy/php-htmldiff/pull/5) ([jschroed91](https://github.com/jschroed91))
121
+
122
+## [0.0.2](https://github.com/caxy/php-htmldiff/tree/0.0.2) (2014-08-12)
123
+[Full Changelog](https://github.com/caxy/php-htmldiff/compare/0.0.1...0.0.2)
124
+
125
+**Features and Enhancements:**
126
+
127
+- 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))
128
+
129
+**Fixed bugs:**
130
+
131
+- Fix error caused when passing empty array into setSpecialCaseTags [\#7](https://github.com/caxy/php-htmldiff/pull/7) ([jschroed91](https://github.com/jschroed91))
132
+
133
+## [0.0.1](https://github.com/caxy/php-htmldiff/tree/0.0.1) (2014-07-31)
134
+**Features and Enhancements:**
135
+
136
+- Added static properties for the default config variables [\#4](https://github.com/caxy/php-htmldiff/pull/4) ([jschroed91](https://github.com/jschroed91))
137
+- Feature nonpartial word diffing [\#3](https://github.com/caxy/php-htmldiff/pull/3) ([jschroed91](https://github.com/jschroed91))
138
+- Added option to group together diffed words in output [\#2](https://github.com/caxy/php-htmldiff/pull/2) ([jschroed91](https://github.com/jschroed91))
139
+
140
+
141
+
142
+\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
143
+
144
+
145
+\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*

+ 74
- 0
vendor/caxy/php-htmldiff/CODE_OF_CONDUCT.md View File

@@ -0,0 +1,74 @@
1
+# Contributor Covenant Code of Conduct
2
+
3
+## Our Pledge
4
+
5
+In the interest of fostering an open and welcoming environment, we as
6
+contributors and maintainers pledge to making participation in our project and
7
+our community a harassment-free experience for everyone, regardless of age, body
8
+size, disability, ethnicity, gender identity and expression, level of experience,
9
+nationality, personal appearance, race, religion, or sexual identity and
10
+orientation.
11
+
12
+## Our Standards
13
+
14
+Examples of behavior that contributes to creating a positive environment
15
+include:
16
+
17
+* Using welcoming and inclusive language
18
+* Being respectful of differing viewpoints and experiences
19
+* Gracefully accepting constructive criticism
20
+* Focusing on what is best for the community
21
+* Showing empathy towards other community members
22
+
23
+Examples of unacceptable behavior by participants include:
24
+
25
+* The use of sexualized language or imagery and unwelcome sexual attention or
26
+advances
27
+* Trolling, insulting/derogatory comments, and personal or political attacks
28
+* Public or private harassment
29
+* Publishing others' private information, such as a physical or electronic
30
+  address, without explicit permission
31
+* Other conduct which could reasonably be considered inappropriate in a
32
+  professional setting
33
+
34
+## Our Responsibilities
35
+
36
+Project maintainers are responsible for clarifying the standards of acceptable
37
+behavior and are expected to take appropriate and fair corrective action in
38
+response to any instances of unacceptable behavior.
39
+
40
+Project maintainers have the right and responsibility to remove, edit, or
41
+reject comments, commits, code, wiki edits, issues, and other contributions
42
+that are not aligned to this Code of Conduct, or to ban temporarily or
43
+permanently any contributor for other behaviors that they deem inappropriate,
44
+threatening, offensive, or harmful.
45
+
46
+## Scope
47
+
48
+This Code of Conduct applies both within project spaces and in public spaces
49
+when an individual is representing the project or its community. Examples of
50
+representing a project or community include using an official project e-mail
51
+address, posting via an official social media account, or acting as an appointed
52
+representative at an online or offline event. Representation of a project may be
53
+further defined and clarified by project maintainers.
54
+
55
+## Enforcement
56
+
57
+Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+reported by contacting the project team at dev@caxy.com. All
59
+complaints will be reviewed and investigated and will result in a response that
60
+is deemed necessary and appropriate to the circumstances. The project team is
61
+obligated to maintain confidentiality with regard to the reporter of an incident.
62
+Further details of specific enforcement policies may be posted separately.
63
+
64
+Project maintainers who do not follow or enforce the Code of Conduct in good
65
+faith may face temporary or permanent repercussions as determined by other
66
+members of the project's leadership.
67
+
68
+## Attribution
69
+
70
+This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+[homepage]: http://contributor-covenant.org
74
+[version]: http://contributor-covenant.org/version/1/4/

+ 33
- 0
vendor/caxy/php-htmldiff/CONTRIBUTING.md View File

@@ -0,0 +1,33 @@
1
+Contributing
2
+============
3
+
4
+First of all, **thank you** for contributing, **you are awesome**!
5
+
6
+Here are a few rules to follow in order to ease code reviews, and discussions before
7
+maintainers accept and merge your work.
8
+
9
+You MUST follow the [PSR-1](http://www.php-fig.org/psr/1/) and
10
+[PSR-2](http://www.php-fig.org/psr/2/). If you don't know about any of them, you
11
+should really read the recommendations. Can't wait? Use the [PHP-CS-Fixer
12
+tool](http://cs.sensiolabs.org/).
13
+
14
+You MUST run the test suite.
15
+
16
+You MUST write (or update) unit tests.
17
+
18
+You SHOULD write documentation.
19
+
20
+Please, write [commit messages that make
21
+sense](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html),
22
+and [rebase your branch](http://git-scm.com/book/en/Git-Branching-Rebasing)
23
+before submitting your Pull Request.
24
+
25
+One may ask you to [squash your
26
+commits](http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html)
27
+too. This is used to "clean" your Pull Request before merging it (we don't want
28
+commits such as `fix tests`, `fix 2`, `fix 3`, etc.).
29
+
30
+Also, while creating your Pull Request on GitHub, you MUST write a description
31
+which gives the context and/or explains why you are creating it.
32
+
33
+Thank you!

+ 130
- 0
vendor/caxy/php-htmldiff/LICENSE View File

@@ -0,0 +1,130 @@
1
+GNU GENERAL PUBLIC LICENSE
2
+
3
+Version 2, June 1991
4
+
5
+Copyright (C) 1989, 1991 Free Software Foundation, Inc.  
6
+51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
7
+
8
+Everyone is permitted to copy and distribute verbatim copies
9
+of this license document, but changing it is not allowed.
10
+Preamble
11
+
12
+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.
13
+
14
+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.
15
+
16
+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.
17
+
18
+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.
19
+
20
+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.
21
+
22
+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.
23
+
24
+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.
25
+
26
+The precise terms and conditions for copying, distribution and modification follow.
27
+
28
+TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
29
+
30
+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".
31
+
32
+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.
33
+
34
+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.
35
+
36
+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.
37
+
38
+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:
39
+
40
+a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.
41
+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.
42
+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.)
43
+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.
44
+
45
+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.
46
+
47
+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.
48
+
49
+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:
50
+
51
+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,
52
+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,
53
+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.)
54
+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.
55
+
56
+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.
57
+
58
+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.
59
+
60
+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.
61
+
62
+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.
63
+
64
+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.
65
+
66
+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.
67
+
68
+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.
69
+
70
+This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
71
+
72
+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.
73
+
74
+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.
75
+
76
+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.
77
+
78
+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.
79
+
80
+NO WARRANTY
81
+
82
+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.
83
+
84
+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.
85
+
86
+END OF TERMS AND CONDITIONS
87
+
88
+How to Apply These Terms to Your New Programs
89
+
90
+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.
91
+
92
+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.
93
+
94
+one line to give the program's name and an idea of what it does.
95
+Copyright (C) yyyy  name of author
96
+
97
+This program is free software; you can redistribute it and/or
98
+modify it under the terms of the GNU General Public License
99
+as published by the Free Software Foundation; either version 2
100
+of the License, or (at your option) any later version.
101
+
102
+This program is distributed in the hope that it will be useful,
103
+but WITHOUT ANY WARRANTY; without even the implied warranty of
104
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
105
+GNU General Public License for more details.
106
+
107
+You should have received a copy of the GNU General Public License
108
+along with this program; if not, write to the Free Software
109
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
110
+Also add information on how to contact you by electronic and paper mail.
111
+
112
+If the program is interactive, make it output a short notice like this when it starts in an interactive mode:
113
+
114
+Gnomovision version 69, Copyright (C) year name of author
115
+Gnomovision comes with ABSOLUTELY NO WARRANTY; for details
116
+type `show w'.  This is free software, and you are welcome
117
+to redistribute it under certain conditions; type `show c' 
118
+for details.
119
+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.
120
+
121
+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:
122
+
123
+Yoyodyne, Inc., hereby disclaims all copyright
124
+interest in the program `Gnomovision'
125
+(which makes passes at compilers) written 
126
+by James Hacker.
127
+
128
+signature of Ty Coon, 1 April 1989
129
+Ty Coon, President of Vice
130
+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.

+ 201
- 0
vendor/caxy/php-htmldiff/README.md View File

@@ -0,0 +1,201 @@
1
+php-htmldiff
2
+============
3
+
4
+[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/caxy/php-htmldiff/badges/quality-score.png?b=master)][badge_score]
5
+[![Build Status](https://scrutinizer-ci.com/g/caxy/php-htmldiff/badges/build.png?b=master)][badge_status]
6
+[![Code Coverage](https://scrutinizer-ci.com/g/caxy/php-htmldiff/badges/coverage.png?b=master)][badge_coverage]
7
+[![Packagist](https://img.shields.io/packagist/dt/caxy/php-htmldiff.svg)][badge_packagist]
8
+[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/caxy/php-htmldiff.svg)][badge_resolve]
9
+[![Percentage of issues still open](http://isitmaintained.com/badge/open/caxy/php-htmldiff.svg)][badge_issues]
10
+
11
+php-htmldiff is a library for comparing two HTML files/snippets and highlighting the differences using simple HTML.
12
+
13
+This HTML Diff implementation was forked from [rashid2538/php-htmldiff][upstream] and has been modified with new features,
14
+bug fixes, and enhancements to the original code.
15
+
16
+For more information on these modifications, read the [differences from rashid2538/php-htmldiff][differences] or view the [CHANGELOG][changelog].
17
+
18
+## Installation
19
+
20
+The recommended way to install php-htmldiff is through [Composer][composer].
21
+Require the [caxy/php-htmldiff][badge_packagist] package by running following command:
22
+
23
+```sh
24
+composer require caxy/php-htmldiff
25
+```
26
+
27
+This will resolve the latest stable version.
28
+
29
+Otherwise, install the library and setup the autoloader yourself.
30
+
31
+### Working with Symfony
32
+
33
+If you are using Symfony, you can use the [caxy/HtmlDiffBundle][htmldiffbundle] to make life easy!
34
+
35
+## Usage
36
+
37
+```php
38
+use Caxy\HtmlDiff\HtmlDiff;
39
+
40
+$htmlDiff = new HtmlDiff($oldHtml, $newHtml);
41
+$content = $htmlDiff->build();
42
+```
43
+
44
+## Configuration
45
+
46
+The configuration for HtmlDiff is contained in the `Caxy\HtmlDiff\HtmlDiffConfig` class.
47
+
48
+There are two ways to set the configuration:
49
+
50
+1. [Configure an Existing HtmlDiff Object](#configure-an-existing-htmldiff-object)
51
+2. [Create and Use a HtmlDiffConfig Object](#create-and-use-a-htmldiffconfig-object)
52
+
53
+#### Configure an Existing HtmlDiff Object
54
+
55
+When a new `HtmlDiff` object is created, it creates a `HtmlDiffConfig` object with the default configuration.
56
+You can change the configuration using setters on the object:
57
+
58
+```php
59
+use Caxy\HtmlDiff\HtmlDiff;
60
+
61
+// ...
62
+
63
+$htmlDiff = new HtmlDiff($oldHtml, $newHtml);
64
+
65
+// Set some of the configuration options.
66
+$htmlDiff->getConfig()
67
+    ->setMatchThreshold(80)
68
+    ->setInsertSpaceInReplace(true)
69
+;
70
+
71
+// Calculate the differences using the configuration and get the html diff.
72
+$content = $htmlDiff->build();
73
+
74
+// ...
75
+
76
+```
77
+
78
+#### Create and Use a HtmlDiffConfig Object
79
+
80
+You can also set the configuration by creating an instance of
81
+`Caxy\HtmlDiff\HtmlDiffConfig` and using it when creating a new `HtmlDiff`
82
+object using `HtmlDiff::create`.
83
+
84
+This is useful when creating more than one instance of `HtmlDiff`:
85
+
86
+```php
87
+use Caxy\HtmlDiff\HtmlDiff;
88
+use Caxy\HtmlDiff\HtmlDiffConfig;
89
+
90
+// ...
91
+
92
+$config = new HtmlDiffConfig();
93
+$config
94
+    ->setMatchThreshold(95)
95
+    ->setInsertSpaceInReplace(true)
96
+;
97
+
98
+// Create an HtmlDiff object with the custom configuration.
99
+$firstHtmlDiff = HtmlDiff::create($oldHtml, $newHtml, $config);
100
+$firstContent = $firstHtmlDiff->build();
101
+
102
+$secondHtmlDiff = HtmlDiff::create($oldHtml2, $newHtml2, $config);
103
+$secondHtmlDiff->getConfig()->setMatchThreshold(50);
104
+
105
+$secondContent = $secondHtmlDiff->build();
106
+
107
+// ...
108
+```
109
+
110
+#### Full Configuration with Defaults:
111
+
112
+```php
113
+
114
+$config = new HtmlDiffConfig();
115
+$config
116
+    // Percentage required for list items to be considered a match.
117
+    ->setMatchThreshold(80)
118
+    
119
+    // Set the encoding of the text to be diffed.
120
+    ->setEncoding('UTF-8')
121
+    
122
+    // If true, a space will be added between the <del> and <ins> tags of text that was replaced.
123
+    ->setInsertSpaceInReplace(false)
124
+    
125
+    // Option to disable the new Table Diffing feature and treat tables as regular text.
126
+    ->setUseTableDiffing(true)
127
+    
128
+    // Pass an instance of \Doctrine\Common\Cache\Cache to cache the calculated diffs.
129
+    ->setCacheProvider(null)
130
+    
131
+    // Set the cache directory that HTMLPurifier should use.
132
+    ->setPurifierCacheLocation(null)
133
+    
134
+    // Group consecutive deletions and insertions instead of showing a deletion and insertion for each word individually. 
135
+    ->setGroupDiffs(true)
136
+    
137
+    // List of characters to consider part of a single word when in the middle of text.
138
+    ->setSpecialCaseChars(array('.', ',', '(', ')', '\''))
139
+    
140
+    // List of tags to treat as special case tags.
141
+    ->setSpecialCaseTags(array('strong', 'b', 'i', 'big', 'small', 'u', 'sub', 'sup', 'strike', 's', 'p'))
142
+    
143
+    // List of tags (and their replacement strings) to be diffed in isolation.
144
+    ->setIsolatedDiffTags(array(
145
+        'ol'     => '[[REPLACE_ORDERED_LIST]]',
146
+        'ul'     => '[[REPLACE_UNORDERED_LIST]]',
147
+        'sub'    => '[[REPLACE_SUB_SCRIPT]]',
148
+        'sup'    => '[[REPLACE_SUPER_SCRIPT]]',
149
+        'dl'     => '[[REPLACE_DEFINITION_LIST]]',
150
+        'table'  => '[[REPLACE_TABLE]]',
151
+        'strong' => '[[REPLACE_STRONG]]',
152
+        'b'      => '[[REPLACE_B]]',
153
+        'em'     => '[[REPLACE_EM]]',
154
+        'i'      => '[[REPLACE_I]]',
155
+        'a'      => '[[REPLACE_A]]',
156
+    ))
157
+;
158
+
159
+```
160
+
161
+## Contributing
162
+
163
+See [CONTRIBUTING][contributing] file.
164
+
165
+## Contributor Code of Conduct
166
+
167
+Please note that this project is released with a [Contributor Code of
168
+Conduct][contributor_covenant]. By participating in this project
169
+you agree to abide by its terms. See [CODE_OF_CONDUCT][code_of_conduct] file.
170
+
171
+## Credits
172
+
173
+* [rashid2538][] for the port to PHP and the base for our project: [rashid2538/php-htmldiff][upstream]
174
+* [willdurand][] for an excellent post on [open sourcing libraries][].
175
+Much of this documentation is based off of the examples in the post.
176
+
177
+Did we miss anyone? If we did, let us know or put in a pull request!
178
+
179
+## License
180
+
181
+php-htmldiff is available under [GNU General Public License, version 2][gnu]. See the [LICENSE][license] file for details.
182
+
183
+[badge_score]: https://scrutinizer-ci.com/g/caxy/php-htmldiff/?branch=master
184
+[badge_status]: https://scrutinizer-ci.com/g/caxy/php-htmldiff/build-status/master
185
+[badge_coverage]: https://scrutinizer-ci.com/g/caxy/php-htmldiff/?branch=master
186
+[badge_packagist]: https://packagist.org/packages/caxy/php-htmldiff
187
+[badge_resolve]: http://isitmaintained.com/project/caxy/php-htmldiff "Average time to resolve an issue"
188
+[badge_issues]: http://isitmaintained.com/project/caxy/php-htmldiff "Percentage of issues still open"
189
+[upstream]: https://github.com/rashid2538/php-htmldiff
190
+[htmldiffbundle]: https://github.com/caxy/HtmlDiffBundle
191
+[differences]: https://github.com/caxy/php-htmldiff/blob/master/doc/differences.rst
192
+[changelog]: https://github.com/caxy/php-htmldiff/blob/master/CHANGELOG.md
193
+[contributing]: https://github.com/caxy/php-htmldiff/blob/master/CONTRIBUTING.md
194
+[gnu]: http://www.gnu.org/licenses/gpl-2.0.html
195
+[license]: https://github.com/caxy/php-htmldiff/blob/master/LICENSE
196
+[code_of_conduct]: https://github.com/caxy/php-htmldiff/blob/master/CODE_OF_CONDUCT.md
197
+[composer]: http://getcomposer.org/
198
+[contributor_covenant]: http://contributor-covenant.org/
199
+[rashid2538]: https://github.com/rashid2538
200
+[willdurand]: https://github.com/willdurand
201
+[open sourcing libraries]: http://williamdurand.fr/2013/07/04/on-open-sourcing-libraries/

+ 43
- 0
vendor/caxy/php-htmldiff/composer.json View File

@@ -0,0 +1,43 @@
1
+{
2
+    "name": "caxy/php-htmldiff",
3
+    "type": "library",
4
+    "description": "A library for comparing two HTML files/snippets and highlighting the differences using simple HTML.",
5
+    "keywords": [
6
+        "diff",
7
+        "html"
8
+    ],
9
+    "homepage": "https://github.com/caxy/php-htmldiff",
10
+    "license": "GPL-2.0",
11
+    "authors": [
12
+        {
13
+            "name": "Josh Schroeder",
14
+            "email": "jschroeder@caxy.com",
15
+            "homepage": "http://www.caxy.com"
16
+        }
17
+    ],
18
+    "support": {
19
+        "issues": "https://github.com/caxy/php-htmldiff/issues"
20
+    },
21
+    "require": {
22
+        "php": ">=5.3.3",
23
+        "ezyang/htmlpurifier": "^4.7"
24
+    },
25
+    "require-dev": {
26
+        "phpunit/phpunit": "~4.8",
27
+        "doctrine/cache": "~1.0"
28
+    },
29
+    "suggest": {
30
+        "doctrine/cache": "Used for caching the calculated diffs using a Doctrine Cache Provider"
31
+    },
32
+    "autoload": {
33
+        "psr-0": { "Caxy\\HtmlDiff": "lib/" }
34
+    },
35
+    "autoload-dev": {
36
+        "psr-4": { "Caxy\\Tests\\": "tests/Caxy/Tests" }
37
+    },
38
+    "extra": {
39
+        "branch-alias": {
40
+            "dev-master": "0.1.x-dev"
41
+        }
42
+    }
43
+}

+ 1
- 0
vendor/caxy/php-htmldiff/demo/README.md View File

@@ -0,0 +1 @@
1
+Just write the code as shown in php file and enjoy.

+ 16
- 0
vendor/caxy/php-htmldiff/demo/bower.json View File

@@ -0,0 +1,16 @@
1
+{
2
+  "name": "php-htmldiff-demo",
3
+  "dependencies": {
4
+    "bootstrap": "v4.0.0-alpha.2",
5
+    "angular": "1.5.0",
6
+    "clipboard": "^1.5.8",
7
+    "font-awesome": "^4.5.0",
8
+    "angular-sanitize": "^1.5.0",
9
+    "tether": "^1.2.0",
10
+    "ng-ckeditor": "^0.2.1",
11
+    "ckeditor": "^4.5.7",
12
+    "angular-ui": "^0.4.0",
13
+    "AngularJS-Toaster": "angularjs-toaster#^1.2.0",
14
+    "angular-bootstrap": "^1.1.2"
15
+  }
16
+}

+ 276
- 0
vendor/caxy/php-htmldiff/demo/codes.css View File

@@ -0,0 +1,276 @@
1
+/*
2
+    Document   : codes
3
+    Created on : Sep 23, 2013, 4:41:58 PM
4
+    Author     : mgersten
5
+    Description: CSS related to I-code specific display
6
+*/
7
+.diff-list > li.normal,
8
+.diff-list > li.removed,
9
+.diff-list > li.replacement{
10
+    display: table-row;
11
+}
12
+.diff-list > li.normal:before,
13
+.diff-list > li.removed:before,
14
+.diff-list > li.replacement:before{
15
+    width: 15px;
16
+    overflow: hidden;
17
+    content: counters(section,".") ". ";
18
+    display: table-cell;
19
+    text-indent: -1em;
20
+    padding-left: 1em;
21
+}
22
+
23
+/* overwrite width of :before on ballot pages */
24
+.ballot-monograph .diff-list > li.normal:before,
25
+.ballot-monograph .diff-list > li.removed:before,