af91c49d by Jeff Balicki

dd

1 parent 3546c9e4
1 <?php 1 <?php
2
2 namespace Tz\WordPress\Tools\Notifications\Settings; 3 namespace Tz\WordPress\Tools\Notifications\Settings;
3 4
4 use Tz\Common; 5 use Tz\Common;
...@@ -18,7 +19,7 @@ call_user_func( ...@@ -18,7 +19,7 @@ call_user_func(
18 19
19 Vars::$settings = new Tools\WP_Option(SETTING_NS); 20 Vars::$settings = new Tools\WP_Option(SETTING_NS);
20 21
21 Tools\add_actions(__NAMESPACE__.'\Actions'); 22 Tools\add_actions(__NAMESPACE__ . '\Actions');
22 } 23 }
23 ); 24 );
24 25
...@@ -55,10 +56,10 @@ function display_page() ...@@ -55,10 +56,10 @@ function display_page()
55 $validation->set_rules('system_message_type', 'System Message Type', 'trim'); 56 $validation->set_rules('system_message_type', 'System Message Type', 'trim');
56 57
57 foreach (['en', 'fr'] as $lang) { 58 foreach (['en', 'fr'] as $lang) {
58 $validation->set_rules($lang.'_subject', 'Subject', 'trim'); 59 $validation->set_rules($lang . '_subject', 'Subject', 'trim');
59 $validation->set_rules($lang.'_text', 'Text Version', 'trim|min_length[16]'); 60 $validation->set_rules($lang . '_text', 'Text Version', 'trim|min_length[16]');
60 $validation->set_rules($lang.'_html', 'HTML Version', 'trim|min_length[16]'); 61 $validation->set_rules($lang . '_html', 'HTML Version', 'trim|min_length[16]');
61 $validation->set_rules($lang.'_system', 'System Message', 'trim|min_length[16]'); 62 $validation->set_rules($lang . '_system', 'System Message', 'trim|min_length[16]');
62 } 63 }
63 64
64 //details 65 //details
...@@ -70,71 +71,71 @@ function display_page() ...@@ -70,71 +71,71 @@ function display_page()
70 $type = $_POST['type']; 71 $type = $_POST['type'];
71 $title = $_POST['title']; 72 $title = $_POST['title'];
72 $sendto = $_POST['sendto']; 73 $sendto = $_POST['sendto'];
73 $executeDate = ($type == 'scheduled' || $type == 'newsletter' ) ? $_POST['execute_date'] : '0000-00-00 00:00:00'; 74 $executeDate = ($type == 'scheduled' || $type == 'newsletter') ? $_POST['execute_date'] : '0000-00-00 00:00:00';
74 $trigger = ($type == 'scheduled' || $type == 'newsletter' ) ? 'scheduled-cron-job' : $_POST['trigger']; 75 $trigger = ($type == 'scheduled' || $type == 'newsletter') ? 'scheduled-cron-job' : $_POST['trigger'];
75 $style = $_POST['email_style']; 76 $style = $_POST['email_style'];
76 $emailData = []; 77 $emailData = [];
77 $systemMessageData = []; 78 $systemMessageData = [];
78 $pushMessageData = []; 79 $pushMessageData = [];
79 80
80 foreach (['en', 'fr'] as $lang) { 81 foreach (['en', 'fr'] as $lang) {
81 // email 82 // email
82 $subject = $_POST[$lang.'_subject']; 83 $subject = $_POST[$lang . '_subject'];
83 $text = $_POST[$lang.'_text']; 84 $text = $_POST[$lang . '_text'];
84 $html = $_POST[$lang.'_html']; 85 $html = $_POST[$lang . '_html'];
85 $attachments = []; 86 $attachments = [];
86 $upload_dir = wp_upload_dir(); 87 $upload_dir = wp_upload_dir();
87 $uploadDir = $upload_dir['basedir'].'/notifications/'; 88 $uploadDir = $upload_dir['basedir'] . '/notifications/';
88 89
89 fixFilesArray($_FILES[$lang.'_attachment']); 90 fixFilesArray($_FILES[$lang . '_attachment']);
90 91
91 foreach ($_FILES[$lang.'_attachment'] as $position => $file) { 92 foreach ($_FILES[$lang . '_attachment'] as $position => $file) {
92 // should output array with indices name, type, tmp_name, error, size 93 // should output array with indices name, type, tmp_name, error, size
93 if ($file['name'] != '') { 94 if ($file['name'] != '') {
94 move_uploaded_file($file['tmp_name'], $uploadDir.$file['name']); 95 move_uploaded_file($file['tmp_name'], $uploadDir . $file['name']);
95 $attachments[] = $file['name']; 96 $attachments[] = $file['name'];
96 } 97 }
97 } 98 }
98 99
99 // system 100 // system
100 $systemMessageType = $_POST['system_message_type']; 101 $systemMessageType = $_POST['system_message_type'];
101 $system = $_POST[$lang.'_system']; 102 $system = $_POST[$lang . '_system'];
102 103
103 $pushMessageTime = $_POST[$lang.'_push_notifications_time']; 104 $pushMessageTime = $_POST[$lang . '_push_notifications_time'];
104 $title = $_POST[$lang.'_push_notifications_title']; 105 $title = $_POST[$lang . '_push_notifications_title'];
105 $message = $_POST[$lang.'_push_notifications_message']; 106 $message = $_POST[$lang . '_push_notifications_message'];
106 $link = $_POST[$lang.'_push_notifications_link']; 107 $link = $_POST[$lang . '_push_notifications_link'];
107 $status = $_POST[$lang.'_push_notifications_status']; 108 $status = $_POST[$lang . '_push_notifications_status'];
108 109
109 110
110 if (count($entry->email[$lang.'_attachments']) > 0) { 111 if (count($entry->email[$lang . '_attachments']) > 0) {
111 $attachments = array_merge($entry->email[$lang.'_attachments'], $attachments); 112 $attachments = array_merge($entry->email[$lang . '_attachments'], $attachments);
112 } 113 }
113 114
114 $emailData = array_merge( 115 $emailData = array_merge(
115 $emailData, 116 $emailData,
116 [ 117 [
117 $lang.'_subject' => $subject, 118 $lang . '_subject' => $subject,
118 $lang.'_text' => $text, 119 $lang . '_text' => $text,
119 $lang.'_html' => $html, 120 $lang . '_html' => $html,
120 $lang.'_attachments' => $attachments 121 $lang . '_attachments' => $attachments
121 ] 122 ]
122 ); 123 );
123 $systemMessageData = array_merge( 124 $systemMessageData = array_merge(
124 $systemMessageData, 125 $systemMessageData,
125 [ 126 [
126 'system_message_type' => $systemMessageType, 127 'system_message_type' => $systemMessageType,
127 $lang.'_message' => $system 128 $lang . '_message' => $system
128 ] 129 ]
129 ); 130 );
130 $pushMessageData = array_merge( 131 $pushMessageData = array_merge(
131 $pushMessageData, 132 $pushMessageData,
132 [ 133 [
133 'push_message_time' => $pushMessageTime, 134 'push_message_time' => $pushMessageTime,
134 $lang.'_title' => $title, 135 $lang . '_title' => $title,
135 $lang.'_message' => $message, 136 $lang . '_message' => $message,
136 $lang.'_link' => $link, 137 $lang . '_link' => $link,
137 $lang.'_status' => $status 138 $lang . '_status' => $status
138 ] 139 ]
139 ); 140 );
140 } 141 }
...@@ -148,13 +149,13 @@ function display_page() ...@@ -148,13 +149,13 @@ function display_page()
148 'status' => $entry->details['status'], 149 'status' => $entry->details['status'],
149 'trigger' => $trigger, 150 'trigger' => $trigger,
150 'execute_date' => $executeDate 151 'execute_date' => $executeDate
151 152
152 153
153 ] 154 ]
154 ); 155 );
155 update_post_meta($id, 'send_status', $entry->details['status']); 156 update_post_meta($id, 'send_status', $entry->details['status']);
156 update_post_meta($id, 'notif_type', $type); 157 update_post_meta($id, 'notif_type', $type);
157 // update_post_meta($id, 'execute_date', mysqldatetime_to_timestamp($executeDate)); 158 // update_post_meta($id, 'execute_date', mysqldatetime_to_timestamp($executeDate));
158 update_post_meta($id, 'execute_date', strtotime($executeDate)); 159 update_post_meta($id, 'execute_date', strtotime($executeDate));
159 update_post_meta($id, 'trigger', $trigger); 160 update_post_meta($id, 'trigger', $trigger);
160 161
...@@ -181,9 +182,9 @@ function display_page() ...@@ -181,9 +182,9 @@ function display_page()
181 $entry->push = $push; 182 $entry->push = $push;
182 183
183 $flash = '<strong>Notification Saved Successfully!</strong><br /><a href=""/wp-admin/admin.php?page=notifications">Click here</a> to view all notifications.</a>'; 184 $flash = '<strong>Notification Saved Successfully!</strong><br /><a href=""/wp-admin/admin.php?page=notifications">Click here</a> to view all notifications.</a>';
184 require_once(__DIR__.'/views/form.php'); 185 require_once(__DIR__ . '/views/form.php');
185 } else { 186 } else {
186 require_once(__DIR__.'/views/form.php'); 187 require_once(__DIR__ . '/views/form.php');
187 } 188 }
188 } else { 189 } else {
189 if (isset($_GET['action']) && $_GET['action'] == 'delete') { 190 if (isset($_GET['action']) && $_GET['action'] == 'delete') {
...@@ -238,7 +239,7 @@ function display_page() ...@@ -238,7 +239,7 @@ function display_page()
238 } 239 }
239 } 240 }
240 241
241 require_once(__DIR__.'/views/admin.php'); 242 require_once(__DIR__ . '/views/admin.php');
242 } 243 }
243 } 244 }
244 245
...@@ -281,7 +282,7 @@ function fixFilesArray(&$files) ...@@ -281,7 +282,7 @@ function fixFilesArray(&$files)
281 282
282 foreach ($files as $key => $part) { 283 foreach ($files as $key => $part) {
283 // only deal with valid keys and multiple files 284 // only deal with valid keys and multiple files
284 $key = (string)$key; 285 $key = (string) $key;
285 if (isset($names[$key]) && is_array($part)) { 286 if (isset($names[$key]) && is_array($part)) {
286 foreach ($part as $position => $value) { 287 foreach ($part as $position => $value) {
287 $files[$position][$key] = $value; 288 $files[$position][$key] = $value;
...@@ -295,7 +296,7 @@ function fixFilesArray(&$files) ...@@ -295,7 +296,7 @@ function fixFilesArray(&$files)
295 function notification_settings() 296 function notification_settings()
296 { 297 {
297 298
298 require_once(__DIR__.'/views/settings.php'); 299 require_once(__DIR__ . '/views/settings.php');
299 } 300 }
300 301
301 function create_notification() 302 function create_notification()
...@@ -315,17 +316,17 @@ function create_notification() ...@@ -315,17 +316,17 @@ function create_notification()
315 $validation->set_rules('system_message_type', 'System Message Type', 'trim'); 316 $validation->set_rules('system_message_type', 'System Message Type', 'trim');
316 317
317 foreach (['en', 'fr'] as $lang) { 318 foreach (['en', 'fr'] as $lang) {
318 $validation->set_rules($lang.'_subject', 'Subject', 'trim'); 319 $validation->set_rules($lang . '_subject', 'Subject', 'trim');
319 // $validation->set_rules($lang.'_text', 'Text Version', 'trim|min_length[16]'); 320 // $validation->set_rules($lang.'_text', 'Text Version', 'trim|min_length[16]');
320 // $validation->set_rules($lang.'_html', 'HTML Version', 'trim|min_length[16]'); 321 // $validation->set_rules($lang.'_html', 'HTML Version', 'trim|min_length[16]');
321 $validation->set_rules($lang.'_text', 'Text Version', 'trim'); 322 $validation->set_rules($lang . '_text', 'Text Version', 'trim');
322 $validation->set_rules($lang.'_html', 'HTML Version', 'trim'); 323 $validation->set_rules($lang . '_html', 'HTML Version', 'trim');
323 $validation->set_rules($lang.'_system', 'System Message', 'trim|min_length[16]'); 324 $validation->set_rules($lang . '_system', 'System Message', 'trim|min_length[16]');
324 } 325 }
325 326
326 if ($_POST && ($_POST['en_subject'] == '' && $_POST['fr_subject'] == '' && $_POST['en_system'] == '' && $_POST['fr_system'] == '')) { 327 if ($_POST && ($_POST['en_subject'] == '' && $_POST['fr_subject'] == '' && $_POST['en_system'] == '' && $_POST['fr_system'] == '')) {
327 $form_error = true; 328 $form_error = true;
328 require_once(__DIR__.'/views/create.php'); 329 require_once(__DIR__ . '/views/create.php');
329 } else { 330 } else {
330 if ($validation->run() == true) { 331 if ($validation->run() == true) {
331 332
...@@ -348,146 +349,142 @@ function create_notification() ...@@ -348,146 +349,142 @@ function create_notification()
348 $sendto = $_POST['sendto']; 349 $sendto = $_POST['sendto'];
349 $executeDate = ($type == 'scheduled' || $type == 'newsletter') ? $_POST['execute_date'] : '0000-00-00 00:00:00'; 350 $executeDate = ($type == 'scheduled' || $type == 'newsletter') ? $_POST['execute_date'] : '0000-00-00 00:00:00';
350 $trigger = ($type == 'scheduled' || $type == 'newsletter') ? 'scheduled-cron-job' : $_POST['trigger']; 351 $trigger = ($type == 'scheduled' || $type == 'newsletter') ? 'scheduled-cron-job' : $_POST['trigger'];
351 $style = $_POST['email_style']; 352 $style = $_POST['email_style'];
352 $emailData = []; 353 $emailData = [];
353 $systemMessageData = []; 354 $systemMessageData = [];
354 $pushMessageData = []; 355 $pushMessageData = [];
355
356
357 356
358 357
359 358
360 359
361 360
361
362
362 363
363 foreach (['en', 'fr'] as $lang) { 364 foreach (['en', 'fr'] as $lang) {
364 // email 365 // email
365 $subject = $_POST[$lang.'_subject']; 366 $subject = $_POST[$lang . '_subject'];
366 $text = $_POST[$lang.'_text']; 367 $text = $_POST[$lang . '_text'];
367 $html = strip_word_html($_POST[$lang.'_html']); 368 $html = strip_word_html($_POST[$lang . '_html']);
368 $attachments = []; 369 $attachments = [];
369 $uploadDir = wp_upload_dir()['basedir'].'/notifications/'; 370 $uploadDir = wp_upload_dir()['basedir'] . '/notifications/';
370 371
371 fixFilesArray($_FILES[$lang.'_attachment']); 372 fixFilesArray($_FILES[$lang . '_attachment']);
372 373
373 foreach ($_FILES[$lang.'_attachment'] as $position => $file) { 374 foreach ($_FILES[$lang . '_attachment'] as $position => $file) {
374 // should output array with indices name, type, tmp_name, error, size 375 // should output array with indices name, type, tmp_name, error, size
375 if ($file['name'] != '') { 376 if ($file['name'] != '') {
376 move_uploaded_file($file['tmp_name'], $uploadDir.$file['name']); 377 move_uploaded_file($file['tmp_name'], $uploadDir . $file['name']);
377 $attachments[] = $file['name']; 378 $attachments[] = $file['name'];
378 } 379 }
379 } 380 }
380 381
381 if($style == 'newsletter'){ 382 if ($style == 'newsletter') {
382 $newletter_id = -1; 383 $newletter_id = -1;
383 $author_id = 1; 384 $author_id = 1;
384 $slug = strtolower($subject); 385 $slug = strtolower($subject);
385 386
386 if( null == get_page_by_title( $title ) ) { 387 if (null == get_page_by_title($subject)) {
387 388
388 // Set the page ID so that we know the page was created successfully 389 // Set the page ID so that we know the page was created successfully
389 $post_id = wp_insert_post( 390 $post_id = wp_insert_post(
390 array( 391 array(
391 'comment_status' => 'closed', 392 'comment_status' => 'closed',
392 'ping_status' => 'closed', 393 'ping_status' => 'closed',
393 'post_author' => '1', 394 'post_author' => '1',
394 'post_name' => $slug, 395 'post_name' => $slug,
395 'post_title' => $subject, 396 'post_title' => $subject,
396 'post_status' => 'publish', 397 'post_status' => 'publish',
397 'post_type' => 'newsLetter', 398 'post_type' => 'newsLetter',
398 'post_content' => '<div id="newsletter">'.$html.'</div>' , 399 'post_content' => '<div id="newsletter">' . $html . '</div>',
399 400
400 ) 401 )
401 ); 402 );
402 403
403 if ($post_id) { 404 if ($post_id) {
404 // https://wpml.org/wpml-hook/wpml_element_type/ 405 // https://wpml.org/wpml-hook/wpml_element_type/
405 $wpml_element_type = apply_filters( 'wpml_element_type', 'newsletter' ); 406 $wpml_element_type = apply_filters('wpml_element_type', 'newsletter');
406 407
407 // get the language info of the original post 408 // get the language info of the original post
408 // https://wpml.org/wpml-hook/wpml_element_language_details/ 409 // https://wpml.org/wpml-hook/wpml_element_language_details/
409 $get_language_args = array('element_id' => $post_id, 'element_type' => 'post_product' ); 410 $get_language_args = array('element_id' => $post_id, 'element_type' => 'post_product');
410 $original_post_language_info = apply_filters( 'wpml_element_language_details', null, $get_language_args ); 411 $original_post_language_info = apply_filters('wpml_element_language_details', null, $get_language_args);
411 412
412 $set_language_args = array( 413 $set_language_args = array(
413 'element_id' => $post_id, 414 'element_id' => $post_id,
414 'element_type' => $wpml_element_type, 415 'element_type' => $wpml_element_type,
415 'trid' => $original_post_language_info->trid, 416 'trid' => $original_post_language_info->trid,
416 'language_code' => $lang, 417 'language_code' => $lang,
417 'source_language_code' => $original_post_language_info->language_code 418 'source_language_code' => $original_post_language_info->language_code
418 ); 419 );
419 420
420 do_action( 'wpml_set_element_language_details', $set_language_args ); 421 do_action('wpml_set_element_language_details', $set_language_args);
421 } 422 }
422 423 } else {
423 } else { 424
424 425 $post_id = -2;
425 $post_id = -2; 426 }
426 427 }
427 }
428
429 }
430 428
431 // system 429 // system
432 $systemMessageType = $_POST['system_message_type']; 430 $systemMessageType = $_POST['system_message_type'];
433 $system = $_POST[$lang.'_system']; 431 $system = $_POST[$lang . '_system'];
432
433 $pushMessageTime = $_POST[$lang . '_push_notifications_time'];
434 $title = $_POST[$lang . '_push_notifications_title'];
435 $message = $_POST[$lang . '_push_notifications_message'];
436 $link = $_POST[$lang . '_push_notifications_link'];
437 $status = $_POST[$lang . '_push_notifications_status'];
434 438
435 $pushMessageTime = $_POST[$lang.'_push_notifications_time'];
436 $title = $_POST[$lang.'_push_notifications_title'];
437 $message = $_POST[$lang.'_push_notifications_message'];
438 $link = $_POST[$lang.'_push_notifications_link'];
439 $status = $_POST[$lang.'_push_notifications_status'];
440 439
441
442 440
443 $emailData = array_merge( 441 $emailData = array_merge(
444 $emailData, 442 $emailData,
445 [ 443 [
446 $lang.'_subject' => $subject, 444 $lang . '_subject' => $subject,
447 $lang.'_text' => $text, 445 $lang . '_text' => $text,
448 $lang.'_html' => $html, 446 $lang . '_html' => $html,
449 $lang.'_attachments' => $attachments, 447 $lang . '_attachments' => $attachments,
450 448
451 ] 449 ]
452 ); 450 );
453 $systemMessageData = array_merge( 451 $systemMessageData = array_merge(
454 $systemMessageData, 452 $systemMessageData,
455 [ 453 [
456 'system_message_type' => $systemMessageType, 454 'system_message_type' => $systemMessageType,
457 $lang.'_message' => $system 455 $lang . '_message' => $system
458 ] 456 ]
459 ); 457 );
460 $pushMessageData = array_merge( 458 $pushMessageData = array_merge(
461 $pushMessageData, 459 $pushMessageData,
462 [ 460 [
463 'push_message_time' => $pushMessageTime, 461 'push_message_time' => $pushMessageTime,
464 $lang.'_title' => $title, 462 $lang . '_title' => $title,
465 $lang.'_message' => $message, 463 $lang . '_message' => $message,
466 $lang.'_link' => $link, 464 $lang . '_link' => $link,
467 $lang.'_status' => $status 465 $lang . '_status' => $status
468 ] 466 ]
469 ); 467 );
470 468
471 469
472 $links[$lang] = get_permalink($post_id); 470 $links[$lang] = get_permalink($post_id);
473
474 } 471 }
475 472
476 473
477 474
478 // make post... 475 // make post...
479 $notification = new PostTemplate(); 476 $notification = new PostTemplate();
480 $notification->post_title = $title; 477 $notification->post_title = $title;
481 $notification->post_content = 'Notification created '.date( 478 $notification->post_content = 'Notification created ' . date(
482 'Y-m-d H:i:s' 479 'Y-m-d H:i:s'
483 )." --- to be sent on $executeDate"; 480 ) . " --- to be sent on $executeDate";
484 $notification->post_date_gmt = date('Y-m-d H:i:s', time()); 481 $notification->post_date_gmt = date('Y-m-d H:i:s', time());
485 482
486 $id = wp_insert_post((array)$notification); 483 $id = wp_insert_post((array) $notification);
487 484
488 if($style == 'newsletter'){ 485 if ($style == 'newsletter') {
489 update_post_meta($id, 'links', $links); 486 update_post_meta($id, 'links', $links);
490 } 487 }
491 488
492 update_post_meta( 489 update_post_meta(
493 $id, 490 $id,
...@@ -498,32 +495,26 @@ function create_notification() ...@@ -498,32 +495,26 @@ function create_notification()
498 'status' => 'pending', 495 'status' => 'pending',
499 'trigger' => $trigger, 496 'trigger' => $trigger,
500 'execute_date' => $executeDate 497 'execute_date' => $executeDate
501 498
502 ] 499 ]
503 ); 500 );
504 update_post_meta($id, 'send_status', 'pending'); 501 update_post_meta($id, 'send_status', 'pending');
505 update_post_meta($id, 'notif_type', $type); 502 update_post_meta($id, 'notif_type', $type);
506 // update_post_meta($id, 'execute_date', mysqldatetime_to_timestamp($executeDate)); 503 // update_post_meta($id, 'execute_date', mysqldatetime_to_timestamp($executeDate));
507 update_post_meta($id, 'execute_date', strtotime($executeDate)); 504 update_post_meta($id, 'execute_date', strtotime($executeDate));
508 505
509 update_post_meta($id, 'trigger', $trigger); 506 update_post_meta($id, 'trigger', $trigger);
510 507
511 508
512 update_post_meta($id, 'email', $emailData); 509 update_post_meta($id, 'email', $emailData);
513 update_post_meta($id, 'style', $style); 510 update_post_meta($id, 'style', $style);
514 update_post_meta($id, 'system', $systemMessageData); 511 update_post_meta($id, 'system', $systemMessageData);
515 update_post_meta($id, 'push', $pushMessageData); 512 update_post_meta($id, 'push', $pushMessageData);
516 513
517 $flash = "<strong>Notification Saved Successfully!</strong><br /><a href='/wp-admin/admin.php?page=notifications'>Click here</a> to view all notifications.</a>"; 514 $flash = "<strong>Notification Saved Successfully!</strong><br /><a href='/wp-admin/admin.php?page=notifications'>Click here</a> to view all notifications.</a>";
518 require_once(__DIR__.'/views/create.php'); 515 require_once(__DIR__ . '/views/create.php');
519
520
521
522
523
524
525 } else { 516 } else {
526 require_once(__DIR__.DIRECTORY_SEPARATOR.'views'.DIRECTORY_SEPARATOR.'create.php'); 517 require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'create.php');
527 } 518 }
528 } 519 }
529 } 520 }
...@@ -533,7 +524,7 @@ function create_notification() ...@@ -533,7 +524,7 @@ function create_notification()
533 function strip_word_html($text, $allowed_tags = '<b><i><sup><sub><em><strong><u><br>') 524 function strip_word_html($text, $allowed_tags = '<b><i><sup><sub><em><strong><u><br>')
534 { 525 {
535 526
536 527
537 mb_regex_encoding('UTF-8'); 528 mb_regex_encoding('UTF-8');
538 //replace MS special characters first 529 //replace MS special characters first
539 $search = array('/&lsquo;/u', '/&rsquo;/u', '/&ldquo;/u', '/&rdquo;/u', '/&mdash;/u'); 530 $search = array('/&lsquo;/u', '/&rsquo;/u', '/&ldquo;/u', '/&rdquo;/u', '/&mdash;/u');
...@@ -542,16 +533,16 @@ function strip_word_html($text, $allowed_tags = '<b><i><sup><sub><em><strong><u> ...@@ -542,16 +533,16 @@ function strip_word_html($text, $allowed_tags = '<b><i><sup><sub><em><strong><u>
542 //make sure _all_ html entities are converted to the plain ascii equivalents - it appears 533 //make sure _all_ html entities are converted to the plain ascii equivalents - it appears
543 //in some MS headers, some html entities are encoded and some aren't 534 //in some MS headers, some html entities are encoded and some aren't
544 $text = html_entity_decode($text, ENT_QUOTES, 'UTF-8'); 535 $text = html_entity_decode($text, ENT_QUOTES, 'UTF-8');
545 536
546 //on some of the ?newer MS Word exports, where you get conditionals of the form 'if gte mso 9', etc., it appears 537 //on some of the ?newer MS Word exports, where you get conditionals of the form 'if gte mso 9', etc., it appears
547 //that whatever is in one of the html comments prevents strip_tags from eradicating the html comment that contains 538 //that whatever is in one of the html comments prevents strip_tags from eradicating the html comment that contains
548 //some MS Style Definitions - this last bit gets rid of any leftover comments */ 539 //some MS Style Definitions - this last bit gets rid of any leftover comments */
549 $num_matches = preg_match_all("/\<!--/u", $text, $matches); 540 $num_matches = preg_match_all("/\<!--/u", $text, $matches);
550 if($num_matches){ 541 if ($num_matches) {
551 $text = preg_replace('/\<!--(.)*--\>/isu', '', $text); 542 $text = preg_replace('/\<!--(.)*--\>/isu', '', $text);
552 } 543 }
553 544
554 545
555 $text = preg_replace('/(?:width\=\"\d*\")\S/mxi', '>', $text); 546 $text = preg_replace('/(?:width\=\"\d*\")\S/mxi', '>', $text);
556 $text = preg_replace('/(?:width\=\"\d*%\")\S/mxi', '>', $text); 547 $text = preg_replace('/(?:width\=\"\d*%\")\S/mxi', '>', $text);
557 return $text; 548 return $text;
......