PluginProbe
E2Pdf – Export Pdf Tool for WordPress / 1.32.49
E2Pdf – Export Pdf Tool for WordPress v1.32.49
1.32.49 1.32.48 1.32.43 1.32.40 1.32.34 1.32.32 1.32.31 1.32.26 1.32.22 1.32.23 1.32.18 1.32.17 1.32.15 trunk 1.00.00 1.00.13 1.01.01 1.02.02 1.03.07 1.04.07 1.05.03 1.06.02 1.07.11 1.08.00 1.08.06 All 72 releases
← All changes | classes/helper/e2pdf-sort.php +24 -4 1.02.021.32.49 View file →
@@ -3,9 +3,9 @@
3 3 /**
4 4 * E2pdf Helper
5 5 *
6 6 * @copyright Copyright 2017 https://e2pdf.com
7 - * @license GPL v2
7 + * @license GPLv3
8 8 * @version 1
9 9 * @link https://e2pdf.com
10 10 * @since 0.00.01
11 11 */
@@ -15,8 +15,16 @@
15 15
16 16 class Helper_E2pdf_Sort {
17 17
18 18 private function sort_by_zindex($a, $b) {
19 + if (!isset($a['properties']['z_index']) || (isset($a['properties']['z_index']) && !$a['properties']['z_index'])) {
20 + $a['properties']['z_index'] = '0';
21 + }
22 +
23 + if (!isset($b['properties']['z_index']) || (isset($b['properties']['z_index']) && !$b['properties']['z_index'])) {
24 + $b['properties']['z_index'] = '0';
25 + }
26 +
19 27 if ($a['properties']['z_index'] == $b['properties']['z_index']) {
20 28 return 0;
21 29 }
22 30 return ($a['properties']['z_index'] < $b['properties']['z_index']) ? -1 : 1;
@@ -21,8 +29,15 @@
21 29 }
22 30 return ($a['properties']['z_index'] < $b['properties']['z_index']) ? -1 : 1;
23 31 }
24 32
33 + private function sort_by_elementid($a, $b) {
34 + if ($a['element_id'] == $b['element_id']) {
35 + return 0;
36 + }
37 + return ($a['element_id'] < $b['element_id']) ? -1 : 1;
38 + }
39 +
25 40 private function sort_by_pageid($a, $b) {
26 41 if ($a['page_id'] == $b['page_id']) {
27 42 return 0;
28 43 }
@@ -28,15 +43,20 @@
28 43 }
29 44 return ($a['page_id'] < $b['page_id']) ? -1 : 1;
30 45 }
31 46
47 + public function uasort(&$array, $cmp_function) {
48 + uasort($array, array($this, $cmp_function));
49 + return;
50 + }
51 +
32 52 public function stable_uasort(&$array, $cmp_function) {
33 53 if (count($array) < 2) {
34 54 return;
35 55 }
36 - $halfway = count($array) / 2;
37 - $array1 = array_slice($array, 0, $halfway, TRUE);
38 - $array2 = array_slice($array, $halfway, NULL, TRUE);
56 + $halfway = (int) (count($array) / 2);
57 + $array1 = array_slice($array, 0, $halfway, true);
58 + $array2 = array_slice($array, $halfway, null, true);
39 59
40 60 $this->stable_uasort($array1, $cmp_function);
41 61 $this->stable_uasort($array2, $cmp_function);
42 62 if (call_user_func(array($this, $cmp_function), end($array1), reset($array2)) < 1) {