PluginProbe
E2Pdf – Export Pdf Tool for WordPress / 1.03.07
E2Pdf – Export Pdf Tool for WordPress v1.03.07
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
e2pdf / classes / helper / e2pdf-sort.php

e2pdf-sort.php in E2Pdf – Export Pdf Tool for WordPress 1.03.07, at classes/helper/e2pdf-sort.php

90 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * E2pdf Helper
5 *
6 * @copyright Copyright 2017 https://e2pdf.com
7 * @license GPL v2
8 * @version 1
9 * @link https://e2pdf.com
10 * @since 0.00.01
11 */
12 if (!defined('ABSPATH')) {
13 die('Access denied.');
14 }
15
16 class Helper_E2pdf_Sort {
17
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
27 if ($a['properties']['z_index'] == $b['properties']['z_index']) {
28 return 0;
29 }
30 return ($a['properties']['z_index'] < $b['properties']['z_index']) ? -1 : 1;
31 }
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
40 private function sort_by_pageid($a, $b) {
41 if ($a['page_id'] == $b['page_id']) {
42 return 0;
43 }
44 return ($a['page_id'] < $b['page_id']) ? -1 : 1;
45 }
46
47 public function uasort(&$array, $cmp_function) {
48 uasort($array, array($this, $cmp_function));
49 return;
50 }
51
52 public function stable_uasort(&$array, $cmp_function) {
53 if (count($array) < 2) {
54 return;
55 }
56 $halfway = count($array) / 2;
57 $array1 = array_slice($array, 0, $halfway, TRUE);
58 $array2 = array_slice($array, $halfway, NULL, TRUE);
59
60 $this->stable_uasort($array1, $cmp_function);
61 $this->stable_uasort($array2, $cmp_function);
62 if (call_user_func(array($this, $cmp_function), end($array1), reset($array2)) < 1) {
63 $array = $array1 + $array2;
64 return;
65 }
66 $array = array();
67 reset($array1);
68 reset($array2);
69 while (current($array1) && current($array2)) {
70 if (call_user_func(array($this, $cmp_function), current($array1), current($array2)) < 1) {
71 $array[key($array1)] = current($array1);
72 next($array1);
73 } else {
74 $array[key($array2)] = current($array2);
75 next($array2);
76 }
77 }
78 while (current($array1)) {
79 $array[key($array1)] = current($array1);
80 next($array1);
81 }
82 while (current($array2)) {
83 $array[key($array2)] = current($array2);
84 next($array2);
85 }
86 return;
87 }
88
89 }
90