Completed
Push — master ( 24f014...ee1ff0 )
by
unknown
13:44
created
includes/modules/wps_barcode/controller/wps_barcode_ajax.ctr.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -105,7 +105,7 @@
 block discarded – undo
105 105
 
106 106
 	/**
107 107
 	 * Generate barcode image
108
-	 * @param object $barcode Instance of wps_barcodegen
108
+	 * @param wps_barcodegen $barcode Instance of wps_barcodegen
109 109
 	 * @param string $meta Numerical code of barcode
110 110
 	 * @param string $type Texte for complete message
111 111
 	 * @param string $price Price of product
Please login to merge, or discard this patch.
Braces   +16 added lines, -19 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 
3 5
 class wps_barcode_ajax {
4 6
 	public function __construct() {
@@ -10,8 +12,9 @@  discard block
 block discarded – undo
10 12
 	public function imgProduct() {
11 13
 		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
12 14
 
13
-		if ( !wp_verify_nonce( $_wpnonce, 'imgProduct' ) )
14
-			wp_die();
15
+		if ( !wp_verify_nonce( $_wpnonce, 'imgProduct' ) ) {
16
+					wp_die();
17
+		}
15 18
 
16 19
 		global $meta, $barcode, $post_ID, $wpdb, $table_prefix, $gg;
17 20
 		require_once('wps_barcodegen.ctr.php');
@@ -50,8 +53,9 @@  discard block
 block discarded – undo
50 53
 	public function imgCoupons() {
51 54
 		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
52 55
 
53
-		if ( !wp_verify_nonce( $_wpnonce, 'imgProduct' ) )
54
-			wp_die();
56
+		if ( !wp_verify_nonce( $_wpnonce, 'imgProduct' ) ) {
57
+					wp_die();
58
+		}
55 59
 
56 60
 		global $meta, $barcode, $post_ID, $wpdb, $table_prefix;
57 61
 
@@ -90,8 +94,7 @@  discard block
 block discarded – undo
90 94
 				$code = $type.$date.$id;
91 95
 				$meta = $barcode->checksum($code);
92 96
 				add_post_meta($post_ID, 'wpshop_coupon_barcode', $meta);
93
-			}
94
-			else {
97
+			} else {
95 98
 				$meta = $result['wpshop_coupon_barcode'][0];
96 99
 			}
97 100
 
@@ -105,8 +108,7 @@  discard block
 block discarded – undo
105 108
 			$array = array('img' => $barcode);
106 109
 			echo json_encode($array);
107 110
 			wp_die();
108
-		}
109
-		else {
111
+		} else {
110 112
 			echo '<p>'.__('None bardcode generated as coupon has not created.',
111 113
 					'wps_barcode').'</p>';
112 114
 			wp_die();
@@ -158,8 +160,7 @@  discard block
 block discarded – undo
158 160
 			for ($i=0; $i<42 ; $i++) {
159 161
 				if( substr($binCode, $i, 1) === '0' ) {
160 162
 					$color = imagecolorallocate($im, 255, 255, 255);
161
-				}
162
-				else {
163
+				} else {
163 164
 					$color = imagecolorallocate($im, 0, 0, 0);
164 165
 				}
165 166
 
@@ -187,8 +188,7 @@  discard block
 block discarded – undo
187 188
 			for ($i=42; $i<84 ; $i++) {
188 189
 				if( substr($binCode, $i, 1) === '0' ) {
189 190
 					$color = imagecolorallocate($im, 255, 255, 255);
190
-				}
191
-				else {
191
+				} else {
192 192
 					$color = imagecolorallocate($im, 0, 0, 0);
193 193
 				}
194 194
 
@@ -241,12 +241,10 @@  discard block
 block discarded – undo
241 241
 				$coupon_postmeta = get_post_meta($post_ID, 'wpshop_coupon_discount_type');
242 242
 				if ( $coupon_postmeta[0] === 'percent' ) {
243 243
 					$price = $price.' %';
244
-				}
245
-				else {
244
+				} else {
246 245
 					$price = sprintf( number_format( $price, 2 ). ' '.$currency);
247 246
 				}
248
-			}
249
-			else {
247
+			} else {
250 248
 				$price = sprintf( number_format( $price, 2 ). ' '.$currency);
251 249
 			}
252 250
 
@@ -282,8 +280,7 @@  discard block
 block discarded – undo
282 280
 					} catch (Exception $e) {
283 281
 						echo __('Generation problem', 'wps_barcode');
284 282
 					}*/
285
-		}
286
-		else {
283
+		} else {
287 284
 			return '<p>'.sprintf( __('None bardcode generated as you did create %s.',
288 285
 					'wps_barcode'), $type).'</p>';
289 286
 		}
Please login to merge, or discard this patch.
Spacing   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 
3 3
 class wps_barcode_ajax {
4 4
 	public function __construct() {
5
-		add_action( 'wp_ajax_barcode_img_product', array($this, 'imgProduct') );
6
-		add_action( 'wp_ajax_barcode_img_coupons', array($this, 'imgCoupons') );
5
+		add_action('wp_ajax_barcode_img_product', array($this, 'imgProduct'));
6
+		add_action('wp_ajax_barcode_img_coupons', array($this, 'imgCoupons'));
7 7
 	}
8 8
 
9 9
 	public function imgProduct() {
10
-		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
10
+		$_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : '';
11 11
 
12
-		if ( !wp_verify_nonce( $_wpnonce, 'imgProduct' ) )
12
+		if (!wp_verify_nonce($_wpnonce, 'imgProduct'))
13 13
 			wp_die();
14 14
 
15 15
 		global $meta, $barcode, $post_ID, $wpdb, $table_prefix, $gg;
@@ -23,17 +23,17 @@  discard block
 block discarded – undo
23 23
 
24 24
 		/*Select value of barcode*/
25 25
 		$result = $wpdb->get_results(
26
-				'SELECT value FROM '.WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR.
27
-				' WHERE attribute_id=(SELECT id FROM '.WPSHOP_DBT_ATTRIBUTE.
28
-				' WHERE code = "barcode") AND entity_id="'.$post_ID.'"', ARRAY_A);
26
+				'SELECT value FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_VARCHAR .
27
+				' WHERE attribute_id=(SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE .
28
+				' WHERE code = "barcode") AND entity_id="' . $post_ID . '"', ARRAY_A);
29 29
 		$meta = !empty($result) ? $result[0]['value'] : '';
30 30
 
31 31
 		/*Get price of product*/
32
-		$result = $wpdb->get_results('SELECT value FROM '.WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL.
33
-				' WHERE attribute_id=(SELECT id FROM '.WPSHOP_DBT_ATTRIBUTE.
34
-				' WHERE code="'.WPSHOP_PRODUCT_PRICE_TTC.'") AND entity_id='.$post_ID, ARRAY_A);
32
+		$result = $wpdb->get_results('SELECT value FROM ' . WPSHOP_DBT_ATTRIBUTE_VALUES_DECIMAL .
33
+				' WHERE attribute_id=(SELECT id FROM ' . WPSHOP_DBT_ATTRIBUTE .
34
+				' WHERE code="' . WPSHOP_PRODUCT_PRICE_TTC . '") AND entity_id=' . $post_ID, ARRAY_A);
35 35
 
36
-		if ( !empty($result) && $result[0]['value'] >= 0) {
36
+		if (!empty($result) && $result[0]['value'] >= 0) {
37 37
 			$price = $result[0]['value'];
38 38
 
39 39
 			$post = get_post($post_ID, ARRAY_A);
@@ -47,9 +47,9 @@  discard block
 block discarded – undo
47 47
 	}
48 48
 
49 49
 	public function imgCoupons() {
50
-		$_wpnonce = !empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : '';
50
+		$_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : '';
51 51
 
52
-		if ( !wp_verify_nonce( $_wpnonce, 'imgProduct' ) )
52
+		if (!wp_verify_nonce($_wpnonce, 'imgProduct'))
53 53
 			wp_die();
54 54
 
55 55
 		global $meta, $barcode, $post_ID, $wpdb, $table_prefix;
@@ -65,14 +65,14 @@  discard block
 block discarded – undo
65 65
 		$country = '000';
66 66
 		$result = get_post_meta($post_ID);
67 67
 
68
-		if ( !empty($result) ) {
69
-			if ( empty($result['wpshop_coupon_barcode']) ) {
68
+		if (!empty($result)) {
69
+			if (empty($result['wpshop_coupon_barcode'])) {
70 70
 				$conf = get_option('wps_barcode');
71 71
 				if ($conf['type'] === 'internal') {
72 72
 					$type = $conf['internal_coupons'];
73 73
 
74
-					$query = $wpdb->get_results('SELECT post_date FROM '.
75
-							$table_prefix.'posts WHERE ID='.$post_ID, ARRAY_A);
74
+					$query = $wpdb->get_results('SELECT post_date FROM ' .
75
+							$table_prefix . 'posts WHERE ID=' . $post_ID, ARRAY_A);
76 76
 
77 77
 					$pDate = new DateTime($query[0]['post_date']);
78 78
 					$date = $pDate->format('my');
@@ -80,13 +80,13 @@  discard block
 block discarded – undo
80 80
 
81 81
 				$len = strlen($post_ID);
82 82
 				$ref = '';
83
-				if ( $len < 5 ) {
84
-					for ($i=0; $i <= $len; $i++) {
83
+				if ($len < 5) {
84
+					for ($i = 0; $i <= $len; $i++) {
85 85
 						$ref .= '0';
86 86
 					}
87 87
 				}
88
-				$id = $ref.$post_ID;
89
-				$code = $type.$date.$id;
88
+				$id = $ref . $post_ID;
89
+				$code = $type . $date . $id;
90 90
 				$meta = $barcode->checksum($code);
91 91
 				add_post_meta($post_ID, 'wpshop_coupon_barcode', $meta);
92 92
 			}
@@ -94,8 +94,8 @@  discard block
 block discarded – undo
94 94
 				$meta = $result['wpshop_coupon_barcode'][0];
95 95
 			}
96 96
 
97
-			$query = $wpdb->get_results('SELECT post_title FROM '.
98
-					$table_prefix.'posts WHERE ID='.$post_ID, ARRAY_A);
97
+			$query = $wpdb->get_results('SELECT post_title FROM ' .
98
+					$table_prefix . 'posts WHERE ID=' . $post_ID, ARRAY_A);
99 99
 
100 100
 			$post = get_post($post_ID, ARRAY_A);
101 101
 
@@ -106,8 +106,8 @@  discard block
 block discarded – undo
106 106
 			wp_die();
107 107
 		}
108 108
 		else {
109
-			echo '<p>'.__('None bardcode generated as coupon has not created.',
110
-					'wps_barcode').'</p>';
109
+			echo '<p>' . __('None bardcode generated as coupon has not created.',
110
+					'wps_barcode') . '</p>';
111 111
 			wp_die();
112 112
 		}
113 113
 	}
@@ -121,44 +121,44 @@  discard block
 block discarded – undo
121 121
 	 * @param string $title Title of product
122 122
 	 */
123 123
 	public function generate_image(&$barcode, $meta, $type, $price, $title, $post_ID = 0) {
124
-		if ( !extension_loaded('gd') ) {
125
-			return '<p>'.__('Library GD is requiered.', 'wps_barcode').'</p>';
124
+		if (!extension_loaded('gd')) {
125
+			return '<p>' . __('Library GD is requiered.', 'wps_barcode') . '</p>';
126 126
 		}
127
-		if ( !empty($meta) ) {
127
+		if (!empty($meta)) {
128 128
 			$barcode->setGenerateCode($meta);
129 129
 			$binCode = $barcode->getBinCode();
130 130
 
131 131
 			$px = 3.779528;
132
-			$x = round(66*$px); //249.449 px
133
-			$y = round(50*$px); //188.976 px
134
-			$bar_size = round(63.393/72); //0.880 px
132
+			$x = round(66 * $px); //249.449 px
133
+			$y = round(50 * $px); //188.976 px
134
+			$bar_size = round(63.393 / 72); //0.880 px
135 135
 
136 136
 			$len = 0;
137 137
 			$test = '';
138 138
 
139
-			while ($len !== strlen($binCode) ) {
140
-				$test .= substr($binCode, $len, 7).' ';
141
-				$len = $len+7;
139
+			while ($len !== strlen($binCode)) {
140
+				$test .= substr($binCode, $len, 7) . ' ';
141
+				$len = $len + 7;
142 142
 			}
143 143
 
144 144
 			$im = imagecreate($x, $y);
145 145
 			$background_color = imagecolorallocate($im, 255, 255, 255);
146
-			$start = round(5.79*$px); //21.883
146
+			$start = round(5.79 * $px); //21.883
147 147
 
148 148
 			/*Write First left guard*/
149
-			$this->imgNormalGuard($im, $start, $start+$bar_size,
149
+			$this->imgNormalGuard($im, $start, $start + $bar_size,
150 150
 					imagecolorallocate($im, 0, 0, 0));
151
-			$this->imgNormalGuard($im, $start+($bar_size*2),
152
-					$start+($bar_size*3), imagecolorallocate($im, 255, 255, 255));
153
-			$this->imgNormalGuard($im, $start+($bar_size*4),
154
-					$start+($bar_size*5), imagecolorallocate($im, 0, 0, 0));
151
+			$this->imgNormalGuard($im, $start + ($bar_size * 2),
152
+					$start + ($bar_size * 3), imagecolorallocate($im, 255, 255, 255));
153
+			$this->imgNormalGuard($im, $start + ($bar_size * 4),
154
+					$start + ($bar_size * 5), imagecolorallocate($im, 0, 0, 0));
155 155
 
156
-			$pos = $start+($bar_size*7);
157
-			$newPos = $pos+$bar_size;
156
+			$pos = $start + ($bar_size * 7);
157
+			$newPos = $pos + $bar_size;
158 158
 
159 159
 			/*Write left barcode*/
160
-			for ($i=0; $i<42 ; $i++) {
161
-				if( substr($binCode, $i, 1) === '0' ) {
160
+			for ($i = 0; $i < 42; $i++) {
161
+				if (substr($binCode, $i, 1) === '0') {
162 162
 					$color = imagecolorallocate($im, 255, 255, 255);
163 163
 				}
164 164
 				else {
@@ -166,108 +166,108 @@  discard block
 block discarded – undo
166 166
 				}
167 167
 
168 168
 				$this->imgSymbole($im, $pos, $newPos, $color);
169
-				$newPos = $pos+$bar_size;
170
-				$pos = $newPos+$bar_size;
169
+				$newPos = $pos + $bar_size;
170
+				$pos = $newPos + $bar_size;
171 171
 			}
172 172
 
173 173
 			/*Writer center guard*/
174 174
 			$pos = $newPos;
175
-			$this->imgNormalGuard($im, $pos, $newPos+$bar_size,
175
+			$this->imgNormalGuard($im, $pos, $newPos + $bar_size,
176 176
 					imagecolorallocate($im, 255, 255, 255));
177
-			$this->imgNormalGuard($im, $pos+($bar_size*2),
178
-					$newPos+($bar_size*3), imagecolorallocate($im, 0, 0, 0));
179
-			$this->imgNormalGuard($im, $pos+($bar_size*4),
180
-					$newPos+($bar_size*5), imagecolorallocate($im, 255, 255, 255));
181
-			$this->imgNormalGuard($im, $pos+($bar_size*6),
182
-					$newPos+($bar_size*7), imagecolorallocate($im, 0, 0, 0));
183
-			$this->imgNormalGuard($im, $pos+($bar_size*8),
184
-					$newPos+($bar_size*9), imagecolorallocate($im, 255, 255, 255));
177
+			$this->imgNormalGuard($im, $pos + ($bar_size * 2),
178
+					$newPos + ($bar_size * 3), imagecolorallocate($im, 0, 0, 0));
179
+			$this->imgNormalGuard($im, $pos + ($bar_size * 4),
180
+					$newPos + ($bar_size * 5), imagecolorallocate($im, 255, 255, 255));
181
+			$this->imgNormalGuard($im, $pos + ($bar_size * 6),
182
+					$newPos + ($bar_size * 7), imagecolorallocate($im, 0, 0, 0));
183
+			$this->imgNormalGuard($im, $pos + ($bar_size * 8),
184
+					$newPos + ($bar_size * 9), imagecolorallocate($im, 255, 255, 255));
185 185
 
186
-			$pos = $newPos+($bar_size*10);
186
+			$pos = $newPos + ($bar_size * 10);
187 187
 
188 188
 			/*Write right barcode*/
189
-			for ($i=42; $i<84 ; $i++) {
190
-				if( substr($binCode, $i, 1) === '0' ) {
189
+			for ($i = 42; $i < 84; $i++) {
190
+				if (substr($binCode, $i, 1) === '0') {
191 191
 					$color = imagecolorallocate($im, 255, 255, 255);
192 192
 				}
193 193
 				else {
194 194
 					$color = imagecolorallocate($im, 0, 0, 0);
195 195
 				}
196 196
 
197
-				$newPos = $pos+$bar_size;
197
+				$newPos = $pos + $bar_size;
198 198
 
199 199
 				$this->imgSymbole($im, $pos, $newPos, $color);
200
-				$pos = $newPos+$bar_size;
200
+				$pos = $newPos + $bar_size;
201 201
 			}
202 202
 
203 203
 			/*Write right guard*/
204
-			$pos = $newPos+$bar_size;
205
-			$this->imgNormalGuard($im, $pos, $pos+$bar_size,
204
+			$pos = $newPos + $bar_size;
205
+			$this->imgNormalGuard($im, $pos, $pos + $bar_size,
206 206
 					imagecolorallocate($im, 0, 0, 0));
207
-			$this->imgNormalGuard($im, $pos+($bar_size*2),
208
-					$pos+($bar_size*3), imagecolorallocate($im, 255, 255, 255));
209
-			$this->imgNormalGuard($im, $pos+($bar_size*4),
210
-					$pos+($bar_size*5), imagecolorallocate($im, 0, 0, 0));
207
+			$this->imgNormalGuard($im, $pos + ($bar_size * 2),
208
+					$pos + ($bar_size * 3), imagecolorallocate($im, 255, 255, 255));
209
+			$this->imgNormalGuard($im, $pos + ($bar_size * 4),
210
+					$pos + ($bar_size * 5), imagecolorallocate($im, 0, 0, 0));
211 211
 
212 212
 			$textSize = 16;
213
-			$font = WPS_BARCODE_FONTS.'/arialbd.ttf';
214
-			imagettftext($im, $textSize, 0, 8, $y-$start-5,
213
+			$font = WPS_BARCODE_FONTS . '/arialbd.ttf';
214
+			imagettftext($im, $textSize, 0, 8, $y - $start - 5,
215 215
 			imagecolorallocate($im, 0, 0, 0), $font, substr($meta, 0, 1));
216 216
 
217 217
 			$continue = true;
218 218
 			$i = 28; $j = 0;
219 219
 
220 220
 			/*Write left number code*/
221
-			while ($j<5) {
222
-				$j=$j+1;
223
-				imagettftext($im, $textSize, 0, $i, $y-$start-5,
221
+			while ($j < 5) {
222
+				$j = $j + 1;
223
+				imagettftext($im, $textSize, 0, $i, $y - $start - 5,
224 224
 				imagecolorallocate($im, 0, 0, 0), $font, substr($meta, $j, 1));
225
-				$i = $i+14;
225
+				$i = $i + 14;
226 226
 			}
227 227
 
228 228
 			/*Write right number code*/
229
-			while ($j<11) {
230
-				$j=$j+1;
231
-				imagettftext($im, $textSize, 0, $i+6, $y-$start-5,
229
+			while ($j < 11) {
230
+				$j = $j + 1;
231
+				imagettftext($im, $textSize, 0, $i + 6, $y - $start - 5,
232 232
 					imagecolorallocate($im, 0, 0, 0), $font, substr($meta, $j, 1));
233
-				$i = $i+15;
233
+				$i = $i + 15;
234 234
 			}
235
-			imagettftext($im, $textSize, 0, $i+4, $y-$start-5,
236
-				imagecolorallocate($im, 0, 0, 0), $font, substr($meta, $j+1, 1));
235
+			imagettftext($im, $textSize, 0, $i + 4, $y - $start - 5,
236
+				imagecolorallocate($im, 0, 0, 0), $font, substr($meta, $j + 1, 1));
237 237
 
238 238
 			/*Write ref product and price*/
239 239
 			$textSize = 12;
240 240
 			$currency = (wpshop_tools::wpshop_get_currency() === '&euro;') ? "€" : wpshop_tools::wpshop_get_currency();
241 241
 
242
-			if ( $type === __('coupon', 'wps_barcode') ) {
242
+			if ($type === __('coupon', 'wps_barcode')) {
243 243
 				$coupon_postmeta = get_post_meta($post_ID, 'wpshop_coupon_discount_type');
244
-				if ( $coupon_postmeta[0] === 'percent' ) {
245
-					$price = $price.' %';
244
+				if ($coupon_postmeta[0] === 'percent') {
245
+					$price = $price . ' %';
246 246
 				}
247 247
 				else {
248
-					$price = sprintf( number_format( $price, 2 ). ' '.$currency);
248
+					$price = sprintf(number_format($price, 2) . ' ' . $currency);
249 249
 				}
250 250
 			}
251 251
 			else {
252
-				$price = sprintf( number_format( $price, 2 ). ' '.$currency);
252
+				$price = sprintf(number_format($price, 2) . ' ' . $currency);
253 253
 			}
254 254
 
255
-			imagettftext($im, $textSize, 0, 20, round(6*$px),
255
+			imagettftext($im, $textSize, 0, 20, round(6 * $px),
256 256
 				imagecolorallocate($im, 0, 0, 0), $font, $title);
257
-			imagettftext($im, $textSize, 0, ($x/2)+40, round(6*$px),
257
+			imagettftext($im, $textSize, 0, ($x / 2) + 40, round(6 * $px),
258 258
 				imagecolorallocate($im, 0, 0, 0), $font, $price);
259 259
 
260 260
 			ob_start();
261 261
 			imagepng($im);
262 262
 			$img = ob_get_clean();
263 263
 
264
-			return '<p><img src="data:image/png;base64,'.base64_encode($img).
265
-			'" id="barcode" width="160" height="90" /></p>'.
264
+			return '<p><img src="data:image/png;base64,' . base64_encode($img) .
265
+			'" id="barcode" width="160" height="90" /></p>' .
266 266
 
267
-			'<p style="text-align: right"><button class="button '.
268
-					'button-primary button-large" type="button"'.
269
-					'id="print_barcode">'.
270
-					__('Print', 'wps_barcode').'</button></p>';
267
+			'<p style="text-align: right"><button class="button ' .
268
+					'button-primary button-large" type="button"' .
269
+					'id="print_barcode">' .
270
+					__('Print', 'wps_barcode') . '</button></p>';
271 271
 
272 272
 					/*wp_mkdir_p( WPS_BARCODE_UPLOAD );
273 273
 
@@ -286,8 +286,8 @@  discard block
 block discarded – undo
286 286
 					}*/
287 287
 		}
288 288
 		else {
289
-			return '<p>'.sprintf( __('None bardcode generated as you did create %s.',
290
-					'wps_barcode'), $type).'</p>';
289
+			return '<p>' . sprintf(__('None bardcode generated as you did create %s.',
290
+					'wps_barcode'), $type) . '</p>';
291 291
 		}
292 292
 	}
293 293
 
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 	 * @param integer $color Color of rectangle
300 300
 	 */
301 301
 	private function imgNormalGuard(&$image, $pos, $size, $color) {
302
-		imagefilledrectangle($image, $pos, 180*0.25,$size, 180-10, $color );
302
+		imagefilledrectangle($image, $pos, 180 * 0.25, $size, 180 - 10, $color);
303 303
 	}
304 304
 
305 305
 	/**
@@ -310,6 +310,6 @@  discard block
 block discarded – undo
310 310
 	 * @param integer $color Color of rectangle
311 311
 	 */
312 312
 	private function imgSymbole(&$image, $pos, $size, $color) {
313
-		imagefilledrectangle($image, $pos, 180*0.25,$size, 180-40, $color );
313
+		imagefilledrectangle($image, $pos, 180 * 0.25, $size, 180 - 40, $color);
314 314
 	}
315 315
 }
Please login to merge, or discard this patch.
includes/modules/wps_barcode/controller/wps_barcodegen.ctr.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -147,7 +147,7 @@
 block discarded – undo
147 147
 
148 148
 	/**
149 149
 	 * get binary code of barcode
150
-	 * @return binary code
150
+	 * @return string code
151 151
 	 */
152 152
 	public function getBinCode() {
153 153
 		return $this->binCode;
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	/**
53 53
 	 * Write line of log
54 54
 	 * @param string $string Line writing
55
-	*/
55
+	 */
56 56
 	public function writeLog($string) {
57 57
 		$this->log .= $string;
58 58
 	}
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	/**
69 69
 	 * Set generate code for barcode has been generate
70 70
 	 * @param string $code Number code of barcode
71
-	*/
71
+	 */
72 72
 	public function setGenerateCode($code) {
73 73
 		$code = $this->checksum( substr($code, 0, 12) );
74 74
 		$this->originalCode = $code;
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 
156 156
 	/**
157 157
 	 * Read INI configuration for country generate code
158
-	*/
158
+	 */
159 159
 	private function readGencodeIni() {
160 160
 		$ini = parse_ini_file('assets/config/gencode.ini', true);
161 161
 
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 
173 173
 	/**
174 174
 	 * Read INI general configuration
175
-	*/
175
+	 */
176 176
 	private function readConfigIni() {
177 177
 		$ini = parse_ini_file('assets/config/config.ini', true);
178 178
 
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	 * Cut and parse string for generate code
191 191
 	 * @param string $ctry Country number code
192 192
 	 * @return array String exploding with explode PHP function and parsing
193
-	*/
193
+	 */
194 194
 	private function explodingString($ctry) {
195 195
 		global $count, $gen, $leftRnd;
196 196
 
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 	 * @param string $country International country code
270 270
 	 * @param string $code Type for number code generate (country, distributors...)
271 271
 	 * @return string Number code generate
272
-	*/
272
+	 */
273 273
 	private function ean13($country, $code, $ref) {
274 274
 		global $count, $gen, $leftRnd;
275 275
 
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
 	/**
467 467
 	 * Generate bincode
468 468
 	 * @param string $code Number code generated by normalization function
469
-	*/
469
+	 */
470 470
 	public function bin($code) {
471 471
 		if ($this->binCode === '') {
472 472
 			$binCode = '';
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
 	/**
496 496
 	 * Calcul motif for generate barcode
497 497
 	 * @param string $code Number code generate
498
-	*/
498
+	 */
499 499
 	private function motifCalc($code) {
500 500
 		$start = substr($code, 0, 1);
501 501
 		switch ($start) {
Please login to merge, or discard this patch.
Spacing   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 
3 3
 /**
4 4
  * Generate barcodes with informations
@@ -30,17 +30,17 @@  discard block
 block discarded – undo
30 30
 	private $config = array();
31 31
 
32 32
 	public function __construct() {
33
-	$this->setA = array( 0 => '0001101',	1 => '0011001',	2 => '0010011',
34
-		3 => '0111101',	4 => '0100011',	5 => '0110001',	6 => '0101111',
35
-		7 => '0111011',	8 => '0110111',	9 => '0001011'	);
33
+	$this->setA = array(0 => '0001101', 1 => '0011001', 2 => '0010011',
34
+		3 => '0111101', 4 => '0100011', 5 => '0110001', 6 => '0101111',
35
+		7 => '0111011', 8 => '0110111', 9 => '0001011');
36 36
 
37
-	$this->setB = array( 0 => '0100111', 1 => '0110011', 2 => '0011011',
37
+	$this->setB = array(0 => '0100111', 1 => '0110011', 2 => '0011011',
38 38
 		3 => '0100001', 4 => '0011101', 5 => '0111001', 6 => '0000101',
39
-		7 => '0010001', 8 => '0001001', 9 => '0010111' );
39
+		7 => '0010001', 8 => '0001001', 9 => '0010111');
40 40
 
41
-	$this->setC = array( 0 => '1110010', 1 => '1100110', 2 => '1101100',
41
+	$this->setC = array(0 => '1110010', 1 => '1100110', 2 => '1101100',
42 42
 		3 => '1000010', 4 => '1011100', 5 => '1001110', 6 => '1010000',
43
-		7 => '1000100', 8 => '1001000', 9 => '1110100' );
43
+		7 => '1000100', 8 => '1001000', 9 => '1110100');
44 44
 
45 45
 	//$this->file = fopen(/logs/ean13.log', 'a');
46 46
 	}
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 	 * @param string $code Number code of barcode
71 71
 	*/
72 72
 	public function setGenerateCode($code) {
73
-		$code = $this->checksum( substr($code, 0, 12) );
73
+		$code = $this->checksum(substr($code, 0, 12));
74 74
 		$this->originalCode = $code;
75 75
 		$this->motifCalc($code);
76 76
 		$this->bin(substr($code, 1));
@@ -82,15 +82,15 @@  discard block
 block discarded – undo
82 82
 	 * @return string Number code with checksum
83 83
 	 */
84 84
 	public static function checksum($code) {
85
-		$leftRnd = str_split( substr($code, 0, 7) );
86
-		$rightRnd = str_split( substr($code, 7) );
85
+		$leftRnd = str_split(substr($code, 0, 7));
86
+		$rightRnd = str_split(substr($code, 7));
87 87
 
88 88
 		/*Generate checksum*/
89
-		$leftSum = ($leftRnd[1]+$leftRnd[3]+$leftRnd[5]+$rightRnd[0]+$rightRnd[2]+$rightRnd[4])*3;
90
-		$rightSum = $leftRnd[0]+$leftRnd[2]+$leftRnd[4]+$leftRnd[6]+$rightRnd[1]+$rightRnd[3];
91
-		$sum = $leftSum+$rightSum;
89
+		$leftSum = ($leftRnd[1] + $leftRnd[3] + $leftRnd[5] + $rightRnd[0] + $rightRnd[2] + $rightRnd[4]) * 3;
90
+		$rightSum = $leftRnd[0] + $leftRnd[2] + $leftRnd[4] + $leftRnd[6] + $rightRnd[1] + $rightRnd[3];
91
+		$sum = $leftSum + $rightSum;
92 92
 
93
-		$checksum = (ceil($sum/10)*10)-$sum;
93
+		$checksum = (ceil($sum / 10) * 10) - $sum;
94 94
 		$rightRnd[5] = strval($checksum);
95 95
 		$gencode = implode($leftRnd);
96 96
 		$gencode .= implode($rightRnd);
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	public function setCountry($code) {
115 115
 		$this->country = $code;
116 116
 
117
-		if ( $this->fixed !== '' ) {
117
+		if ($this->fixed !== '') {
118 118
 				$this->fixed .= ';country';
119 119
 		}
120 120
 		else {
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 	public function setEnterpriseCode($code) {
130 130
 		$this->enterprise = $code;
131 131
 
132
-		if ( $this->fixed !== '' ) {
132
+		if ($this->fixed !== '') {
133 133
 			$this->fixed .= ';enterprise';
134 134
 		}
135 135
 		else {
@@ -159,13 +159,13 @@  discard block
 block discarded – undo
159 159
 	private function readGencodeIni() {
160 160
 		$ini = parse_ini_file('assets/config/gencode.ini', true);
161 161
 
162
-		if ( array_key_exists("EAN13", $ini) ) {
163
-			$pos = array_search( "EAN13", array_keys($ini) );
162
+		if (array_key_exists("EAN13", $ini)) {
163
+			$pos = array_search("EAN13", array_keys($ini));
164 164
 			$this->ean13 = array_slice($ini["EAN13"], 0);
165 165
 		}
166 166
 
167
-		if ( array_key_exists("OTHEREAN13", $ini) ) {
168
-			$pos = array_search( "OTHEREAN13" , array_keys($ini) );
167
+		if (array_key_exists("OTHEREAN13", $ini)) {
168
+			$pos = array_search("OTHEREAN13", array_keys($ini));
169 169
 			$this->other_ean13 = array_slice($ini["OTHEREAN13"], 0);
170 170
 		}
171 171
 	}
@@ -176,8 +176,8 @@  discard block
 block discarded – undo
176 176
 	private function readConfigIni() {
177 177
 		$ini = parse_ini_file('assets/config/config.ini', true);
178 178
 
179
-		if ( array_key_exists("general", $ini) ) {
180
-			$pos = array_search( "general", array_keys($ini) );
179
+		if (array_key_exists("general", $ini)) {
180
+			$pos = array_search("general", array_keys($ini));
181 181
 
182 182
 			$this->enterprise = $ini["general"]["enteprise"];
183 183
 			$this->country = $ini["general"]["country"];
@@ -199,12 +199,12 @@  discard block
 block discarded – undo
199 199
 
200 200
 		/*If minimum two informations*/
201 201
 		if ($count > 1) {
202
-			for ($i=0; $i<$count ; $i++) {
202
+			for ($i = 0; $i < $count; $i++) {
203 203
 				$pos = strpos($exploding[$i], ":");
204 204
 				$gen[$i]["start"] = substr($exploding[$i], 0, $pos);
205 205
 
206
-				if ( intval( substr($exploding[$i], $pos) ) < 1 ) {
207
-					$gen[$i]["end"] = substr($exploding[$i], $pos+1);
206
+				if (intval(substr($exploding[$i], $pos)) < 1) {
207
+					$gen[$i]["end"] = substr($exploding[$i], $pos + 1);
208 208
 				}
209 209
 				else {
210 210
 					$gen[$i]["end"] = substr($exploding[$i], $pos);
@@ -215,17 +215,17 @@  discard block
 block discarded – undo
215 215
 				}
216 216
 			}
217 217
 
218
-			$select = mt_rand( 0, count($gen)-1 );
218
+			$select = mt_rand(0, count($gen) - 1);
219 219
 			$g1 = strval($gen[$select]["start"]);
220 220
 			$g2 = strval($gen[$select]["end"]);
221 221
 
222
-			$rand = mt_rand( $g1, $g2 );
222
+			$rand = mt_rand($g1, $g2);
223 223
 
224
-				if ( $rand >= 10 and $rand < 100 ) {
225
-					$strNum = '0'.intval($rand);
224
+				if ($rand >= 10 and $rand < 100) {
225
+					$strNum = '0' . intval($rand);
226 226
 				}
227
-				else if ( $rand < 10 ) {
228
-					$strNum = '00'.intval($rand);
227
+				else if ($rand < 10) {
228
+					$strNum = '00' . intval($rand);
229 229
 				}
230 230
 				else {
231 231
 					$strNum = intval($rand);
@@ -235,21 +235,21 @@  discard block
 block discarded – undo
235 235
 			$pos = strpos($exploding[0], ":");
236 236
 			if ($pos > 0) {
237 237
 				$gen[0]["start"] = substr($exploding[0], 0, $pos);
238
-				$gen[0]["end"] = substr($exploding[0], $pos+1);
238
+				$gen[0]["end"] = substr($exploding[0], $pos + 1);
239 239
 
240
-				$select = mt_rand( intval($gen[0]["start"]),
241
-				intval($gen[0]["end"]) );
240
+				$select = mt_rand(intval($gen[0]["start"]),
241
+				intval($gen[0]["end"]));
242 242
 
243 243
 				$strNum = strval($select);
244 244
 				$len = strlen($strNum);
245
-				if ( $len < 3 ) {
245
+				if ($len < 3) {
246 246
 					switch ($len) {
247 247
 						case 1:
248
-							$strNum = '00'.$strNum;
248
+							$strNum = '00' . $strNum;
249 249
 							break;
250 250
 
251 251
 						case 2:
252
-							$strNum = '0'.$strNum;
252
+							$strNum = '0' . $strNum;
253 253
 							break;
254 254
 					}
255 255
 				}
@@ -258,9 +258,9 @@  discard block
 block discarded – undo
258 258
 				$strNum = strval($exploding[0]);
259 259
 			}
260 260
 		}
261
-				$leftRnd[0] = substr( $strNum, 0, 1);
262
-				$leftRnd[1] = substr( $strNum, 1, 1);
263
-				$leftRnd[2] = substr( $strNum, 2, 1);
261
+				$leftRnd[0] = substr($strNum, 0, 1);
262
+				$leftRnd[1] = substr($strNum, 1, 1);
263
+				$leftRnd[2] = substr($strNum, 2, 1);
264 264
 		return $gen;
265 265
 	}
266 266
 
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 
280 280
 		$this->readGencodeIni();
281 281
 
282
-		if ( $this->fixed === '' ) {
282
+		if ($this->fixed === '') {
283 283
 			$this->readConfigIni();
284 284
 		}
285 285
 
@@ -287,28 +287,28 @@  discard block
 block discarded – undo
287 287
 			$explodingConf = explode(";", $this->fixed);
288 288
 
289 289
 			foreach ($explodingConf as $key => $value) {
290
-				if ( strtolower($value) === "country" ) {
290
+				if (strtolower($value) === "country") {
291 291
 					$country = $this->country;
292 292
 					$code = "country";
293 293
 					$countryViaConf = true;
294 294
 				}
295
-				elseif ( strtolower($value) === "enterprise" ) {
295
+				elseif (strtolower($value) === "enterprise") {
296 296
 					$enterpriseViaConf = true;
297 297
 				}
298 298
 			}
299 299
 		}
300 300
 
301
-		if ( $countryViaConf === true ) {
302
-			if ( $this->countryCode !== '' )
301
+		if ($countryViaConf === true) {
302
+			if ($this->countryCode !== '')
303 303
 			{
304 304
 				$strNum = strval($this->countryCode);
305
-				$leftRnd[0] = substr( $strNum, 0, 1);
306
-				$leftRnd[1] = substr( $strNum, 1, 1);
307
-				$leftRnd[2] = substr( $strNum, 2, 1);
305
+				$leftRnd[0] = substr($strNum, 0, 1);
306
+				$leftRnd[1] = substr($strNum, 1, 1);
307
+				$leftRnd[2] = substr($strNum, 2, 1);
308 308
 			}
309 309
 			else {
310 310
 
311
-				if ( array_key_exists(strtoupper($country), $this->ean13) ) {
311
+				if (array_key_exists(strtoupper($country), $this->ean13)) {
312 312
 					$ctry = $this->ean13[strtoupper($country)];
313 313
 				}
314 314
 
@@ -339,17 +339,17 @@  discard block
 block discarded – undo
339 339
 			$this->countryGen($country, $code);
340 340
 
341 341
 			/*Generate left section of gencode*/
342
-			if ( !isset($leftRnd[2]) ) {
342
+			if (!isset($leftRnd[2])) {
343 343
 				$leftRnd[2] = mt_rand(0, 9);
344 344
 			}
345 345
 		}
346 346
 
347
-		if ( $enterpriseViaConf === true ) {
347
+		if ($enterpriseViaConf === true) {
348 348
 			$strNum2 = strval($this->enterprise);
349
-			$leftRnd[3] = substr( $strNum2, 0, 1);
350
-			$leftRnd[4] = substr( $strNum2, 1, 1);
351
-			$leftRnd[5] = substr( $strNum2, 2, 1);
352
-			$leftRnd[6] = substr( $strNum2, 3, 1);
349
+			$leftRnd[3] = substr($strNum2, 0, 1);
350
+			$leftRnd[4] = substr($strNum2, 1, 1);
351
+			$leftRnd[5] = substr($strNum2, 2, 1);
352
+			$leftRnd[6] = substr($strNum2, 3, 1);
353 353
 		}
354 354
 		else {
355 355
 			$leftRnd[3] = mt_rand(0, 9);
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 		}
360 360
 
361 361
 		/*Generate right section of gencode*/
362
-		switch ( strlen($ref) ) {
362
+		switch (strlen($ref)) {
363 363
 			case 0:
364 364
 				$rightRnd[0] = mt_rand(0, 9);
365 365
 				$rightRnd[1] = mt_rand(0, 9);
@@ -380,32 +380,32 @@  discard block
 block discarded – undo
380 380
 				$rightRnd[0] = 0;
381 381
 				$rightRnd[1] = 0;
382 382
 				$rightRnd[2] = 0;
383
-				$rightRnd[3] = substr( $ref, 0, 1);
384
-				$rightRnd[4] = substr( $ref, 1, 1);
383
+				$rightRnd[3] = substr($ref, 0, 1);
384
+				$rightRnd[4] = substr($ref, 1, 1);
385 385
 				break;
386 386
 
387 387
 			case 3:
388 388
 				$rightRnd[0] = 0;
389 389
 				$rightRnd[1] = 0;
390
-				$rightRnd[2] = substr( $ref, 0, 1);
391
-				$rightRnd[3] = substr( $ref, 1, 1);
392
-				$rightRnd[4] = substr( $ref, 2, 1);
390
+				$rightRnd[2] = substr($ref, 0, 1);
391
+				$rightRnd[3] = substr($ref, 1, 1);
392
+				$rightRnd[4] = substr($ref, 2, 1);
393 393
 				break;
394 394
 
395 395
 			case 4:
396 396
 				$rightRnd[0] = 0;
397
-				$rightRnd[1] = substr( $ref, 0, 1);
398
-				$rightRnd[2] = substr( $ref, 1, 1);
399
-				$rightRnd[3] = substr( $ref, 2, 1);
400
-				$rightRnd[4] = substr( $ref, 3, 1);
397
+				$rightRnd[1] = substr($ref, 0, 1);
398
+				$rightRnd[2] = substr($ref, 1, 1);
399
+				$rightRnd[3] = substr($ref, 2, 1);
400
+				$rightRnd[4] = substr($ref, 3, 1);
401 401
 				break;
402 402
 
403 403
 			case 5:
404
-				$rightRnd[0] = substr( $ref, 0, 1);
405
-				$rightRnd[1] = substr( $ref, 1, 1);
406
-				$rightRnd[2] = substr( $ref, 2, 1);
407
-				$rightRnd[3] = substr( $ref, 3, 1);
408
-				$rightRnd[4] = substr( $ref, 4, 1);
404
+				$rightRnd[0] = substr($ref, 0, 1);
405
+				$rightRnd[1] = substr($ref, 1, 1);
406
+				$rightRnd[2] = substr($ref, 2, 1);
407
+				$rightRnd[3] = substr($ref, 3, 1);
408
+				$rightRnd[4] = substr($ref, 4, 1);
409 409
 				break;
410 410
 
411 411
 			default:
@@ -443,8 +443,8 @@  discard block
 block discarded – undo
443 443
 	 */
444 444
 	public function countryGen($country, $code) {
445 445
 		/*Generation for country selection*/
446
-		if ( !empty($country) && $code == 'country' ) {
447
-			if ( array_key_exists(strtoupper($country), $this->ean13) ) {
446
+		if (!empty($country) && $code == 'country') {
447
+			if (array_key_exists(strtoupper($country), $this->ean13)) {
448 448
 				$ctry = $this->ean13[strtoupper($country)];
449 449
 				$gen = $this->explodingString($ctry);
450 450
 			}
@@ -453,8 +453,8 @@  discard block
 block discarded – undo
453 453
 			if ($code == 'distrib' or $code == 'weight' or
454 454
 					$code == 'interne' or $code == 'coupons' or
455 455
 					$code == 'issn' or $code == 'isbn') {
456
-				if ( !empty($this->other_ean13) ) {
457
-					if ( array_key_exists($code, $this->other_ean13) ) {
456
+				if (!empty($this->other_ean13)) {
457
+					if (array_key_exists($code, $this->other_ean13)) {
458 458
 
459 459
 						$gen = $this->explodingString($this->other_ean13[$code]);
460 460
 					}
@@ -471,23 +471,23 @@  discard block
 block discarded – undo
471 471
 		if ($this->binCode === '') {
472 472
 			$binCode = '';
473 473
 			/*Generate left bincode*/
474
-			for ($i=0; $i<6 ; $i++) {
475
-				if( substr($this->motif, $i, 1) === 'A' ) {
474
+			for ($i = 0; $i < 6; $i++) {
475
+				if (substr($this->motif, $i, 1) === 'A') {
476 476
 					$binCode .= $this->setA[substr($code, $i, 1)];
477 477
 				}
478
-				else if ( substr($this->motif, $i, 1) === 'B' ) {
478
+				else if (substr($this->motif, $i, 1) === 'B') {
479 479
 					$binCode .= $this->setB[substr($code, $i, 1)];
480 480
 				}
481 481
 			}
482 482
 
483 483
 			/*Generate right bincode*/
484
-			for ($i=6; $i<12 ; $i++) {
484
+			for ($i = 6; $i < 12; $i++) {
485 485
 				$binCode .= $this->setC[substr($code, $i, 1)];
486 486
 			}
487 487
 		}
488 488
 
489
-		$this->writeLog( sprintf( __("Bincode generate: %s <br />", 'wps_barcode'),
490
-				'<b>'.$binCode.'</b>') );
489
+		$this->writeLog(sprintf(__("Bincode generate: %s <br />", 'wps_barcode'),
490
+				'<b>' . $binCode . '</b>'));
491 491
 
492 492
 		$this->binCode = $binCode;
493 493
 	}
@@ -540,8 +540,8 @@  discard block
 block discarded – undo
540 540
 				break;
541 541
 		}
542 542
 
543
-		$this->writeLog( sprintf( __("Motif: %s<br />", 'wps_barcode'),
544
-				$this->motif) );
543
+		$this->writeLog(sprintf(__("Motif: %s<br />", 'wps_barcode'),
544
+				$this->motif));
545 545
 	}
546 546
 }
547 547
 
Please login to merge, or discard this patch.
Braces   +17 added lines, -29 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 
3 5
 /**
4 6
  * Generate barcodes with informations
@@ -116,8 +118,7 @@  discard block
 block discarded – undo
116 118
 
117 119
 		if ( $this->fixed !== '' ) {
118 120
 				$this->fixed .= ';country';
119
-		}
120
-		else {
121
+		} else {
121 122
 			$this->fixed .= 'country';
122 123
 		}
123 124
 	}
@@ -131,8 +132,7 @@  discard block
 block discarded – undo
131 132
 
132 133
 		if ( $this->fixed !== '' ) {
133 134
 			$this->fixed .= ';enterprise';
134
-		}
135
-		else {
135
+		} else {
136 136
 			$this->fixed .= 'enterprise';
137 137
 		}
138 138
 	}
@@ -205,8 +205,7 @@  discard block
 block discarded – undo
205 205
 
206 206
 				if ( intval( substr($exploding[$i], $pos) ) < 1 ) {
207 207
 					$gen[$i]["end"] = substr($exploding[$i], $pos+1);
208
-				}
209
-				else {
208
+				} else {
210 209
 					$gen[$i]["end"] = substr($exploding[$i], $pos);
211 210
 				}
212 211
 
@@ -223,15 +222,12 @@  discard block
 block discarded – undo
223 222
 
224 223
 				if ( $rand >= 10 and $rand < 100 ) {
225 224
 					$strNum = '0'.intval($rand);
226
-				}
227
-				else if ( $rand < 10 ) {
225
+				} else if ( $rand < 10 ) {
228 226
 					$strNum = '00'.intval($rand);
229
-				}
230
-				else {
227
+				} else {
231 228
 					$strNum = intval($rand);
232 229
 				}
233
-		}
234
-		else {
230
+		} else {
235 231
 			$pos = strpos($exploding[0], ":");
236 232
 			if ($pos > 0) {
237 233
 				$gen[0]["start"] = substr($exploding[0], 0, $pos);
@@ -253,8 +249,7 @@  discard block
 block discarded – undo
253 249
 							break;
254 250
 					}
255 251
 				}
256
-			}
257
-			else {
252
+			} else {
258 253
 				$strNum = strval($exploding[0]);
259 254
 			}
260 255
 		}
@@ -291,8 +286,7 @@  discard block
 block discarded – undo
291 286
 					$country = $this->country;
292 287
 					$code = "country";
293 288
 					$countryViaConf = true;
294
-				}
295
-				elseif ( strtolower($value) === "enterprise" ) {
289
+				} elseif ( strtolower($value) === "enterprise" ) {
296 290
 					$enterpriseViaConf = true;
297 291
 				}
298 292
 			}
@@ -305,8 +299,7 @@  discard block
 block discarded – undo
305 299
 				$leftRnd[0] = substr( $strNum, 0, 1);
306 300
 				$leftRnd[1] = substr( $strNum, 1, 1);
307 301
 				$leftRnd[2] = substr( $strNum, 2, 1);
308
-			}
309
-			else {
302
+			} else {
310 303
 
311 304
 				if ( array_key_exists(strtoupper($country), $this->ean13) ) {
312 305
 					$ctry = $this->ean13[strtoupper($country)];
@@ -314,8 +307,7 @@  discard block
 block discarded – undo
314 307
 
315 308
 				$gen = $this->explodingString($ctry);
316 309
 			}
317
-		}
318
-		else {
310
+		} else {
319 311
 			/*Generation for country selection*/
320 312
 			/*if ( !empty($country) && $code == 'country' ) {
321 313
 				if ( array_key_exists(strtoupper($country), $this->ean13) ) {
@@ -350,8 +342,7 @@  discard block
 block discarded – undo
350 342
 			$leftRnd[4] = substr( $strNum2, 1, 1);
351 343
 			$leftRnd[5] = substr( $strNum2, 2, 1);
352 344
 			$leftRnd[6] = substr( $strNum2, 3, 1);
353
-		}
354
-		else {
345
+		} else {
355 346
 			$leftRnd[3] = mt_rand(0, 9);
356 347
 			$leftRnd[4] = mt_rand(0, 9);
357 348
 			$leftRnd[5] = mt_rand(0, 9);
@@ -426,8 +417,7 @@  discard block
 block discarded – undo
426 417
 			foreach ($rightRnd as $key => $value) {
427 418
 				$codeForChecksum .= $value;
428 419
 			}
429
-		}
430
-		else {
420
+		} else {
431 421
 			$codeForChecksum = $this->originalCode;
432 422
 		}
433 423
 
@@ -448,8 +438,7 @@  discard block
 block discarded – undo
448 438
 				$ctry = $this->ean13[strtoupper($country)];
449 439
 				$gen = $this->explodingString($ctry);
450 440
 			}
451
-		}
452
-		else {
441
+		} else {
453 442
 			if ($code == 'distrib' or $code == 'weight' or
454 443
 					$code == 'interne' or $code == 'coupons' or
455 444
 					$code == 'issn' or $code == 'isbn') {
@@ -474,8 +463,7 @@  discard block
 block discarded – undo
474 463
 			for ($i=0; $i<6 ; $i++) {
475 464
 				if( substr($this->motif, $i, 1) === 'A' ) {
476 465
 					$binCode .= $this->setA[substr($code, $i, 1)];
477
-				}
478
-				else if ( substr($this->motif, $i, 1) === 'B' ) {
466
+				} else if ( substr($this->motif, $i, 1) === 'B' ) {
479 467
 					$binCode .= $this->setB[substr($code, $i, 1)];
480 468
 				}
481 469
 			}
Please login to merge, or discard this patch.
includes/modules/wps_barcode/librairies/odtphp/zip/pclzip/pclzip.lib.php 4 patches
Doc Comments   +34 added lines patch added patch discarded remove patch
@@ -212,6 +212,10 @@  discard block
 block discarded – undo
212 212
   //   Note that no real action is taken, if the archive does not exist it is not
213 213
   //   created. Use create() for that.
214 214
   // --------------------------------------------------------------------------------
215
+
216
+  /**
217
+   * @param string $p_zipname
218
+   */
215 219
   function PclZip($p_zipname)
216 220
   {
217 221
 
@@ -220,6 +224,10 @@  discard block
 block discarded – undo
220 224
     {
221 225
       if (!function_exists('gzopen')
222 226
         && function_exists('gzopen64')) {
227
+
228
+        /**
229
+         * @param string $filename
230
+         */
223 231
         function gzopen($filename , $mode = 'r', $use_include_path = 0 )
224 232
         {
225 233
             return gzopen64($filename , $mode, $use_include_path);
@@ -457,6 +465,10 @@  discard block
 block discarded – undo
457 465
   //   The list of the added files, with a status of the add action.
458 466
   //   (see PclZip::listContent() for list entry format)
459 467
   // --------------------------------------------------------------------------------
468
+
469
+  /**
470
+   * @param string $p_filelist
471
+   */
460 472
   function add($p_filelist)
461 473
   {
462 474
     $v_result=1;
@@ -2341,6 +2353,10 @@  discard block
 block discarded – undo
2341 2353
   // Description :
2342 2354
   // Parameters :
2343 2355
   // --------------------------------------------------------------------------------
2356
+
2357
+  /**
2358
+   * @param string $p_mode
2359
+   */
2344 2360
   function privOpenFd($p_mode)
2345 2361
   {
2346 2362
     $v_result=1;
@@ -4157,6 +4173,10 @@  discard block
 block discarded – undo
4157 4173
   // Parameters :
4158 4174
   // Return Values :
4159 4175
   // --------------------------------------------------------------------------------
4176
+
4177
+  /**
4178
+   * @param string $p_string
4179
+   */
4160 4180
   function privExtractFileAsString(&$p_entry, &$p_string, &$p_options)
4161 4181
   {
4162 4182
     $v_result=1;
@@ -5050,6 +5070,10 @@  discard block
 block discarded – undo
5050 5070
   // Parameters :
5051 5071
   // Return Values :
5052 5072
   // --------------------------------------------------------------------------------
5073
+
5074
+  /**
5075
+   * @param PclZip $p_archive_to_add
5076
+   */
5053 5077
   function privMerge(&$p_archive_to_add)
5054 5078
   {
5055 5079
     $v_result=1;
@@ -5557,6 +5581,11 @@  discard block
 block discarded – undo
5557 5581
   //             3 : src & dest gzip
5558 5582
   // Return Values :
5559 5583
   // --------------------------------------------------------------------------------
5584
+
5585
+  /**
5586
+   * @param integer $p_src
5587
+   * @param integer $p_dest
5588
+   */
5560 5589
   function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0)
5561 5590
   {
5562 5591
     $v_result = 1;
@@ -5619,6 +5648,11 @@  discard block
 block discarded – undo
5619 5648
   // Return Values :
5620 5649
   //   1 on success, 0 on failure.
5621 5650
   // --------------------------------------------------------------------------------
5651
+
5652
+  /**
5653
+   * @param string $p_src
5654
+   * @param string $p_dest
5655
+   */
5622 5656
   function PclZipUtilRename($p_src, $p_dest)
5623 5657
   {
5624 5658
     $v_result = 1;
Please login to merge, or discard this patch.
Indentation   +3762 added lines, -3762 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 
28 28
   // ----- Constants
29 29
   if (!defined('PCLZIP_READ_BLOCK_SIZE')) {
30
-    define( 'PCLZIP_READ_BLOCK_SIZE', 2048 );
30
+	define( 'PCLZIP_READ_BLOCK_SIZE', 2048 );
31 31
   }
32 32
   
33 33
   // ----- File list separator
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
   //define( 'PCLZIP_SEPARATOR', ' ' );
42 42
   // Recommanded values for smart separation of filenames.
43 43
   if (!defined('PCLZIP_SEPARATOR')) {
44
-    define( 'PCLZIP_SEPARATOR', ',' );
44
+	define( 'PCLZIP_SEPARATOR', ',' );
45 45
   }
46 46
 
47 47
   // ----- Error configuration
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
   //     you must ensure that you have included PclError library.
51 51
   // [2,...] : reserved for futur use
52 52
   if (!defined('PCLZIP_ERROR_EXTERNAL')) {
53
-    define( 'PCLZIP_ERROR_EXTERNAL', 0 );
53
+	define( 'PCLZIP_ERROR_EXTERNAL', 0 );
54 54
   }
55 55
 
56 56
   // ----- Optional static temporary directory
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
   // define( 'PCLZIP_TEMPORARY_DIR', '/temp/' );
64 64
   // define( 'PCLZIP_TEMPORARY_DIR', 'C:/Temp/' );
65 65
   if (!defined('PCLZIP_TEMPORARY_DIR')) {
66
-    define( 'PCLZIP_TEMPORARY_DIR', '' );
66
+	define( 'PCLZIP_TEMPORARY_DIR', '' );
67 67
   }
68 68
 
69 69
   // ----- Optional threshold ratio for use of temporary files
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
   //       Samples :
76 76
   // define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.5 );
77 77
   if (!defined('PCLZIP_TEMPORARY_FILE_RATIO')) {
78
-    define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.47 );
78
+	define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.47 );
79 79
   }
80 80
 
81 81
 // --------------------------------------------------------------------------------
@@ -189,20 +189,20 @@  discard block
 block discarded – undo
189 189
   // --------------------------------------------------------------------------------
190 190
   class PclZip
191 191
   {
192
-    // ----- Filename of the zip file
193
-    var $zipname = '';
192
+	// ----- Filename of the zip file
193
+	var $zipname = '';
194 194
 
195
-    // ----- File descriptor of the zip file
196
-    var $zip_fd = 0;
195
+	// ----- File descriptor of the zip file
196
+	var $zip_fd = 0;
197 197
 
198
-    // ----- Internal error handling
199
-    var $error_code = 1;
200
-    var $error_string = '';
198
+	// ----- Internal error handling
199
+	var $error_code = 1;
200
+	var $error_string = '';
201 201
     
202
-    // ----- Current status of the magic_quotes_runtime
203
-    // This value store the php configuration for magic_quotes
204
-    // The class can then disable the magic_quotes and reset it after
205
-    var $magic_quotes_status;
202
+	// ----- Current status of the magic_quotes_runtime
203
+	// This value store the php configuration for magic_quotes
204
+	// The class can then disable the magic_quotes and reset it after
205
+	var $magic_quotes_status;
206 206
 
207 207
   // --------------------------------------------------------------------------------
208 208
   // Function : PclZip()
@@ -215,25 +215,25 @@  discard block
 block discarded – undo
215 215
   function PclZip($p_zipname)
216 216
   {
217 217
 
218
-    // ----- Tests the zlib
219
-    if (!function_exists('gzopen'))
220
-    {
221
-      if (!function_exists('gzopen')
222
-        && function_exists('gzopen64')) {
223
-        function gzopen($filename , $mode = 'r', $use_include_path = 0 )
224
-        {
225
-            return gzopen64($filename , $mode, $use_include_path);
226
-        }
227
-      }
228
-    }
218
+	// ----- Tests the zlib
219
+	if (!function_exists('gzopen'))
220
+	{
221
+	  if (!function_exists('gzopen')
222
+		&& function_exists('gzopen64')) {
223
+		function gzopen($filename , $mode = 'r', $use_include_path = 0 )
224
+		{
225
+			return gzopen64($filename , $mode, $use_include_path);
226
+		}
227
+	  }
228
+	}
229 229
 
230
-    // ----- Set the attributes
231
-    $this->zipname = $p_zipname;
232
-    $this->zip_fd = 0;
233
-    $this->magic_quotes_status = -1;
230
+	// ----- Set the attributes
231
+	$this->zipname = $p_zipname;
232
+	$this->zip_fd = 0;
233
+	$this->magic_quotes_status = -1;
234 234
 
235
-    // ----- Return
236
-    return;
235
+	// ----- Return
236
+	return;
237 237
   }
238 238
   // --------------------------------------------------------------------------------
239 239
 
@@ -276,149 +276,149 @@  discard block
 block discarded – undo
276 276
   // --------------------------------------------------------------------------------
277 277
   function create($p_filelist)
278 278
   {
279
-    $v_result=1;
280
-
281
-    // ----- Reset the error handler
282
-    $this->privErrorReset();
283
-
284
-    // ----- Set default values
285
-    $v_options = array();
286
-    $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE;
287
-
288
-    // ----- Look for variable options arguments
289
-    $v_size = func_num_args();
290
-
291
-    // ----- Look for arguments
292
-    if ($v_size > 1) {
293
-      // ----- Get the arguments
294
-      $v_arg_list = func_get_args();
295
-
296
-      // ----- Remove from the options list the first argument
297
-      array_shift($v_arg_list);
298
-      $v_size--;
299
-
300
-      // ----- Look for first arg
301
-      if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
302
-
303
-        // ----- Parse the options
304
-        $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
305
-                                            array (PCLZIP_OPT_REMOVE_PATH => 'optional',
306
-                                                   PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
307
-                                                   PCLZIP_OPT_ADD_PATH => 'optional',
308
-                                                   PCLZIP_CB_PRE_ADD => 'optional',
309
-                                                   PCLZIP_CB_POST_ADD => 'optional',
310
-                                                   PCLZIP_OPT_NO_COMPRESSION => 'optional',
311
-                                                   PCLZIP_OPT_COMMENT => 'optional',
312
-                                                   PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
313
-                                                   PCLZIP_OPT_TEMP_FILE_ON => 'optional',
314
-                                                   PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
315
-                                                   //, PCLZIP_OPT_CRYPT => 'optional'
316
-                                             ));
317
-        if ($v_result != 1) {
318
-          return 0;
319
-        }
320
-      }
279
+	$v_result=1;
280
+
281
+	// ----- Reset the error handler
282
+	$this->privErrorReset();
283
+
284
+	// ----- Set default values
285
+	$v_options = array();
286
+	$v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE;
287
+
288
+	// ----- Look for variable options arguments
289
+	$v_size = func_num_args();
290
+
291
+	// ----- Look for arguments
292
+	if ($v_size > 1) {
293
+	  // ----- Get the arguments
294
+	  $v_arg_list = func_get_args();
295
+
296
+	  // ----- Remove from the options list the first argument
297
+	  array_shift($v_arg_list);
298
+	  $v_size--;
299
+
300
+	  // ----- Look for first arg
301
+	  if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
302
+
303
+		// ----- Parse the options
304
+		$v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
305
+											array (PCLZIP_OPT_REMOVE_PATH => 'optional',
306
+												   PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
307
+												   PCLZIP_OPT_ADD_PATH => 'optional',
308
+												   PCLZIP_CB_PRE_ADD => 'optional',
309
+												   PCLZIP_CB_POST_ADD => 'optional',
310
+												   PCLZIP_OPT_NO_COMPRESSION => 'optional',
311
+												   PCLZIP_OPT_COMMENT => 'optional',
312
+												   PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
313
+												   PCLZIP_OPT_TEMP_FILE_ON => 'optional',
314
+												   PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
315
+												   //, PCLZIP_OPT_CRYPT => 'optional'
316
+											 ));
317
+		if ($v_result != 1) {
318
+		  return 0;
319
+		}
320
+	  }
321 321
 
322
-      // ----- Look for 2 args
323
-      // Here we need to support the first historic synopsis of the
324
-      // method.
325
-      else {
326
-
327
-        // ----- Get the first argument
328
-        $v_options[PCLZIP_OPT_ADD_PATH] = $v_arg_list[0];
329
-
330
-        // ----- Look for the optional second argument
331
-        if ($v_size == 2) {
332
-          $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
333
-        }
334
-        else if ($v_size > 2) {
335
-          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
336
-		                       "Invalid number / type of arguments");
337
-          return 0;
338
-        }
339
-      }
340
-    }
322
+	  // ----- Look for 2 args
323
+	  // Here we need to support the first historic synopsis of the
324
+	  // method.
325
+	  else {
326
+
327
+		// ----- Get the first argument
328
+		$v_options[PCLZIP_OPT_ADD_PATH] = $v_arg_list[0];
329
+
330
+		// ----- Look for the optional second argument
331
+		if ($v_size == 2) {
332
+		  $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
333
+		}
334
+		else if ($v_size > 2) {
335
+		  PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
336
+							   "Invalid number / type of arguments");
337
+		  return 0;
338
+		}
339
+	  }
340
+	}
341 341
     
342
-    // ----- Look for default option values
343
-    $this->privOptionDefaultThreshold($v_options);
344
-
345
-    // ----- Init
346
-    $v_string_list = array();
347
-    $v_att_list = array();
348
-    $v_filedescr_list = array();
349
-    $p_result_list = array();
342
+	// ----- Look for default option values
343
+	$this->privOptionDefaultThreshold($v_options);
344
+
345
+	// ----- Init
346
+	$v_string_list = array();
347
+	$v_att_list = array();
348
+	$v_filedescr_list = array();
349
+	$p_result_list = array();
350 350
     
351
-    // ----- Look if the $p_filelist is really an array
352
-    if (is_array($p_filelist)) {
351
+	// ----- Look if the $p_filelist is really an array
352
+	if (is_array($p_filelist)) {
353 353
     
354
-      // ----- Look if the first element is also an array
355
-      //       This will mean that this is a file description entry
356
-      if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
357
-        $v_att_list = $p_filelist;
358
-      }
354
+	  // ----- Look if the first element is also an array
355
+	  //       This will mean that this is a file description entry
356
+	  if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
357
+		$v_att_list = $p_filelist;
358
+	  }
359 359
       
360
-      // ----- The list is a list of string names
361
-      else {
362
-        $v_string_list = $p_filelist;
363
-      }
364
-    }
360
+	  // ----- The list is a list of string names
361
+	  else {
362
+		$v_string_list = $p_filelist;
363
+	  }
364
+	}
365 365
 
366
-    // ----- Look if the $p_filelist is a string
367
-    else if (is_string($p_filelist)) {
368
-      // ----- Create a list from the string
369
-      $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist);
370
-    }
366
+	// ----- Look if the $p_filelist is a string
367
+	else if (is_string($p_filelist)) {
368
+	  // ----- Create a list from the string
369
+	  $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist);
370
+	}
371 371
 
372
-    // ----- Invalid variable type for $p_filelist
373
-    else {
374
-      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist");
375
-      return 0;
376
-    }
372
+	// ----- Invalid variable type for $p_filelist
373
+	else {
374
+	  PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist");
375
+	  return 0;
376
+	}
377 377
     
378
-    // ----- Reformat the string list
379
-    if (sizeof($v_string_list) != 0) {
380
-      foreach ($v_string_list as $v_string) {
381
-        if ($v_string != '') {
382
-          $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
383
-        }
384
-        else {
385
-        }
386
-      }
387
-    }
378
+	// ----- Reformat the string list
379
+	if (sizeof($v_string_list) != 0) {
380
+	  foreach ($v_string_list as $v_string) {
381
+		if ($v_string != '') {
382
+		  $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
383
+		}
384
+		else {
385
+		}
386
+	  }
387
+	}
388 388
     
389
-    // ----- For each file in the list check the attributes
390
-    $v_supported_attributes
391
-    = array ( PCLZIP_ATT_FILE_NAME => 'mandatory'
392
-             ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional'
393
-             ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional'
394
-             ,PCLZIP_ATT_FILE_MTIME => 'optional'
395
-             ,PCLZIP_ATT_FILE_CONTENT => 'optional'
396
-             ,PCLZIP_ATT_FILE_COMMENT => 'optional'
389
+	// ----- For each file in the list check the attributes
390
+	$v_supported_attributes
391
+	= array ( PCLZIP_ATT_FILE_NAME => 'mandatory'
392
+			 ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional'
393
+			 ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional'
394
+			 ,PCLZIP_ATT_FILE_MTIME => 'optional'
395
+			 ,PCLZIP_ATT_FILE_CONTENT => 'optional'
396
+			 ,PCLZIP_ATT_FILE_COMMENT => 'optional'
397 397
 						);
398
-    foreach ($v_att_list as $v_entry) {
399
-      $v_result = $this->privFileDescrParseAtt($v_entry,
400
-                                               $v_filedescr_list[],
401
-                                               $v_options,
402
-                                               $v_supported_attributes);
403
-      if ($v_result != 1) {
404
-        return 0;
405
-      }
406
-    }
398
+	foreach ($v_att_list as $v_entry) {
399
+	  $v_result = $this->privFileDescrParseAtt($v_entry,
400
+											   $v_filedescr_list[],
401
+											   $v_options,
402
+											   $v_supported_attributes);
403
+	  if ($v_result != 1) {
404
+		return 0;
405
+	  }
406
+	}
407 407
 
408
-    // ----- Expand the filelist (expand directories)
409
-    $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options);
410
-    if ($v_result != 1) {
411
-      return 0;
412
-    }
408
+	// ----- Expand the filelist (expand directories)
409
+	$v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options);
410
+	if ($v_result != 1) {
411
+	  return 0;
412
+	}
413 413
 
414
-    // ----- Call the create fct
415
-    $v_result = $this->privCreate($v_filedescr_list, $p_result_list, $v_options);
416
-    if ($v_result != 1) {
417
-      return 0;
418
-    }
414
+	// ----- Call the create fct
415
+	$v_result = $this->privCreate($v_filedescr_list, $p_result_list, $v_options);
416
+	if ($v_result != 1) {
417
+	  return 0;
418
+	}
419 419
 
420
-    // ----- Return
421
-    return $p_result_list;
420
+	// ----- Return
421
+	return $p_result_list;
422 422
   }
423 423
   // --------------------------------------------------------------------------------
424 424
 
@@ -459,149 +459,149 @@  discard block
 block discarded – undo
459 459
   // --------------------------------------------------------------------------------
460 460
   function add($p_filelist)
461 461
   {
462
-    $v_result=1;
463
-
464
-    // ----- Reset the error handler
465
-    $this->privErrorReset();
466
-
467
-    // ----- Set default values
468
-    $v_options = array();
469
-    $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE;
470
-
471
-    // ----- Look for variable options arguments
472
-    $v_size = func_num_args();
473
-
474
-    // ----- Look for arguments
475
-    if ($v_size > 1) {
476
-      // ----- Get the arguments
477
-      $v_arg_list = func_get_args();
478
-
479
-      // ----- Remove form the options list the first argument
480
-      array_shift($v_arg_list);
481
-      $v_size--;
482
-
483
-      // ----- Look for first arg
484
-      if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
485
-
486
-        // ----- Parse the options
487
-        $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
488
-                                            array (PCLZIP_OPT_REMOVE_PATH => 'optional',
489
-                                                   PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
490
-                                                   PCLZIP_OPT_ADD_PATH => 'optional',
491
-                                                   PCLZIP_CB_PRE_ADD => 'optional',
492
-                                                   PCLZIP_CB_POST_ADD => 'optional',
493
-                                                   PCLZIP_OPT_NO_COMPRESSION => 'optional',
494
-                                                   PCLZIP_OPT_COMMENT => 'optional',
495
-                                                   PCLZIP_OPT_ADD_COMMENT => 'optional',
496
-                                                   PCLZIP_OPT_PREPEND_COMMENT => 'optional',
497
-                                                   PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
498
-                                                   PCLZIP_OPT_TEMP_FILE_ON => 'optional',
499
-                                                   PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
500
-                                                   //, PCLZIP_OPT_CRYPT => 'optional'
462
+	$v_result=1;
463
+
464
+	// ----- Reset the error handler
465
+	$this->privErrorReset();
466
+
467
+	// ----- Set default values
468
+	$v_options = array();
469
+	$v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE;
470
+
471
+	// ----- Look for variable options arguments
472
+	$v_size = func_num_args();
473
+
474
+	// ----- Look for arguments
475
+	if ($v_size > 1) {
476
+	  // ----- Get the arguments
477
+	  $v_arg_list = func_get_args();
478
+
479
+	  // ----- Remove form the options list the first argument
480
+	  array_shift($v_arg_list);
481
+	  $v_size--;
482
+
483
+	  // ----- Look for first arg
484
+	  if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
485
+
486
+		// ----- Parse the options
487
+		$v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
488
+											array (PCLZIP_OPT_REMOVE_PATH => 'optional',
489
+												   PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
490
+												   PCLZIP_OPT_ADD_PATH => 'optional',
491
+												   PCLZIP_CB_PRE_ADD => 'optional',
492
+												   PCLZIP_CB_POST_ADD => 'optional',
493
+												   PCLZIP_OPT_NO_COMPRESSION => 'optional',
494
+												   PCLZIP_OPT_COMMENT => 'optional',
495
+												   PCLZIP_OPT_ADD_COMMENT => 'optional',
496
+												   PCLZIP_OPT_PREPEND_COMMENT => 'optional',
497
+												   PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
498
+												   PCLZIP_OPT_TEMP_FILE_ON => 'optional',
499
+												   PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
500
+												   //, PCLZIP_OPT_CRYPT => 'optional'
501 501
 												   ));
502
-        if ($v_result != 1) {
503
-          return 0;
504
-        }
505
-      }
502
+		if ($v_result != 1) {
503
+		  return 0;
504
+		}
505
+	  }
506 506
 
507
-      // ----- Look for 2 args
508
-      // Here we need to support the first historic synopsis of the
509
-      // method.
510
-      else {
511
-
512
-        // ----- Get the first argument
513
-        $v_options[PCLZIP_OPT_ADD_PATH] = $v_add_path = $v_arg_list[0];
514
-
515
-        // ----- Look for the optional second argument
516
-        if ($v_size == 2) {
517
-          $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
518
-        }
519
-        else if ($v_size > 2) {
520
-          // ----- Error log
521
-          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
522
-
523
-          // ----- Return
524
-          return 0;
525
-        }
526
-      }
527
-    }
507
+	  // ----- Look for 2 args
508
+	  // Here we need to support the first historic synopsis of the
509
+	  // method.
510
+	  else {
511
+
512
+		// ----- Get the first argument
513
+		$v_options[PCLZIP_OPT_ADD_PATH] = $v_add_path = $v_arg_list[0];
514
+
515
+		// ----- Look for the optional second argument
516
+		if ($v_size == 2) {
517
+		  $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
518
+		}
519
+		else if ($v_size > 2) {
520
+		  // ----- Error log
521
+		  PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
522
+
523
+		  // ----- Return
524
+		  return 0;
525
+		}
526
+	  }
527
+	}
528 528
 
529
-    // ----- Look for default option values
530
-    $this->privOptionDefaultThreshold($v_options);
529
+	// ----- Look for default option values
530
+	$this->privOptionDefaultThreshold($v_options);
531 531
 
532
-    // ----- Init
533
-    $v_string_list = array();
534
-    $v_att_list = array();
535
-    $v_filedescr_list = array();
536
-    $p_result_list = array();
532
+	// ----- Init
533
+	$v_string_list = array();
534
+	$v_att_list = array();
535
+	$v_filedescr_list = array();
536
+	$p_result_list = array();
537 537
     
538
-    // ----- Look if the $p_filelist is really an array
539
-    if (is_array($p_filelist)) {
538
+	// ----- Look if the $p_filelist is really an array
539
+	if (is_array($p_filelist)) {
540 540
     
541
-      // ----- Look if the first element is also an array
542
-      //       This will mean that this is a file description entry
543
-      if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
544
-        $v_att_list = $p_filelist;
545
-      }
541
+	  // ----- Look if the first element is also an array
542
+	  //       This will mean that this is a file description entry
543
+	  if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
544
+		$v_att_list = $p_filelist;
545
+	  }
546 546
       
547
-      // ----- The list is a list of string names
548
-      else {
549
-        $v_string_list = $p_filelist;
550
-      }
551
-    }
547
+	  // ----- The list is a list of string names
548
+	  else {
549
+		$v_string_list = $p_filelist;
550
+	  }
551
+	}
552 552
 
553
-    // ----- Look if the $p_filelist is a string
554
-    else if (is_string($p_filelist)) {
555
-      // ----- Create a list from the string
556
-      $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist);
557
-    }
553
+	// ----- Look if the $p_filelist is a string
554
+	else if (is_string($p_filelist)) {
555
+	  // ----- Create a list from the string
556
+	  $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist);
557
+	}
558 558
 
559
-    // ----- Invalid variable type for $p_filelist
560
-    else {
561
-      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '".gettype($p_filelist)."' for p_filelist");
562
-      return 0;
563
-    }
559
+	// ----- Invalid variable type for $p_filelist
560
+	else {
561
+	  PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '".gettype($p_filelist)."' for p_filelist");
562
+	  return 0;
563
+	}
564 564
     
565
-    // ----- Reformat the string list
566
-    if (sizeof($v_string_list) != 0) {
567
-      foreach ($v_string_list as $v_string) {
568
-        $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
569
-      }
570
-    }
565
+	// ----- Reformat the string list
566
+	if (sizeof($v_string_list) != 0) {
567
+	  foreach ($v_string_list as $v_string) {
568
+		$v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
569
+	  }
570
+	}
571 571
     
572
-    // ----- For each file in the list check the attributes
573
-    $v_supported_attributes
574
-    = array ( PCLZIP_ATT_FILE_NAME => 'mandatory'
575
-             ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional'
576
-             ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional'
577
-             ,PCLZIP_ATT_FILE_MTIME => 'optional'
578
-             ,PCLZIP_ATT_FILE_CONTENT => 'optional'
579
-             ,PCLZIP_ATT_FILE_COMMENT => 'optional'
572
+	// ----- For each file in the list check the attributes
573
+	$v_supported_attributes
574
+	= array ( PCLZIP_ATT_FILE_NAME => 'mandatory'
575
+			 ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional'
576
+			 ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional'
577
+			 ,PCLZIP_ATT_FILE_MTIME => 'optional'
578
+			 ,PCLZIP_ATT_FILE_CONTENT => 'optional'
579
+			 ,PCLZIP_ATT_FILE_COMMENT => 'optional'
580 580
 						);
581
-    foreach ($v_att_list as $v_entry) {
582
-      $v_result = $this->privFileDescrParseAtt($v_entry,
583
-                                               $v_filedescr_list[],
584
-                                               $v_options,
585
-                                               $v_supported_attributes);
586
-      if ($v_result != 1) {
587
-        return 0;
588
-      }
589
-    }
581
+	foreach ($v_att_list as $v_entry) {
582
+	  $v_result = $this->privFileDescrParseAtt($v_entry,
583
+											   $v_filedescr_list[],
584
+											   $v_options,
585
+											   $v_supported_attributes);
586
+	  if ($v_result != 1) {
587
+		return 0;
588
+	  }
589
+	}
590 590
 
591
-    // ----- Expand the filelist (expand directories)
592
-    $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options);
593
-    if ($v_result != 1) {
594
-      return 0;
595
-    }
591
+	// ----- Expand the filelist (expand directories)
592
+	$v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options);
593
+	if ($v_result != 1) {
594
+	  return 0;
595
+	}
596 596
 
597
-    // ----- Call the create fct
598
-    $v_result = $this->privAdd($v_filedescr_list, $p_result_list, $v_options);
599
-    if ($v_result != 1) {
600
-      return 0;
601
-    }
597
+	// ----- Call the create fct
598
+	$v_result = $this->privAdd($v_filedescr_list, $p_result_list, $v_options);
599
+	if ($v_result != 1) {
600
+	  return 0;
601
+	}
602 602
 
603
-    // ----- Return
604
-    return $p_result_list;
603
+	// ----- Return
604
+	return $p_result_list;
605 605
   }
606 606
   // --------------------------------------------------------------------------------
607 607
 
@@ -648,26 +648,26 @@  discard block
 block discarded – undo
648 648
   // --------------------------------------------------------------------------------
649 649
   function listContent()
650 650
   {
651
-    $v_result=1;
651
+	$v_result=1;
652 652
 
653
-    // ----- Reset the error handler
654
-    $this->privErrorReset();
653
+	// ----- Reset the error handler
654
+	$this->privErrorReset();
655 655
 
656
-    // ----- Check archive
657
-    if (!$this->privCheckFormat()) {
658
-      return(0);
659
-    }
656
+	// ----- Check archive
657
+	if (!$this->privCheckFormat()) {
658
+	  return(0);
659
+	}
660 660
 
661
-    // ----- Call the extracting fct
662
-    $p_list = array();
663
-    if (($v_result = $this->privList($p_list)) != 1)
664
-    {
665
-      unset($p_list);
666
-      return(0);
667
-    }
661
+	// ----- Call the extracting fct
662
+	$p_list = array();
663
+	if (($v_result = $this->privList($p_list)) != 1)
664
+	{
665
+	  unset($p_list);
666
+	  return(0);
667
+	}
668 668
 
669
-    // ----- Return
670
-    return $p_list;
669
+	// ----- Return
670
+	return $p_list;
671 671
   }
672 672
   // --------------------------------------------------------------------------------
673 673
 
@@ -705,120 +705,120 @@  discard block
 block discarded – undo
705 705
   // --------------------------------------------------------------------------------
706 706
   function extract()
707 707
   {
708
-    $v_result=1;
708
+	$v_result=1;
709 709
 
710
-    // ----- Reset the error handler
711
-    $this->privErrorReset();
710
+	// ----- Reset the error handler
711
+	$this->privErrorReset();
712 712
 
713
-    // ----- Check archive
714
-    if (!$this->privCheckFormat()) {
715
-      return(0);
716
-    }
713
+	// ----- Check archive
714
+	if (!$this->privCheckFormat()) {
715
+	  return(0);
716
+	}
717 717
 
718
-    // ----- Set default values
719
-    $v_options = array();
718
+	// ----- Set default values
719
+	$v_options = array();
720 720
 //    $v_path = "./";
721
-    $v_path = '';
722
-    $v_remove_path = "";
723
-    $v_remove_all_path = false;
724
-
725
-    // ----- Look for variable options arguments
726
-    $v_size = func_num_args();
727
-
728
-    // ----- Default values for option
729
-    $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
730
-
731
-    // ----- Look for arguments
732
-    if ($v_size > 0) {
733
-      // ----- Get the arguments
734
-      $v_arg_list = func_get_args();
735
-
736
-      // ----- Look for first arg
737
-      if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
738
-
739
-        // ----- Parse the options
740
-        $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
741
-                                            array (PCLZIP_OPT_PATH => 'optional',
742
-                                                   PCLZIP_OPT_REMOVE_PATH => 'optional',
743
-                                                   PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
744
-                                                   PCLZIP_OPT_ADD_PATH => 'optional',
745
-                                                   PCLZIP_CB_PRE_EXTRACT => 'optional',
746
-                                                   PCLZIP_CB_POST_EXTRACT => 'optional',
747
-                                                   PCLZIP_OPT_SET_CHMOD => 'optional',
748
-                                                   PCLZIP_OPT_BY_NAME => 'optional',
749
-                                                   PCLZIP_OPT_BY_EREG => 'optional',
750
-                                                   PCLZIP_OPT_BY_PREG => 'optional',
751
-                                                   PCLZIP_OPT_BY_INDEX => 'optional',
752
-                                                   PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',
753
-                                                   PCLZIP_OPT_EXTRACT_IN_OUTPUT => 'optional',
754
-                                                   PCLZIP_OPT_REPLACE_NEWER => 'optional'
755
-                                                   ,PCLZIP_OPT_STOP_ON_ERROR => 'optional'
756
-                                                   ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional',
757
-                                                   PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
758
-                                                   PCLZIP_OPT_TEMP_FILE_ON => 'optional',
759
-                                                   PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
760
-												    ));
761
-        if ($v_result != 1) {
762
-          return 0;
763
-        }
764
-
765
-        // ----- Set the arguments
766
-        if (isset($v_options[PCLZIP_OPT_PATH])) {
767
-          $v_path = $v_options[PCLZIP_OPT_PATH];
768
-        }
769
-        if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {
770
-          $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];
771
-        }
772
-        if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
773
-          $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];
774
-        }
775
-        if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
776
-          // ----- Check for '/' in last path char
777
-          if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
778
-            $v_path .= '/';
779
-          }
780
-          $v_path .= $v_options[PCLZIP_OPT_ADD_PATH];
781
-        }
782
-      }
721
+	$v_path = '';
722
+	$v_remove_path = "";
723
+	$v_remove_all_path = false;
724
+
725
+	// ----- Look for variable options arguments
726
+	$v_size = func_num_args();
727
+
728
+	// ----- Default values for option
729
+	$v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
730
+
731
+	// ----- Look for arguments
732
+	if ($v_size > 0) {
733
+	  // ----- Get the arguments
734
+	  $v_arg_list = func_get_args();
735
+
736
+	  // ----- Look for first arg
737
+	  if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
738
+
739
+		// ----- Parse the options
740
+		$v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
741
+											array (PCLZIP_OPT_PATH => 'optional',
742
+												   PCLZIP_OPT_REMOVE_PATH => 'optional',
743
+												   PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
744
+												   PCLZIP_OPT_ADD_PATH => 'optional',
745
+												   PCLZIP_CB_PRE_EXTRACT => 'optional',
746
+												   PCLZIP_CB_POST_EXTRACT => 'optional',
747
+												   PCLZIP_OPT_SET_CHMOD => 'optional',
748
+												   PCLZIP_OPT_BY_NAME => 'optional',
749
+												   PCLZIP_OPT_BY_EREG => 'optional',
750
+												   PCLZIP_OPT_BY_PREG => 'optional',
751
+												   PCLZIP_OPT_BY_INDEX => 'optional',
752
+												   PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',
753
+												   PCLZIP_OPT_EXTRACT_IN_OUTPUT => 'optional',
754
+												   PCLZIP_OPT_REPLACE_NEWER => 'optional'
755
+												   ,PCLZIP_OPT_STOP_ON_ERROR => 'optional'
756
+												   ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional',
757
+												   PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
758
+												   PCLZIP_OPT_TEMP_FILE_ON => 'optional',
759
+												   PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
760
+													));
761
+		if ($v_result != 1) {
762
+		  return 0;
763
+		}
764
+
765
+		// ----- Set the arguments
766
+		if (isset($v_options[PCLZIP_OPT_PATH])) {
767
+		  $v_path = $v_options[PCLZIP_OPT_PATH];
768
+		}
769
+		if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {
770
+		  $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];
771
+		}
772
+		if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
773
+		  $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];
774
+		}
775
+		if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
776
+		  // ----- Check for '/' in last path char
777
+		  if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
778
+			$v_path .= '/';
779
+		  }
780
+		  $v_path .= $v_options[PCLZIP_OPT_ADD_PATH];
781
+		}
782
+	  }
783 783
 
784
-      // ----- Look for 2 args
785
-      // Here we need to support the first historic synopsis of the
786
-      // method.
787
-      else {
788
-
789
-        // ----- Get the first argument
790
-        $v_path = $v_arg_list[0];
791
-
792
-        // ----- Look for the optional second argument
793
-        if ($v_size == 2) {
794
-          $v_remove_path = $v_arg_list[1];
795
-        }
796
-        else if ($v_size > 2) {
797
-          // ----- Error log
798
-          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
799
-
800
-          // ----- Return
801
-          return 0;
802
-        }
803
-      }
804
-    }
784
+	  // ----- Look for 2 args
785
+	  // Here we need to support the first historic synopsis of the
786
+	  // method.
787
+	  else {
788
+
789
+		// ----- Get the first argument
790
+		$v_path = $v_arg_list[0];
791
+
792
+		// ----- Look for the optional second argument
793
+		if ($v_size == 2) {
794
+		  $v_remove_path = $v_arg_list[1];
795
+		}
796
+		else if ($v_size > 2) {
797
+		  // ----- Error log
798
+		  PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
799
+
800
+		  // ----- Return
801
+		  return 0;
802
+		}
803
+	  }
804
+	}
805 805
 
806
-    // ----- Look for default option values
807
-    $this->privOptionDefaultThreshold($v_options);
806
+	// ----- Look for default option values
807
+	$this->privOptionDefaultThreshold($v_options);
808 808
 
809
-    // ----- Trace
809
+	// ----- Trace
810 810
 
811
-    // ----- Call the extracting fct
812
-    $p_list = array();
813
-    $v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path,
814
-	                                     $v_remove_all_path, $v_options);
815
-    if ($v_result < 1) {
816
-      unset($p_list);
817
-      return(0);
818
-    }
811
+	// ----- Call the extracting fct
812
+	$p_list = array();
813
+	$v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path,
814
+										 $v_remove_all_path, $v_options);
815
+	if ($v_result < 1) {
816
+	  unset($p_list);
817
+	  return(0);
818
+	}
819 819
 
820
-    // ----- Return
821
-    return $p_list;
820
+	// ----- Return
821
+	return $p_list;
822 822
   }
823 823
   // --------------------------------------------------------------------------------
824 824
 
@@ -862,132 +862,132 @@  discard block
 block discarded – undo
862 862
   //function extractByIndex($p_index, options...)
863 863
   function extractByIndex($p_index)
864 864
   {
865
-    $v_result=1;
865
+	$v_result=1;
866 866
 
867
-    // ----- Reset the error handler
868
-    $this->privErrorReset();
867
+	// ----- Reset the error handler
868
+	$this->privErrorReset();
869 869
 
870
-    // ----- Check archive
871
-    if (!$this->privCheckFormat()) {
872
-      return(0);
873
-    }
870
+	// ----- Check archive
871
+	if (!$this->privCheckFormat()) {
872
+	  return(0);
873
+	}
874 874
 
875
-    // ----- Set default values
876
-    $v_options = array();
875
+	// ----- Set default values
876
+	$v_options = array();
877 877
 //    $v_path = "./";
878
-    $v_path = '';
879
-    $v_remove_path = "";
880
-    $v_remove_all_path = false;
881
-
882
-    // ----- Look for variable options arguments
883
-    $v_size = func_num_args();
884
-
885
-    // ----- Default values for option
886
-    $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
887
-
888
-    // ----- Look for arguments
889
-    if ($v_size > 1) {
890
-      // ----- Get the arguments
891
-      $v_arg_list = func_get_args();
892
-
893
-      // ----- Remove form the options list the first argument
894
-      array_shift($v_arg_list);
895
-      $v_size--;
896
-
897
-      // ----- Look for first arg
898
-      if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
899
-
900
-        // ----- Parse the options
901
-        $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
902
-                                            array (PCLZIP_OPT_PATH => 'optional',
903
-                                                   PCLZIP_OPT_REMOVE_PATH => 'optional',
904
-                                                   PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
905
-                                                   PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',
906
-                                                   PCLZIP_OPT_ADD_PATH => 'optional',
907
-                                                   PCLZIP_CB_PRE_EXTRACT => 'optional',
908
-                                                   PCLZIP_CB_POST_EXTRACT => 'optional',
909
-                                                   PCLZIP_OPT_SET_CHMOD => 'optional',
910
-                                                   PCLZIP_OPT_REPLACE_NEWER => 'optional'
911
-                                                   ,PCLZIP_OPT_STOP_ON_ERROR => 'optional'
912
-                                                   ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional',
913
-                                                   PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
914
-                                                   PCLZIP_OPT_TEMP_FILE_ON => 'optional',
915
-                                                   PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
878
+	$v_path = '';
879
+	$v_remove_path = "";
880
+	$v_remove_all_path = false;
881
+
882
+	// ----- Look for variable options arguments
883
+	$v_size = func_num_args();
884
+
885
+	// ----- Default values for option
886
+	$v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
887
+
888
+	// ----- Look for arguments
889
+	if ($v_size > 1) {
890
+	  // ----- Get the arguments
891
+	  $v_arg_list = func_get_args();
892
+
893
+	  // ----- Remove form the options list the first argument
894
+	  array_shift($v_arg_list);
895
+	  $v_size--;
896
+
897
+	  // ----- Look for first arg
898
+	  if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
899
+
900
+		// ----- Parse the options
901
+		$v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
902
+											array (PCLZIP_OPT_PATH => 'optional',
903
+												   PCLZIP_OPT_REMOVE_PATH => 'optional',
904
+												   PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
905
+												   PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',
906
+												   PCLZIP_OPT_ADD_PATH => 'optional',
907
+												   PCLZIP_CB_PRE_EXTRACT => 'optional',
908
+												   PCLZIP_CB_POST_EXTRACT => 'optional',
909
+												   PCLZIP_OPT_SET_CHMOD => 'optional',
910
+												   PCLZIP_OPT_REPLACE_NEWER => 'optional'
911
+												   ,PCLZIP_OPT_STOP_ON_ERROR => 'optional'
912
+												   ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional',
913
+												   PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
914
+												   PCLZIP_OPT_TEMP_FILE_ON => 'optional',
915
+												   PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
916 916
 												   ));
917
-        if ($v_result != 1) {
918
-          return 0;
919
-        }
920
-
921
-        // ----- Set the arguments
922
-        if (isset($v_options[PCLZIP_OPT_PATH])) {
923
-          $v_path = $v_options[PCLZIP_OPT_PATH];
924
-        }
925
-        if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {
926
-          $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];
927
-        }
928
-        if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
929
-          $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];
930
-        }
931
-        if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
932
-          // ----- Check for '/' in last path char
933
-          if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
934
-            $v_path .= '/';
935
-          }
936
-          $v_path .= $v_options[PCLZIP_OPT_ADD_PATH];
937
-        }
938
-        if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) {
939
-          $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
940
-        }
941
-        else {
942
-        }
943
-      }
917
+		if ($v_result != 1) {
918
+		  return 0;
919
+		}
920
+
921
+		// ----- Set the arguments
922
+		if (isset($v_options[PCLZIP_OPT_PATH])) {
923
+		  $v_path = $v_options[PCLZIP_OPT_PATH];
924
+		}
925
+		if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {
926
+		  $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];
927
+		}
928
+		if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
929
+		  $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];
930
+		}
931
+		if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
932
+		  // ----- Check for '/' in last path char
933
+		  if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
934
+			$v_path .= '/';
935
+		  }
936
+		  $v_path .= $v_options[PCLZIP_OPT_ADD_PATH];
937
+		}
938
+		if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) {
939
+		  $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
940
+		}
941
+		else {
942
+		}
943
+	  }
944 944
 
945
-      // ----- Look for 2 args
946
-      // Here we need to support the first historic synopsis of the
947
-      // method.
948
-      else {
949
-
950
-        // ----- Get the first argument
951
-        $v_path = $v_arg_list[0];
952
-
953
-        // ----- Look for the optional second argument
954
-        if ($v_size == 2) {
955
-          $v_remove_path = $v_arg_list[1];
956
-        }
957
-        else if ($v_size > 2) {
958
-          // ----- Error log
959
-          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
960
-
961
-          // ----- Return
962
-          return 0;
963
-        }
964
-      }
965
-    }
945
+	  // ----- Look for 2 args
946
+	  // Here we need to support the first historic synopsis of the
947
+	  // method.
948
+	  else {
949
+
950
+		// ----- Get the first argument
951
+		$v_path = $v_arg_list[0];
952
+
953
+		// ----- Look for the optional second argument
954
+		if ($v_size == 2) {
955
+		  $v_remove_path = $v_arg_list[1];
956
+		}
957
+		else if ($v_size > 2) {
958
+		  // ----- Error log
959
+		  PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
960
+
961
+		  // ----- Return
962
+		  return 0;
963
+		}
964
+	  }
965
+	}
966 966
 
967
-    // ----- Trace
968
-
969
-    // ----- Trick
970
-    // Here I want to reuse extractByRule(), so I need to parse the $p_index
971
-    // with privParseOptions()
972
-    $v_arg_trick = array (PCLZIP_OPT_BY_INDEX, $p_index);
973
-    $v_options_trick = array();
974
-    $v_result = $this->privParseOptions($v_arg_trick, sizeof($v_arg_trick), $v_options_trick,
975
-                                        array (PCLZIP_OPT_BY_INDEX => 'optional' ));
976
-    if ($v_result != 1) {
977
-        return 0;
978
-    }
979
-    $v_options[PCLZIP_OPT_BY_INDEX] = $v_options_trick[PCLZIP_OPT_BY_INDEX];
967
+	// ----- Trace
968
+
969
+	// ----- Trick
970
+	// Here I want to reuse extractByRule(), so I need to parse the $p_index
971
+	// with privParseOptions()
972
+	$v_arg_trick = array (PCLZIP_OPT_BY_INDEX, $p_index);
973
+	$v_options_trick = array();
974
+	$v_result = $this->privParseOptions($v_arg_trick, sizeof($v_arg_trick), $v_options_trick,
975
+										array (PCLZIP_OPT_BY_INDEX => 'optional' ));
976
+	if ($v_result != 1) {
977
+		return 0;
978
+	}
979
+	$v_options[PCLZIP_OPT_BY_INDEX] = $v_options_trick[PCLZIP_OPT_BY_INDEX];
980 980
 
981
-    // ----- Look for default option values
982
-    $this->privOptionDefaultThreshold($v_options);
981
+	// ----- Look for default option values
982
+	$this->privOptionDefaultThreshold($v_options);
983 983
 
984
-    // ----- Call the extracting fct
985
-    if (($v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, $v_remove_all_path, $v_options)) < 1) {
986
-        return(0);
987
-    }
984
+	// ----- Call the extracting fct
985
+	if (($v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, $v_remove_all_path, $v_options)) < 1) {
986
+		return(0);
987
+	}
988 988
 
989
-    // ----- Return
990
-    return $p_list;
989
+	// ----- Return
990
+	return $p_list;
991 991
   }
992 992
   // --------------------------------------------------------------------------------
993 993
 
@@ -1011,54 +1011,54 @@  discard block
 block discarded – undo
1011 1011
   // --------------------------------------------------------------------------------
1012 1012
   function delete()
1013 1013
   {
1014
-    $v_result=1;
1014
+	$v_result=1;
1015 1015
 
1016
-    // ----- Reset the error handler
1017
-    $this->privErrorReset();
1016
+	// ----- Reset the error handler
1017
+	$this->privErrorReset();
1018 1018
 
1019
-    // ----- Check archive
1020
-    if (!$this->privCheckFormat()) {
1021
-      return(0);
1022
-    }
1019
+	// ----- Check archive
1020
+	if (!$this->privCheckFormat()) {
1021
+	  return(0);
1022
+	}
1023 1023
 
1024
-    // ----- Set default values
1025
-    $v_options = array();
1026
-
1027
-    // ----- Look for variable options arguments
1028
-    $v_size = func_num_args();
1029
-
1030
-    // ----- Look for arguments
1031
-    if ($v_size > 0) {
1032
-      // ----- Get the arguments
1033
-      $v_arg_list = func_get_args();
1034
-
1035
-      // ----- Parse the options
1036
-      $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
1037
-                                        array (PCLZIP_OPT_BY_NAME => 'optional',
1038
-                                               PCLZIP_OPT_BY_EREG => 'optional',
1039
-                                               PCLZIP_OPT_BY_PREG => 'optional',
1040
-                                               PCLZIP_OPT_BY_INDEX => 'optional' ));
1041
-      if ($v_result != 1) {
1042
-          return 0;
1043
-      }
1044
-    }
1024
+	// ----- Set default values
1025
+	$v_options = array();
1026
+
1027
+	// ----- Look for variable options arguments
1028
+	$v_size = func_num_args();
1029
+
1030
+	// ----- Look for arguments
1031
+	if ($v_size > 0) {
1032
+	  // ----- Get the arguments
1033
+	  $v_arg_list = func_get_args();
1034
+
1035
+	  // ----- Parse the options
1036
+	  $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
1037
+										array (PCLZIP_OPT_BY_NAME => 'optional',
1038
+											   PCLZIP_OPT_BY_EREG => 'optional',
1039
+											   PCLZIP_OPT_BY_PREG => 'optional',
1040
+											   PCLZIP_OPT_BY_INDEX => 'optional' ));
1041
+	  if ($v_result != 1) {
1042
+		  return 0;
1043
+	  }
1044
+	}
1045 1045
 
1046
-    // ----- Magic quotes trick
1047
-    $this->privDisableMagicQuotes();
1046
+	// ----- Magic quotes trick
1047
+	$this->privDisableMagicQuotes();
1048 1048
 
1049
-    // ----- Call the delete fct
1050
-    $v_list = array();
1051
-    if (($v_result = $this->privDeleteByRule($v_list, $v_options)) != 1) {
1052
-      $this->privSwapBackMagicQuotes();
1053
-      unset($v_list);
1054
-      return(0);
1055
-    }
1049
+	// ----- Call the delete fct
1050
+	$v_list = array();
1051
+	if (($v_result = $this->privDeleteByRule($v_list, $v_options)) != 1) {
1052
+	  $this->privSwapBackMagicQuotes();
1053
+	  unset($v_list);
1054
+	  return(0);
1055
+	}
1056 1056
 
1057
-    // ----- Magic quotes trick
1058
-    $this->privSwapBackMagicQuotes();
1057
+	// ----- Magic quotes trick
1058
+	$this->privSwapBackMagicQuotes();
1059 1059
 
1060
-    // ----- Return
1061
-    return $v_list;
1060
+	// ----- Return
1061
+	return $v_list;
1062 1062
   }
1063 1063
   // --------------------------------------------------------------------------------
1064 1064
 
@@ -1071,10 +1071,10 @@  discard block
 block discarded – undo
1071 1071
   function deleteByIndex($p_index)
1072 1072
   {
1073 1073
     
1074
-    $p_list = $this->delete(PCLZIP_OPT_BY_INDEX, $p_index);
1074
+	$p_list = $this->delete(PCLZIP_OPT_BY_INDEX, $p_index);
1075 1075
 
1076
-    // ----- Return
1077
-    return $p_list;
1076
+	// ----- Return
1077
+	return $p_list;
1078 1078
   }
1079 1079
   // --------------------------------------------------------------------------------
1080 1080
 
@@ -1095,61 +1095,61 @@  discard block
 block discarded – undo
1095 1095
   function properties()
1096 1096
   {
1097 1097
 
1098
-    // ----- Reset the error handler
1099
-    $this->privErrorReset();
1098
+	// ----- Reset the error handler
1099
+	$this->privErrorReset();
1100 1100
 
1101
-    // ----- Magic quotes trick
1102
-    $this->privDisableMagicQuotes();
1101
+	// ----- Magic quotes trick
1102
+	$this->privDisableMagicQuotes();
1103 1103
 
1104
-    // ----- Check archive
1105
-    if (!$this->privCheckFormat()) {
1106
-      $this->privSwapBackMagicQuotes();
1107
-      return(0);
1108
-    }
1104
+	// ----- Check archive
1105
+	if (!$this->privCheckFormat()) {
1106
+	  $this->privSwapBackMagicQuotes();
1107
+	  return(0);
1108
+	}
1109 1109
 
1110
-    // ----- Default properties
1111
-    $v_prop = array();
1112
-    $v_prop['comment'] = '';
1113
-    $v_prop['nb'] = 0;
1114
-    $v_prop['status'] = 'not_exist';
1115
-
1116
-    // ----- Look if file exists
1117
-    if (@is_file($this->zipname))
1118
-    {
1119
-      // ----- Open the zip file
1120
-      if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)
1121
-      {
1122
-        $this->privSwapBackMagicQuotes();
1110
+	// ----- Default properties
1111
+	$v_prop = array();
1112
+	$v_prop['comment'] = '';
1113
+	$v_prop['nb'] = 0;
1114
+	$v_prop['status'] = 'not_exist';
1115
+
1116
+	// ----- Look if file exists
1117
+	if (@is_file($this->zipname))
1118
+	{
1119
+	  // ----- Open the zip file
1120
+	  if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)
1121
+	  {
1122
+		$this->privSwapBackMagicQuotes();
1123 1123
         
1124
-        // ----- Error log
1125
-        PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
1124
+		// ----- Error log
1125
+		PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
1126 1126
 
1127
-        // ----- Return
1128
-        return 0;
1129
-      }
1127
+		// ----- Return
1128
+		return 0;
1129
+	  }
1130 1130
 
1131
-      // ----- Read the central directory informations
1132
-      $v_central_dir = array();
1133
-      if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
1134
-      {
1135
-        $this->privSwapBackMagicQuotes();
1136
-        return 0;
1137
-      }
1131
+	  // ----- Read the central directory informations
1132
+	  $v_central_dir = array();
1133
+	  if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
1134
+	  {
1135
+		$this->privSwapBackMagicQuotes();
1136
+		return 0;
1137
+	  }
1138 1138
 
1139
-      // ----- Close the zip file
1140
-      $this->privCloseFd();
1139
+	  // ----- Close the zip file
1140
+	  $this->privCloseFd();
1141 1141
 
1142
-      // ----- Set the user attributes
1143
-      $v_prop['comment'] = $v_central_dir['comment'];
1144
-      $v_prop['nb'] = $v_central_dir['entries'];
1145
-      $v_prop['status'] = 'ok';
1146
-    }
1142
+	  // ----- Set the user attributes
1143
+	  $v_prop['comment'] = $v_central_dir['comment'];
1144
+	  $v_prop['nb'] = $v_central_dir['entries'];
1145
+	  $v_prop['status'] = 'ok';
1146
+	}
1147 1147
 
1148
-    // ----- Magic quotes trick
1149
-    $this->privSwapBackMagicQuotes();
1148
+	// ----- Magic quotes trick
1149
+	$this->privSwapBackMagicQuotes();
1150 1150
 
1151
-    // ----- Return
1152
-    return $v_prop;
1151
+	// ----- Return
1152
+	return $v_prop;
1153 1153
   }
1154 1154
   // --------------------------------------------------------------------------------
1155 1155
 
@@ -1167,46 +1167,46 @@  discard block
 block discarded – undo
1167 1167
   // --------------------------------------------------------------------------------
1168 1168
   function duplicate($p_archive)
1169 1169
   {
1170
-    $v_result = 1;
1170
+	$v_result = 1;
1171 1171
 
1172
-    // ----- Reset the error handler
1173
-    $this->privErrorReset();
1172
+	// ----- Reset the error handler
1173
+	$this->privErrorReset();
1174 1174
 
1175
-    // ----- Look if the $p_archive is a PclZip object
1176
-    if ((is_object($p_archive)) && (get_class($p_archive) == 'pclzip'))
1177
-    {
1175
+	// ----- Look if the $p_archive is a PclZip object
1176
+	if ((is_object($p_archive)) && (get_class($p_archive) == 'pclzip'))
1177
+	{
1178 1178
 
1179
-      // ----- Duplicate the archive
1180
-      $v_result = $this->privDuplicate($p_archive->zipname);
1181
-    }
1179
+	  // ----- Duplicate the archive
1180
+	  $v_result = $this->privDuplicate($p_archive->zipname);
1181
+	}
1182 1182
 
1183
-    // ----- Look if the $p_archive is a string (so a filename)
1184
-    else if (is_string($p_archive))
1185
-    {
1183
+	// ----- Look if the $p_archive is a string (so a filename)
1184
+	else if (is_string($p_archive))
1185
+	{
1186 1186
 
1187
-      // ----- Check that $p_archive is a valid zip file
1188
-      // TBC : Should also check the archive format
1189
-      if (!is_file($p_archive)) {
1190
-        // ----- Error log
1191
-        PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "No file with filename '".$p_archive."'");
1192
-        $v_result = PCLZIP_ERR_MISSING_FILE;
1193
-      }
1194
-      else {
1195
-        // ----- Duplicate the archive
1196
-        $v_result = $this->privDuplicate($p_archive);
1197
-      }
1198
-    }
1187
+	  // ----- Check that $p_archive is a valid zip file
1188
+	  // TBC : Should also check the archive format
1189
+	  if (!is_file($p_archive)) {
1190
+		// ----- Error log
1191
+		PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "No file with filename '".$p_archive."'");
1192
+		$v_result = PCLZIP_ERR_MISSING_FILE;
1193
+	  }
1194
+	  else {
1195
+		// ----- Duplicate the archive
1196
+		$v_result = $this->privDuplicate($p_archive);
1197
+	  }
1198
+	}
1199 1199
 
1200
-    // ----- Invalid variable
1201
-    else
1202
-    {
1203
-      // ----- Error log
1204
-      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
1205
-      $v_result = PCLZIP_ERR_INVALID_PARAMETER;
1206
-    }
1200
+	// ----- Invalid variable
1201
+	else
1202
+	{
1203
+	  // ----- Error log
1204
+	  PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
1205
+	  $v_result = PCLZIP_ERR_INVALID_PARAMETER;
1206
+	}
1207 1207
 
1208
-    // ----- Return
1209
-    return $v_result;
1208
+	// ----- Return
1209
+	return $v_result;
1210 1210
   }
1211 1211
   // --------------------------------------------------------------------------------
1212 1212
 
@@ -1226,45 +1226,45 @@  discard block
 block discarded – undo
1226 1226
   // --------------------------------------------------------------------------------
1227 1227
   function merge($p_archive_to_add)
1228 1228
   {
1229
-    $v_result = 1;
1229
+	$v_result = 1;
1230 1230
 
1231
-    // ----- Reset the error handler
1232
-    $this->privErrorReset();
1231
+	// ----- Reset the error handler
1232
+	$this->privErrorReset();
1233 1233
 
1234
-    // ----- Check archive
1235
-    if (!$this->privCheckFormat()) {
1236
-      return(0);
1237
-    }
1234
+	// ----- Check archive
1235
+	if (!$this->privCheckFormat()) {
1236
+	  return(0);
1237
+	}
1238 1238
 
1239
-    // ----- Look if the $p_archive_to_add is a PclZip object
1240
-    if ((is_object($p_archive_to_add)) && (get_class($p_archive_to_add) == 'pclzip'))
1241
-    {
1239
+	// ----- Look if the $p_archive_to_add is a PclZip object
1240
+	if ((is_object($p_archive_to_add)) && (get_class($p_archive_to_add) == 'pclzip'))
1241
+	{
1242 1242
 
1243
-      // ----- Merge the archive
1244
-      $v_result = $this->privMerge($p_archive_to_add);
1245
-    }
1243
+	  // ----- Merge the archive
1244
+	  $v_result = $this->privMerge($p_archive_to_add);
1245
+	}
1246 1246
 
1247
-    // ----- Look if the $p_archive_to_add is a string (so a filename)
1248
-    else if (is_string($p_archive_to_add))
1249
-    {
1247
+	// ----- Look if the $p_archive_to_add is a string (so a filename)
1248
+	else if (is_string($p_archive_to_add))
1249
+	{
1250 1250
 
1251
-      // ----- Create a temporary archive
1252
-      $v_object_archive = new PclZip($p_archive_to_add);
1251
+	  // ----- Create a temporary archive
1252
+	  $v_object_archive = new PclZip($p_archive_to_add);
1253 1253
 
1254
-      // ----- Merge the archive
1255
-      $v_result = $this->privMerge($v_object_archive);
1256
-    }
1254
+	  // ----- Merge the archive
1255
+	  $v_result = $this->privMerge($v_object_archive);
1256
+	}
1257 1257
 
1258
-    // ----- Invalid variable
1259
-    else
1260
-    {
1261
-      // ----- Error log
1262
-      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
1263
-      $v_result = PCLZIP_ERR_INVALID_PARAMETER;
1264
-    }
1258
+	// ----- Invalid variable
1259
+	else
1260
+	{
1261
+	  // ----- Error log
1262
+	  PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
1263
+	  $v_result = PCLZIP_ERR_INVALID_PARAMETER;
1264
+	}
1265 1265
 
1266
-    // ----- Return
1267
-    return $v_result;
1266
+	// ----- Return
1267
+	return $v_result;
1268 1268
   }
1269 1269
   // --------------------------------------------------------------------------------
1270 1270
 
@@ -1277,12 +1277,12 @@  discard block
 block discarded – undo
1277 1277
   // --------------------------------------------------------------------------------
1278 1278
   function errorCode()
1279 1279
   {
1280
-    if (PCLZIP_ERROR_EXTERNAL == 1) {
1281
-      return(PclErrorCode());
1282
-    }
1283
-    else {
1284
-      return($this->error_code);
1285
-    }
1280
+	if (PCLZIP_ERROR_EXTERNAL == 1) {
1281
+	  return(PclErrorCode());
1282
+	}
1283
+	else {
1284
+	  return($this->error_code);
1285
+	}
1286 1286
   }
1287 1287
   // --------------------------------------------------------------------------------
1288 1288
 
@@ -1293,42 +1293,42 @@  discard block
 block discarded – undo
1293 1293
   // --------------------------------------------------------------------------------
1294 1294
   function errorName($p_with_code=false)
1295 1295
   {
1296
-    $v_name = array ( PCLZIP_ERR_NO_ERROR => 'PCLZIP_ERR_NO_ERROR',
1297
-                      PCLZIP_ERR_WRITE_OPEN_FAIL => 'PCLZIP_ERR_WRITE_OPEN_FAIL',
1298
-                      PCLZIP_ERR_READ_OPEN_FAIL => 'PCLZIP_ERR_READ_OPEN_FAIL',
1299
-                      PCLZIP_ERR_INVALID_PARAMETER => 'PCLZIP_ERR_INVALID_PARAMETER',
1300
-                      PCLZIP_ERR_MISSING_FILE => 'PCLZIP_ERR_MISSING_FILE',
1301
-                      PCLZIP_ERR_FILENAME_TOO_LONG => 'PCLZIP_ERR_FILENAME_TOO_LONG',
1302
-                      PCLZIP_ERR_INVALID_ZIP => 'PCLZIP_ERR_INVALID_ZIP',
1303
-                      PCLZIP_ERR_BAD_EXTRACTED_FILE => 'PCLZIP_ERR_BAD_EXTRACTED_FILE',
1304
-                      PCLZIP_ERR_DIR_CREATE_FAIL => 'PCLZIP_ERR_DIR_CREATE_FAIL',
1305
-                      PCLZIP_ERR_BAD_EXTENSION => 'PCLZIP_ERR_BAD_EXTENSION',
1306
-                      PCLZIP_ERR_BAD_FORMAT => 'PCLZIP_ERR_BAD_FORMAT',
1307
-                      PCLZIP_ERR_DELETE_FILE_FAIL => 'PCLZIP_ERR_DELETE_FILE_FAIL',
1308
-                      PCLZIP_ERR_RENAME_FILE_FAIL => 'PCLZIP_ERR_RENAME_FILE_FAIL',
1309
-                      PCLZIP_ERR_BAD_CHECKSUM => 'PCLZIP_ERR_BAD_CHECKSUM',
1310
-                      PCLZIP_ERR_INVALID_ARCHIVE_ZIP => 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP',
1311
-                      PCLZIP_ERR_MISSING_OPTION_VALUE => 'PCLZIP_ERR_MISSING_OPTION_VALUE',
1312
-                      PCLZIP_ERR_INVALID_OPTION_VALUE => 'PCLZIP_ERR_INVALID_OPTION_VALUE',
1313
-                      PCLZIP_ERR_UNSUPPORTED_COMPRESSION => 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION',
1314
-                      PCLZIP_ERR_UNSUPPORTED_ENCRYPTION => 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION'
1315
-                      ,PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE => 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE'
1316
-                      ,PCLZIP_ERR_DIRECTORY_RESTRICTION => 'PCLZIP_ERR_DIRECTORY_RESTRICTION'
1317
-                    );
1318
-
1319
-    if (isset($v_name[$this->error_code])) {
1320
-      $v_value = $v_name[$this->error_code];
1321
-    }
1322
-    else {
1323
-      $v_value = 'NoName';
1324
-    }
1296
+	$v_name = array ( PCLZIP_ERR_NO_ERROR => 'PCLZIP_ERR_NO_ERROR',
1297
+					  PCLZIP_ERR_WRITE_OPEN_FAIL => 'PCLZIP_ERR_WRITE_OPEN_FAIL',
1298
+					  PCLZIP_ERR_READ_OPEN_FAIL => 'PCLZIP_ERR_READ_OPEN_FAIL',
1299
+					  PCLZIP_ERR_INVALID_PARAMETER => 'PCLZIP_ERR_INVALID_PARAMETER',
1300
+					  PCLZIP_ERR_MISSING_FILE => 'PCLZIP_ERR_MISSING_FILE',
1301
+					  PCLZIP_ERR_FILENAME_TOO_LONG => 'PCLZIP_ERR_FILENAME_TOO_LONG',
1302
+					  PCLZIP_ERR_INVALID_ZIP => 'PCLZIP_ERR_INVALID_ZIP',
1303
+					  PCLZIP_ERR_BAD_EXTRACTED_FILE => 'PCLZIP_ERR_BAD_EXTRACTED_FILE',
1304
+					  PCLZIP_ERR_DIR_CREATE_FAIL => 'PCLZIP_ERR_DIR_CREATE_FAIL',
1305
+					  PCLZIP_ERR_BAD_EXTENSION => 'PCLZIP_ERR_BAD_EXTENSION',
1306
+					  PCLZIP_ERR_BAD_FORMAT => 'PCLZIP_ERR_BAD_FORMAT',
1307
+					  PCLZIP_ERR_DELETE_FILE_FAIL => 'PCLZIP_ERR_DELETE_FILE_FAIL',
1308
+					  PCLZIP_ERR_RENAME_FILE_FAIL => 'PCLZIP_ERR_RENAME_FILE_FAIL',
1309
+					  PCLZIP_ERR_BAD_CHECKSUM => 'PCLZIP_ERR_BAD_CHECKSUM',
1310
+					  PCLZIP_ERR_INVALID_ARCHIVE_ZIP => 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP',
1311
+					  PCLZIP_ERR_MISSING_OPTION_VALUE => 'PCLZIP_ERR_MISSING_OPTION_VALUE',
1312
+					  PCLZIP_ERR_INVALID_OPTION_VALUE => 'PCLZIP_ERR_INVALID_OPTION_VALUE',
1313
+					  PCLZIP_ERR_UNSUPPORTED_COMPRESSION => 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION',
1314
+					  PCLZIP_ERR_UNSUPPORTED_ENCRYPTION => 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION'
1315
+					  ,PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE => 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE'
1316
+					  ,PCLZIP_ERR_DIRECTORY_RESTRICTION => 'PCLZIP_ERR_DIRECTORY_RESTRICTION'
1317
+					);
1318
+
1319
+	if (isset($v_name[$this->error_code])) {
1320
+	  $v_value = $v_name[$this->error_code];
1321
+	}
1322
+	else {
1323
+	  $v_value = 'NoName';
1324
+	}
1325 1325
 
1326
-    if ($p_with_code) {
1327
-      return($v_value.' ('.$this->error_code.')');
1328
-    }
1329
-    else {
1330
-      return($v_value);
1331
-    }
1326
+	if ($p_with_code) {
1327
+	  return($v_value.' ('.$this->error_code.')');
1328
+	}
1329
+	else {
1330
+	  return($v_value);
1331
+	}
1332 1332
   }
1333 1333
   // --------------------------------------------------------------------------------
1334 1334
 
@@ -1339,17 +1339,17 @@  discard block
 block discarded – undo
1339 1339
   // --------------------------------------------------------------------------------
1340 1340
   function errorInfo($p_full=false)
1341 1341
   {
1342
-    if (PCLZIP_ERROR_EXTERNAL == 1) {
1343
-      return(PclErrorString());
1344
-    }
1345
-    else {
1346
-      if ($p_full) {
1347
-        return($this->errorName(true)." : ".$this->error_string);
1348
-      }
1349
-      else {
1350
-        return($this->error_string." [code ".$this->error_code."]");
1351
-      }
1352
-    }
1342
+	if (PCLZIP_ERROR_EXTERNAL == 1) {
1343
+	  return(PclErrorString());
1344
+	}
1345
+	else {
1346
+	  if ($p_full) {
1347
+		return($this->errorName(true)." : ".$this->error_string);
1348
+	  }
1349
+	  else {
1350
+		return($this->error_string." [code ".$this->error_code."]");
1351
+	  }
1352
+	}
1353 1353
   }
1354 1354
   // --------------------------------------------------------------------------------
1355 1355
 
@@ -1378,39 +1378,39 @@  discard block
 block discarded – undo
1378 1378
   // --------------------------------------------------------------------------------
1379 1379
   function privCheckFormat($p_level=0)
1380 1380
   {
1381
-    $v_result = true;
1381
+	$v_result = true;
1382 1382
 
1383 1383
 	// ----- Reset the file system cache
1384
-    clearstatcache();
1384
+	clearstatcache();
1385 1385
 
1386
-    // ----- Reset the error handler
1387
-    $this->privErrorReset();
1386
+	// ----- Reset the error handler
1387
+	$this->privErrorReset();
1388 1388
 
1389
-    // ----- Look if the file exits
1390
-    if (!is_file($this->zipname)) {
1391
-      // ----- Error log
1392
-      PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "Missing archive file '".$this->zipname."'");
1393
-      return(false);
1394
-    }
1389
+	// ----- Look if the file exits
1390
+	if (!is_file($this->zipname)) {
1391
+	  // ----- Error log
1392
+	  PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "Missing archive file '".$this->zipname."'");
1393
+	  return(false);
1394
+	}
1395 1395
 
1396
-    // ----- Check that the file is readeable
1397
-    if (!is_readable($this->zipname)) {
1398
-      // ----- Error log
1399
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '".$this->zipname."'");
1400
-      return(false);
1401
-    }
1396
+	// ----- Check that the file is readeable
1397
+	if (!is_readable($this->zipname)) {
1398
+	  // ----- Error log
1399
+	  PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '".$this->zipname."'");
1400
+	  return(false);
1401
+	}
1402 1402
 
1403
-    // ----- Check the magic code
1404
-    // TBC
1403
+	// ----- Check the magic code
1404
+	// TBC
1405 1405
 
1406
-    // ----- Check the central header
1407
-    // TBC
1406
+	// ----- Check the central header
1407
+	// TBC
1408 1408
 
1409
-    // ----- Check each file header
1410
-    // TBC
1409
+	// ----- Check each file header
1410
+	// TBC
1411 1411
 
1412
-    // ----- Return
1413
-    return $v_result;
1412
+	// ----- Return
1413
+	return $v_result;
1414 1414
   }
1415 1415
   // --------------------------------------------------------------------------------
1416 1416
 
@@ -1431,395 +1431,395 @@  discard block
 block discarded – undo
1431 1431
   // --------------------------------------------------------------------------------
1432 1432
   function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options=false)
1433 1433
   {
1434
-    $v_result=1;
1434
+	$v_result=1;
1435 1435
     
1436
-    // ----- Read the options
1437
-    $i=0;
1438
-    while ($i<$p_size) {
1436
+	// ----- Read the options
1437
+	$i=0;
1438
+	while ($i<$p_size) {
1439 1439
 
1440
-      // ----- Check if the option is supported
1441
-      if (!isset($v_requested_options[$p_options_list[$i]])) {
1442
-        // ----- Error log
1443
-        PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid optional parameter '".$p_options_list[$i]."' for this method");
1440
+	  // ----- Check if the option is supported
1441
+	  if (!isset($v_requested_options[$p_options_list[$i]])) {
1442
+		// ----- Error log
1443
+		PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid optional parameter '".$p_options_list[$i]."' for this method");
1444 1444
 
1445
-        // ----- Return
1446
-        return PclZip::errorCode();
1447
-      }
1445
+		// ----- Return
1446
+		return PclZip::errorCode();
1447
+	  }
1448 1448
 
1449
-      // ----- Look for next option
1450
-      switch ($p_options_list[$i]) {
1451
-        // ----- Look for options that request a path value
1452
-        case PCLZIP_OPT_PATH :
1453
-        case PCLZIP_OPT_REMOVE_PATH :
1454
-        case PCLZIP_OPT_ADD_PATH :
1455
-          // ----- Check the number of parameters
1456
-          if (($i+1) >= $p_size) {
1457
-            // ----- Error log
1458
-            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1459
-
1460
-            // ----- Return
1461
-            return PclZip::errorCode();
1462
-          }
1449
+	  // ----- Look for next option
1450
+	  switch ($p_options_list[$i]) {
1451
+		// ----- Look for options that request a path value
1452
+		case PCLZIP_OPT_PATH :
1453
+		case PCLZIP_OPT_REMOVE_PATH :
1454
+		case PCLZIP_OPT_ADD_PATH :
1455
+		  // ----- Check the number of parameters
1456
+		  if (($i+1) >= $p_size) {
1457
+			// ----- Error log
1458
+			PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1459
+
1460
+			// ----- Return
1461
+			return PclZip::errorCode();
1462
+		  }
1463 1463
 
1464
-          // ----- Get the value
1465
-          $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE);
1466
-          $i++;
1467
-        break;
1464
+		  // ----- Get the value
1465
+		  $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE);
1466
+		  $i++;
1467
+		break;
1468 1468
 
1469
-        case PCLZIP_OPT_TEMP_FILE_THRESHOLD :
1470
-          // ----- Check the number of parameters
1471
-          if (($i+1) >= $p_size) {
1472
-            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1473
-            return PclZip::errorCode();
1474
-          }
1469
+		case PCLZIP_OPT_TEMP_FILE_THRESHOLD :
1470
+		  // ----- Check the number of parameters
1471
+		  if (($i+1) >= $p_size) {
1472
+			PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1473
+			return PclZip::errorCode();
1474
+		  }
1475 1475
           
1476
-          // ----- Check for incompatible options
1477
-          if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) {
1478
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'");
1479
-            return PclZip::errorCode();
1480
-          }
1476
+		  // ----- Check for incompatible options
1477
+		  if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) {
1478
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'");
1479
+			return PclZip::errorCode();
1480
+		  }
1481 1481
           
1482
-          // ----- Check the value
1483
-          $v_value = $p_options_list[$i+1];
1484
-          if ((!is_integer($v_value)) || ($v_value<0)) {
1485
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Integer expected for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1486
-            return PclZip::errorCode();
1487
-          }
1482
+		  // ----- Check the value
1483
+		  $v_value = $p_options_list[$i+1];
1484
+		  if ((!is_integer($v_value)) || ($v_value<0)) {
1485
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Integer expected for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1486
+			return PclZip::errorCode();
1487
+		  }
1488 1488
 
1489
-          // ----- Get the value (and convert it in bytes)
1490
-          $v_result_list[$p_options_list[$i]] = $v_value*1048576;
1491
-          $i++;
1492
-        break;
1489
+		  // ----- Get the value (and convert it in bytes)
1490
+		  $v_result_list[$p_options_list[$i]] = $v_value*1048576;
1491
+		  $i++;
1492
+		break;
1493 1493
 
1494
-        case PCLZIP_OPT_TEMP_FILE_ON :
1495
-          // ----- Check for incompatible options
1496
-          if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) {
1497
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'");
1498
-            return PclZip::errorCode();
1499
-          }
1494
+		case PCLZIP_OPT_TEMP_FILE_ON :
1495
+		  // ----- Check for incompatible options
1496
+		  if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) {
1497
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'");
1498
+			return PclZip::errorCode();
1499
+		  }
1500 1500
           
1501
-          $v_result_list[$p_options_list[$i]] = true;
1502
-        break;
1503
-
1504
-        case PCLZIP_OPT_TEMP_FILE_OFF :
1505
-          // ----- Check for incompatible options
1506
-          if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_ON])) {
1507
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_ON'");
1508
-            return PclZip::errorCode();
1509
-          }
1510
-          // ----- Check for incompatible options
1511
-          if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) {
1512
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_THRESHOLD'");
1513
-            return PclZip::errorCode();
1514
-          }
1501
+		  $v_result_list[$p_options_list[$i]] = true;
1502
+		break;
1503
+
1504
+		case PCLZIP_OPT_TEMP_FILE_OFF :
1505
+		  // ----- Check for incompatible options
1506
+		  if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_ON])) {
1507
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_ON'");
1508
+			return PclZip::errorCode();
1509
+		  }
1510
+		  // ----- Check for incompatible options
1511
+		  if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) {
1512
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_THRESHOLD'");
1513
+			return PclZip::errorCode();
1514
+		  }
1515 1515
           
1516
-          $v_result_list[$p_options_list[$i]] = true;
1517
-        break;
1516
+		  $v_result_list[$p_options_list[$i]] = true;
1517
+		break;
1518 1518
 
1519
-        case PCLZIP_OPT_EXTRACT_DIR_RESTRICTION :
1520
-          // ----- Check the number of parameters
1521
-          if (($i+1) >= $p_size) {
1522
-            // ----- Error log
1523
-            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1519
+		case PCLZIP_OPT_EXTRACT_DIR_RESTRICTION :
1520
+		  // ----- Check the number of parameters
1521
+		  if (($i+1) >= $p_size) {
1522
+			// ----- Error log
1523
+			PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1524 1524
 
1525
-            // ----- Return
1526
-            return PclZip::errorCode();
1527
-          }
1525
+			// ----- Return
1526
+			return PclZip::errorCode();
1527
+		  }
1528 1528
 
1529
-          // ----- Get the value
1530
-          if (   is_string($p_options_list[$i+1])
1531
-              && ($p_options_list[$i+1] != '')) {
1532
-            $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE);
1533
-            $i++;
1534
-          }
1535
-          else {
1536
-          }
1537
-        break;
1529
+		  // ----- Get the value
1530
+		  if (   is_string($p_options_list[$i+1])
1531
+			  && ($p_options_list[$i+1] != '')) {
1532
+			$v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE);
1533
+			$i++;
1534
+		  }
1535
+		  else {
1536
+		  }
1537
+		break;
1538 1538
 
1539
-        // ----- Look for options that request an array of string for value
1540
-        case PCLZIP_OPT_BY_NAME :
1541
-          // ----- Check the number of parameters
1542
-          if (($i+1) >= $p_size) {
1543
-            // ----- Error log
1544
-            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1539
+		// ----- Look for options that request an array of string for value
1540
+		case PCLZIP_OPT_BY_NAME :
1541
+		  // ----- Check the number of parameters
1542
+		  if (($i+1) >= $p_size) {
1543
+			// ----- Error log
1544
+			PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1545 1545
 
1546
-            // ----- Return
1547
-            return PclZip::errorCode();
1548
-          }
1546
+			// ----- Return
1547
+			return PclZip::errorCode();
1548
+		  }
1549 1549
 
1550
-          // ----- Get the value
1551
-          if (is_string($p_options_list[$i+1])) {
1552
-              $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i+1];
1553
-          }
1554
-          else if (is_array($p_options_list[$i+1])) {
1555
-              $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1556
-          }
1557
-          else {
1558
-            // ----- Error log
1559
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1550
+		  // ----- Get the value
1551
+		  if (is_string($p_options_list[$i+1])) {
1552
+			  $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i+1];
1553
+		  }
1554
+		  else if (is_array($p_options_list[$i+1])) {
1555
+			  $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1556
+		  }
1557
+		  else {
1558
+			// ----- Error log
1559
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1560 1560
 
1561
-            // ----- Return
1562
-            return PclZip::errorCode();
1563
-          }
1564
-          $i++;
1565
-        break;
1566
-
1567
-        // ----- Look for options that request an EREG or PREG expression
1568
-        case PCLZIP_OPT_BY_EREG :
1569
-          // ereg() is deprecated starting with PHP 5.3. Move PCLZIP_OPT_BY_EREG
1570
-          // to PCLZIP_OPT_BY_PREG
1571
-          $p_options_list[$i] = PCLZIP_OPT_BY_PREG;
1572
-        case PCLZIP_OPT_BY_PREG :
1573
-        //case PCLZIP_OPT_CRYPT :
1574
-          // ----- Check the number of parameters
1575
-          if (($i+1) >= $p_size) {
1576
-            // ----- Error log
1577
-            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1578
-
1579
-            // ----- Return
1580
-            return PclZip::errorCode();
1581
-          }
1561
+			// ----- Return
1562
+			return PclZip::errorCode();
1563
+		  }
1564
+		  $i++;
1565
+		break;
1566
+
1567
+		// ----- Look for options that request an EREG or PREG expression
1568
+		case PCLZIP_OPT_BY_EREG :
1569
+		  // ereg() is deprecated starting with PHP 5.3. Move PCLZIP_OPT_BY_EREG
1570
+		  // to PCLZIP_OPT_BY_PREG
1571
+		  $p_options_list[$i] = PCLZIP_OPT_BY_PREG;
1572
+		case PCLZIP_OPT_BY_PREG :
1573
+		//case PCLZIP_OPT_CRYPT :
1574
+		  // ----- Check the number of parameters
1575
+		  if (($i+1) >= $p_size) {
1576
+			// ----- Error log
1577
+			PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1578
+
1579
+			// ----- Return
1580
+			return PclZip::errorCode();
1581
+		  }
1582 1582
 
1583
-          // ----- Get the value
1584
-          if (is_string($p_options_list[$i+1])) {
1585
-              $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1586
-          }
1587
-          else {
1588
-            // ----- Error log
1589
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1583
+		  // ----- Get the value
1584
+		  if (is_string($p_options_list[$i+1])) {
1585
+			  $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1586
+		  }
1587
+		  else {
1588
+			// ----- Error log
1589
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1590 1590
 
1591
-            // ----- Return
1592
-            return PclZip::errorCode();
1593
-          }
1594
-          $i++;
1595
-        break;
1596
-
1597
-        // ----- Look for options that takes a string
1598
-        case PCLZIP_OPT_COMMENT :
1599
-        case PCLZIP_OPT_ADD_COMMENT :
1600
-        case PCLZIP_OPT_PREPEND_COMMENT :
1601
-          // ----- Check the number of parameters
1602
-          if (($i+1) >= $p_size) {
1603
-            // ----- Error log
1604
-            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE,
1605
-			                     "Missing parameter value for option '"
1591
+			// ----- Return
1592
+			return PclZip::errorCode();
1593
+		  }
1594
+		  $i++;
1595
+		break;
1596
+
1597
+		// ----- Look for options that takes a string
1598
+		case PCLZIP_OPT_COMMENT :
1599
+		case PCLZIP_OPT_ADD_COMMENT :
1600
+		case PCLZIP_OPT_PREPEND_COMMENT :
1601
+		  // ----- Check the number of parameters
1602
+		  if (($i+1) >= $p_size) {
1603
+			// ----- Error log
1604
+			PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE,
1605
+								 "Missing parameter value for option '"
1606 1606
 								 .PclZipUtilOptionText($p_options_list[$i])
1607 1607
 								 ."'");
1608 1608
 
1609
-            // ----- Return
1610
-            return PclZip::errorCode();
1611
-          }
1609
+			// ----- Return
1610
+			return PclZip::errorCode();
1611
+		  }
1612 1612
 
1613
-          // ----- Get the value
1614
-          if (is_string($p_options_list[$i+1])) {
1615
-              $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1616
-          }
1617
-          else {
1618
-            // ----- Error log
1619
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE,
1620
-			                     "Wrong parameter value for option '"
1613
+		  // ----- Get the value
1614
+		  if (is_string($p_options_list[$i+1])) {
1615
+			  $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1616
+		  }
1617
+		  else {
1618
+			// ----- Error log
1619
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE,
1620
+								 "Wrong parameter value for option '"
1621 1621
 								 .PclZipUtilOptionText($p_options_list[$i])
1622 1622
 								 ."'");
1623 1623
 
1624
-            // ----- Return
1625
-            return PclZip::errorCode();
1626
-          }
1627
-          $i++;
1628
-        break;
1629
-
1630
-        // ----- Look for options that request an array of index
1631
-        case PCLZIP_OPT_BY_INDEX :
1632
-          // ----- Check the number of parameters
1633
-          if (($i+1) >= $p_size) {
1634
-            // ----- Error log
1635
-            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1636
-
1637
-            // ----- Return
1638
-            return PclZip::errorCode();
1639
-          }
1624
+			// ----- Return
1625
+			return PclZip::errorCode();
1626
+		  }
1627
+		  $i++;
1628
+		break;
1629
+
1630
+		// ----- Look for options that request an array of index
1631
+		case PCLZIP_OPT_BY_INDEX :
1632
+		  // ----- Check the number of parameters
1633
+		  if (($i+1) >= $p_size) {
1634
+			// ----- Error log
1635
+			PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1636
+
1637
+			// ----- Return
1638
+			return PclZip::errorCode();
1639
+		  }
1640 1640
 
1641
-          // ----- Get the value
1642
-          $v_work_list = array();
1643
-          if (is_string($p_options_list[$i+1])) {
1641
+		  // ----- Get the value
1642
+		  $v_work_list = array();
1643
+		  if (is_string($p_options_list[$i+1])) {
1644 1644
 
1645
-              // ----- Remove spaces
1646
-              $p_options_list[$i+1] = strtr($p_options_list[$i+1], ' ', '');
1645
+			  // ----- Remove spaces
1646
+			  $p_options_list[$i+1] = strtr($p_options_list[$i+1], ' ', '');
1647 1647
 
1648
-              // ----- Parse items
1649
-              $v_work_list = explode(",", $p_options_list[$i+1]);
1650
-          }
1651
-          else if (is_integer($p_options_list[$i+1])) {
1652
-              $v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1];
1653
-          }
1654
-          else if (is_array($p_options_list[$i+1])) {
1655
-              $v_work_list = $p_options_list[$i+1];
1656
-          }
1657
-          else {
1658
-            // ----- Error log
1659
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1648
+			  // ----- Parse items
1649
+			  $v_work_list = explode(",", $p_options_list[$i+1]);
1650
+		  }
1651
+		  else if (is_integer($p_options_list[$i+1])) {
1652
+			  $v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1];
1653
+		  }
1654
+		  else if (is_array($p_options_list[$i+1])) {
1655
+			  $v_work_list = $p_options_list[$i+1];
1656
+		  }
1657
+		  else {
1658
+			// ----- Error log
1659
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1660 1660
 
1661
-            // ----- Return
1662
-            return PclZip::errorCode();
1663
-          }
1661
+			// ----- Return
1662
+			return PclZip::errorCode();
1663
+		  }
1664 1664
           
1665
-          // ----- Reduce the index list
1666
-          // each index item in the list must be a couple with a start and
1667
-          // an end value : [0,3], [5-5], [8-10], ...
1668
-          // ----- Check the format of each item
1669
-          $v_sort_flag=false;
1670
-          $v_sort_value=0;
1671
-          for ($j=0; $j<sizeof($v_work_list); $j++) {
1672
-              // ----- Explode the item
1673
-              $v_item_list = explode("-", $v_work_list[$j]);
1674
-              $v_size_item_list = sizeof($v_item_list);
1665
+		  // ----- Reduce the index list
1666
+		  // each index item in the list must be a couple with a start and
1667
+		  // an end value : [0,3], [5-5], [8-10], ...
1668
+		  // ----- Check the format of each item
1669
+		  $v_sort_flag=false;
1670
+		  $v_sort_value=0;
1671
+		  for ($j=0; $j<sizeof($v_work_list); $j++) {
1672
+			  // ----- Explode the item
1673
+			  $v_item_list = explode("-", $v_work_list[$j]);
1674
+			  $v_size_item_list = sizeof($v_item_list);
1675 1675
               
1676
-              // ----- TBC : Here we might check that each item is a
1677
-              // real integer ...
1676
+			  // ----- TBC : Here we might check that each item is a
1677
+			  // real integer ...
1678 1678
               
1679
-              // ----- Look for single value
1680
-              if ($v_size_item_list == 1) {
1681
-                  // ----- Set the option value
1682
-                  $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0];
1683
-                  $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[0];
1684
-              }
1685
-              elseif ($v_size_item_list == 2) {
1686
-                  // ----- Set the option value
1687
-                  $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0];
1688
-                  $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[1];
1689
-              }
1690
-              else {
1691
-                  // ----- Error log
1692
-                  PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Too many values in index range for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1693
-
1694
-                  // ----- Return
1695
-                  return PclZip::errorCode();
1696
-              }
1697
-
1698
-
1699
-              // ----- Look for list sort
1700
-              if ($v_result_list[$p_options_list[$i]][$j]['start'] < $v_sort_value) {
1701
-                  $v_sort_flag=true;
1702
-
1703
-                  // ----- TBC : An automatic sort should be writen ...
1704
-                  // ----- Error log
1705
-                  PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Invalid order of index range for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1706
-
1707
-                  // ----- Return
1708
-                  return PclZip::errorCode();
1709
-              }
1710
-              $v_sort_value = $v_result_list[$p_options_list[$i]][$j]['start'];
1711
-          }
1679
+			  // ----- Look for single value
1680
+			  if ($v_size_item_list == 1) {
1681
+				  // ----- Set the option value
1682
+				  $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0];
1683
+				  $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[0];
1684
+			  }
1685
+			  elseif ($v_size_item_list == 2) {
1686
+				  // ----- Set the option value
1687
+				  $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0];
1688
+				  $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[1];
1689
+			  }
1690
+			  else {
1691
+				  // ----- Error log
1692
+				  PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Too many values in index range for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1693
+
1694
+				  // ----- Return
1695
+				  return PclZip::errorCode();
1696
+			  }
1697
+
1698
+
1699
+			  // ----- Look for list sort
1700
+			  if ($v_result_list[$p_options_list[$i]][$j]['start'] < $v_sort_value) {
1701
+				  $v_sort_flag=true;
1702
+
1703
+				  // ----- TBC : An automatic sort should be writen ...
1704
+				  // ----- Error log
1705
+				  PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Invalid order of index range for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1706
+
1707
+				  // ----- Return
1708
+				  return PclZip::errorCode();
1709
+			  }
1710
+			  $v_sort_value = $v_result_list[$p_options_list[$i]][$j]['start'];
1711
+		  }
1712 1712
           
1713
-          // ----- Sort the items
1714
-          if ($v_sort_flag) {
1715
-              // TBC : To Be Completed
1716
-          }
1713
+		  // ----- Sort the items
1714
+		  if ($v_sort_flag) {
1715
+			  // TBC : To Be Completed
1716
+		  }
1717 1717
 
1718
-          // ----- Next option
1719
-          $i++;
1720
-        break;
1721
-
1722
-        // ----- Look for options that request no value
1723
-        case PCLZIP_OPT_REMOVE_ALL_PATH :
1724
-        case PCLZIP_OPT_EXTRACT_AS_STRING :
1725
-        case PCLZIP_OPT_NO_COMPRESSION :
1726
-        case PCLZIP_OPT_EXTRACT_IN_OUTPUT :
1727
-        case PCLZIP_OPT_REPLACE_NEWER :
1728
-        case PCLZIP_OPT_STOP_ON_ERROR :
1729
-          $v_result_list[$p_options_list[$i]] = true;
1730
-        break;
1731
-
1732
-        // ----- Look for options that request an octal value
1733
-        case PCLZIP_OPT_SET_CHMOD :
1734
-          // ----- Check the number of parameters
1735
-          if (($i+1) >= $p_size) {
1736
-            // ----- Error log
1737
-            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1738
-
1739
-            // ----- Return
1740
-            return PclZip::errorCode();
1741
-          }
1718
+		  // ----- Next option
1719
+		  $i++;
1720
+		break;
1721
+
1722
+		// ----- Look for options that request no value
1723
+		case PCLZIP_OPT_REMOVE_ALL_PATH :
1724
+		case PCLZIP_OPT_EXTRACT_AS_STRING :
1725
+		case PCLZIP_OPT_NO_COMPRESSION :
1726
+		case PCLZIP_OPT_EXTRACT_IN_OUTPUT :
1727
+		case PCLZIP_OPT_REPLACE_NEWER :
1728
+		case PCLZIP_OPT_STOP_ON_ERROR :
1729
+		  $v_result_list[$p_options_list[$i]] = true;
1730
+		break;
1731
+
1732
+		// ----- Look for options that request an octal value
1733
+		case PCLZIP_OPT_SET_CHMOD :
1734
+		  // ----- Check the number of parameters
1735
+		  if (($i+1) >= $p_size) {
1736
+			// ----- Error log
1737
+			PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1738
+
1739
+			// ----- Return
1740
+			return PclZip::errorCode();
1741
+		  }
1742 1742
 
1743
-          // ----- Get the value
1744
-          $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1745
-          $i++;
1746
-        break;
1747
-
1748
-        // ----- Look for options that request a call-back
1749
-        case PCLZIP_CB_PRE_EXTRACT :
1750
-        case PCLZIP_CB_POST_EXTRACT :
1751
-        case PCLZIP_CB_PRE_ADD :
1752
-        case PCLZIP_CB_POST_ADD :
1753
-        /* for futur use
1743
+		  // ----- Get the value
1744
+		  $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1745
+		  $i++;
1746
+		break;
1747
+
1748
+		// ----- Look for options that request a call-back
1749
+		case PCLZIP_CB_PRE_EXTRACT :
1750
+		case PCLZIP_CB_POST_EXTRACT :
1751
+		case PCLZIP_CB_PRE_ADD :
1752
+		case PCLZIP_CB_POST_ADD :
1753
+		/* for futur use
1754 1754
         case PCLZIP_CB_PRE_DELETE :
1755 1755
         case PCLZIP_CB_POST_DELETE :
1756 1756
         case PCLZIP_CB_PRE_LIST :
1757 1757
         case PCLZIP_CB_POST_LIST :
1758 1758
         */
1759
-          // ----- Check the number of parameters
1760
-          if (($i+1) >= $p_size) {
1761
-            // ----- Error log
1762
-            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1759
+		  // ----- Check the number of parameters
1760
+		  if (($i+1) >= $p_size) {
1761
+			// ----- Error log
1762
+			PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1763 1763
 
1764
-            // ----- Return
1765
-            return PclZip::errorCode();
1766
-          }
1764
+			// ----- Return
1765
+			return PclZip::errorCode();
1766
+		  }
1767 1767
 
1768
-          // ----- Get the value
1769
-          $v_function_name = $p_options_list[$i+1];
1768
+		  // ----- Get the value
1769
+		  $v_function_name = $p_options_list[$i+1];
1770 1770
 
1771
-          // ----- Check that the value is a valid existing function
1772
-          if (!function_exists($v_function_name)) {
1773
-            // ----- Error log
1774
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Function '".$v_function_name."()' is not an existing function for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1771
+		  // ----- Check that the value is a valid existing function
1772
+		  if (!function_exists($v_function_name)) {
1773
+			// ----- Error log
1774
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Function '".$v_function_name."()' is not an existing function for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1775 1775
 
1776
-            // ----- Return
1777
-            return PclZip::errorCode();
1778
-          }
1776
+			// ----- Return
1777
+			return PclZip::errorCode();
1778
+		  }
1779 1779
 
1780
-          // ----- Set the attribute
1781
-          $v_result_list[$p_options_list[$i]] = $v_function_name;
1782
-          $i++;
1783
-        break;
1780
+		  // ----- Set the attribute
1781
+		  $v_result_list[$p_options_list[$i]] = $v_function_name;
1782
+		  $i++;
1783
+		break;
1784 1784
 
1785
-        default :
1786
-          // ----- Error log
1787
-          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
1788
-		                       "Unknown parameter '"
1785
+		default :
1786
+		  // ----- Error log
1787
+		  PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
1788
+							   "Unknown parameter '"
1789 1789
 							   .$p_options_list[$i]."'");
1790 1790
 
1791
-          // ----- Return
1792
-          return PclZip::errorCode();
1793
-      }
1791
+		  // ----- Return
1792
+		  return PclZip::errorCode();
1793
+	  }
1794 1794
 
1795
-      // ----- Next options
1796
-      $i++;
1797
-    }
1795
+	  // ----- Next options
1796
+	  $i++;
1797
+	}
1798 1798
 
1799
-    // ----- Look for mandatory options
1800
-    if ($v_requested_options !== false) {
1801
-      for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
1802
-        // ----- Look for mandatory option
1803
-        if ($v_requested_options[$key] == 'mandatory') {
1804
-          // ----- Look if present
1805
-          if (!isset($v_result_list[$key])) {
1806
-            // ----- Error log
1807
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
1808
-
1809
-            // ----- Return
1810
-            return PclZip::errorCode();
1811
-          }
1812
-        }
1813
-      }
1814
-    }
1799
+	// ----- Look for mandatory options
1800
+	if ($v_requested_options !== false) {
1801
+	  for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
1802
+		// ----- Look for mandatory option
1803
+		if ($v_requested_options[$key] == 'mandatory') {
1804
+		  // ----- Look if present
1805
+		  if (!isset($v_result_list[$key])) {
1806
+			// ----- Error log
1807
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
1808
+
1809
+			// ----- Return
1810
+			return PclZip::errorCode();
1811
+		  }
1812
+		}
1813
+	  }
1814
+	}
1815 1815
     
1816
-    // ----- Look for default values
1817
-    if (!isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) {
1816
+	// ----- Look for default values
1817
+	if (!isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) {
1818 1818
       
1819
-    }
1819
+	}
1820 1820
 
1821
-    // ----- Return
1822
-    return $v_result;
1821
+	// ----- Return
1822
+	return $v_result;
1823 1823
   }
1824 1824
   // --------------------------------------------------------------------------------
1825 1825
 
@@ -1831,37 +1831,37 @@  discard block
 block discarded – undo
1831 1831
   // --------------------------------------------------------------------------------
1832 1832
   function privOptionDefaultThreshold(&$p_options)
1833 1833
   {
1834
-    $v_result=1;
1834
+	$v_result=1;
1835 1835
     
1836
-    if (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
1837
-        || isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) {
1838
-      return $v_result;
1839
-    }
1836
+	if (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
1837
+		|| isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) {
1838
+	  return $v_result;
1839
+	}
1840 1840
     
1841
-    // ----- Get 'memory_limit' configuration value
1842
-    $v_memory_limit = ini_get('memory_limit');
1843
-    $v_memory_limit = trim($v_memory_limit);
1844
-    $last = strtolower(substr($v_memory_limit, -1));
1841
+	// ----- Get 'memory_limit' configuration value
1842
+	$v_memory_limit = ini_get('memory_limit');
1843
+	$v_memory_limit = trim($v_memory_limit);
1844
+	$last = strtolower(substr($v_memory_limit, -1));
1845 1845
  
1846
-    if($last == 'g')
1847
-        //$v_memory_limit = $v_memory_limit*1024*1024*1024;
1848
-        $v_memory_limit = $v_memory_limit*1073741824;
1849
-    if($last == 'm')
1850
-        //$v_memory_limit = $v_memory_limit*1024*1024;
1851
-        $v_memory_limit = $v_memory_limit*1048576;
1852
-    if($last == 'k')
1853
-        $v_memory_limit = $v_memory_limit*1024;
1846
+	if($last == 'g')
1847
+		//$v_memory_limit = $v_memory_limit*1024*1024*1024;
1848
+		$v_memory_limit = $v_memory_limit*1073741824;
1849
+	if($last == 'm')
1850
+		//$v_memory_limit = $v_memory_limit*1024*1024;
1851
+		$v_memory_limit = $v_memory_limit*1048576;
1852
+	if($last == 'k')
1853
+		$v_memory_limit = $v_memory_limit*1024;
1854 1854
             
1855
-    $p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit*PCLZIP_TEMPORARY_FILE_RATIO);
1855
+	$p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit*PCLZIP_TEMPORARY_FILE_RATIO);
1856 1856
     
1857 1857
 
1858
-    // ----- Sanity check : No threshold if value lower than 1M
1859
-    if ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] < 1048576) {
1860
-      unset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]);
1861
-    }
1858
+	// ----- Sanity check : No threshold if value lower than 1M
1859
+	if ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] < 1048576) {
1860
+	  unset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]);
1861
+	}
1862 1862
           
1863
-    // ----- Return
1864
-    return $v_result;
1863
+	// ----- Return
1864
+	return $v_result;
1865 1865
   }
1866 1866
   // --------------------------------------------------------------------------------
1867 1867
 
@@ -1875,116 +1875,116 @@  discard block
 block discarded – undo
1875 1875
   // --------------------------------------------------------------------------------
1876 1876
   function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options=false)
1877 1877
   {
1878
-    $v_result=1;
1878
+	$v_result=1;
1879 1879
     
1880
-    // ----- For each file in the list check the attributes
1881
-    foreach ($p_file_list as $v_key => $v_value) {
1880
+	// ----- For each file in the list check the attributes
1881
+	foreach ($p_file_list as $v_key => $v_value) {
1882 1882
     
1883
-      // ----- Check if the option is supported
1884
-      if (!isset($v_requested_options[$v_key])) {
1885
-        // ----- Error log
1886
-        PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file attribute '".$v_key."' for this file");
1883
+	  // ----- Check if the option is supported
1884
+	  if (!isset($v_requested_options[$v_key])) {
1885
+		// ----- Error log
1886
+		PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file attribute '".$v_key."' for this file");
1887 1887
 
1888
-        // ----- Return
1889
-        return PclZip::errorCode();
1890
-      }
1888
+		// ----- Return
1889
+		return PclZip::errorCode();
1890
+	  }
1891 1891
 
1892
-      // ----- Look for attribute
1893
-      switch ($v_key) {
1894
-        case PCLZIP_ATT_FILE_NAME :
1895
-          if (!is_string($v_value)) {
1896
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1897
-            return PclZip::errorCode();
1898
-          }
1892
+	  // ----- Look for attribute
1893
+	  switch ($v_key) {
1894
+		case PCLZIP_ATT_FILE_NAME :
1895
+		  if (!is_string($v_value)) {
1896
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1897
+			return PclZip::errorCode();
1898
+		  }
1899 1899
 
1900
-          $p_filedescr['filename'] = PclZipUtilPathReduction($v_value);
1900
+		  $p_filedescr['filename'] = PclZipUtilPathReduction($v_value);
1901 1901
           
1902
-          if ($p_filedescr['filename'] == '') {
1903
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty filename for attribute '".PclZipUtilOptionText($v_key)."'");
1904
-            return PclZip::errorCode();
1905
-          }
1902
+		  if ($p_filedescr['filename'] == '') {
1903
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty filename for attribute '".PclZipUtilOptionText($v_key)."'");
1904
+			return PclZip::errorCode();
1905
+		  }
1906 1906
 
1907
-        break;
1907
+		break;
1908 1908
 
1909
-        case PCLZIP_ATT_FILE_NEW_SHORT_NAME :
1910
-          if (!is_string($v_value)) {
1911
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1912
-            return PclZip::errorCode();
1913
-          }
1909
+		case PCLZIP_ATT_FILE_NEW_SHORT_NAME :
1910
+		  if (!is_string($v_value)) {
1911
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1912
+			return PclZip::errorCode();
1913
+		  }
1914 1914
 
1915
-          $p_filedescr['new_short_name'] = PclZipUtilPathReduction($v_value);
1915
+		  $p_filedescr['new_short_name'] = PclZipUtilPathReduction($v_value);
1916 1916
 
1917
-          if ($p_filedescr['new_short_name'] == '') {
1918
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty short filename for attribute '".PclZipUtilOptionText($v_key)."'");
1919
-            return PclZip::errorCode();
1920
-          }
1921
-        break;
1917
+		  if ($p_filedescr['new_short_name'] == '') {
1918
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty short filename for attribute '".PclZipUtilOptionText($v_key)."'");
1919
+			return PclZip::errorCode();
1920
+		  }
1921
+		break;
1922 1922
 
1923
-        case PCLZIP_ATT_FILE_NEW_FULL_NAME :
1924
-          if (!is_string($v_value)) {
1925
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1926
-            return PclZip::errorCode();
1927
-          }
1923
+		case PCLZIP_ATT_FILE_NEW_FULL_NAME :
1924
+		  if (!is_string($v_value)) {
1925
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1926
+			return PclZip::errorCode();
1927
+		  }
1928 1928
 
1929
-          $p_filedescr['new_full_name'] = PclZipUtilPathReduction($v_value);
1929
+		  $p_filedescr['new_full_name'] = PclZipUtilPathReduction($v_value);
1930 1930
 
1931
-          if ($p_filedescr['new_full_name'] == '') {
1932
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty full filename for attribute '".PclZipUtilOptionText($v_key)."'");
1933
-            return PclZip::errorCode();
1934
-          }
1935
-        break;
1931
+		  if ($p_filedescr['new_full_name'] == '') {
1932
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty full filename for attribute '".PclZipUtilOptionText($v_key)."'");
1933
+			return PclZip::errorCode();
1934
+		  }
1935
+		break;
1936 1936
 
1937
-        // ----- Look for options that takes a string
1938
-        case PCLZIP_ATT_FILE_COMMENT :
1939
-          if (!is_string($v_value)) {
1940
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1941
-            return PclZip::errorCode();
1942
-          }
1937
+		// ----- Look for options that takes a string
1938
+		case PCLZIP_ATT_FILE_COMMENT :
1939
+		  if (!is_string($v_value)) {
1940
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1941
+			return PclZip::errorCode();
1942
+		  }
1943 1943
 
1944
-          $p_filedescr['comment'] = $v_value;
1945
-        break;
1944
+		  $p_filedescr['comment'] = $v_value;
1945
+		break;
1946 1946
 
1947
-        case PCLZIP_ATT_FILE_MTIME :
1948
-          if (!is_integer($v_value)) {
1949
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". Integer expected for attribute '".PclZipUtilOptionText($v_key)."'");
1950
-            return PclZip::errorCode();
1951
-          }
1947
+		case PCLZIP_ATT_FILE_MTIME :
1948
+		  if (!is_integer($v_value)) {
1949
+			PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". Integer expected for attribute '".PclZipUtilOptionText($v_key)."'");
1950
+			return PclZip::errorCode();
1951
+		  }
1952 1952
 
1953
-          $p_filedescr['mtime'] = $v_value;
1954
-        break;
1953
+		  $p_filedescr['mtime'] = $v_value;
1954
+		break;
1955 1955
 
1956
-        case PCLZIP_ATT_FILE_CONTENT :
1957
-          $p_filedescr['content'] = $v_value;
1958
-        break;
1956
+		case PCLZIP_ATT_FILE_CONTENT :
1957
+		  $p_filedescr['content'] = $v_value;
1958
+		break;
1959 1959
 
1960
-        default :
1961
-          // ----- Error log
1962
-          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
1963
-		                           "Unknown parameter '".$v_key."'");
1960
+		default :
1961
+		  // ----- Error log
1962
+		  PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
1963
+								   "Unknown parameter '".$v_key."'");
1964 1964
 
1965
-          // ----- Return
1966
-          return PclZip::errorCode();
1967
-      }
1965
+		  // ----- Return
1966
+		  return PclZip::errorCode();
1967
+	  }
1968 1968
 
1969
-      // ----- Look for mandatory options
1970
-      if ($v_requested_options !== false) {
1971
-        for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
1972
-          // ----- Look for mandatory option
1973
-          if ($v_requested_options[$key] == 'mandatory') {
1974
-            // ----- Look if present
1975
-            if (!isset($p_file_list[$key])) {
1976
-              PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
1977
-              return PclZip::errorCode();
1978
-            }
1979
-          }
1980
-        }
1981
-      }
1969
+	  // ----- Look for mandatory options
1970
+	  if ($v_requested_options !== false) {
1971
+		for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
1972
+		  // ----- Look for mandatory option
1973
+		  if ($v_requested_options[$key] == 'mandatory') {
1974
+			// ----- Look if present
1975
+			if (!isset($p_file_list[$key])) {
1976
+			  PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
1977
+			  return PclZip::errorCode();
1978
+			}
1979
+		  }
1980
+		}
1981
+	  }
1982 1982
     
1983
-    // end foreach
1984
-    }
1983
+	// end foreach
1984
+	}
1985 1985
     
1986
-    // ----- Return
1987
-    return $v_result;
1986
+	// ----- Return
1987
+	return $v_result;
1988 1988
   }
1989 1989
   // --------------------------------------------------------------------------------
1990 1990
 
@@ -2004,120 +2004,120 @@  discard block
 block discarded – undo
2004 2004
   // --------------------------------------------------------------------------------
2005 2005
   function privFileDescrExpand(&$p_filedescr_list, &$p_options)
2006 2006
   {
2007
-    $v_result=1;
2007
+	$v_result=1;
2008 2008
     
2009
-    // ----- Create a result list
2010
-    $v_result_list = array();
2009
+	// ----- Create a result list
2010
+	$v_result_list = array();
2011 2011
     
2012
-    // ----- Look each entry
2013
-    for ($i=0; $i<sizeof($p_filedescr_list); $i++) {
2012
+	// ----- Look each entry
2013
+	for ($i=0; $i<sizeof($p_filedescr_list); $i++) {
2014 2014
       
2015
-      // ----- Get filedescr
2016
-      $v_descr = $p_filedescr_list[$i];
2015
+	  // ----- Get filedescr
2016
+	  $v_descr = $p_filedescr_list[$i];
2017 2017
       
2018
-      // ----- Reduce the filename
2019
-      $v_descr['filename'] = PclZipUtilTranslateWinPath($v_descr['filename'], false);
2020
-      $v_descr['filename'] = PclZipUtilPathReduction($v_descr['filename']);
2018
+	  // ----- Reduce the filename
2019
+	  $v_descr['filename'] = PclZipUtilTranslateWinPath($v_descr['filename'], false);
2020
+	  $v_descr['filename'] = PclZipUtilPathReduction($v_descr['filename']);
2021 2021
       
2022
-      // ----- Look for real file or folder
2023
-      if (file_exists($v_descr['filename'])) {
2024
-        if (@is_file($v_descr['filename'])) {
2025
-          $v_descr['type'] = 'file';
2026
-        }
2027
-        else if (@is_dir($v_descr['filename'])) {
2028
-          $v_descr['type'] = 'folder';
2029
-        }
2030
-        else if (@is_link($v_descr['filename'])) {
2031
-          // skip
2032
-          continue;
2033
-        }
2034
-        else {
2035
-          // skip
2036
-          continue;
2037
-        }
2038
-      }
2022
+	  // ----- Look for real file or folder
2023
+	  if (file_exists($v_descr['filename'])) {
2024
+		if (@is_file($v_descr['filename'])) {
2025
+		  $v_descr['type'] = 'file';
2026
+		}
2027
+		else if (@is_dir($v_descr['filename'])) {
2028
+		  $v_descr['type'] = 'folder';
2029
+		}
2030
+		else if (@is_link($v_descr['filename'])) {
2031
+		  // skip
2032
+		  continue;
2033
+		}
2034
+		else {
2035
+		  // skip
2036
+		  continue;
2037
+		}
2038
+	  }
2039 2039
       
2040
-      // ----- Look for string added as file
2041
-      else if (isset($v_descr['content'])) {
2042
-        $v_descr['type'] = 'virtual_file';
2043
-      }
2040
+	  // ----- Look for string added as file
2041
+	  else if (isset($v_descr['content'])) {
2042
+		$v_descr['type'] = 'virtual_file';
2043
+	  }
2044 2044
       
2045
-      // ----- Missing file
2046
-      else {
2047
-        // ----- Error log
2048
-        PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$v_descr['filename']."' does not exist");
2045
+	  // ----- Missing file
2046
+	  else {
2047
+		// ----- Error log
2048
+		PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$v_descr['filename']."' does not exist");
2049 2049
 
2050
-        // ----- Return
2051
-        return PclZip::errorCode();
2052
-      }
2050
+		// ----- Return
2051
+		return PclZip::errorCode();
2052
+	  }
2053 2053
       
2054
-      // ----- Calculate the stored filename
2055
-      $this->privCalculateStoredFilename($v_descr, $p_options);
2054
+	  // ----- Calculate the stored filename
2055
+	  $this->privCalculateStoredFilename($v_descr, $p_options);
2056 2056
       
2057
-      // ----- Add the descriptor in result list
2058
-      $v_result_list[sizeof($v_result_list)] = $v_descr;
2057
+	  // ----- Add the descriptor in result list
2058
+	  $v_result_list[sizeof($v_result_list)] = $v_descr;
2059 2059
       
2060
-      // ----- Look for folder
2061
-      if ($v_descr['type'] == 'folder') {
2062
-        // ----- List of items in folder
2063
-        $v_dirlist_descr = array();
2064
-        $v_dirlist_nb = 0;
2065
-        if ($v_folder_handler = @opendir($v_descr['filename'])) {
2066
-          while (($v_item_handler = @readdir($v_folder_handler)) !== false) {
2067
-
2068
-            // ----- Skip '.' and '..'
2069
-            if (($v_item_handler == '.') || ($v_item_handler == '..')) {
2070
-                continue;
2071
-            }
2060
+	  // ----- Look for folder
2061
+	  if ($v_descr['type'] == 'folder') {
2062
+		// ----- List of items in folder
2063
+		$v_dirlist_descr = array();
2064
+		$v_dirlist_nb = 0;
2065
+		if ($v_folder_handler = @opendir($v_descr['filename'])) {
2066
+		  while (($v_item_handler = @readdir($v_folder_handler)) !== false) {
2067
+
2068
+			// ----- Skip '.' and '..'
2069
+			if (($v_item_handler == '.') || ($v_item_handler == '..')) {
2070
+				continue;
2071
+			}
2072 2072
             
2073
-            // ----- Compose the full filename
2074
-            $v_dirlist_descr[$v_dirlist_nb]['filename'] = $v_descr['filename'].'/'.$v_item_handler;
2073
+			// ----- Compose the full filename
2074
+			$v_dirlist_descr[$v_dirlist_nb]['filename'] = $v_descr['filename'].'/'.$v_item_handler;
2075 2075
             
2076
-            // ----- Look for different stored filename
2077
-            // Because the name of the folder was changed, the name of the
2078
-            // files/sub-folders also change
2079
-            if (($v_descr['stored_filename'] != $v_descr['filename'])
2080
-                 && (!isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))) {
2081
-              if ($v_descr['stored_filename'] != '') {
2082
-                $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler;
2083
-              }
2084
-              else {
2085
-                $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_item_handler;
2086
-              }
2087
-            }
2076
+			// ----- Look for different stored filename
2077
+			// Because the name of the folder was changed, the name of the
2078
+			// files/sub-folders also change
2079
+			if (($v_descr['stored_filename'] != $v_descr['filename'])
2080
+				 && (!isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))) {
2081
+			  if ($v_descr['stored_filename'] != '') {
2082
+				$v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler;
2083
+			  }
2084
+			  else {
2085
+				$v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_item_handler;
2086
+			  }
2087
+			}
2088 2088
       
2089
-            $v_dirlist_nb++;
2090
-          }
2089
+			$v_dirlist_nb++;
2090
+		  }
2091 2091
           
2092
-          @closedir($v_folder_handler);
2093
-        }
2094
-        else {
2095
-          // TBC : unable to open folder in read mode
2096
-        }
2092
+		  @closedir($v_folder_handler);
2093
+		}
2094
+		else {
2095
+		  // TBC : unable to open folder in read mode
2096
+		}
2097 2097
         
2098
-        // ----- Expand each element of the list
2099
-        if ($v_dirlist_nb != 0) {
2100
-          // ----- Expand
2101
-          if (($v_result = $this->privFileDescrExpand($v_dirlist_descr, $p_options)) != 1) {
2102
-            return $v_result;
2103
-          }
2098
+		// ----- Expand each element of the list
2099
+		if ($v_dirlist_nb != 0) {
2100
+		  // ----- Expand
2101
+		  if (($v_result = $this->privFileDescrExpand($v_dirlist_descr, $p_options)) != 1) {
2102
+			return $v_result;
2103
+		  }
2104 2104
           
2105
-          // ----- Concat the resulting list
2106
-          $v_result_list = array_merge($v_result_list, $v_dirlist_descr);
2107
-        }
2108
-        else {
2109
-        }
2105
+		  // ----- Concat the resulting list
2106
+		  $v_result_list = array_merge($v_result_list, $v_dirlist_descr);
2107
+		}
2108
+		else {
2109
+		}
2110 2110
           
2111
-        // ----- Free local array
2112
-        unset($v_dirlist_descr);
2113
-      }
2114
-    }
2111
+		// ----- Free local array
2112
+		unset($v_dirlist_descr);
2113
+	  }
2114
+	}
2115 2115
     
2116
-    // ----- Get the result list
2117
-    $p_filedescr_list = $v_result_list;
2116
+	// ----- Get the result list
2117
+	$p_filedescr_list = $v_result_list;
2118 2118
 
2119
-    // ----- Return
2120
-    return $v_result;
2119
+	// ----- Return
2120
+	return $v_result;
2121 2121
   }
2122 2122
   // --------------------------------------------------------------------------------
2123 2123
 
@@ -2129,30 +2129,30 @@  discard block
 block discarded – undo
2129 2129
   // --------------------------------------------------------------------------------
2130 2130
   function privCreate($p_filedescr_list, &$p_result_list, &$p_options)
2131 2131
   {
2132
-    $v_result=1;
2133
-    $v_list_detail = array();
2132
+	$v_result=1;
2133
+	$v_list_detail = array();
2134 2134
     
2135
-    // ----- Magic quotes trick
2136
-    $this->privDisableMagicQuotes();
2137
-
2138
-    // ----- Open the file in write mode
2139
-    if (($v_result = $this->privOpenFd('wb')) != 1)
2140
-    {
2141
-      // ----- Return
2142
-      return $v_result;
2143
-    }
2135
+	// ----- Magic quotes trick
2136
+	$this->privDisableMagicQuotes();
2137
+
2138
+	// ----- Open the file in write mode
2139
+	if (($v_result = $this->privOpenFd('wb')) != 1)
2140
+	{
2141
+	  // ----- Return
2142
+	  return $v_result;
2143
+	}
2144 2144
 
2145
-    // ----- Add the list of files
2146
-    $v_result = $this->privAddList($p_filedescr_list, $p_result_list, $p_options);
2145
+	// ----- Add the list of files
2146
+	$v_result = $this->privAddList($p_filedescr_list, $p_result_list, $p_options);
2147 2147
 
2148
-    // ----- Close
2149
-    $this->privCloseFd();
2148
+	// ----- Close
2149
+	$this->privCloseFd();
2150 2150
 
2151
-    // ----- Magic quotes trick
2152
-    $this->privSwapBackMagicQuotes();
2151
+	// ----- Magic quotes trick
2152
+	$this->privSwapBackMagicQuotes();
2153 2153
 
2154
-    // ----- Return
2155
-    return $v_result;
2154
+	// ----- Return
2155
+	return $v_result;
2156 2156
   }
2157 2157
   // --------------------------------------------------------------------------------
2158 2158
 
@@ -2164,175 +2164,175 @@  discard block
 block discarded – undo
2164 2164
   // --------------------------------------------------------------------------------
2165 2165
   function privAdd($p_filedescr_list, &$p_result_list, &$p_options)
2166 2166
   {
2167
-    $v_result=1;
2168
-    $v_list_detail = array();
2167
+	$v_result=1;
2168
+	$v_list_detail = array();
2169 2169
 
2170
-    // ----- Look if the archive exists or is empty
2171
-    if ((!is_file($this->zipname)) || (filesize($this->zipname) == 0))
2172
-    {
2170
+	// ----- Look if the archive exists or is empty
2171
+	if ((!is_file($this->zipname)) || (filesize($this->zipname) == 0))
2172
+	{
2173 2173
 
2174
-      // ----- Do a create
2175
-      $v_result = $this->privCreate($p_filedescr_list, $p_result_list, $p_options);
2174
+	  // ----- Do a create
2175
+	  $v_result = $this->privCreate($p_filedescr_list, $p_result_list, $p_options);
2176 2176
 
2177
-      // ----- Return
2178
-      return $v_result;
2179
-    }
2180
-    // ----- Magic quotes trick
2181
-    $this->privDisableMagicQuotes();
2177
+	  // ----- Return
2178
+	  return $v_result;
2179
+	}
2180
+	// ----- Magic quotes trick
2181
+	$this->privDisableMagicQuotes();
2182 2182
 
2183
-    // ----- Open the zip file
2184
-    if (($v_result=$this->privOpenFd('rb')) != 1)
2185
-    {
2186
-      // ----- Magic quotes trick
2187
-      $this->privSwapBackMagicQuotes();
2183
+	// ----- Open the zip file
2184
+	if (($v_result=$this->privOpenFd('rb')) != 1)
2185
+	{
2186
+	  // ----- Magic quotes trick
2187
+	  $this->privSwapBackMagicQuotes();
2188 2188
 
2189
-      // ----- Return
2190
-      return $v_result;
2191
-    }
2189
+	  // ----- Return
2190
+	  return $v_result;
2191
+	}
2192 2192
 
2193
-    // ----- Read the central directory informations
2194
-    $v_central_dir = array();
2195
-    if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
2196
-    {
2197
-      $this->privCloseFd();
2198
-      $this->privSwapBackMagicQuotes();
2199
-      return $v_result;
2200
-    }
2193
+	// ----- Read the central directory informations
2194
+	$v_central_dir = array();
2195
+	if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
2196
+	{
2197
+	  $this->privCloseFd();
2198
+	  $this->privSwapBackMagicQuotes();
2199
+	  return $v_result;
2200
+	}
2201 2201
 
2202
-    // ----- Go to beginning of File
2203
-    @rewind($this->zip_fd);
2202
+	// ----- Go to beginning of File
2203
+	@rewind($this->zip_fd);
2204 2204
 
2205
-    // ----- Creates a temporay file
2206
-    $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
2205
+	// ----- Creates a temporay file
2206
+	$v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
2207 2207
 
2208
-    // ----- Open the temporary file in write mode
2209
-    if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
2210
-    {
2211
-      $this->privCloseFd();
2212
-      $this->privSwapBackMagicQuotes();
2208
+	// ----- Open the temporary file in write mode
2209
+	if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
2210
+	{
2211
+	  $this->privCloseFd();
2212
+	  $this->privSwapBackMagicQuotes();
2213 2213
 
2214
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
2214
+	  PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
2215 2215
 
2216
-      // ----- Return
2217
-      return PclZip::errorCode();
2218
-    }
2216
+	  // ----- Return
2217
+	  return PclZip::errorCode();
2218
+	}
2219 2219
 
2220
-    // ----- Copy the files from the archive to the temporary file
2221
-    // TBC : Here I should better append the file and go back to erase the central dir
2222
-    $v_size = $v_central_dir['offset'];
2223
-    while ($v_size != 0)
2224
-    {
2225
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2226
-      $v_buffer = fread($this->zip_fd, $v_read_size);
2227
-      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
2228
-      $v_size -= $v_read_size;
2229
-    }
2220
+	// ----- Copy the files from the archive to the temporary file
2221
+	// TBC : Here I should better append the file and go back to erase the central dir
2222
+	$v_size = $v_central_dir['offset'];
2223
+	while ($v_size != 0)
2224
+	{
2225
+	  $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2226
+	  $v_buffer = fread($this->zip_fd, $v_read_size);
2227
+	  @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
2228
+	  $v_size -= $v_read_size;
2229
+	}
2230 2230
 
2231
-    // ----- Swap the file descriptor
2232
-    // Here is a trick : I swap the temporary fd with the zip fd, in order to use
2233
-    // the following methods on the temporary fil and not the real archive
2234
-    $v_swap = $this->zip_fd;
2235
-    $this->zip_fd = $v_zip_temp_fd;
2236
-    $v_zip_temp_fd = $v_swap;
2237
-
2238
-    // ----- Add the files
2239
-    $v_header_list = array();
2240
-    if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1)
2241
-    {
2242
-      fclose($v_zip_temp_fd);
2243
-      $this->privCloseFd();
2244
-      @unlink($v_zip_temp_name);
2245
-      $this->privSwapBackMagicQuotes();
2246
-
2247
-      // ----- Return
2248
-      return $v_result;
2249
-    }
2231
+	// ----- Swap the file descriptor
2232
+	// Here is a trick : I swap the temporary fd with the zip fd, in order to use
2233
+	// the following methods on the temporary fil and not the real archive
2234
+	$v_swap = $this->zip_fd;
2235
+	$this->zip_fd = $v_zip_temp_fd;
2236
+	$v_zip_temp_fd = $v_swap;
2237
+
2238
+	// ----- Add the files
2239
+	$v_header_list = array();
2240
+	if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1)
2241
+	{
2242
+	  fclose($v_zip_temp_fd);
2243
+	  $this->privCloseFd();
2244
+	  @unlink($v_zip_temp_name);
2245
+	  $this->privSwapBackMagicQuotes();
2246
+
2247
+	  // ----- Return
2248
+	  return $v_result;
2249
+	}
2250 2250
 
2251
-    // ----- Store the offset of the central dir
2252
-    $v_offset = @ftell($this->zip_fd);
2253
-
2254
-    // ----- Copy the block of file headers from the old archive
2255
-    $v_size = $v_central_dir['size'];
2256
-    while ($v_size != 0)
2257
-    {
2258
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2259
-      $v_buffer = @fread($v_zip_temp_fd, $v_read_size);
2260
-      @fwrite($this->zip_fd, $v_buffer, $v_read_size);
2261
-      $v_size -= $v_read_size;
2262
-    }
2251
+	// ----- Store the offset of the central dir
2252
+	$v_offset = @ftell($this->zip_fd);
2253
+
2254
+	// ----- Copy the block of file headers from the old archive
2255
+	$v_size = $v_central_dir['size'];
2256
+	while ($v_size != 0)
2257
+	{
2258
+	  $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2259
+	  $v_buffer = @fread($v_zip_temp_fd, $v_read_size);
2260
+	  @fwrite($this->zip_fd, $v_buffer, $v_read_size);
2261
+	  $v_size -= $v_read_size;
2262
+	}
2263 2263
 
2264
-    // ----- Create the Central Dir files header
2265
-    for ($i=0, $v_count=0; $i<sizeof($v_header_list); $i++)
2266
-    {
2267
-      // ----- Create the file header
2268
-      if ($v_header_list[$i]['status'] == 'ok') {
2269
-        if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
2270
-          fclose($v_zip_temp_fd);
2271
-          $this->privCloseFd();
2272
-          @unlink($v_zip_temp_name);
2273
-          $this->privSwapBackMagicQuotes();
2274
-
2275
-          // ----- Return
2276
-          return $v_result;
2277
-        }
2278
-        $v_count++;
2279
-      }
2264
+	// ----- Create the Central Dir files header
2265
+	for ($i=0, $v_count=0; $i<sizeof($v_header_list); $i++)
2266
+	{
2267
+	  // ----- Create the file header
2268
+	  if ($v_header_list[$i]['status'] == 'ok') {
2269
+		if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
2270
+		  fclose($v_zip_temp_fd);
2271
+		  $this->privCloseFd();
2272
+		  @unlink($v_zip_temp_name);
2273
+		  $this->privSwapBackMagicQuotes();
2274
+
2275
+		  // ----- Return
2276
+		  return $v_result;
2277
+		}
2278
+		$v_count++;
2279
+	  }
2280 2280
 
2281
-      // ----- Transform the header to a 'usable' info
2282
-      $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
2283
-    }
2281
+	  // ----- Transform the header to a 'usable' info
2282
+	  $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
2283
+	}
2284 2284
 
2285
-    // ----- Zip file comment
2286
-    $v_comment = $v_central_dir['comment'];
2287
-    if (isset($p_options[PCLZIP_OPT_COMMENT])) {
2288
-      $v_comment = $p_options[PCLZIP_OPT_COMMENT];
2289
-    }
2290
-    if (isset($p_options[PCLZIP_OPT_ADD_COMMENT])) {
2291
-      $v_comment = $v_comment.$p_options[PCLZIP_OPT_ADD_COMMENT];
2292
-    }
2293
-    if (isset($p_options[PCLZIP_OPT_PREPEND_COMMENT])) {
2294
-      $v_comment = $p_options[PCLZIP_OPT_PREPEND_COMMENT].$v_comment;
2295
-    }
2285
+	// ----- Zip file comment
2286
+	$v_comment = $v_central_dir['comment'];
2287
+	if (isset($p_options[PCLZIP_OPT_COMMENT])) {
2288
+	  $v_comment = $p_options[PCLZIP_OPT_COMMENT];
2289
+	}
2290
+	if (isset($p_options[PCLZIP_OPT_ADD_COMMENT])) {
2291
+	  $v_comment = $v_comment.$p_options[PCLZIP_OPT_ADD_COMMENT];
2292
+	}
2293
+	if (isset($p_options[PCLZIP_OPT_PREPEND_COMMENT])) {
2294
+	  $v_comment = $p_options[PCLZIP_OPT_PREPEND_COMMENT].$v_comment;
2295
+	}
2296 2296
 
2297
-    // ----- Calculate the size of the central header
2298
-    $v_size = @ftell($this->zip_fd)-$v_offset;
2297
+	// ----- Calculate the size of the central header
2298
+	$v_size = @ftell($this->zip_fd)-$v_offset;
2299 2299
 
2300
-    // ----- Create the central dir footer
2301
-    if (($v_result = $this->privWriteCentralHeader($v_count+$v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1)
2302
-    {
2303
-      // ----- Reset the file list
2304
-      unset($v_header_list);
2305
-      $this->privSwapBackMagicQuotes();
2300
+	// ----- Create the central dir footer
2301
+	if (($v_result = $this->privWriteCentralHeader($v_count+$v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1)
2302
+	{
2303
+	  // ----- Reset the file list
2304
+	  unset($v_header_list);
2305
+	  $this->privSwapBackMagicQuotes();
2306 2306
 
2307
-      // ----- Return
2308
-      return $v_result;
2309
-    }
2307
+	  // ----- Return
2308
+	  return $v_result;
2309
+	}
2310 2310
 
2311
-    // ----- Swap back the file descriptor
2312
-    $v_swap = $this->zip_fd;
2313
-    $this->zip_fd = $v_zip_temp_fd;
2314
-    $v_zip_temp_fd = $v_swap;
2311
+	// ----- Swap back the file descriptor
2312
+	$v_swap = $this->zip_fd;
2313
+	$this->zip_fd = $v_zip_temp_fd;
2314
+	$v_zip_temp_fd = $v_swap;
2315 2315
 
2316
-    // ----- Close
2317
-    $this->privCloseFd();
2316
+	// ----- Close
2317
+	$this->privCloseFd();
2318 2318
 
2319
-    // ----- Close the temporary file
2320
-    @fclose($v_zip_temp_fd);
2319
+	// ----- Close the temporary file
2320
+	@fclose($v_zip_temp_fd);
2321 2321
 
2322
-    // ----- Magic quotes trick
2323
-    $this->privSwapBackMagicQuotes();
2322
+	// ----- Magic quotes trick
2323
+	$this->privSwapBackMagicQuotes();
2324 2324
 
2325
-    // ----- Delete the zip file
2326
-    // TBC : I should test the result ...
2327
-    @unlink($this->zipname);
2325
+	// ----- Delete the zip file
2326
+	// TBC : I should test the result ...
2327
+	@unlink($this->zipname);
2328 2328
 
2329
-    // ----- Rename the temporary file
2330
-    // TBC : I should test the result ...
2331
-    //@rename($v_zip_temp_name, $this->zipname);
2332
-    PclZipUtilRename($v_zip_temp_name, $this->zipname);
2329
+	// ----- Rename the temporary file
2330
+	// TBC : I should test the result ...
2331
+	//@rename($v_zip_temp_name, $this->zipname);
2332
+	PclZipUtilRename($v_zip_temp_name, $this->zipname);
2333 2333
 
2334
-    // ----- Return
2335
-    return $v_result;
2334
+	// ----- Return
2335
+	return $v_result;
2336 2336
   }
2337 2337
   // --------------------------------------------------------------------------------
2338 2338
 
@@ -2343,30 +2343,30 @@  discard block
 block discarded – undo
2343 2343
   // --------------------------------------------------------------------------------
2344 2344
   function privOpenFd($p_mode)
2345 2345
   {
2346
-    $v_result=1;
2346
+	$v_result=1;
2347 2347
 
2348
-    // ----- Look if already open
2349
-    if ($this->zip_fd != 0)
2350
-    {
2351
-      // ----- Error log
2352
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Zip file \''.$this->zipname.'\' already open');
2348
+	// ----- Look if already open
2349
+	if ($this->zip_fd != 0)
2350
+	{
2351
+	  // ----- Error log
2352
+	  PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Zip file \''.$this->zipname.'\' already open');
2353 2353
 
2354
-      // ----- Return
2355
-      return PclZip::errorCode();
2356
-    }
2354
+	  // ----- Return
2355
+	  return PclZip::errorCode();
2356
+	}
2357 2357
 
2358
-    // ----- Open the zip file
2359
-    if (($this->zip_fd = @fopen($this->zipname, $p_mode)) == 0)
2360
-    {
2361
-      // ----- Error log
2362
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in '.$p_mode.' mode');
2358
+	// ----- Open the zip file
2359
+	if (($this->zip_fd = @fopen($this->zipname, $p_mode)) == 0)
2360
+	{
2361
+	  // ----- Error log
2362
+	  PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in '.$p_mode.' mode');
2363 2363
 
2364
-      // ----- Return
2365
-      return PclZip::errorCode();
2366
-    }
2364
+	  // ----- Return
2365
+	  return PclZip::errorCode();
2366
+	}
2367 2367
 
2368
-    // ----- Return
2369
-    return $v_result;
2368
+	// ----- Return
2369
+	return $v_result;
2370 2370
   }
2371 2371
   // --------------------------------------------------------------------------------
2372 2372
 
@@ -2377,14 +2377,14 @@  discard block
 block discarded – undo
2377 2377
   // --------------------------------------------------------------------------------
2378 2378
   function privCloseFd()
2379 2379
   {
2380
-    $v_result=1;
2380
+	$v_result=1;
2381 2381
 
2382
-    if ($this->zip_fd != 0)
2383
-      @fclose($this->zip_fd);
2384
-    $this->zip_fd = 0;
2382
+	if ($this->zip_fd != 0)
2383
+	  @fclose($this->zip_fd);
2384
+	$this->zip_fd = 0;
2385 2385
 
2386
-    // ----- Return
2387
-    return $v_result;
2386
+	// ----- Return
2387
+	return $v_result;
2388 2388
   }
2389 2389
   // --------------------------------------------------------------------------------
2390 2390
 
@@ -2404,56 +2404,56 @@  discard block
 block discarded – undo
2404 2404
 //  function privAddList($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options)
2405 2405
   function privAddList($p_filedescr_list, &$p_result_list, &$p_options)
2406 2406
   {
2407
-    $v_result=1;
2408
-
2409
-    // ----- Add the files
2410
-    $v_header_list = array();
2411
-    if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1)
2412
-    {
2413
-      // ----- Return
2414
-      return $v_result;
2415
-    }
2407
+	$v_result=1;
2408
+
2409
+	// ----- Add the files
2410
+	$v_header_list = array();
2411
+	if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1)
2412
+	{
2413
+	  // ----- Return
2414
+	  return $v_result;
2415
+	}
2416 2416
 
2417
-    // ----- Store the offset of the central dir
2418
-    $v_offset = @ftell($this->zip_fd);
2419
-
2420
-    // ----- Create the Central Dir files header
2421
-    for ($i=0,$v_count=0; $i<sizeof($v_header_list); $i++)
2422
-    {
2423
-      // ----- Create the file header
2424
-      if ($v_header_list[$i]['status'] == 'ok') {
2425
-        if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
2426
-          // ----- Return
2427
-          return $v_result;
2428
-        }
2429
-        $v_count++;
2430
-      }
2417
+	// ----- Store the offset of the central dir
2418
+	$v_offset = @ftell($this->zip_fd);
2419
+
2420
+	// ----- Create the Central Dir files header
2421
+	for ($i=0,$v_count=0; $i<sizeof($v_header_list); $i++)
2422
+	{
2423
+	  // ----- Create the file header
2424
+	  if ($v_header_list[$i]['status'] == 'ok') {
2425
+		if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
2426
+		  // ----- Return
2427
+		  return $v_result;
2428
+		}
2429
+		$v_count++;
2430
+	  }
2431 2431
 
2432
-      // ----- Transform the header to a 'usable' info
2433
-      $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
2434
-    }
2432
+	  // ----- Transform the header to a 'usable' info
2433
+	  $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
2434
+	}
2435 2435
 
2436
-    // ----- Zip file comment
2437
-    $v_comment = '';
2438
-    if (isset($p_options[PCLZIP_OPT_COMMENT])) {
2439
-      $v_comment = $p_options[PCLZIP_OPT_COMMENT];
2440
-    }
2436
+	// ----- Zip file comment
2437
+	$v_comment = '';
2438
+	if (isset($p_options[PCLZIP_OPT_COMMENT])) {
2439
+	  $v_comment = $p_options[PCLZIP_OPT_COMMENT];
2440
+	}
2441 2441
 
2442
-    // ----- Calculate the size of the central header
2443
-    $v_size = @ftell($this->zip_fd)-$v_offset;
2442
+	// ----- Calculate the size of the central header
2443
+	$v_size = @ftell($this->zip_fd)-$v_offset;
2444 2444
 
2445
-    // ----- Create the central dir footer
2446
-    if (($v_result = $this->privWriteCentralHeader($v_count, $v_size, $v_offset, $v_comment)) != 1)
2447
-    {
2448
-      // ----- Reset the file list
2449
-      unset($v_header_list);
2445
+	// ----- Create the central dir footer
2446
+	if (($v_result = $this->privWriteCentralHeader($v_count, $v_size, $v_offset, $v_comment)) != 1)
2447
+	{
2448
+	  // ----- Reset the file list
2449
+	  unset($v_header_list);
2450 2450
 
2451
-      // ----- Return
2452
-      return $v_result;
2453
-    }
2451
+	  // ----- Return
2452
+	  return $v_result;
2453
+	}
2454 2454
 
2455
-    // ----- Return
2456
-    return $v_result;
2455
+	// ----- Return
2456
+	return $v_result;
2457 2457
   }
2458 2458
   // --------------------------------------------------------------------------------
2459 2459
 
@@ -2468,57 +2468,57 @@  discard block
 block discarded – undo
2468 2468
   // --------------------------------------------------------------------------------
2469 2469
   function privAddFileList($p_filedescr_list, &$p_result_list, &$p_options)
2470 2470
   {
2471
-    $v_result=1;
2472
-    $v_header = array();
2471
+	$v_result=1;
2472
+	$v_header = array();
2473 2473
 
2474
-    // ----- Recuperate the current number of elt in list
2475
-    $v_nb = sizeof($p_result_list);
2474
+	// ----- Recuperate the current number of elt in list
2475
+	$v_nb = sizeof($p_result_list);
2476 2476
 
2477
-    // ----- Loop on the files
2478
-    for ($j=0; ($j<sizeof($p_filedescr_list)) && ($v_result==1); $j++) {
2479
-      // ----- Format the filename
2480
-      $p_filedescr_list[$j]['filename']
2481
-      = PclZipUtilTranslateWinPath($p_filedescr_list[$j]['filename'], false);
2477
+	// ----- Loop on the files
2478
+	for ($j=0; ($j<sizeof($p_filedescr_list)) && ($v_result==1); $j++) {
2479
+	  // ----- Format the filename
2480
+	  $p_filedescr_list[$j]['filename']
2481
+	  = PclZipUtilTranslateWinPath($p_filedescr_list[$j]['filename'], false);
2482 2482
       
2483 2483
 
2484
-      // ----- Skip empty file names
2485
-      // TBC : Can this be possible ? not checked in DescrParseAtt ?
2486
-      if ($p_filedescr_list[$j]['filename'] == "") {
2487
-        continue;
2488
-      }
2484
+	  // ----- Skip empty file names
2485
+	  // TBC : Can this be possible ? not checked in DescrParseAtt ?
2486
+	  if ($p_filedescr_list[$j]['filename'] == "") {
2487
+		continue;
2488
+	  }
2489 2489
 
2490
-      // ----- Check the filename
2491
-      if (   ($p_filedescr_list[$j]['type'] != 'virtual_file')
2492
-          && (!file_exists($p_filedescr_list[$j]['filename']))) {
2493
-        PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$p_filedescr_list[$j]['filename']."' does not exist");
2494
-        return PclZip::errorCode();
2495
-      }
2490
+	  // ----- Check the filename
2491
+	  if (   ($p_filedescr_list[$j]['type'] != 'virtual_file')
2492
+		  && (!file_exists($p_filedescr_list[$j]['filename']))) {
2493
+		PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$p_filedescr_list[$j]['filename']."' does not exist");
2494
+		return PclZip::errorCode();
2495
+	  }
2496 2496
 
2497
-      // ----- Look if it is a file or a dir with no all path remove option
2498
-      // or a dir with all its path removed
2497
+	  // ----- Look if it is a file or a dir with no all path remove option
2498
+	  // or a dir with all its path removed
2499 2499
 //      if (   (is_file($p_filedescr_list[$j]['filename']))
2500 2500
 //          || (   is_dir($p_filedescr_list[$j]['filename'])
2501
-      if (   ($p_filedescr_list[$j]['type'] == 'file')
2502
-          || ($p_filedescr_list[$j]['type'] == 'virtual_file')
2503
-          || (   ($p_filedescr_list[$j]['type'] == 'folder')
2504
-              && (   !isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])
2505
-                  || !$p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))
2506
-          ) {
2507
-
2508
-        // ----- Add the file
2509
-        $v_result = $this->privAddFile($p_filedescr_list[$j], $v_header,
2510
-                                       $p_options);
2511
-        if ($v_result != 1) {
2512
-          return $v_result;
2513
-        }
2514
-
2515
-        // ----- Store the file infos
2516
-        $p_result_list[$v_nb++] = $v_header;
2517
-      }
2518
-    }
2501
+	  if (   ($p_filedescr_list[$j]['type'] == 'file')
2502
+		  || ($p_filedescr_list[$j]['type'] == 'virtual_file')
2503
+		  || (   ($p_filedescr_list[$j]['type'] == 'folder')
2504
+			  && (   !isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])
2505
+				  || !$p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))
2506
+		  ) {
2507
+
2508
+		// ----- Add the file
2509
+		$v_result = $this->privAddFile($p_filedescr_list[$j], $v_header,
2510
+									   $p_options);
2511
+		if ($v_result != 1) {
2512
+		  return $v_result;
2513
+		}
2514
+
2515
+		// ----- Store the file infos
2516
+		$p_result_list[$v_nb++] = $v_header;
2517
+	  }
2518
+	}
2519 2519
 
2520
-    // ----- Return
2521
-    return $v_result;
2520
+	// ----- Return
2521
+	return $v_result;
2522 2522
   }
2523 2523
   // --------------------------------------------------------------------------------
2524 2524
 
@@ -2530,22 +2530,22 @@  discard block
 block discarded – undo
2530 2530
   // --------------------------------------------------------------------------------
2531 2531
   function privAddFile($p_filedescr, &$p_header, &$p_options)
2532 2532
   {
2533
-    $v_result=1;
2533
+	$v_result=1;
2534 2534
     
2535
-    // ----- Working variable
2536
-    $p_filename = $p_filedescr['filename'];
2535
+	// ----- Working variable
2536
+	$p_filename = $p_filedescr['filename'];
2537 2537
 
2538
-    // TBC : Already done in the fileAtt check ... ?
2539
-    if ($p_filename == "") {
2540
-      // ----- Error log
2541
-      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)");
2538
+	// TBC : Already done in the fileAtt check ... ?
2539
+	if ($p_filename == "") {
2540
+	  // ----- Error log
2541
+	  PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)");
2542 2542
 
2543
-      // ----- Return
2544
-      return PclZip::errorCode();
2545
-    }
2543
+	  // ----- Return
2544
+	  return PclZip::errorCode();
2545
+	}
2546 2546
   
2547
-    // ----- Look for a stored different filename 
2548
-    /* TBC : Removed
2547
+	// ----- Look for a stored different filename 
2548
+	/* TBC : Removed
2549 2549
     if (isset($p_filedescr['stored_filename'])) {
2550 2550
       $v_stored_filename = $p_filedescr['stored_filename'];
2551 2551
     }
@@ -2554,244 +2554,244 @@  discard block
 block discarded – undo
2554 2554
     }
2555 2555
     */
2556 2556
 
2557
-    // ----- Set the file properties
2558
-    clearstatcache();
2559
-    $p_header['version'] = 20;
2560
-    $p_header['version_extracted'] = 10;
2561
-    $p_header['flag'] = 0;
2562
-    $p_header['compression'] = 0;
2563
-    $p_header['crc'] = 0;
2564
-    $p_header['compressed_size'] = 0;
2565
-    $p_header['filename_len'] = strlen($p_filename);
2566
-    $p_header['extra_len'] = 0;
2567
-    $p_header['disk'] = 0;
2568
-    $p_header['internal'] = 0;
2569
-    $p_header['offset'] = 0;
2570
-    $p_header['filename'] = $p_filename;
2557
+	// ----- Set the file properties
2558
+	clearstatcache();
2559
+	$p_header['version'] = 20;
2560
+	$p_header['version_extracted'] = 10;
2561
+	$p_header['flag'] = 0;
2562
+	$p_header['compression'] = 0;
2563
+	$p_header['crc'] = 0;
2564
+	$p_header['compressed_size'] = 0;
2565
+	$p_header['filename_len'] = strlen($p_filename);
2566
+	$p_header['extra_len'] = 0;
2567
+	$p_header['disk'] = 0;
2568
+	$p_header['internal'] = 0;
2569
+	$p_header['offset'] = 0;
2570
+	$p_header['filename'] = $p_filename;
2571 2571
 // TBC : Removed    $p_header['stored_filename'] = $v_stored_filename;
2572
-    $p_header['stored_filename'] = $p_filedescr['stored_filename'];
2573
-    $p_header['extra'] = '';
2574
-    $p_header['status'] = 'ok';
2575
-    $p_header['index'] = -1;
2576
-
2577
-    // ----- Look for regular file
2578
-    if ($p_filedescr['type']=='file') {
2579
-      $p_header['external'] = 0x00000000;
2580
-      $p_header['size'] = filesize($p_filename);
2581
-    }
2572
+	$p_header['stored_filename'] = $p_filedescr['stored_filename'];
2573
+	$p_header['extra'] = '';
2574
+	$p_header['status'] = 'ok';
2575
+	$p_header['index'] = -1;
2576
+
2577
+	// ----- Look for regular file
2578
+	if ($p_filedescr['type']=='file') {
2579
+	  $p_header['external'] = 0x00000000;
2580
+	  $p_header['size'] = filesize($p_filename);
2581
+	}
2582 2582
     
2583
-    // ----- Look for regular folder
2584
-    else if ($p_filedescr['type']=='folder') {
2585
-      $p_header['external'] = 0x00000010;
2586
-      $p_header['mtime'] = filemtime($p_filename);
2587
-      $p_header['size'] = filesize($p_filename);
2588
-    }
2583
+	// ----- Look for regular folder
2584
+	else if ($p_filedescr['type']=='folder') {
2585
+	  $p_header['external'] = 0x00000010;
2586
+	  $p_header['mtime'] = filemtime($p_filename);
2587
+	  $p_header['size'] = filesize($p_filename);
2588
+	}
2589 2589
     
2590
-    // ----- Look for virtual file
2591
-    else if ($p_filedescr['type'] == 'virtual_file') {
2592
-      $p_header['external'] = 0x00000000;
2593
-      $p_header['size'] = strlen($p_filedescr['content']);
2594
-    }
2590
+	// ----- Look for virtual file
2591
+	else if ($p_filedescr['type'] == 'virtual_file') {
2592
+	  $p_header['external'] = 0x00000000;
2593
+	  $p_header['size'] = strlen($p_filedescr['content']);
2594
+	}
2595 2595
     
2596 2596
 
2597
-    // ----- Look for filetime
2598
-    if (isset($p_filedescr['mtime'])) {
2599
-      $p_header['mtime'] = $p_filedescr['mtime'];
2600
-    }
2601
-    else if ($p_filedescr['type'] == 'virtual_file') {
2602
-      $p_header['mtime'] = time();
2603
-    }
2604
-    else {
2605
-      $p_header['mtime'] = filemtime($p_filename);
2606
-    }
2597
+	// ----- Look for filetime
2598
+	if (isset($p_filedescr['mtime'])) {
2599
+	  $p_header['mtime'] = $p_filedescr['mtime'];
2600
+	}
2601
+	else if ($p_filedescr['type'] == 'virtual_file') {
2602
+	  $p_header['mtime'] = time();
2603
+	}
2604
+	else {
2605
+	  $p_header['mtime'] = filemtime($p_filename);
2606
+	}
2607 2607
 
2608
-    // ------ Look for file comment
2609
-    if (isset($p_filedescr['comment'])) {
2610
-      $p_header['comment_len'] = strlen($p_filedescr['comment']);
2611
-      $p_header['comment'] = $p_filedescr['comment'];
2612
-    }
2613
-    else {
2614
-      $p_header['comment_len'] = 0;
2615
-      $p_header['comment'] = '';
2616
-    }
2608
+	// ------ Look for file comment
2609
+	if (isset($p_filedescr['comment'])) {
2610
+	  $p_header['comment_len'] = strlen($p_filedescr['comment']);
2611
+	  $p_header['comment'] = $p_filedescr['comment'];
2612
+	}
2613
+	else {
2614
+	  $p_header['comment_len'] = 0;
2615
+	  $p_header['comment'] = '';
2616
+	}
2617 2617
 
2618
-    // ----- Look for pre-add callback
2619
-    if (isset($p_options[PCLZIP_CB_PRE_ADD])) {
2618
+	// ----- Look for pre-add callback
2619
+	if (isset($p_options[PCLZIP_CB_PRE_ADD])) {
2620 2620
 
2621
-      // ----- Generate a local information
2622
-      $v_local_header = array();
2623
-      $this->privConvertHeader2FileInfo($p_header, $v_local_header);
2621
+	  // ----- Generate a local information
2622
+	  $v_local_header = array();
2623
+	  $this->privConvertHeader2FileInfo($p_header, $v_local_header);
2624 2624
 
2625
-      // ----- Call the callback
2626
-      // Here I do not use call_user_func() because I need to send a reference to the
2627
-      // header.
2625
+	  // ----- Call the callback
2626
+	  // Here I do not use call_user_func() because I need to send a reference to the
2627
+	  // header.
2628 2628
 //      eval('$v_result = '.$p_options[PCLZIP_CB_PRE_ADD].'(PCLZIP_CB_PRE_ADD, $v_local_header);');
2629
-      $v_result = $p_options[PCLZIP_CB_PRE_ADD](PCLZIP_CB_PRE_ADD, $v_local_header);
2630
-      if ($v_result == 0) {
2631
-        // ----- Change the file status
2632
-        $p_header['status'] = "skipped";
2633
-        $v_result = 1;
2634
-      }
2629
+	  $v_result = $p_options[PCLZIP_CB_PRE_ADD](PCLZIP_CB_PRE_ADD, $v_local_header);
2630
+	  if ($v_result == 0) {
2631
+		// ----- Change the file status
2632
+		$p_header['status'] = "skipped";
2633
+		$v_result = 1;
2634
+	  }
2635 2635
 
2636
-      // ----- Update the informations
2637
-      // Only some fields can be modified
2638
-      if ($p_header['stored_filename'] != $v_local_header['stored_filename']) {
2639
-        $p_header['stored_filename'] = PclZipUtilPathReduction($v_local_header['stored_filename']);
2640
-      }
2641
-    }
2636
+	  // ----- Update the informations
2637
+	  // Only some fields can be modified
2638
+	  if ($p_header['stored_filename'] != $v_local_header['stored_filename']) {
2639
+		$p_header['stored_filename'] = PclZipUtilPathReduction($v_local_header['stored_filename']);
2640
+	  }
2641
+	}
2642 2642
 
2643
-    // ----- Look for empty stored filename
2644
-    if ($p_header['stored_filename'] == "") {
2645
-      $p_header['status'] = "filtered";
2646
-    }
2643
+	// ----- Look for empty stored filename
2644
+	if ($p_header['stored_filename'] == "") {
2645
+	  $p_header['status'] = "filtered";
2646
+	}
2647 2647
     
2648
-    // ----- Check the path length
2649
-    if (strlen($p_header['stored_filename']) > 0xFF) {
2650
-      $p_header['status'] = 'filename_too_long';
2651
-    }
2648
+	// ----- Check the path length
2649
+	if (strlen($p_header['stored_filename']) > 0xFF) {
2650
+	  $p_header['status'] = 'filename_too_long';
2651
+	}
2652 2652
 
2653
-    // ----- Look if no error, or file not skipped
2654
-    if ($p_header['status'] == 'ok') {
2655
-
2656
-      // ----- Look for a file
2657
-      if ($p_filedescr['type'] == 'file') {
2658
-        // ----- Look for using temporary file to zip
2659
-        if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) 
2660
-            && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON])
2661
-                || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
2662
-                    && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_header['size'])) ) ) {
2663
-          $v_result = $this->privAddFileUsingTempFile($p_filedescr, $p_header, $p_options);
2664
-          if ($v_result < PCLZIP_ERR_NO_ERROR) {
2665
-            return $v_result;
2666
-          }
2667
-        }
2653
+	// ----- Look if no error, or file not skipped
2654
+	if ($p_header['status'] == 'ok') {
2655
+
2656
+	  // ----- Look for a file
2657
+	  if ($p_filedescr['type'] == 'file') {
2658
+		// ----- Look for using temporary file to zip
2659
+		if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) 
2660
+			&& (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON])
2661
+				|| (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
2662
+					&& ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_header['size'])) ) ) {
2663
+		  $v_result = $this->privAddFileUsingTempFile($p_filedescr, $p_header, $p_options);
2664
+		  if ($v_result < PCLZIP_ERR_NO_ERROR) {
2665
+			return $v_result;
2666
+		  }
2667
+		}
2668 2668
         
2669
-        // ----- Use "in memory" zip algo
2670
-        else {
2669
+		// ----- Use "in memory" zip algo
2670
+		else {
2671 2671
 
2672
-        // ----- Open the source file
2673
-        if (($v_file = @fopen($p_filename, "rb")) == 0) {
2674
-          PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
2675
-          return PclZip::errorCode();
2676
-        }
2672
+		// ----- Open the source file
2673
+		if (($v_file = @fopen($p_filename, "rb")) == 0) {
2674
+		  PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
2675
+		  return PclZip::errorCode();
2676
+		}
2677 2677
 
2678
-        // ----- Read the file content
2679
-        $v_content = @fread($v_file, $p_header['size']);
2678
+		// ----- Read the file content
2679
+		$v_content = @fread($v_file, $p_header['size']);
2680 2680
 
2681
-        // ----- Close the file
2682
-        @fclose($v_file);
2681
+		// ----- Close the file
2682
+		@fclose($v_file);
2683 2683
 
2684
-        // ----- Calculate the CRC
2685
-        $p_header['crc'] = @crc32($v_content);
2684
+		// ----- Calculate the CRC
2685
+		$p_header['crc'] = @crc32($v_content);
2686 2686
         
2687
-        // ----- Look for no compression
2688
-        if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
2689
-          // ----- Set header parameters
2690
-          $p_header['compressed_size'] = $p_header['size'];
2691
-          $p_header['compression'] = 0;
2692
-        }
2687
+		// ----- Look for no compression
2688
+		if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
2689
+		  // ----- Set header parameters
2690
+		  $p_header['compressed_size'] = $p_header['size'];
2691
+		  $p_header['compression'] = 0;
2692
+		}
2693 2693
         
2694
-        // ----- Look for normal compression
2695
-        else {
2696
-          // ----- Compress the content
2697
-          $v_content = @gzdeflate($v_content);
2698
-
2699
-          // ----- Set header parameters
2700
-          $p_header['compressed_size'] = strlen($v_content);
2701
-          $p_header['compression'] = 8;
2702
-        }
2694
+		// ----- Look for normal compression
2695
+		else {
2696
+		  // ----- Compress the content
2697
+		  $v_content = @gzdeflate($v_content);
2698
+
2699
+		  // ----- Set header parameters
2700
+		  $p_header['compressed_size'] = strlen($v_content);
2701
+		  $p_header['compression'] = 8;
2702
+		}
2703 2703
         
2704
-        // ----- Call the header generation
2705
-        if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
2706
-          @fclose($v_file);
2707
-          return $v_result;
2708
-        }
2704
+		// ----- Call the header generation
2705
+		if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
2706
+		  @fclose($v_file);
2707
+		  return $v_result;
2708
+		}
2709 2709
 
2710
-        // ----- Write the compressed (or not) content
2711
-        @fwrite($this->zip_fd, $v_content, $p_header['compressed_size']);
2710
+		// ----- Write the compressed (or not) content
2711
+		@fwrite($this->zip_fd, $v_content, $p_header['compressed_size']);
2712 2712
 
2713
-        }
2713
+		}
2714 2714
 
2715
-      }
2715
+	  }
2716 2716
 
2717
-      // ----- Look for a virtual file (a file from string)
2718
-      else if ($p_filedescr['type'] == 'virtual_file') {
2717
+	  // ----- Look for a virtual file (a file from string)
2718
+	  else if ($p_filedescr['type'] == 'virtual_file') {
2719 2719
           
2720
-        $v_content = $p_filedescr['content'];
2720
+		$v_content = $p_filedescr['content'];
2721 2721
 
2722
-        // ----- Calculate the CRC
2723
-        $p_header['crc'] = @crc32($v_content);
2722
+		// ----- Calculate the CRC
2723
+		$p_header['crc'] = @crc32($v_content);
2724 2724
         
2725
-        // ----- Look for no compression
2726
-        if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
2727
-          // ----- Set header parameters
2728
-          $p_header['compressed_size'] = $p_header['size'];
2729
-          $p_header['compression'] = 0;
2730
-        }
2725
+		// ----- Look for no compression
2726
+		if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
2727
+		  // ----- Set header parameters
2728
+		  $p_header['compressed_size'] = $p_header['size'];
2729
+		  $p_header['compression'] = 0;
2730
+		}
2731 2731
         
2732
-        // ----- Look for normal compression
2733
-        else {
2734
-          // ----- Compress the content
2735
-          $v_content = @gzdeflate($v_content);
2736
-
2737
-          // ----- Set header parameters
2738
-          $p_header['compressed_size'] = strlen($v_content);
2739
-          $p_header['compression'] = 8;
2740
-        }
2732
+		// ----- Look for normal compression
2733
+		else {
2734
+		  // ----- Compress the content
2735
+		  $v_content = @gzdeflate($v_content);
2736
+
2737
+		  // ----- Set header parameters
2738
+		  $p_header['compressed_size'] = strlen($v_content);
2739
+		  $p_header['compression'] = 8;
2740
+		}
2741 2741
         
2742
-        // ----- Call the header generation
2743
-        if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
2744
-          @fclose($v_file);
2745
-          return $v_result;
2746
-        }
2747
-
2748
-        // ----- Write the compressed (or not) content
2749
-        @fwrite($this->zip_fd, $v_content, $p_header['compressed_size']);
2750
-      }
2742
+		// ----- Call the header generation
2743
+		if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
2744
+		  @fclose($v_file);
2745
+		  return $v_result;
2746
+		}
2747
+
2748
+		// ----- Write the compressed (or not) content
2749
+		@fwrite($this->zip_fd, $v_content, $p_header['compressed_size']);
2750
+	  }
2751 2751
 
2752
-      // ----- Look for a directory
2753
-      else if ($p_filedescr['type'] == 'folder') {
2754
-        // ----- Look for directory last '/'
2755
-        if (@substr($p_header['stored_filename'], -1) != '/') {
2756
-          $p_header['stored_filename'] .= '/';
2757
-        }
2758
-
2759
-        // ----- Set the file properties
2760
-        $p_header['size'] = 0;
2761
-        //$p_header['external'] = 0x41FF0010;   // Value for a folder : to be checked
2762
-        $p_header['external'] = 0x00000010;   // Value for a folder : to be checked
2763
-
2764
-        // ----- Call the header generation
2765
-        if (($v_result = $this->privWriteFileHeader($p_header)) != 1)
2766
-        {
2767
-          return $v_result;
2768
-        }
2769
-      }
2770
-    }
2752
+	  // ----- Look for a directory
2753
+	  else if ($p_filedescr['type'] == 'folder') {
2754
+		// ----- Look for directory last '/'
2755
+		if (@substr($p_header['stored_filename'], -1) != '/') {
2756
+		  $p_header['stored_filename'] .= '/';
2757
+		}
2758
+
2759
+		// ----- Set the file properties
2760
+		$p_header['size'] = 0;
2761
+		//$p_header['external'] = 0x41FF0010;   // Value for a folder : to be checked
2762
+		$p_header['external'] = 0x00000010;   // Value for a folder : to be checked
2763
+
2764
+		// ----- Call the header generation
2765
+		if (($v_result = $this->privWriteFileHeader($p_header)) != 1)
2766
+		{
2767
+		  return $v_result;
2768
+		}
2769
+	  }
2770
+	}
2771 2771
 
2772
-    // ----- Look for post-add callback
2773
-    if (isset($p_options[PCLZIP_CB_POST_ADD])) {
2772
+	// ----- Look for post-add callback
2773
+	if (isset($p_options[PCLZIP_CB_POST_ADD])) {
2774 2774
 
2775
-      // ----- Generate a local information
2776
-      $v_local_header = array();
2777
-      $this->privConvertHeader2FileInfo($p_header, $v_local_header);
2775
+	  // ----- Generate a local information
2776
+	  $v_local_header = array();
2777
+	  $this->privConvertHeader2FileInfo($p_header, $v_local_header);
2778 2778
 
2779
-      // ----- Call the callback
2780
-      // Here I do not use call_user_func() because I need to send a reference to the
2781
-      // header.
2779
+	  // ----- Call the callback
2780
+	  // Here I do not use call_user_func() because I need to send a reference to the
2781
+	  // header.
2782 2782
 //      eval('$v_result = '.$p_options[PCLZIP_CB_POST_ADD].'(PCLZIP_CB_POST_ADD, $v_local_header);');
2783
-      $v_result = $p_options[PCLZIP_CB_POST_ADD](PCLZIP_CB_POST_ADD, $v_local_header);
2784
-      if ($v_result == 0) {
2785
-        // ----- Ignored
2786
-        $v_result = 1;
2787
-      }
2783
+	  $v_result = $p_options[PCLZIP_CB_POST_ADD](PCLZIP_CB_POST_ADD, $v_local_header);
2784
+	  if ($v_result == 0) {
2785
+		// ----- Ignored
2786
+		$v_result = 1;
2787
+	  }
2788 2788
 
2789
-      // ----- Update the informations
2790
-      // Nothing can be modified
2791
-    }
2789
+	  // ----- Update the informations
2790
+	  // Nothing can be modified
2791
+	}
2792 2792
 
2793
-    // ----- Return
2794
-    return $v_result;
2793
+	// ----- Return
2794
+	return $v_result;
2795 2795
   }
2796 2796
   // --------------------------------------------------------------------------------
2797 2797
 
@@ -2803,105 +2803,105 @@  discard block
 block discarded – undo
2803 2803
   // --------------------------------------------------------------------------------
2804 2804
   function privAddFileUsingTempFile($p_filedescr, &$p_header, &$p_options)
2805 2805
   {
2806
-    $v_result=PCLZIP_ERR_NO_ERROR;
2806
+	$v_result=PCLZIP_ERR_NO_ERROR;
2807 2807
     
2808
-    // ----- Working variable
2809
-    $p_filename = $p_filedescr['filename'];
2808
+	// ----- Working variable
2809
+	$p_filename = $p_filedescr['filename'];
2810 2810
 
2811 2811
 
2812
-    // ----- Open the source file
2813
-    if (($v_file = @fopen($p_filename, "rb")) == 0) {
2814
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
2815
-      return PclZip::errorCode();
2816
-    }
2812
+	// ----- Open the source file
2813
+	if (($v_file = @fopen($p_filename, "rb")) == 0) {
2814
+	  PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
2815
+	  return PclZip::errorCode();
2816
+	}
2817 2817
 
2818
-    // ----- Creates a compressed temporary file
2819
-    $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
2820
-    if (($v_file_compressed = @gzopen($v_gzip_temp_name, "wb")) == 0) {
2821
-      fclose($v_file);
2822
-      PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
2823
-      return PclZip::errorCode();
2824
-    }
2818
+	// ----- Creates a compressed temporary file
2819
+	$v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
2820
+	if (($v_file_compressed = @gzopen($v_gzip_temp_name, "wb")) == 0) {
2821
+	  fclose($v_file);
2822
+	  PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
2823
+	  return PclZip::errorCode();
2824
+	}
2825 2825
 
2826
-    // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
2827
-    $v_size = filesize($p_filename);
2828
-    while ($v_size != 0) {
2829
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2830
-      $v_buffer = @fread($v_file, $v_read_size);
2831
-      //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
2832
-      @gzputs($v_file_compressed, $v_buffer, $v_read_size);
2833
-      $v_size -= $v_read_size;
2834
-    }
2826
+	// ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
2827
+	$v_size = filesize($p_filename);
2828
+	while ($v_size != 0) {
2829
+	  $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2830
+	  $v_buffer = @fread($v_file, $v_read_size);
2831
+	  //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
2832
+	  @gzputs($v_file_compressed, $v_buffer, $v_read_size);
2833
+	  $v_size -= $v_read_size;
2834
+	}
2835 2835
 
2836
-    // ----- Close the file
2837
-    @fclose($v_file);
2838
-    @gzclose($v_file_compressed);
2836
+	// ----- Close the file
2837
+	@fclose($v_file);
2838
+	@gzclose($v_file_compressed);
2839 2839
 
2840
-    // ----- Check the minimum file size
2841
-    if (filesize($v_gzip_temp_name) < 18) {
2842
-      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'gzip temporary file \''.$v_gzip_temp_name.'\' has invalid filesize - should be minimum 18 bytes');
2843
-      return PclZip::errorCode();
2844
-    }
2840
+	// ----- Check the minimum file size
2841
+	if (filesize($v_gzip_temp_name) < 18) {
2842
+	  PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'gzip temporary file \''.$v_gzip_temp_name.'\' has invalid filesize - should be minimum 18 bytes');
2843
+	  return PclZip::errorCode();
2844
+	}
2845 2845
 
2846
-    // ----- Extract the compressed attributes
2847
-    if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0) {
2848
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
2849
-      return PclZip::errorCode();
2850
-    }
2846
+	// ----- Extract the compressed attributes
2847
+	if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0) {
2848
+	  PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
2849
+	  return PclZip::errorCode();
2850
+	}
2851 2851
 
2852
-    // ----- Read the gzip file header
2853
-    $v_binary_data = @fread($v_file_compressed, 10);
2854
-    $v_data_header = unpack('a1id1/a1id2/a1cm/a1flag/Vmtime/a1xfl/a1os', $v_binary_data);
2852
+	// ----- Read the gzip file header
2853
+	$v_binary_data = @fread($v_file_compressed, 10);
2854
+	$v_data_header = unpack('a1id1/a1id2/a1cm/a1flag/Vmtime/a1xfl/a1os', $v_binary_data);
2855 2855
 
2856
-    // ----- Check some parameters
2857
-    $v_data_header['os'] = bin2hex($v_data_header['os']);
2856
+	// ----- Check some parameters
2857
+	$v_data_header['os'] = bin2hex($v_data_header['os']);
2858 2858
 
2859
-    // ----- Read the gzip file footer
2860
-    @fseek($v_file_compressed, filesize($v_gzip_temp_name)-8);
2861
-    $v_binary_data = @fread($v_file_compressed, 8);
2862
-    $v_data_footer = unpack('Vcrc/Vcompressed_size', $v_binary_data);
2859
+	// ----- Read the gzip file footer
2860
+	@fseek($v_file_compressed, filesize($v_gzip_temp_name)-8);
2861
+	$v_binary_data = @fread($v_file_compressed, 8);
2862
+	$v_data_footer = unpack('Vcrc/Vcompressed_size', $v_binary_data);
2863 2863
 
2864
-    // ----- Set the attributes
2865
-    $p_header['compression'] = ord($v_data_header['cm']);
2866
-    //$p_header['mtime'] = $v_data_header['mtime'];
2867
-    $p_header['crc'] = $v_data_footer['crc'];
2868
-    $p_header['compressed_size'] = filesize($v_gzip_temp_name)-18;
2864
+	// ----- Set the attributes
2865
+	$p_header['compression'] = ord($v_data_header['cm']);
2866
+	//$p_header['mtime'] = $v_data_header['mtime'];
2867
+	$p_header['crc'] = $v_data_footer['crc'];
2868
+	$p_header['compressed_size'] = filesize($v_gzip_temp_name)-18;
2869 2869
 
2870
-    // ----- Close the file
2871
-    @fclose($v_file_compressed);
2870
+	// ----- Close the file
2871
+	@fclose($v_file_compressed);
2872 2872
 
2873
-    // ----- Call the header generation
2874
-    if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
2875
-      return $v_result;
2876
-    }
2873
+	// ----- Call the header generation
2874
+	if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
2875
+	  return $v_result;
2876
+	}
2877 2877
 
2878
-    // ----- Add the compressed data
2879
-    if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0)
2880
-    {
2881
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
2882
-      return PclZip::errorCode();
2883
-    }
2878
+	// ----- Add the compressed data
2879
+	if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0)
2880
+	{
2881
+	  PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
2882
+	  return PclZip::errorCode();
2883
+	}
2884 2884
 
2885
-    // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
2886
-    fseek($v_file_compressed, 10);
2887
-    $v_size = $p_header['compressed_size'];
2888
-    while ($v_size != 0)
2889
-    {
2890
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2891
-      $v_buffer = @fread($v_file_compressed, $v_read_size);
2892
-      //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
2893
-      @fwrite($this->zip_fd, $v_buffer, $v_read_size);
2894
-      $v_size -= $v_read_size;
2895
-    }
2885
+	// ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
2886
+	fseek($v_file_compressed, 10);
2887
+	$v_size = $p_header['compressed_size'];
2888
+	while ($v_size != 0)
2889
+	{
2890
+	  $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2891
+	  $v_buffer = @fread($v_file_compressed, $v_read_size);
2892
+	  //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
2893
+	  @fwrite($this->zip_fd, $v_buffer, $v_read_size);
2894
+	  $v_size -= $v_read_size;
2895
+	}
2896 2896
 
2897
-    // ----- Close the file
2898
-    @fclose($v_file_compressed);
2897
+	// ----- Close the file
2898
+	@fclose($v_file_compressed);
2899 2899
 
2900
-    // ----- Unlink the temporary file
2901
-    @unlink($v_gzip_temp_name);
2900
+	// ----- Unlink the temporary file
2901
+	@unlink($v_gzip_temp_name);
2902 2902
     
2903
-    // ----- Return
2904
-    return $v_result;
2903
+	// ----- Return
2904
+	return $v_result;
2905 2905
   }
2906 2906
   // --------------------------------------------------------------------------------
2907 2907
 
@@ -2915,107 +2915,107 @@  discard block
 block discarded – undo
2915 2915
   // --------------------------------------------------------------------------------
2916 2916
   function privCalculateStoredFilename(&$p_filedescr, &$p_options)
2917 2917
   {
2918
-    $v_result=1;
2918
+	$v_result=1;
2919 2919
     
2920
-    // ----- Working variables
2921
-    $p_filename = $p_filedescr['filename'];
2922
-    if (isset($p_options[PCLZIP_OPT_ADD_PATH])) {
2923
-      $p_add_dir = $p_options[PCLZIP_OPT_ADD_PATH];
2924
-    }
2925
-    else {
2926
-      $p_add_dir = '';
2927
-    }
2928
-    if (isset($p_options[PCLZIP_OPT_REMOVE_PATH])) {
2929
-      $p_remove_dir = $p_options[PCLZIP_OPT_REMOVE_PATH];
2930
-    }
2931
-    else {
2932
-      $p_remove_dir = '';
2933
-    }
2934
-    if (isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
2935
-      $p_remove_all_dir = $p_options[PCLZIP_OPT_REMOVE_ALL_PATH];
2936
-    }
2937
-    else {
2938
-      $p_remove_all_dir = 0;
2939
-    }
2920
+	// ----- Working variables
2921
+	$p_filename = $p_filedescr['filename'];
2922
+	if (isset($p_options[PCLZIP_OPT_ADD_PATH])) {
2923
+	  $p_add_dir = $p_options[PCLZIP_OPT_ADD_PATH];
2924
+	}
2925
+	else {
2926
+	  $p_add_dir = '';
2927
+	}
2928
+	if (isset($p_options[PCLZIP_OPT_REMOVE_PATH])) {
2929
+	  $p_remove_dir = $p_options[PCLZIP_OPT_REMOVE_PATH];
2930
+	}
2931
+	else {
2932
+	  $p_remove_dir = '';
2933
+	}
2934
+	if (isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
2935
+	  $p_remove_all_dir = $p_options[PCLZIP_OPT_REMOVE_ALL_PATH];
2936
+	}
2937
+	else {
2938
+	  $p_remove_all_dir = 0;
2939
+	}
2940 2940
 
2941 2941
 
2942
-    // ----- Look for full name change
2943
-    if (isset($p_filedescr['new_full_name'])) {
2944
-      // ----- Remove drive letter if any
2945
-      $v_stored_filename = PclZipUtilTranslateWinPath($p_filedescr['new_full_name']);
2946
-    }
2942
+	// ----- Look for full name change
2943
+	if (isset($p_filedescr['new_full_name'])) {
2944
+	  // ----- Remove drive letter if any
2945
+	  $v_stored_filename = PclZipUtilTranslateWinPath($p_filedescr['new_full_name']);
2946
+	}
2947 2947
     
2948
-    // ----- Look for path and/or short name change
2949
-    else {
2950
-
2951
-      // ----- Look for short name change
2952
-      // Its when we cahnge just the filename but not the path
2953
-      if (isset($p_filedescr['new_short_name'])) {
2954
-        $v_path_info = pathinfo($p_filename);
2955
-        $v_dir = '';
2956
-        if ($v_path_info['dirname'] != '') {
2957
-          $v_dir = $v_path_info['dirname'].'/';
2958
-        }
2959
-        $v_stored_filename = $v_dir.$p_filedescr['new_short_name'];
2960
-      }
2961
-      else {
2962
-        // ----- Calculate the stored filename
2963
-        $v_stored_filename = $p_filename;
2964
-      }
2948
+	// ----- Look for path and/or short name change
2949
+	else {
2950
+
2951
+	  // ----- Look for short name change
2952
+	  // Its when we cahnge just the filename but not the path
2953
+	  if (isset($p_filedescr['new_short_name'])) {
2954
+		$v_path_info = pathinfo($p_filename);
2955
+		$v_dir = '';
2956
+		if ($v_path_info['dirname'] != '') {
2957
+		  $v_dir = $v_path_info['dirname'].'/';
2958
+		}
2959
+		$v_stored_filename = $v_dir.$p_filedescr['new_short_name'];
2960
+	  }
2961
+	  else {
2962
+		// ----- Calculate the stored filename
2963
+		$v_stored_filename = $p_filename;
2964
+	  }
2965 2965
 
2966
-      // ----- Look for all path to remove
2967
-      if ($p_remove_all_dir) {
2968
-        $v_stored_filename = basename($p_filename);
2969
-      }
2970
-      // ----- Look for partial path remove
2971
-      else if ($p_remove_dir != "") {
2972
-        if (substr($p_remove_dir, -1) != '/')
2973
-          $p_remove_dir .= "/";
2966
+	  // ----- Look for all path to remove
2967
+	  if ($p_remove_all_dir) {
2968
+		$v_stored_filename = basename($p_filename);
2969
+	  }
2970
+	  // ----- Look for partial path remove
2971
+	  else if ($p_remove_dir != "") {
2972
+		if (substr($p_remove_dir, -1) != '/')
2973
+		  $p_remove_dir .= "/";
2974 2974
 
2975
-        if (   (substr($p_filename, 0, 2) == "./")
2976
-            || (substr($p_remove_dir, 0, 2) == "./")) {
2975
+		if (   (substr($p_filename, 0, 2) == "./")
2976
+			|| (substr($p_remove_dir, 0, 2) == "./")) {
2977 2977
             
2978
-          if (   (substr($p_filename, 0, 2) == "./")
2979
-              && (substr($p_remove_dir, 0, 2) != "./")) {
2980
-            $p_remove_dir = "./".$p_remove_dir;
2981
-          }
2982
-          if (   (substr($p_filename, 0, 2) != "./")
2983
-              && (substr($p_remove_dir, 0, 2) == "./")) {
2984
-            $p_remove_dir = substr($p_remove_dir, 2);
2985
-          }
2986
-        }
2978
+		  if (   (substr($p_filename, 0, 2) == "./")
2979
+			  && (substr($p_remove_dir, 0, 2) != "./")) {
2980
+			$p_remove_dir = "./".$p_remove_dir;
2981
+		  }
2982
+		  if (   (substr($p_filename, 0, 2) != "./")
2983
+			  && (substr($p_remove_dir, 0, 2) == "./")) {
2984
+			$p_remove_dir = substr($p_remove_dir, 2);
2985
+		  }
2986
+		}
2987 2987
 
2988
-        $v_compare = PclZipUtilPathInclusion($p_remove_dir,
2989
-                                             $v_stored_filename);
2990
-        if ($v_compare > 0) {
2991
-          if ($v_compare == 2) {
2992
-            $v_stored_filename = "";
2993
-          }
2994
-          else {
2995
-            $v_stored_filename = substr($v_stored_filename,
2996
-                                        strlen($p_remove_dir));
2997
-          }
2998
-        }
2999
-      }
2988
+		$v_compare = PclZipUtilPathInclusion($p_remove_dir,
2989
+											 $v_stored_filename);
2990
+		if ($v_compare > 0) {
2991
+		  if ($v_compare == 2) {
2992
+			$v_stored_filename = "";
2993
+		  }
2994
+		  else {
2995
+			$v_stored_filename = substr($v_stored_filename,
2996
+										strlen($p_remove_dir));
2997
+		  }
2998
+		}
2999
+	  }
3000 3000
       
3001
-      // ----- Remove drive letter if any
3002
-      $v_stored_filename = PclZipUtilTranslateWinPath($v_stored_filename);
3001
+	  // ----- Remove drive letter if any
3002
+	  $v_stored_filename = PclZipUtilTranslateWinPath($v_stored_filename);
3003 3003
       
3004
-      // ----- Look for path to add
3005
-      if ($p_add_dir != "") {
3006
-        if (substr($p_add_dir, -1) == "/")
3007
-          $v_stored_filename = $p_add_dir.$v_stored_filename;
3008
-        else
3009
-          $v_stored_filename = $p_add_dir."/".$v_stored_filename;
3010
-      }
3011
-    }
3004
+	  // ----- Look for path to add
3005
+	  if ($p_add_dir != "") {
3006
+		if (substr($p_add_dir, -1) == "/")
3007
+		  $v_stored_filename = $p_add_dir.$v_stored_filename;
3008
+		else
3009
+		  $v_stored_filename = $p_add_dir."/".$v_stored_filename;
3010
+	  }
3011
+	}
3012 3012
 
3013
-    // ----- Filename (reduce the path of stored name)
3014
-    $v_stored_filename = PclZipUtilPathReduction($v_stored_filename);
3015
-    $p_filedescr['stored_filename'] = $v_stored_filename;
3013
+	// ----- Filename (reduce the path of stored name)
3014
+	$v_stored_filename = PclZipUtilPathReduction($v_stored_filename);
3015
+	$p_filedescr['stored_filename'] = $v_stored_filename;
3016 3016
     
3017
-    // ----- Return
3018
-    return $v_result;
3017
+	// ----- Return
3018
+	return $v_result;
3019 3019
   }
3020 3020
   // --------------------------------------------------------------------------------
3021 3021
 
@@ -3027,40 +3027,40 @@  discard block
 block discarded – undo
3027 3027
   // --------------------------------------------------------------------------------
3028 3028
   function privWriteFileHeader(&$p_header)
3029 3029
   {
3030
-    $v_result=1;
3030
+	$v_result=1;
3031 3031
 
3032
-    // ----- Store the offset position of the file
3033
-    $p_header['offset'] = ftell($this->zip_fd);
3032
+	// ----- Store the offset position of the file
3033
+	$p_header['offset'] = ftell($this->zip_fd);
3034 3034
 
3035
-    // ----- Transform UNIX mtime to DOS format mdate/mtime
3036
-    $v_date = getdate($p_header['mtime']);
3037
-    $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
3038
-    $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
3035
+	// ----- Transform UNIX mtime to DOS format mdate/mtime
3036
+	$v_date = getdate($p_header['mtime']);
3037
+	$v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
3038
+	$v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
3039 3039
 
3040
-    // ----- Packed data
3041
-    $v_binary_data = pack("VvvvvvVVVvv", 0x04034b50,
3042
-	                      $p_header['version_extracted'], $p_header['flag'],
3043
-                          $p_header['compression'], $v_mtime, $v_mdate,
3044
-                          $p_header['crc'], $p_header['compressed_size'],
3040
+	// ----- Packed data
3041
+	$v_binary_data = pack("VvvvvvVVVvv", 0x04034b50,
3042
+						  $p_header['version_extracted'], $p_header['flag'],
3043
+						  $p_header['compression'], $v_mtime, $v_mdate,
3044
+						  $p_header['crc'], $p_header['compressed_size'],
3045 3045
 						  $p_header['size'],
3046
-                          strlen($p_header['stored_filename']),
3046
+						  strlen($p_header['stored_filename']),
3047 3047
 						  $p_header['extra_len']);
3048 3048
 
3049
-    // ----- Write the first 148 bytes of the header in the archive
3050
-    fputs($this->zip_fd, $v_binary_data, 30);
3049
+	// ----- Write the first 148 bytes of the header in the archive
3050
+	fputs($this->zip_fd, $v_binary_data, 30);
3051 3051
 
3052
-    // ----- Write the variable fields
3053
-    if (strlen($p_header['stored_filename']) != 0)
3054
-    {
3055
-      fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
3056
-    }
3057
-    if ($p_header['extra_len'] != 0)
3058
-    {
3059
-      fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
3060
-    }
3052
+	// ----- Write the variable fields
3053
+	if (strlen($p_header['stored_filename']) != 0)
3054
+	{
3055
+	  fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
3056
+	}
3057
+	if ($p_header['extra_len'] != 0)
3058
+	{
3059
+	  fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
3060
+	}
3061 3061
 
3062
-    // ----- Return
3063
-    return $v_result;
3062
+	// ----- Return
3063
+	return $v_result;
3064 3064
   }
3065 3065
   // --------------------------------------------------------------------------------
3066 3066
 
@@ -3072,48 +3072,48 @@  discard block
 block discarded – undo
3072 3072
   // --------------------------------------------------------------------------------
3073 3073
   function privWriteCentralFileHeader(&$p_header)
3074 3074
   {
3075
-    $v_result=1;
3075
+	$v_result=1;
3076 3076
 
3077
-    // TBC
3078
-    //for(reset($p_header); $key = key($p_header); next($p_header)) {
3079
-    //}
3077
+	// TBC
3078
+	//for(reset($p_header); $key = key($p_header); next($p_header)) {
3079
+	//}
3080 3080
 
3081
-    // ----- Transform UNIX mtime to DOS format mdate/mtime
3082
-    $v_date = getdate($p_header['mtime']);
3083
-    $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
3084
-    $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
3081
+	// ----- Transform UNIX mtime to DOS format mdate/mtime
3082
+	$v_date = getdate($p_header['mtime']);
3083
+	$v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
3084
+	$v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
3085 3085
 
3086 3086
 
3087
-    // ----- Packed data
3088
-    $v_binary_data = pack("VvvvvvvVVVvvvvvVV", 0x02014b50,
3089
-	                      $p_header['version'], $p_header['version_extracted'],
3090
-                          $p_header['flag'], $p_header['compression'],
3087
+	// ----- Packed data
3088
+	$v_binary_data = pack("VvvvvvvVVVvvvvvVV", 0x02014b50,
3089
+						  $p_header['version'], $p_header['version_extracted'],
3090
+						  $p_header['flag'], $p_header['compression'],
3091 3091
 						  $v_mtime, $v_mdate, $p_header['crc'],
3092
-                          $p_header['compressed_size'], $p_header['size'],
3093
-                          strlen($p_header['stored_filename']),
3092
+						  $p_header['compressed_size'], $p_header['size'],
3093
+						  strlen($p_header['stored_filename']),
3094 3094
 						  $p_header['extra_len'], $p_header['comment_len'],
3095
-                          $p_header['disk'], $p_header['internal'],
3095
+						  $p_header['disk'], $p_header['internal'],
3096 3096
 						  $p_header['external'], $p_header['offset']);
3097 3097
 
3098
-    // ----- Write the 42 bytes of the header in the zip file
3099
-    fputs($this->zip_fd, $v_binary_data, 46);
3098
+	// ----- Write the 42 bytes of the header in the zip file
3099
+	fputs($this->zip_fd, $v_binary_data, 46);
3100 3100
 
3101
-    // ----- Write the variable fields
3102
-    if (strlen($p_header['stored_filename']) != 0)
3103
-    {
3104
-      fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
3105
-    }
3106
-    if ($p_header['extra_len'] != 0)
3107
-    {
3108
-      fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
3109
-    }
3110
-    if ($p_header['comment_len'] != 0)
3111
-    {
3112
-      fputs($this->zip_fd, $p_header['comment'], $p_header['comment_len']);
3113
-    }
3101
+	// ----- Write the variable fields
3102
+	if (strlen($p_header['stored_filename']) != 0)
3103
+	{
3104
+	  fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
3105
+	}
3106
+	if ($p_header['extra_len'] != 0)
3107
+	{
3108
+	  fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
3109
+	}
3110
+	if ($p_header['comment_len'] != 0)
3111
+	{
3112
+	  fputs($this->zip_fd, $p_header['comment'], $p_header['comment_len']);
3113
+	}
3114 3114
 
3115
-    // ----- Return
3116
-    return $v_result;
3115
+	// ----- Return
3116
+	return $v_result;
3117 3117
   }
3118 3118
   // --------------------------------------------------------------------------------
3119 3119
 
@@ -3125,24 +3125,24 @@  discard block
 block discarded – undo
3125 3125
   // --------------------------------------------------------------------------------
3126 3126
   function privWriteCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment)
3127 3127
   {
3128
-    $v_result=1;
3128
+	$v_result=1;
3129 3129
 
3130
-    // ----- Packed data
3131
-    $v_binary_data = pack("VvvvvVVv", 0x06054b50, 0, 0, $p_nb_entries,
3132
-	                      $p_nb_entries, $p_size,
3130
+	// ----- Packed data
3131
+	$v_binary_data = pack("VvvvvVVv", 0x06054b50, 0, 0, $p_nb_entries,
3132
+						  $p_nb_entries, $p_size,
3133 3133
 						  $p_offset, strlen($p_comment));
3134 3134
 
3135
-    // ----- Write the 22 bytes of the header in the zip file
3136
-    fputs($this->zip_fd, $v_binary_data, 22);
3135
+	// ----- Write the 22 bytes of the header in the zip file
3136
+	fputs($this->zip_fd, $v_binary_data, 22);
3137 3137
 
3138
-    // ----- Write the variable fields
3139
-    if (strlen($p_comment) != 0)
3140
-    {
3141
-      fputs($this->zip_fd, $p_comment, strlen($p_comment));
3142
-    }
3138
+	// ----- Write the variable fields
3139
+	if (strlen($p_comment) != 0)
3140
+	{
3141
+	  fputs($this->zip_fd, $p_comment, strlen($p_comment));
3142
+	}
3143 3143
 
3144
-    // ----- Return
3145
-    return $v_result;
3144
+	// ----- Return
3145
+	return $v_result;
3146 3146
   }
3147 3147
   // --------------------------------------------------------------------------------
3148 3148
 
@@ -3154,69 +3154,69 @@  discard block
 block discarded – undo
3154 3154
   // --------------------------------------------------------------------------------
3155 3155
   function privList(&$p_list)
3156 3156
   {
3157
-    $v_result=1;
3157
+	$v_result=1;
3158 3158
 
3159
-    // ----- Magic quotes trick
3160
-    $this->privDisableMagicQuotes();
3159
+	// ----- Magic quotes trick
3160
+	$this->privDisableMagicQuotes();
3161 3161
 
3162
-    // ----- Open the zip file
3163
-    if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)
3164
-    {
3165
-      // ----- Magic quotes trick
3166
-      $this->privSwapBackMagicQuotes();
3162
+	// ----- Open the zip file
3163
+	if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)
3164
+	{
3165
+	  // ----- Magic quotes trick
3166
+	  $this->privSwapBackMagicQuotes();
3167 3167
       
3168
-      // ----- Error log
3169
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
3168
+	  // ----- Error log
3169
+	  PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
3170 3170
 
3171
-      // ----- Return
3172
-      return PclZip::errorCode();
3173
-    }
3171
+	  // ----- Return
3172
+	  return PclZip::errorCode();
3173
+	}
3174 3174
 
3175
-    // ----- Read the central directory informations
3176
-    $v_central_dir = array();
3177
-    if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
3178
-    {
3179
-      $this->privSwapBackMagicQuotes();
3180
-      return $v_result;
3181
-    }
3175
+	// ----- Read the central directory informations
3176
+	$v_central_dir = array();
3177
+	if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
3178
+	{
3179
+	  $this->privSwapBackMagicQuotes();
3180
+	  return $v_result;
3181
+	}
3182 3182
 
3183
-    // ----- Go to beginning of Central Dir
3184
-    @rewind($this->zip_fd);
3185
-    if (@fseek($this->zip_fd, $v_central_dir['offset']))
3186
-    {
3187
-      $this->privSwapBackMagicQuotes();
3183
+	// ----- Go to beginning of Central Dir
3184
+	@rewind($this->zip_fd);
3185
+	if (@fseek($this->zip_fd, $v_central_dir['offset']))
3186
+	{
3187
+	  $this->privSwapBackMagicQuotes();
3188 3188
 
3189
-      // ----- Error log
3190
-      PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
3189
+	  // ----- Error log
3190
+	  PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
3191 3191
 
3192
-      // ----- Return
3193
-      return PclZip::errorCode();
3194
-    }
3192
+	  // ----- Return
3193
+	  return PclZip::errorCode();
3194
+	}
3195 3195
 
3196
-    // ----- Read each entry
3197
-    for ($i=0; $i<$v_central_dir['entries']; $i++)
3198
-    {
3199
-      // ----- Read the file header
3200
-      if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
3201
-      {
3202
-        $this->privSwapBackMagicQuotes();
3203
-        return $v_result;
3204
-      }
3205
-      $v_header['index'] = $i;
3196
+	// ----- Read each entry
3197
+	for ($i=0; $i<$v_central_dir['entries']; $i++)
3198
+	{
3199
+	  // ----- Read the file header
3200
+	  if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
3201
+	  {
3202
+		$this->privSwapBackMagicQuotes();
3203
+		return $v_result;
3204
+	  }
3205
+	  $v_header['index'] = $i;
3206 3206
 
3207
-      // ----- Get the only interesting attributes
3208
-      $this->privConvertHeader2FileInfo($v_header, $p_list[$i]);
3209
-      unset($v_header);
3210
-    }
3207
+	  // ----- Get the only interesting attributes
3208
+	  $this->privConvertHeader2FileInfo($v_header, $p_list[$i]);
3209
+	  unset($v_header);
3210
+	}
3211 3211
 
3212
-    // ----- Close the zip file
3213
-    $this->privCloseFd();
3212
+	// ----- Close the zip file
3213
+	$this->privCloseFd();
3214 3214
 
3215
-    // ----- Magic quotes trick
3216
-    $this->privSwapBackMagicQuotes();
3215
+	// ----- Magic quotes trick
3216
+	$this->privSwapBackMagicQuotes();
3217 3217
 
3218
-    // ----- Return
3219
-    return $v_result;
3218
+	// ----- Return
3219
+	return $v_result;
3220 3220
   }
3221 3221
   // --------------------------------------------------------------------------------
3222 3222
 
@@ -3241,24 +3241,24 @@  discard block
 block discarded – undo
3241 3241
   // --------------------------------------------------------------------------------
3242 3242
   function privConvertHeader2FileInfo($p_header, &$p_info)
3243 3243
   {
3244
-    $v_result=1;
3245
-
3246
-    // ----- Get the interesting attributes
3247
-    $v_temp_path = PclZipUtilPathReduction($p_header['filename']);
3248
-    $p_info['filename'] = $v_temp_path;
3249
-    $v_temp_path = PclZipUtilPathReduction($p_header['stored_filename']);
3250
-    $p_info['stored_filename'] = $v_temp_path;
3251
-    $p_info['size'] = $p_header['size'];
3252
-    $p_info['compressed_size'] = $p_header['compressed_size'];
3253
-    $p_info['mtime'] = $p_header['mtime'];
3254
-    $p_info['comment'] = $p_header['comment'];
3255
-    $p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010);
3256
-    $p_info['index'] = $p_header['index'];
3257
-    $p_info['status'] = $p_header['status'];
3258
-    $p_info['crc'] = $p_header['crc'];
3259
-
3260
-    // ----- Return
3261
-    return $v_result;
3244
+	$v_result=1;
3245
+
3246
+	// ----- Get the interesting attributes
3247
+	$v_temp_path = PclZipUtilPathReduction($p_header['filename']);
3248
+	$p_info['filename'] = $v_temp_path;
3249
+	$v_temp_path = PclZipUtilPathReduction($p_header['stored_filename']);
3250
+	$p_info['stored_filename'] = $v_temp_path;
3251
+	$p_info['size'] = $p_header['size'];
3252
+	$p_info['compressed_size'] = $p_header['compressed_size'];
3253
+	$p_info['mtime'] = $p_header['mtime'];
3254
+	$p_info['comment'] = $p_header['comment'];
3255
+	$p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010);
3256
+	$p_info['index'] = $p_header['index'];
3257
+	$p_info['status'] = $p_header['status'];
3258
+	$p_info['crc'] = $p_header['crc'];
3259
+
3260
+	// ----- Return
3261
+	return $v_result;
3262 3262
   }
3263 3263
   // --------------------------------------------------------------------------------
3264 3264
 
@@ -3280,122 +3280,122 @@  discard block
 block discarded – undo
3280 3280
   // --------------------------------------------------------------------------------
3281 3281
   function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
3282 3282
   {
3283
-    $v_result=1;
3283
+	$v_result=1;
3284 3284
 
3285
-    // ----- Magic quotes trick
3286
-    $this->privDisableMagicQuotes();
3285
+	// ----- Magic quotes trick
3286
+	$this->privDisableMagicQuotes();
3287 3287
 
3288
-    // ----- Check the path
3289
-    if (   ($p_path == "")
3290
-	    || (   (substr($p_path, 0, 1) != "/")
3291
-		    && (substr($p_path, 0, 3) != "../")
3288
+	// ----- Check the path
3289
+	if (   ($p_path == "")
3290
+		|| (   (substr($p_path, 0, 1) != "/")
3291
+			&& (substr($p_path, 0, 3) != "../")
3292 3292
 			&& (substr($p_path,1,2)!=":/")))
3293
-      $p_path = "./".$p_path;
3294
-
3295
-    // ----- Reduce the path last (and duplicated) '/'
3296
-    if (($p_path != "./") && ($p_path != "/"))
3297
-    {
3298
-      // ----- Look for the path end '/'
3299
-      while (substr($p_path, -1) == "/")
3300
-      {
3301
-        $p_path = substr($p_path, 0, strlen($p_path)-1);
3302
-      }
3303
-    }
3293
+	  $p_path = "./".$p_path;
3294
+
3295
+	// ----- Reduce the path last (and duplicated) '/'
3296
+	if (($p_path != "./") && ($p_path != "/"))
3297
+	{
3298
+	  // ----- Look for the path end '/'
3299
+	  while (substr($p_path, -1) == "/")
3300
+	  {
3301
+		$p_path = substr($p_path, 0, strlen($p_path)-1);
3302
+	  }
3303
+	}
3304 3304
 
3305
-    // ----- Look for path to remove format (should end by /)
3306
-    if (($p_remove_path != "") && (substr($p_remove_path, -1) != '/'))
3307
-    {
3308
-      $p_remove_path .= '/';
3309
-    }
3310
-    $p_remove_path_size = strlen($p_remove_path);
3305
+	// ----- Look for path to remove format (should end by /)
3306
+	if (($p_remove_path != "") && (substr($p_remove_path, -1) != '/'))
3307
+	{
3308
+	  $p_remove_path .= '/';
3309
+	}
3310
+	$p_remove_path_size = strlen($p_remove_path);
3311 3311
 
3312
-    // ----- Open the zip file
3313
-    if (($v_result = $this->privOpenFd('rb')) != 1)
3314
-    {
3315
-      $this->privSwapBackMagicQuotes();
3316
-      return $v_result;
3317
-    }
3312
+	// ----- Open the zip file
3313
+	if (($v_result = $this->privOpenFd('rb')) != 1)
3314
+	{
3315
+	  $this->privSwapBackMagicQuotes();
3316
+	  return $v_result;
3317
+	}
3318 3318
 
3319
-    // ----- Read the central directory informations
3320
-    $v_central_dir = array();
3321
-    if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
3322
-    {
3323
-      // ----- Close the zip file
3324
-      $this->privCloseFd();
3325
-      $this->privSwapBackMagicQuotes();
3319
+	// ----- Read the central directory informations
3320
+	$v_central_dir = array();
3321
+	if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
3322
+	{
3323
+	  // ----- Close the zip file
3324
+	  $this->privCloseFd();
3325
+	  $this->privSwapBackMagicQuotes();
3326 3326
 
3327
-      return $v_result;
3328
-    }
3327
+	  return $v_result;
3328
+	}
3329 3329
 
3330
-    // ----- Start at beginning of Central Dir
3331
-    $v_pos_entry = $v_central_dir['offset'];
3330
+	// ----- Start at beginning of Central Dir
3331
+	$v_pos_entry = $v_central_dir['offset'];
3332 3332
 
3333
-    // ----- Read each entry
3334
-    $j_start = 0;
3335
-    for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
3336
-    {
3333
+	// ----- Read each entry
3334
+	$j_start = 0;
3335
+	for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
3336
+	{
3337 3337
 
3338
-      // ----- Read next Central dir entry
3339
-      @rewind($this->zip_fd);
3340
-      if (@fseek($this->zip_fd, $v_pos_entry))
3341
-      {
3342
-        // ----- Close the zip file
3343
-        $this->privCloseFd();
3344
-        $this->privSwapBackMagicQuotes();
3338
+	  // ----- Read next Central dir entry
3339
+	  @rewind($this->zip_fd);
3340
+	  if (@fseek($this->zip_fd, $v_pos_entry))
3341
+	  {
3342
+		// ----- Close the zip file
3343
+		$this->privCloseFd();
3344
+		$this->privSwapBackMagicQuotes();
3345 3345
 
3346
-        // ----- Error log
3347
-        PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
3346
+		// ----- Error log
3347
+		PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
3348 3348
 
3349
-        // ----- Return
3350
-        return PclZip::errorCode();
3351
-      }
3349
+		// ----- Return
3350
+		return PclZip::errorCode();
3351
+	  }
3352 3352
 
3353
-      // ----- Read the file header
3354
-      $v_header = array();
3355
-      if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
3356
-      {
3357
-        // ----- Close the zip file
3358
-        $this->privCloseFd();
3359
-        $this->privSwapBackMagicQuotes();
3353
+	  // ----- Read the file header
3354
+	  $v_header = array();
3355
+	  if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
3356
+	  {
3357
+		// ----- Close the zip file
3358
+		$this->privCloseFd();
3359
+		$this->privSwapBackMagicQuotes();
3360 3360
 
3361
-        return $v_result;
3362
-      }
3361
+		return $v_result;
3362
+	  }
3363 3363
 
3364
-      // ----- Store the index
3365
-      $v_header['index'] = $i;
3364
+	  // ----- Store the index
3365
+	  $v_header['index'] = $i;
3366 3366
 
3367
-      // ----- Store the file position
3368
-      $v_pos_entry = ftell($this->zip_fd);
3367
+	  // ----- Store the file position
3368
+	  $v_pos_entry = ftell($this->zip_fd);
3369 3369
 
3370
-      // ----- Look for the specific extract rules
3371
-      $v_extract = false;
3370
+	  // ----- Look for the specific extract rules
3371
+	  $v_extract = false;
3372 3372
 
3373
-      // ----- Look for extract by name rule
3374
-      if (   (isset($p_options[PCLZIP_OPT_BY_NAME]))
3375
-          && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
3373
+	  // ----- Look for extract by name rule
3374
+	  if (   (isset($p_options[PCLZIP_OPT_BY_NAME]))
3375
+		  && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
3376 3376
 
3377
-          // ----- Look if the filename is in the list
3378
-          for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) {
3377
+		  // ----- Look if the filename is in the list
3378
+		  for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) {
3379 3379
 
3380
-              // ----- Look for a directory
3381
-              if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
3380
+			  // ----- Look for a directory
3381
+			  if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
3382 3382
 
3383
-                  // ----- Look if the directory is in the filename path
3384
-                  if (   (strlen($v_header['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
3385
-                      && (substr($v_header['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
3386
-                      $v_extract = true;
3387
-                  }
3388
-              }
3389
-              // ----- Look for a filename
3390
-              elseif ($v_header['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
3391
-                  $v_extract = true;
3392
-              }
3393
-          }
3394
-      }
3383
+				  // ----- Look if the directory is in the filename path
3384
+				  if (   (strlen($v_header['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
3385
+					  && (substr($v_header['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
3386
+					  $v_extract = true;
3387
+				  }
3388
+			  }
3389
+			  // ----- Look for a filename
3390
+			  elseif ($v_header['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
3391
+				  $v_extract = true;
3392
+			  }
3393
+		  }
3394
+	  }
3395 3395
 
3396
-      // ----- Look for extract by ereg rule
3397
-      // ereg() is deprecated with PHP 5.3
3398
-      /* 
3396
+	  // ----- Look for extract by ereg rule
3397
+	  // ereg() is deprecated with PHP 5.3
3398
+	  /* 
3399 3399
       else if (   (isset($p_options[PCLZIP_OPT_BY_EREG]))
3400 3400
                && ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
3401 3401
 
@@ -3405,207 +3405,207 @@  discard block
 block discarded – undo
3405 3405
       }
3406 3406
       */
3407 3407
 
3408
-      // ----- Look for extract by preg rule
3409
-      else if (   (isset($p_options[PCLZIP_OPT_BY_PREG]))
3410
-               && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
3408
+	  // ----- Look for extract by preg rule
3409
+	  else if (   (isset($p_options[PCLZIP_OPT_BY_PREG]))
3410
+			   && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
3411 3411
 
3412
-          if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) {
3413
-              $v_extract = true;
3414
-          }
3415
-      }
3412
+		  if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) {
3413
+			  $v_extract = true;
3414
+		  }
3415
+	  }
3416 3416
 
3417
-      // ----- Look for extract by index rule
3418
-      else if (   (isset($p_options[PCLZIP_OPT_BY_INDEX]))
3419
-               && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
3417
+	  // ----- Look for extract by index rule
3418
+	  else if (   (isset($p_options[PCLZIP_OPT_BY_INDEX]))
3419
+			   && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
3420 3420
           
3421
-          // ----- Look if the index is in the list
3422
-          for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) {
3423
-
3424
-              if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
3425
-                  $v_extract = true;
3426
-              }
3427
-              if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
3428
-                  $j_start = $j+1;
3429
-              }
3430
-
3431
-              if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
3432
-                  break;
3433
-              }
3434
-          }
3435
-      }
3421
+		  // ----- Look if the index is in the list
3422
+		  for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) {
3423
+
3424
+			  if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
3425
+				  $v_extract = true;
3426
+			  }
3427
+			  if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
3428
+				  $j_start = $j+1;
3429
+			  }
3430
+
3431
+			  if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
3432
+				  break;
3433
+			  }
3434
+		  }
3435
+	  }
3436 3436
 
3437
-      // ----- Look for no rule, which means extract all the archive
3438
-      else {
3439
-          $v_extract = true;
3440
-      }
3437
+	  // ----- Look for no rule, which means extract all the archive
3438
+	  else {
3439
+		  $v_extract = true;
3440
+	  }
3441 3441
 
3442 3442
 	  // ----- Check compression method
3443 3443
 	  if (   ($v_extract)
3444
-	      && (   ($v_header['compression'] != 8)
3445
-		      && ($v_header['compression'] != 0))) {
3446
-          $v_header['status'] = 'unsupported_compression';
3444
+		  && (   ($v_header['compression'] != 8)
3445
+			  && ($v_header['compression'] != 0))) {
3446
+		  $v_header['status'] = 'unsupported_compression';
3447 3447
 
3448
-          // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3449
-          if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3450
-		      && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3448
+		  // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3449
+		  if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3450
+			  && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3451 3451
 
3452
-              $this->privSwapBackMagicQuotes();
3452
+			  $this->privSwapBackMagicQuotes();
3453 3453
               
3454
-              PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION,
3455
-			                       "Filename '".$v_header['stored_filename']."' is "
3456
-				  	    	  	   ."compressed by an unsupported compression "
3457
-				  	    	  	   ."method (".$v_header['compression'].") ");
3454
+			  PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION,
3455
+								   "Filename '".$v_header['stored_filename']."' is "
3456
+				  			  	   ."compressed by an unsupported compression "
3457
+				  			  	   ."method (".$v_header['compression'].") ");
3458 3458
 
3459
-              return PclZip::errorCode();
3459
+			  return PclZip::errorCode();
3460 3460
 		  }
3461 3461
 	  }
3462 3462
 	  
3463 3463
 	  // ----- Check encrypted files
3464 3464
 	  if (($v_extract) && (($v_header['flag'] & 1) == 1)) {
3465
-          $v_header['status'] = 'unsupported_encryption';
3465
+		  $v_header['status'] = 'unsupported_encryption';
3466 3466
 
3467
-          // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3468
-          if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3469
-		      && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3467
+		  // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3468
+		  if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3469
+			  && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3470 3470
 
3471
-              $this->privSwapBackMagicQuotes();
3471
+			  $this->privSwapBackMagicQuotes();
3472 3472
 
3473
-              PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION,
3474
-			                       "Unsupported encryption for "
3475
-				  	    	  	   ." filename '".$v_header['stored_filename']
3473
+			  PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION,
3474
+								   "Unsupported encryption for "
3475
+				  			  	   ." filename '".$v_header['stored_filename']
3476 3476
 								   ."'");
3477 3477
 
3478
-              return PclZip::errorCode();
3478
+			  return PclZip::errorCode();
3479 3479
 		  }
3480
-    }
3480
+	}
3481 3481
 
3482
-      // ----- Look for real extraction
3483
-      if (($v_extract) && ($v_header['status'] != 'ok')) {
3484
-          $v_result = $this->privConvertHeader2FileInfo($v_header,
3485
-		                                        $p_file_list[$v_nb_extracted++]);
3486
-          if ($v_result != 1) {
3487
-              $this->privCloseFd();
3488
-              $this->privSwapBackMagicQuotes();
3489
-              return $v_result;
3490
-          }
3482
+	  // ----- Look for real extraction
3483
+	  if (($v_extract) && ($v_header['status'] != 'ok')) {
3484
+		  $v_result = $this->privConvertHeader2FileInfo($v_header,
3485
+												$p_file_list[$v_nb_extracted++]);
3486
+		  if ($v_result != 1) {
3487
+			  $this->privCloseFd();
3488
+			  $this->privSwapBackMagicQuotes();
3489
+			  return $v_result;
3490
+		  }
3491 3491
 
3492
-          $v_extract = false;
3493
-      }
3492
+		  $v_extract = false;
3493
+	  }
3494 3494
       
3495
-      // ----- Look for real extraction
3496
-      if ($v_extract)
3497
-      {
3495
+	  // ----- Look for real extraction
3496
+	  if ($v_extract)
3497
+	  {
3498 3498
 
3499
-        // ----- Go to the file position
3500
-        @rewind($this->zip_fd);
3501
-        if (@fseek($this->zip_fd, $v_header['offset']))
3502
-        {
3503
-          // ----- Close the zip file
3504
-          $this->privCloseFd();
3499
+		// ----- Go to the file position
3500
+		@rewind($this->zip_fd);
3501
+		if (@fseek($this->zip_fd, $v_header['offset']))
3502
+		{
3503
+		  // ----- Close the zip file
3504
+		  $this->privCloseFd();
3505 3505
 
3506
-          $this->privSwapBackMagicQuotes();
3506
+		  $this->privSwapBackMagicQuotes();
3507 3507
 
3508
-          // ----- Error log
3509
-          PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
3508
+		  // ----- Error log
3509
+		  PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
3510 3510
 
3511
-          // ----- Return
3512
-          return PclZip::errorCode();
3513
-        }
3511
+		  // ----- Return
3512
+		  return PclZip::errorCode();
3513
+		}
3514 3514
 
3515
-        // ----- Look for extraction as string
3516
-        if ($p_options[PCLZIP_OPT_EXTRACT_AS_STRING]) {
3515
+		// ----- Look for extraction as string
3516
+		if ($p_options[PCLZIP_OPT_EXTRACT_AS_STRING]) {
3517 3517
 
3518
-          $v_string = '';
3518
+		  $v_string = '';
3519 3519
 
3520
-          // ----- Extracting the file
3521
-          $v_result1 = $this->privExtractFileAsString($v_header, $v_string, $p_options);
3522
-          if ($v_result1 < 1) {
3523
-            $this->privCloseFd();
3524
-            $this->privSwapBackMagicQuotes();
3525
-            return $v_result1;
3526
-          }
3520
+		  // ----- Extracting the file
3521
+		  $v_result1 = $this->privExtractFileAsString($v_header, $v_string, $p_options);
3522
+		  if ($v_result1 < 1) {
3523
+			$this->privCloseFd();
3524
+			$this->privSwapBackMagicQuotes();
3525
+			return $v_result1;
3526
+		  }
3527 3527
 
3528
-          // ----- Get the only interesting attributes
3529
-          if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted])) != 1)
3530
-          {
3531
-            // ----- Close the zip file
3532
-            $this->privCloseFd();
3533
-            $this->privSwapBackMagicQuotes();
3528
+		  // ----- Get the only interesting attributes
3529
+		  if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted])) != 1)
3530
+		  {
3531
+			// ----- Close the zip file
3532
+			$this->privCloseFd();
3533
+			$this->privSwapBackMagicQuotes();
3534 3534
 
3535
-            return $v_result;
3536
-          }
3535
+			return $v_result;
3536
+		  }
3537 3537
 
3538
-          // ----- Set the file content
3539
-          $p_file_list[$v_nb_extracted]['content'] = $v_string;
3538
+		  // ----- Set the file content
3539
+		  $p_file_list[$v_nb_extracted]['content'] = $v_string;
3540 3540
 
3541
-          // ----- Next extracted file
3542
-          $v_nb_extracted++;
3541
+		  // ----- Next extracted file
3542
+		  $v_nb_extracted++;
3543 3543
           
3544
-          // ----- Look for user callback abort
3545
-          if ($v_result1 == 2) {
3546
-          	break;
3547
-          }
3548
-        }
3549
-        // ----- Look for extraction in standard output
3550
-        elseif (   (isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT]))
3551
-		        && ($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) {
3552
-          // ----- Extracting the file in standard output
3553
-          $v_result1 = $this->privExtractFileInOutput($v_header, $p_options);
3554
-          if ($v_result1 < 1) {
3555
-            $this->privCloseFd();
3556
-            $this->privSwapBackMagicQuotes();
3557
-            return $v_result1;
3558
-          }
3544
+		  // ----- Look for user callback abort
3545
+		  if ($v_result1 == 2) {
3546
+		  	break;
3547
+		  }
3548
+		}
3549
+		// ----- Look for extraction in standard output
3550
+		elseif (   (isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT]))
3551
+				&& ($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) {
3552
+		  // ----- Extracting the file in standard output
3553
+		  $v_result1 = $this->privExtractFileInOutput($v_header, $p_options);
3554
+		  if ($v_result1 < 1) {
3555
+			$this->privCloseFd();
3556
+			$this->privSwapBackMagicQuotes();
3557
+			return $v_result1;
3558
+		  }
3559 3559
 
3560
-          // ----- Get the only interesting attributes
3561
-          if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) {
3562
-            $this->privCloseFd();
3563
-            $this->privSwapBackMagicQuotes();
3564
-            return $v_result;
3565
-          }
3560
+		  // ----- Get the only interesting attributes
3561
+		  if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) {
3562
+			$this->privCloseFd();
3563
+			$this->privSwapBackMagicQuotes();
3564
+			return $v_result;
3565
+		  }
3566 3566
 
3567
-          // ----- Look for user callback abort
3568
-          if ($v_result1 == 2) {
3569
-          	break;
3570
-          }
3571
-        }
3572
-        // ----- Look for normal extraction
3573
-        else {
3574
-          // ----- Extracting the file
3575
-          $v_result1 = $this->privExtractFile($v_header,
3576
-		                                      $p_path, $p_remove_path,
3567
+		  // ----- Look for user callback abort
3568
+		  if ($v_result1 == 2) {
3569
+		  	break;
3570
+		  }
3571
+		}
3572
+		// ----- Look for normal extraction
3573
+		else {
3574
+		  // ----- Extracting the file
3575
+		  $v_result1 = $this->privExtractFile($v_header,
3576
+											  $p_path, $p_remove_path,
3577 3577
 											  $p_remove_all_path,
3578 3578
 											  $p_options);
3579
-          if ($v_result1 < 1) {
3580
-            $this->privCloseFd();
3581
-            $this->privSwapBackMagicQuotes();
3582
-            return $v_result1;
3583
-          }
3579
+		  if ($v_result1 < 1) {
3580
+			$this->privCloseFd();
3581
+			$this->privSwapBackMagicQuotes();
3582
+			return $v_result1;
3583
+		  }
3584 3584
 
3585
-          // ----- Get the only interesting attributes
3586
-          if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1)
3587
-          {
3588
-            // ----- Close the zip file
3589
-            $this->privCloseFd();
3590
-            $this->privSwapBackMagicQuotes();
3585
+		  // ----- Get the only interesting attributes
3586
+		  if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1)
3587
+		  {
3588
+			// ----- Close the zip file
3589
+			$this->privCloseFd();
3590
+			$this->privSwapBackMagicQuotes();
3591 3591
 
3592
-            return $v_result;
3593
-          }
3592
+			return $v_result;
3593
+		  }
3594 3594
 
3595
-          // ----- Look for user callback abort
3596
-          if ($v_result1 == 2) {
3597
-          	break;
3598
-          }
3599
-        }
3600
-      }
3601
-    }
3595
+		  // ----- Look for user callback abort
3596
+		  if ($v_result1 == 2) {
3597
+		  	break;
3598
+		  }
3599
+		}
3600
+	  }
3601
+	}
3602 3602
 
3603
-    // ----- Close the zip file
3604
-    $this->privCloseFd();
3605
-    $this->privSwapBackMagicQuotes();
3603
+	// ----- Close the zip file
3604
+	$this->privCloseFd();
3605
+	$this->privSwapBackMagicQuotes();
3606 3606
 
3607
-    // ----- Return
3608
-    return $v_result;
3607
+	// ----- Return
3608
+	return $v_result;
3609 3609
   }
3610 3610
   // --------------------------------------------------------------------------------
3611 3611
 
@@ -3620,346 +3620,346 @@  discard block
 block discarded – undo
3620 3620
   // --------------------------------------------------------------------------------
3621 3621
   function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
3622 3622
   {
3623
-    $v_result=1;
3623
+	$v_result=1;
3624 3624
 
3625
-    // ----- Read the file header
3626
-    if (($v_result = $this->privReadFileHeader($v_header)) != 1)
3627
-    {
3628
-      // ----- Return
3629
-      return $v_result;
3630
-    }
3625
+	// ----- Read the file header
3626
+	if (($v_result = $this->privReadFileHeader($v_header)) != 1)
3627
+	{
3628
+	  // ----- Return
3629
+	  return $v_result;
3630
+	}
3631 3631
 
3632 3632
 
3633
-    // ----- Check that the file header is coherent with $p_entry info
3634
-    if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
3635
-        // TBC
3636
-    }
3633
+	// ----- Check that the file header is coherent with $p_entry info
3634
+	if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
3635
+		// TBC
3636
+	}
3637 3637
 
3638
-    // ----- Look for all path to remove
3639
-    if ($p_remove_all_path == true) {
3640
-        // ----- Look for folder entry that not need to be extracted
3641
-        if (($p_entry['external']&0x00000010)==0x00000010) {
3638
+	// ----- Look for all path to remove
3639
+	if ($p_remove_all_path == true) {
3640
+		// ----- Look for folder entry that not need to be extracted
3641
+		if (($p_entry['external']&0x00000010)==0x00000010) {
3642 3642
 
3643
-            $p_entry['status'] = "filtered";
3643
+			$p_entry['status'] = "filtered";
3644 3644
 
3645
-            return $v_result;
3646
-        }
3645
+			return $v_result;
3646
+		}
3647 3647
 
3648
-        // ----- Get the basename of the path
3649
-        $p_entry['filename'] = basename($p_entry['filename']);
3650
-    }
3648
+		// ----- Get the basename of the path
3649
+		$p_entry['filename'] = basename($p_entry['filename']);
3650
+	}
3651 3651
 
3652
-    // ----- Look for path to remove
3653
-    else if ($p_remove_path != "")
3654
-    {
3655
-      if (PclZipUtilPathInclusion($p_remove_path, $p_entry['filename']) == 2)
3656
-      {
3652
+	// ----- Look for path to remove
3653
+	else if ($p_remove_path != "")
3654
+	{
3655
+	  if (PclZipUtilPathInclusion($p_remove_path, $p_entry['filename']) == 2)
3656
+	  {
3657 3657
 
3658
-        // ----- Change the file status
3659
-        $p_entry['status'] = "filtered";
3658
+		// ----- Change the file status
3659
+		$p_entry['status'] = "filtered";
3660 3660
 
3661
-        // ----- Return
3662
-        return $v_result;
3663
-      }
3661
+		// ----- Return
3662
+		return $v_result;
3663
+	  }
3664 3664
 
3665
-      $p_remove_path_size = strlen($p_remove_path);
3666
-      if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path)
3667
-      {
3665
+	  $p_remove_path_size = strlen($p_remove_path);
3666
+	  if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path)
3667
+	  {
3668 3668
 
3669
-        // ----- Remove the path
3670
-        $p_entry['filename'] = substr($p_entry['filename'], $p_remove_path_size);
3669
+		// ----- Remove the path
3670
+		$p_entry['filename'] = substr($p_entry['filename'], $p_remove_path_size);
3671 3671
 
3672
-      }
3673
-    }
3672
+	  }
3673
+	}
3674 3674
 
3675
-    // ----- Add the path
3676
-    if ($p_path != '') {
3677
-      $p_entry['filename'] = $p_path."/".$p_entry['filename'];
3678
-    }
3675
+	// ----- Add the path
3676
+	if ($p_path != '') {
3677
+	  $p_entry['filename'] = $p_path."/".$p_entry['filename'];
3678
+	}
3679 3679
     
3680
-    // ----- Check a base_dir_restriction
3681
-    if (isset($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) {
3682
-      $v_inclusion
3683
-      = PclZipUtilPathInclusion($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION],
3684
-                                $p_entry['filename']); 
3685
-      if ($v_inclusion == 0) {
3686
-
3687
-        PclZip::privErrorLog(PCLZIP_ERR_DIRECTORY_RESTRICTION,
3688
-			                     "Filename '".$p_entry['filename']."' is "
3680
+	// ----- Check a base_dir_restriction
3681
+	if (isset($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) {
3682
+	  $v_inclusion
3683
+	  = PclZipUtilPathInclusion($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION],
3684
+								$p_entry['filename']); 
3685
+	  if ($v_inclusion == 0) {
3686
+
3687
+		PclZip::privErrorLog(PCLZIP_ERR_DIRECTORY_RESTRICTION,
3688
+								 "Filename '".$p_entry['filename']."' is "
3689 3689
 								 ."outside PCLZIP_OPT_EXTRACT_DIR_RESTRICTION");
3690 3690
 
3691
-        return PclZip::errorCode();
3692
-      }
3693
-    }
3691
+		return PclZip::errorCode();
3692
+	  }
3693
+	}
3694 3694
 
3695
-    // ----- Look for pre-extract callback
3696
-    if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
3695
+	// ----- Look for pre-extract callback
3696
+	if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
3697 3697
 
3698
-      // ----- Generate a local information
3699
-      $v_local_header = array();
3700
-      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
3698
+	  // ----- Generate a local information
3699
+	  $v_local_header = array();
3700
+	  $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
3701 3701
 
3702
-      // ----- Call the callback
3703
-      // Here I do not use call_user_func() because I need to send a reference to the
3704
-      // header.
3702
+	  // ----- Call the callback
3703
+	  // Here I do not use call_user_func() because I need to send a reference to the
3704
+	  // header.
3705 3705
 //      eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
3706
-      $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
3707
-      if ($v_result == 0) {
3708
-        // ----- Change the file status
3709
-        $p_entry['status'] = "skipped";
3710
-        $v_result = 1;
3711
-      }
3706
+	  $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
3707
+	  if ($v_result == 0) {
3708
+		// ----- Change the file status
3709
+		$p_entry['status'] = "skipped";
3710
+		$v_result = 1;
3711
+	  }
3712 3712
       
3713
-      // ----- Look for abort result
3714
-      if ($v_result == 2) {
3715
-        // ----- This status is internal and will be changed in 'skipped'
3716
-        $p_entry['status'] = "aborted";
3717
-      	$v_result = PCLZIP_ERR_USER_ABORTED;
3718
-      }
3713
+	  // ----- Look for abort result
3714
+	  if ($v_result == 2) {
3715
+		// ----- This status is internal and will be changed in 'skipped'
3716
+		$p_entry['status'] = "aborted";
3717
+	  	$v_result = PCLZIP_ERR_USER_ABORTED;
3718
+	  }
3719 3719
 
3720
-      // ----- Update the informations
3721
-      // Only some fields can be modified
3722
-      $p_entry['filename'] = $v_local_header['filename'];
3723
-    }
3720
+	  // ----- Update the informations
3721
+	  // Only some fields can be modified
3722
+	  $p_entry['filename'] = $v_local_header['filename'];
3723
+	}
3724 3724
 
3725 3725
 
3726
-    // ----- Look if extraction should be done
3727
-    if ($p_entry['status'] == 'ok') {
3726
+	// ----- Look if extraction should be done
3727
+	if ($p_entry['status'] == 'ok') {
3728 3728
 
3729
-    // ----- Look for specific actions while the file exist
3730
-    if (file_exists($p_entry['filename']))
3731
-    {
3729
+	// ----- Look for specific actions while the file exist
3730
+	if (file_exists($p_entry['filename']))
3731
+	{
3732 3732
 
3733
-      // ----- Look if file is a directory
3734
-      if (is_dir($p_entry['filename']))
3735
-      {
3733
+	  // ----- Look if file is a directory
3734
+	  if (is_dir($p_entry['filename']))
3735
+	  {
3736 3736
 
3737
-        // ----- Change the file status
3738
-        $p_entry['status'] = "already_a_directory";
3737
+		// ----- Change the file status
3738
+		$p_entry['status'] = "already_a_directory";
3739 3739
         
3740
-        // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3741
-        // For historical reason first PclZip implementation does not stop
3742
-        // when this kind of error occurs.
3743
-        if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3744
-		    && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3745
-
3746
-            PclZip::privErrorLog(PCLZIP_ERR_ALREADY_A_DIRECTORY,
3747
-			                     "Filename '".$p_entry['filename']."' is "
3740
+		// ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3741
+		// For historical reason first PclZip implementation does not stop
3742
+		// when this kind of error occurs.
3743
+		if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3744
+			&& ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3745
+
3746
+			PclZip::privErrorLog(PCLZIP_ERR_ALREADY_A_DIRECTORY,
3747
+								 "Filename '".$p_entry['filename']."' is "
3748 3748
 								 ."already used by an existing directory");
3749 3749
 
3750
-            return PclZip::errorCode();
3751
-		    }
3752
-      }
3753
-      // ----- Look if file is write protected
3754
-      else if (!is_writeable($p_entry['filename']))
3755
-      {
3750
+			return PclZip::errorCode();
3751
+			}
3752
+	  }
3753
+	  // ----- Look if file is write protected
3754
+	  else if (!is_writeable($p_entry['filename']))
3755
+	  {
3756 3756
 
3757
-        // ----- Change the file status
3758
-        $p_entry['status'] = "write_protected";
3757
+		// ----- Change the file status
3758
+		$p_entry['status'] = "write_protected";
3759 3759
 
3760
-        // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3761
-        // For historical reason first PclZip implementation does not stop
3762
-        // when this kind of error occurs.
3763
-        if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3764
-		    && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3760
+		// ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3761
+		// For historical reason first PclZip implementation does not stop
3762
+		// when this kind of error occurs.
3763
+		if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3764
+			&& ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3765 3765
 
3766
-            PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
3767
-			                     "Filename '".$p_entry['filename']."' exists "
3766
+			PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
3767
+								 "Filename '".$p_entry['filename']."' exists "
3768 3768
 								 ."and is write protected");
3769 3769
 
3770
-            return PclZip::errorCode();
3771
-		    }
3772
-      }
3770
+			return PclZip::errorCode();
3771
+			}
3772
+	  }
3773 3773
 
3774
-      // ----- Look if the extracted file is older
3775
-      else if (filemtime($p_entry['filename']) > $p_entry['mtime'])
3776
-      {
3777
-        // ----- Change the file status
3778
-        if (   (isset($p_options[PCLZIP_OPT_REPLACE_NEWER]))
3779
-		    && ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) {
3774
+	  // ----- Look if the extracted file is older
3775
+	  else if (filemtime($p_entry['filename']) > $p_entry['mtime'])
3776
+	  {
3777
+		// ----- Change the file status
3778
+		if (   (isset($p_options[PCLZIP_OPT_REPLACE_NEWER]))
3779
+			&& ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) {
3780 3780
 	  	  }
3781
-		    else {
3782
-            $p_entry['status'] = "newer_exist";
3783
-
3784
-            // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3785
-            // For historical reason first PclZip implementation does not stop
3786
-            // when this kind of error occurs.
3787
-            if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3788
-		        && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3789
-
3790
-                PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
3791
-			             "Newer version of '".$p_entry['filename']."' exists "
3792
-					    ."and option PCLZIP_OPT_REPLACE_NEWER is not selected");
3793
-
3794
-                return PclZip::errorCode();
3795
-		      }
3796
-		    }
3797
-      }
3798
-      else {
3799
-      }
3800
-    }
3781
+			else {
3782
+			$p_entry['status'] = "newer_exist";
3783
+
3784
+			// ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3785
+			// For historical reason first PclZip implementation does not stop
3786
+			// when this kind of error occurs.
3787
+			if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3788
+				&& ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3789
+
3790
+				PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
3791
+						 "Newer version of '".$p_entry['filename']."' exists "
3792
+						."and option PCLZIP_OPT_REPLACE_NEWER is not selected");
3793
+
3794
+				return PclZip::errorCode();
3795
+			  }
3796
+			}
3797
+	  }
3798
+	  else {
3799
+	  }
3800
+	}
3801 3801
 
3802
-    // ----- Check the directory availability and create it if necessary
3803
-    else {
3804
-      if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/'))
3805
-        $v_dir_to_check = $p_entry['filename'];
3806
-      else if (!strstr($p_entry['filename'], "/"))
3807
-        $v_dir_to_check = "";
3808
-      else
3809
-        $v_dir_to_check = dirname($p_entry['filename']);
3810
-
3811
-        if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) {
3812
-  
3813
-          // ----- Change the file status
3814
-          $p_entry['status'] = "path_creation_fail";
3802
+	// ----- Check the directory availability and create it if necessary
3803
+	else {
3804
+	  if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/'))
3805
+		$v_dir_to_check = $p_entry['filename'];
3806
+	  else if (!strstr($p_entry['filename'], "/"))
3807
+		$v_dir_to_check = "";
3808
+	  else
3809
+		$v_dir_to_check = dirname($p_entry['filename']);
3810
+
3811
+		if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) {
3815 3812
   
3816
-          // ----- Return
3817
-          //return $v_result;
3818
-          $v_result = 1;
3819
-        }
3820
-      }
3821
-    }
3813
+		  // ----- Change the file status
3814
+		  $p_entry['status'] = "path_creation_fail";
3815
+  
3816
+		  // ----- Return
3817
+		  //return $v_result;
3818
+		  $v_result = 1;
3819
+		}
3820
+	  }
3821
+	}
3822 3822
 
3823
-    // ----- Look if extraction should be done
3824
-    if ($p_entry['status'] == 'ok') {
3823
+	// ----- Look if extraction should be done
3824
+	if ($p_entry['status'] == 'ok') {
3825 3825
 
3826
-      // ----- Do the extraction (if not a folder)
3827
-      if (!(($p_entry['external']&0x00000010)==0x00000010))
3828
-      {
3829
-        // ----- Look for not compressed file
3830
-        if ($p_entry['compression'] == 0) {
3826
+	  // ----- Do the extraction (if not a folder)
3827
+	  if (!(($p_entry['external']&0x00000010)==0x00000010))
3828
+	  {
3829
+		// ----- Look for not compressed file
3830
+		if ($p_entry['compression'] == 0) {
3831 3831
 
3832
-    		  // ----- Opening destination file
3833
-          if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0)
3834
-          {
3832
+			  // ----- Opening destination file
3833
+		  if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0)
3834
+		  {
3835 3835
 
3836
-            // ----- Change the file status
3837
-            $p_entry['status'] = "write_error";
3836
+			// ----- Change the file status
3837
+			$p_entry['status'] = "write_error";
3838 3838
 
3839
-            // ----- Return
3840
-            return $v_result;
3841
-          }
3839
+			// ----- Return
3840
+			return $v_result;
3841
+		  }
3842 3842
 
3843 3843
 
3844
-          // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
3845
-          $v_size = $p_entry['compressed_size'];
3846
-          while ($v_size != 0)
3847
-          {
3848
-            $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
3849
-            $v_buffer = @fread($this->zip_fd, $v_read_size);
3850
-            /* Try to speed up the code
3844
+		  // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
3845
+		  $v_size = $p_entry['compressed_size'];
3846
+		  while ($v_size != 0)
3847
+		  {
3848
+			$v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
3849
+			$v_buffer = @fread($this->zip_fd, $v_read_size);
3850
+			/* Try to speed up the code
3851 3851
             $v_binary_data = pack('a'.$v_read_size, $v_buffer);
3852 3852
             @fwrite($v_dest_file, $v_binary_data, $v_read_size);
3853 3853
             */
3854
-            @fwrite($v_dest_file, $v_buffer, $v_read_size);            
3855
-            $v_size -= $v_read_size;
3856
-          }
3854
+			@fwrite($v_dest_file, $v_buffer, $v_read_size);            
3855
+			$v_size -= $v_read_size;
3856
+		  }
3857 3857
 
3858
-          // ----- Closing the destination file
3859
-          fclose($v_dest_file);
3858
+		  // ----- Closing the destination file
3859
+		  fclose($v_dest_file);
3860 3860
 
3861
-          // ----- Change the file mtime
3862
-          touch($p_entry['filename'], $p_entry['mtime']);
3861
+		  // ----- Change the file mtime
3862
+		  touch($p_entry['filename'], $p_entry['mtime']);
3863 3863
           
3864 3864
 
3865
-        }
3866
-        else {
3867
-          // ----- TBC
3868
-          // Need to be finished
3869
-          if (($p_entry['flag'] & 1) == 1) {
3870
-            PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, 'File \''.$p_entry['filename'].'\' is encrypted. Encrypted files are not supported.');
3871
-            return PclZip::errorCode();
3872
-          }
3865
+		}
3866
+		else {
3867
+		  // ----- TBC
3868
+		  // Need to be finished
3869
+		  if (($p_entry['flag'] & 1) == 1) {
3870
+			PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, 'File \''.$p_entry['filename'].'\' is encrypted. Encrypted files are not supported.');
3871
+			return PclZip::errorCode();
3872
+		  }
3873 3873
 
3874 3874
 
3875
-          // ----- Look for using temporary file to unzip
3876
-          if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) 
3877
-              && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON])
3878
-                  || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
3879
-                      && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_entry['size'])) ) ) {
3880
-            $v_result = $this->privExtractFileUsingTempFile($p_entry, $p_options);
3881
-            if ($v_result < PCLZIP_ERR_NO_ERROR) {
3882
-              return $v_result;
3883
-            }
3884
-          }
3875
+		  // ----- Look for using temporary file to unzip
3876
+		  if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) 
3877
+			  && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON])
3878
+				  || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
3879
+					  && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_entry['size'])) ) ) {
3880
+			$v_result = $this->privExtractFileUsingTempFile($p_entry, $p_options);
3881
+			if ($v_result < PCLZIP_ERR_NO_ERROR) {
3882
+			  return $v_result;
3883
+			}
3884
+		  }
3885 3885
           
3886
-          // ----- Look for extract in memory
3887
-          else {
3886
+		  // ----- Look for extract in memory
3887
+		  else {
3888 3888
 
3889 3889
           
3890
-            // ----- Read the compressed file in a buffer (one shot)
3891
-            $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
3890
+			// ----- Read the compressed file in a buffer (one shot)
3891
+			$v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
3892 3892
             
3893
-            // ----- Decompress the file
3894
-            $v_file_content = @gzinflate($v_buffer);
3895
-            unset($v_buffer);
3896
-            if ($v_file_content === FALSE) {
3893
+			// ----- Decompress the file
3894
+			$v_file_content = @gzinflate($v_buffer);
3895
+			unset($v_buffer);
3896
+			if ($v_file_content === FALSE) {
3897 3897
   
3898
-              // ----- Change the file status
3899
-              // TBC
3900
-              $p_entry['status'] = "error";
3898
+			  // ----- Change the file status
3899
+			  // TBC
3900
+			  $p_entry['status'] = "error";
3901 3901
               
3902
-              return $v_result;
3903
-            }
3902
+			  return $v_result;
3903
+			}
3904 3904
             
3905
-            // ----- Opening destination file
3906
-            if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
3905
+			// ----- Opening destination file
3906
+			if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
3907 3907
   
3908
-              // ----- Change the file status
3909
-              $p_entry['status'] = "write_error";
3908
+			  // ----- Change the file status
3909
+			  $p_entry['status'] = "write_error";
3910 3910
   
3911
-              return $v_result;
3912
-            }
3911
+			  return $v_result;
3912
+			}
3913 3913
   
3914
-            // ----- Write the uncompressed data
3915
-            @fwrite($v_dest_file, $v_file_content, $p_entry['size']);
3916
-            unset($v_file_content);
3914
+			// ----- Write the uncompressed data
3915
+			@fwrite($v_dest_file, $v_file_content, $p_entry['size']);
3916
+			unset($v_file_content);
3917 3917
   
3918
-            // ----- Closing the destination file
3919
-            @fclose($v_dest_file);
3918
+			// ----- Closing the destination file
3919
+			@fclose($v_dest_file);
3920 3920
             
3921
-          }
3921
+		  }
3922 3922
 
3923
-          // ----- Change the file mtime
3924
-          @touch($p_entry['filename'], $p_entry['mtime']);
3925
-        }
3923
+		  // ----- Change the file mtime
3924
+		  @touch($p_entry['filename'], $p_entry['mtime']);
3925
+		}
3926 3926
 
3927
-        // ----- Look for chmod option
3928
-        if (isset($p_options[PCLZIP_OPT_SET_CHMOD])) {
3927
+		// ----- Look for chmod option
3928
+		if (isset($p_options[PCLZIP_OPT_SET_CHMOD])) {
3929 3929
 
3930
-          // ----- Change the mode of the file
3931
-          @chmod($p_entry['filename'], $p_options[PCLZIP_OPT_SET_CHMOD]);
3932
-        }
3930
+		  // ----- Change the mode of the file
3931
+		  @chmod($p_entry['filename'], $p_options[PCLZIP_OPT_SET_CHMOD]);
3932
+		}
3933 3933
 
3934
-      }
3935
-    }
3934
+	  }
3935
+	}
3936 3936
 
3937 3937
   	// ----- Change abort status
3938 3938
   	if ($p_entry['status'] == "aborted") {
3939
-        $p_entry['status'] = "skipped";
3939
+		$p_entry['status'] = "skipped";
3940 3940
   	}
3941 3941
 	
3942
-    // ----- Look for post-extract callback
3943
-    elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
3942
+	// ----- Look for post-extract callback
3943
+	elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
3944 3944
 
3945
-      // ----- Generate a local information
3946
-      $v_local_header = array();
3947
-      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
3945
+	  // ----- Generate a local information
3946
+	  $v_local_header = array();
3947
+	  $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
3948 3948
 
3949
-      // ----- Call the callback
3950
-      // Here I do not use call_user_func() because I need to send a reference to the
3951
-      // header.
3949
+	  // ----- Call the callback
3950
+	  // Here I do not use call_user_func() because I need to send a reference to the
3951
+	  // header.
3952 3952
 //      eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
3953
-      $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
3953
+	  $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
3954 3954
 
3955
-      // ----- Look for abort result
3956
-      if ($v_result == 2) {
3957
-      	$v_result = PCLZIP_ERR_USER_ABORTED;
3958
-      }
3959
-    }
3955
+	  // ----- Look for abort result
3956
+	  if ($v_result == 2) {
3957
+	  	$v_result = PCLZIP_ERR_USER_ABORTED;
3958
+	  }
3959
+	}
3960 3960
 
3961
-    // ----- Return
3962
-    return $v_result;
3961
+	// ----- Return
3962
+	return $v_result;
3963 3963
   }
3964 3964
   // --------------------------------------------------------------------------------
3965 3965
 
@@ -3971,71 +3971,71 @@  discard block
 block discarded – undo
3971 3971
   // --------------------------------------------------------------------------------
3972 3972
   function privExtractFileUsingTempFile(&$p_entry, &$p_options)
3973 3973
   {
3974
-    $v_result=1;
3974
+	$v_result=1;
3975 3975
         
3976
-    // ----- Creates a temporary file
3977
-    $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
3978
-    if (($v_dest_file = @fopen($v_gzip_temp_name, "wb")) == 0) {
3979
-      fclose($v_file);
3980
-      PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
3981
-      return PclZip::errorCode();
3982
-    }
3976
+	// ----- Creates a temporary file
3977
+	$v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
3978
+	if (($v_dest_file = @fopen($v_gzip_temp_name, "wb")) == 0) {
3979
+	  fclose($v_file);
3980
+	  PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
3981
+	  return PclZip::errorCode();
3982
+	}
3983 3983
 
3984 3984
 
3985
-    // ----- Write gz file format header
3986
-    $v_binary_data = pack('va1a1Va1a1', 0x8b1f, Chr($p_entry['compression']), Chr(0x00), time(), Chr(0x00), Chr(3));
3987
-    @fwrite($v_dest_file, $v_binary_data, 10);
3985
+	// ----- Write gz file format header
3986
+	$v_binary_data = pack('va1a1Va1a1', 0x8b1f, Chr($p_entry['compression']), Chr(0x00), time(), Chr(0x00), Chr(3));
3987
+	@fwrite($v_dest_file, $v_binary_data, 10);
3988 3988
 
3989
-    // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
3990
-    $v_size = $p_entry['compressed_size'];
3991
-    while ($v_size != 0)
3992
-    {
3993
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
3994
-      $v_buffer = @fread($this->zip_fd, $v_read_size);
3995
-      //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
3996
-      @fwrite($v_dest_file, $v_buffer, $v_read_size);
3997
-      $v_size -= $v_read_size;
3998
-    }
3989
+	// ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
3990
+	$v_size = $p_entry['compressed_size'];
3991
+	while ($v_size != 0)
3992
+	{
3993
+	  $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
3994
+	  $v_buffer = @fread($this->zip_fd, $v_read_size);
3995
+	  //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
3996
+	  @fwrite($v_dest_file, $v_buffer, $v_read_size);
3997
+	  $v_size -= $v_read_size;
3998
+	}
3999 3999
 
4000
-    // ----- Write gz file format footer
4001
-    $v_binary_data = pack('VV', $p_entry['crc'], $p_entry['size']);
4002
-    @fwrite($v_dest_file, $v_binary_data, 8);
4000
+	// ----- Write gz file format footer
4001
+	$v_binary_data = pack('VV', $p_entry['crc'], $p_entry['size']);
4002
+	@fwrite($v_dest_file, $v_binary_data, 8);
4003 4003
 
4004
-    // ----- Close the temporary file
4005
-    @fclose($v_dest_file);
4004
+	// ----- Close the temporary file
4005
+	@fclose($v_dest_file);
4006 4006
 
4007
-    // ----- Opening destination file
4008
-    if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
4009
-      $p_entry['status'] = "write_error";
4010
-      return $v_result;
4011
-    }
4007
+	// ----- Opening destination file
4008
+	if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
4009
+	  $p_entry['status'] = "write_error";
4010
+	  return $v_result;
4011
+	}
4012 4012
 
4013
-    // ----- Open the temporary gz file
4014
-    if (($v_src_file = @gzopen($v_gzip_temp_name, 'rb')) == 0) {
4015
-      @fclose($v_dest_file);
4016
-      $p_entry['status'] = "read_error";
4017
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
4018
-      return PclZip::errorCode();
4019
-    }
4013
+	// ----- Open the temporary gz file
4014
+	if (($v_src_file = @gzopen($v_gzip_temp_name, 'rb')) == 0) {
4015
+	  @fclose($v_dest_file);
4016
+	  $p_entry['status'] = "read_error";
4017
+	  PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
4018
+	  return PclZip::errorCode();
4019
+	}
4020 4020
 
4021 4021
 
4022
-    // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
4023
-    $v_size = $p_entry['size'];
4024
-    while ($v_size != 0) {
4025
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
4026
-      $v_buffer = @gzread($v_src_file, $v_read_size);
4027
-      //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
4028
-      @fwrite($v_dest_file, $v_buffer, $v_read_size);
4029
-      $v_size -= $v_read_size;
4030
-    }
4031
-    @fclose($v_dest_file);
4032
-    @gzclose($v_src_file);
4022
+	// ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
4023
+	$v_size = $p_entry['size'];
4024
+	while ($v_size != 0) {
4025
+	  $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
4026
+	  $v_buffer = @gzread($v_src_file, $v_read_size);
4027
+	  //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
4028
+	  @fwrite($v_dest_file, $v_buffer, $v_read_size);
4029
+	  $v_size -= $v_read_size;
4030
+	}
4031
+	@fclose($v_dest_file);
4032
+	@gzclose($v_src_file);
4033 4033
 
4034
-    // ----- Delete the temporary file
4035
-    @unlink($v_gzip_temp_name);
4034
+	// ----- Delete the temporary file
4035
+	@unlink($v_gzip_temp_name);
4036 4036
     
4037
-    // ----- Return
4038
-    return $v_result;
4037
+	// ----- Return
4038
+	return $v_result;
4039 4039
   }
4040 4040
   // --------------------------------------------------------------------------------
4041 4041
 
@@ -4047,107 +4047,107 @@  discard block
 block discarded – undo
4047 4047
   // --------------------------------------------------------------------------------
4048 4048
   function privExtractFileInOutput(&$p_entry, &$p_options)
4049 4049
   {
4050
-    $v_result=1;
4050
+	$v_result=1;
4051 4051
 
4052
-    // ----- Read the file header
4053
-    if (($v_result = $this->privReadFileHeader($v_header)) != 1) {
4054
-      return $v_result;
4055
-    }
4052
+	// ----- Read the file header
4053
+	if (($v_result = $this->privReadFileHeader($v_header)) != 1) {
4054
+	  return $v_result;
4055
+	}
4056 4056
 
4057 4057
 
4058
-    // ----- Check that the file header is coherent with $p_entry info
4059
-    if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
4060
-        // TBC
4061
-    }
4058
+	// ----- Check that the file header is coherent with $p_entry info
4059
+	if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
4060
+		// TBC
4061
+	}
4062 4062
 
4063
-    // ----- Look for pre-extract callback
4064
-    if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
4063
+	// ----- Look for pre-extract callback
4064
+	if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
4065 4065
 
4066
-      // ----- Generate a local information
4067
-      $v_local_header = array();
4068
-      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4066
+	  // ----- Generate a local information
4067
+	  $v_local_header = array();
4068
+	  $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4069 4069
 
4070
-      // ----- Call the callback
4071
-      // Here I do not use call_user_func() because I need to send a reference to the
4072
-      // header.
4070
+	  // ----- Call the callback
4071
+	  // Here I do not use call_user_func() because I need to send a reference to the
4072
+	  // header.
4073 4073
 //      eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
4074
-      $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
4075
-      if ($v_result == 0) {
4076
-        // ----- Change the file status
4077
-        $p_entry['status'] = "skipped";
4078
-        $v_result = 1;
4079
-      }
4074
+	  $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
4075
+	  if ($v_result == 0) {
4076
+		// ----- Change the file status
4077
+		$p_entry['status'] = "skipped";
4078
+		$v_result = 1;
4079
+	  }
4080 4080
 
4081
-      // ----- Look for abort result
4082
-      if ($v_result == 2) {
4083
-        // ----- This status is internal and will be changed in 'skipped'
4084
-        $p_entry['status'] = "aborted";
4085
-      	$v_result = PCLZIP_ERR_USER_ABORTED;
4086
-      }
4081
+	  // ----- Look for abort result
4082
+	  if ($v_result == 2) {
4083
+		// ----- This status is internal and will be changed in 'skipped'
4084
+		$p_entry['status'] = "aborted";
4085
+	  	$v_result = PCLZIP_ERR_USER_ABORTED;
4086
+	  }
4087 4087
 
4088
-      // ----- Update the informations
4089
-      // Only some fields can be modified
4090
-      $p_entry['filename'] = $v_local_header['filename'];
4091
-    }
4088
+	  // ----- Update the informations
4089
+	  // Only some fields can be modified
4090
+	  $p_entry['filename'] = $v_local_header['filename'];
4091
+	}
4092 4092
 
4093
-    // ----- Trace
4093
+	// ----- Trace
4094 4094
 
4095
-    // ----- Look if extraction should be done
4096
-    if ($p_entry['status'] == 'ok') {
4095
+	// ----- Look if extraction should be done
4096
+	if ($p_entry['status'] == 'ok') {
4097 4097
 
4098
-      // ----- Do the extraction (if not a folder)
4099
-      if (!(($p_entry['external']&0x00000010)==0x00000010)) {
4100
-        // ----- Look for not compressed file
4101
-        if ($p_entry['compressed_size'] == $p_entry['size']) {
4098
+	  // ----- Do the extraction (if not a folder)
4099
+	  if (!(($p_entry['external']&0x00000010)==0x00000010)) {
4100
+		// ----- Look for not compressed file
4101
+		if ($p_entry['compressed_size'] == $p_entry['size']) {
4102 4102
 
4103
-          // ----- Read the file in a buffer (one shot)
4104
-          $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
4103
+		  // ----- Read the file in a buffer (one shot)
4104
+		  $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
4105 4105
 
4106
-          // ----- Send the file to the output
4107
-          echo $v_buffer;
4108
-          unset($v_buffer);
4109
-        }
4110
-        else {
4106
+		  // ----- Send the file to the output
4107
+		  echo $v_buffer;
4108
+		  unset($v_buffer);
4109
+		}
4110
+		else {
4111 4111
 
4112
-          // ----- Read the compressed file in a buffer (one shot)
4113
-          $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
4112
+		  // ----- Read the compressed file in a buffer (one shot)
4113
+		  $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
4114 4114
           
4115
-          // ----- Decompress the file
4116
-          $v_file_content = gzinflate($v_buffer);
4117
-          unset($v_buffer);
4118
-
4119
-          // ----- Send the file to the output
4120
-          echo $v_file_content;
4121
-          unset($v_file_content);
4122
-        }
4123
-      }
4124
-    }
4115
+		  // ----- Decompress the file
4116
+		  $v_file_content = gzinflate($v_buffer);
4117
+		  unset($v_buffer);
4118
+
4119
+		  // ----- Send the file to the output
4120
+		  echo $v_file_content;
4121
+		  unset($v_file_content);
4122
+		}
4123
+	  }
4124
+	}
4125 4125
 
4126 4126
 	// ----- Change abort status
4127 4127
 	if ($p_entry['status'] == "aborted") {
4128
-      $p_entry['status'] = "skipped";
4128
+	  $p_entry['status'] = "skipped";
4129 4129
 	}
4130 4130
 
4131
-    // ----- Look for post-extract callback
4132
-    elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
4131
+	// ----- Look for post-extract callback
4132
+	elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
4133 4133
 
4134
-      // ----- Generate a local information
4135
-      $v_local_header = array();
4136
-      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4134
+	  // ----- Generate a local information
4135
+	  $v_local_header = array();
4136
+	  $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4137 4137
 
4138
-      // ----- Call the callback
4139
-      // Here I do not use call_user_func() because I need to send a reference to the
4140
-      // header.
4138
+	  // ----- Call the callback
4139
+	  // Here I do not use call_user_func() because I need to send a reference to the
4140
+	  // header.
4141 4141
 //      eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
4142
-      $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
4142
+	  $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
4143 4143
 
4144
-      // ----- Look for abort result
4145
-      if ($v_result == 2) {
4146
-      	$v_result = PCLZIP_ERR_USER_ABORTED;
4147
-      }
4148
-    }
4144
+	  // ----- Look for abort result
4145
+	  if ($v_result == 2) {
4146
+	  	$v_result = PCLZIP_ERR_USER_ABORTED;
4147
+	  }
4148
+	}
4149 4149
 
4150
-    return $v_result;
4150
+	return $v_result;
4151 4151
   }
4152 4152
   // --------------------------------------------------------------------------------
4153 4153
 
@@ -4159,118 +4159,118 @@  discard block
 block discarded – undo
4159 4159
   // --------------------------------------------------------------------------------
4160 4160
   function privExtractFileAsString(&$p_entry, &$p_string, &$p_options)
4161 4161
   {
4162
-    $v_result=1;
4163
-
4164
-    // ----- Read the file header
4165
-    $v_header = array();
4166
-    if (($v_result = $this->privReadFileHeader($v_header)) != 1)
4167
-    {
4168
-      // ----- Return
4169
-      return $v_result;
4170
-    }
4162
+	$v_result=1;
4163
+
4164
+	// ----- Read the file header
4165
+	$v_header = array();
4166
+	if (($v_result = $this->privReadFileHeader($v_header)) != 1)
4167
+	{
4168
+	  // ----- Return
4169
+	  return $v_result;
4170
+	}
4171 4171
 
4172 4172
 
4173
-    // ----- Check that the file header is coherent with $p_entry info
4174
-    if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
4175
-        // TBC
4176
-    }
4173
+	// ----- Check that the file header is coherent with $p_entry info
4174
+	if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
4175
+		// TBC
4176
+	}
4177 4177
 
4178
-    // ----- Look for pre-extract callback
4179
-    if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
4178
+	// ----- Look for pre-extract callback
4179
+	if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
4180 4180
 
4181
-      // ----- Generate a local information
4182
-      $v_local_header = array();
4183
-      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4181
+	  // ----- Generate a local information
4182
+	  $v_local_header = array();
4183
+	  $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4184 4184
 
4185
-      // ----- Call the callback
4186
-      // Here I do not use call_user_func() because I need to send a reference to the
4187
-      // header.
4185
+	  // ----- Call the callback
4186
+	  // Here I do not use call_user_func() because I need to send a reference to the
4187
+	  // header.
4188 4188
 //      eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
4189
-      $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
4190
-      if ($v_result == 0) {
4191
-        // ----- Change the file status
4192
-        $p_entry['status'] = "skipped";
4193
-        $v_result = 1;
4194
-      }
4189
+	  $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
4190
+	  if ($v_result == 0) {
4191
+		// ----- Change the file status
4192
+		$p_entry['status'] = "skipped";
4193
+		$v_result = 1;
4194
+	  }
4195 4195
       
4196
-      // ----- Look for abort result
4197
-      if ($v_result == 2) {
4198
-        // ----- This status is internal and will be changed in 'skipped'
4199
-        $p_entry['status'] = "aborted";
4200
-      	$v_result = PCLZIP_ERR_USER_ABORTED;
4201
-      }
4196
+	  // ----- Look for abort result
4197
+	  if ($v_result == 2) {
4198
+		// ----- This status is internal and will be changed in 'skipped'
4199
+		$p_entry['status'] = "aborted";
4200
+	  	$v_result = PCLZIP_ERR_USER_ABORTED;
4201
+	  }
4202 4202
 
4203
-      // ----- Update the informations
4204
-      // Only some fields can be modified
4205
-      $p_entry['filename'] = $v_local_header['filename'];
4206
-    }
4203
+	  // ----- Update the informations
4204
+	  // Only some fields can be modified
4205
+	  $p_entry['filename'] = $v_local_header['filename'];
4206
+	}
4207 4207
 
4208 4208
 
4209
-    // ----- Look if extraction should be done
4210
-    if ($p_entry['status'] == 'ok') {
4209
+	// ----- Look if extraction should be done
4210
+	if ($p_entry['status'] == 'ok') {
4211 4211
 
4212
-      // ----- Do the extraction (if not a folder)
4213
-      if (!(($p_entry['external']&0x00000010)==0x00000010)) {
4214
-        // ----- Look for not compressed file
4212
+	  // ----- Do the extraction (if not a folder)
4213
+	  if (!(($p_entry['external']&0x00000010)==0x00000010)) {
4214
+		// ----- Look for not compressed file
4215 4215
   //      if ($p_entry['compressed_size'] == $p_entry['size'])
4216
-        if ($p_entry['compression'] == 0) {
4216
+		if ($p_entry['compression'] == 0) {
4217 4217
   
4218
-          // ----- Reading the file
4219
-          $p_string = @fread($this->zip_fd, $p_entry['compressed_size']);
4220
-        }
4221
-        else {
4218
+		  // ----- Reading the file
4219
+		  $p_string = @fread($this->zip_fd, $p_entry['compressed_size']);
4220
+		}
4221
+		else {
4222 4222
   
4223
-          // ----- Reading the file
4224
-          $v_data = @fread($this->zip_fd, $p_entry['compressed_size']);
4223
+		  // ----- Reading the file
4224
+		  $v_data = @fread($this->zip_fd, $p_entry['compressed_size']);
4225 4225
           
4226
-          // ----- Decompress the file
4227
-          if (($p_string = @gzinflate($v_data)) === FALSE) {
4228
-              // TBC
4229
-          }
4230
-        }
4226
+		  // ----- Decompress the file
4227
+		  if (($p_string = @gzinflate($v_data)) === FALSE) {
4228
+			  // TBC
4229
+		  }
4230
+		}
4231 4231
   
4232
-        // ----- Trace
4233
-      }
4234
-      else {
4235
-          // TBC : error : can not extract a folder in a string
4236
-      }
4232
+		// ----- Trace
4233
+	  }
4234
+	  else {
4235
+		  // TBC : error : can not extract a folder in a string
4236
+	  }
4237 4237
       
4238
-    }
4238
+	}
4239 4239
 
4240 4240
   	// ----- Change abort status
4241 4241
   	if ($p_entry['status'] == "aborted") {
4242
-        $p_entry['status'] = "skipped";
4242
+		$p_entry['status'] = "skipped";
4243 4243
   	}
4244 4244
 	
4245
-    // ----- Look for post-extract callback
4246
-    elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
4245
+	// ----- Look for post-extract callback
4246
+	elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
4247 4247
 
4248
-      // ----- Generate a local information
4249
-      $v_local_header = array();
4250
-      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4248
+	  // ----- Generate a local information
4249
+	  $v_local_header = array();
4250
+	  $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4251 4251
       
4252
-      // ----- Swap the content to header
4253
-      $v_local_header['content'] = $p_string;
4254
-      $p_string = '';
4252
+	  // ----- Swap the content to header
4253
+	  $v_local_header['content'] = $p_string;
4254
+	  $p_string = '';
4255 4255
 
4256
-      // ----- Call the callback
4257
-      // Here I do not use call_user_func() because I need to send a reference to the
4258
-      // header.
4256
+	  // ----- Call the callback
4257
+	  // Here I do not use call_user_func() because I need to send a reference to the
4258
+	  // header.
4259 4259
 //      eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
4260
-      $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
4260
+	  $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
4261 4261
 
4262
-      // ----- Swap back the content to header
4263
-      $p_string = $v_local_header['content'];
4264
-      unset($v_local_header['content']);
4262
+	  // ----- Swap back the content to header
4263
+	  $p_string = $v_local_header['content'];
4264
+	  unset($v_local_header['content']);
4265 4265
 
4266
-      // ----- Look for abort result
4267
-      if ($v_result == 2) {
4268
-      	$v_result = PCLZIP_ERR_USER_ABORTED;
4269
-      }
4270
-    }
4266
+	  // ----- Look for abort result
4267
+	  if ($v_result == 2) {
4268
+	  	$v_result = PCLZIP_ERR_USER_ABORTED;
4269
+	  }
4270
+	}
4271 4271
 
4272
-    // ----- Return
4273
-    return $v_result;
4272
+	// ----- Return
4273
+	return $v_result;
4274 4274
   }
4275 4275
   // --------------------------------------------------------------------------------
4276 4276
 
@@ -4282,98 +4282,98 @@  discard block
 block discarded – undo
4282 4282
   // --------------------------------------------------------------------------------
4283 4283
   function privReadFileHeader(&$p_header)
4284 4284
   {
4285
-    $v_result=1;
4285
+	$v_result=1;
4286 4286
 
4287
-    // ----- Read the 4 bytes signature
4288
-    $v_binary_data = @fread($this->zip_fd, 4);
4289
-    $v_data = unpack('Vid', $v_binary_data);
4287
+	// ----- Read the 4 bytes signature
4288
+	$v_binary_data = @fread($this->zip_fd, 4);
4289
+	$v_data = unpack('Vid', $v_binary_data);
4290 4290
 
4291
-    // ----- Check signature
4292
-    if ($v_data['id'] != 0x04034b50)
4293
-    {
4291
+	// ----- Check signature
4292
+	if ($v_data['id'] != 0x04034b50)
4293
+	{
4294 4294
 
4295
-      // ----- Error log
4296
-      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
4295
+	  // ----- Error log
4296
+	  PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
4297 4297
 
4298
-      // ----- Return
4299
-      return PclZip::errorCode();
4300
-    }
4298
+	  // ----- Return
4299
+	  return PclZip::errorCode();
4300
+	}
4301 4301
 
4302
-    // ----- Read the first 42 bytes of the header
4303
-    $v_binary_data = fread($this->zip_fd, 26);
4302
+	// ----- Read the first 42 bytes of the header
4303
+	$v_binary_data = fread($this->zip_fd, 26);
4304 4304
 
4305
-    // ----- Look for invalid block size
4306
-    if (strlen($v_binary_data) != 26)
4307
-    {
4308
-      $p_header['filename'] = "";
4309
-      $p_header['status'] = "invalid_header";
4305
+	// ----- Look for invalid block size
4306
+	if (strlen($v_binary_data) != 26)
4307
+	{
4308
+	  $p_header['filename'] = "";
4309
+	  $p_header['status'] = "invalid_header";
4310 4310
 
4311
-      // ----- Error log
4312
-      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
4311
+	  // ----- Error log
4312
+	  PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
4313 4313
 
4314
-      // ----- Return
4315
-      return PclZip::errorCode();
4316
-    }
4314
+	  // ----- Return
4315
+	  return PclZip::errorCode();
4316
+	}
4317 4317
 
4318
-    // ----- Extract the values
4319
-    $v_data = unpack('vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len', $v_binary_data);
4318
+	// ----- Extract the values
4319
+	$v_data = unpack('vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len', $v_binary_data);
4320 4320
 
4321
-    // ----- Get filename
4322
-    $p_header['filename'] = fread($this->zip_fd, $v_data['filename_len']);
4321
+	// ----- Get filename
4322
+	$p_header['filename'] = fread($this->zip_fd, $v_data['filename_len']);
4323 4323
 
4324
-    // ----- Get extra_fields
4325
-    if ($v_data['extra_len'] != 0) {
4326
-      $p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']);
4327
-    }
4328
-    else {
4329
-      $p_header['extra'] = '';
4330
-    }
4324
+	// ----- Get extra_fields
4325
+	if ($v_data['extra_len'] != 0) {
4326
+	  $p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']);
4327
+	}
4328
+	else {
4329
+	  $p_header['extra'] = '';
4330
+	}
4331 4331
 
4332
-    // ----- Extract properties
4333
-    $p_header['version_extracted'] = $v_data['version'];
4334
-    $p_header['compression'] = $v_data['compression'];
4335
-    $p_header['size'] = $v_data['size'];
4336
-    $p_header['compressed_size'] = $v_data['compressed_size'];
4337
-    $p_header['crc'] = $v_data['crc'];
4338
-    $p_header['flag'] = $v_data['flag'];
4339
-    $p_header['filename_len'] = $v_data['filename_len'];
4340
-
4341
-    // ----- Recuperate date in UNIX format
4342
-    $p_header['mdate'] = $v_data['mdate'];
4343
-    $p_header['mtime'] = $v_data['mtime'];
4344
-    if ($p_header['mdate'] && $p_header['mtime'])
4345
-    {
4346
-      // ----- Extract time
4347
-      $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
4348
-      $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
4349
-      $v_seconde = ($p_header['mtime'] & 0x001F)*2;
4350
-
4351
-      // ----- Extract date
4352
-      $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
4353
-      $v_month = ($p_header['mdate'] & 0x01E0) >> 5;
4354
-      $v_day = $p_header['mdate'] & 0x001F;
4355
-
4356
-      // ----- Get UNIX date format
4357
-      $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
4332
+	// ----- Extract properties
4333
+	$p_header['version_extracted'] = $v_data['version'];
4334
+	$p_header['compression'] = $v_data['compression'];
4335
+	$p_header['size'] = $v_data['size'];
4336
+	$p_header['compressed_size'] = $v_data['compressed_size'];
4337
+	$p_header['crc'] = $v_data['crc'];
4338
+	$p_header['flag'] = $v_data['flag'];
4339
+	$p_header['filename_len'] = $v_data['filename_len'];
4340
+
4341
+	// ----- Recuperate date in UNIX format
4342
+	$p_header['mdate'] = $v_data['mdate'];
4343
+	$p_header['mtime'] = $v_data['mtime'];
4344
+	if ($p_header['mdate'] && $p_header['mtime'])
4345
+	{
4346
+	  // ----- Extract time
4347
+	  $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
4348
+	  $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
4349
+	  $v_seconde = ($p_header['mtime'] & 0x001F)*2;
4350
+
4351
+	  // ----- Extract date
4352
+	  $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
4353
+	  $v_month = ($p_header['mdate'] & 0x01E0) >> 5;
4354
+	  $v_day = $p_header['mdate'] & 0x001F;
4355
+
4356
+	  // ----- Get UNIX date format
4357
+	  $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
4358 4358
 
4359
-    }
4360
-    else
4361
-    {
4362
-      $p_header['mtime'] = time();
4363
-    }
4359
+	}
4360
+	else
4361
+	{
4362
+	  $p_header['mtime'] = time();
4363
+	}
4364 4364
 
4365
-    // TBC
4366
-    //for(reset($v_data); $key = key($v_data); next($v_data)) {
4367
-    //}
4365
+	// TBC
4366
+	//for(reset($v_data); $key = key($v_data); next($v_data)) {
4367
+	//}
4368 4368
 
4369
-    // ----- Set the stored filename
4370
-    $p_header['stored_filename'] = $p_header['filename'];
4369
+	// ----- Set the stored filename
4370
+	$p_header['stored_filename'] = $p_header['filename'];
4371 4371
 
4372
-    // ----- Set the status field
4373
-    $p_header['status'] = "ok";
4372
+	// ----- Set the status field
4373
+	$p_header['status'] = "ok";
4374 4374
 
4375
-    // ----- Return
4376
-    return $v_result;
4375
+	// ----- Return
4376
+	return $v_result;
4377 4377
   }
4378 4378
   // --------------------------------------------------------------------------------
4379 4379
 
@@ -4385,101 +4385,101 @@  discard block
 block discarded – undo
4385 4385
   // --------------------------------------------------------------------------------
4386 4386
   function privReadCentralFileHeader(&$p_header)
4387 4387
   {
4388
-    $v_result=1;
4388
+	$v_result=1;
4389 4389
 
4390
-    // ----- Read the 4 bytes signature
4391
-    $v_binary_data = @fread($this->zip_fd, 4);
4392
-    $v_data = unpack('Vid', $v_binary_data);
4390
+	// ----- Read the 4 bytes signature
4391
+	$v_binary_data = @fread($this->zip_fd, 4);
4392
+	$v_data = unpack('Vid', $v_binary_data);
4393 4393
 
4394
-    // ----- Check signature
4395
-    if ($v_data['id'] != 0x02014b50)
4396
-    {
4394
+	// ----- Check signature
4395
+	if ($v_data['id'] != 0x02014b50)
4396
+	{
4397 4397
 
4398
-      // ----- Error log
4399
-      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
4398
+	  // ----- Error log
4399
+	  PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
4400 4400
 
4401
-      // ----- Return
4402
-      return PclZip::errorCode();
4403
-    }
4401
+	  // ----- Return
4402
+	  return PclZip::errorCode();
4403
+	}
4404 4404
 
4405
-    // ----- Read the first 42 bytes of the header
4406
-    $v_binary_data = fread($this->zip_fd, 42);
4405
+	// ----- Read the first 42 bytes of the header
4406
+	$v_binary_data = fread($this->zip_fd, 42);
4407 4407
 
4408
-    // ----- Look for invalid block size
4409
-    if (strlen($v_binary_data) != 42)
4410
-    {
4411
-      $p_header['filename'] = "";
4412
-      $p_header['status'] = "invalid_header";
4408
+	// ----- Look for invalid block size
4409
+	if (strlen($v_binary_data) != 42)
4410
+	{
4411
+	  $p_header['filename'] = "";
4412
+	  $p_header['status'] = "invalid_header";
4413 4413
 
4414
-      // ----- Error log
4415
-      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
4414
+	  // ----- Error log
4415
+	  PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
4416 4416
 
4417
-      // ----- Return
4418
-      return PclZip::errorCode();
4419
-    }
4417
+	  // ----- Return
4418
+	  return PclZip::errorCode();
4419
+	}
4420 4420
 
4421
-    // ----- Extract the values
4422
-    $p_header = unpack('vversion/vversion_extracted/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len/vcomment_len/vdisk/vinternal/Vexternal/Voffset', $v_binary_data);
4423
-
4424
-    // ----- Get filename
4425
-    if ($p_header['filename_len'] != 0)
4426
-      $p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']);
4427
-    else
4428
-      $p_header['filename'] = '';
4429
-
4430
-    // ----- Get extra
4431
-    if ($p_header['extra_len'] != 0)
4432
-      $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']);
4433
-    else
4434
-      $p_header['extra'] = '';
4435
-
4436
-    // ----- Get comment
4437
-    if ($p_header['comment_len'] != 0)
4438
-      $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']);
4439
-    else
4440
-      $p_header['comment'] = '';
4441
-
4442
-    // ----- Extract properties
4443
-
4444
-    // ----- Recuperate date in UNIX format
4445
-    //if ($p_header['mdate'] && $p_header['mtime'])
4446
-    // TBC : bug : this was ignoring time with 0/0/0
4447
-    if (1)
4448
-    {
4449
-      // ----- Extract time
4450
-      $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
4451
-      $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
4452
-      $v_seconde = ($p_header['mtime'] & 0x001F)*2;
4453
-
4454
-      // ----- Extract date
4455
-      $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
4456
-      $v_month = ($p_header['mdate'] & 0x01E0) >> 5;
4457
-      $v_day = $p_header['mdate'] & 0x001F;
4458
-
4459
-      // ----- Get UNIX date format
4460
-      $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
4421
+	// ----- Extract the values
4422
+	$p_header = unpack('vversion/vversion_extracted/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len/vcomment_len/vdisk/vinternal/Vexternal/Voffset', $v_binary_data);
4423
+
4424
+	// ----- Get filename
4425
+	if ($p_header['filename_len'] != 0)
4426
+	  $p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']);
4427
+	else
4428
+	  $p_header['filename'] = '';
4429
+
4430
+	// ----- Get extra
4431
+	if ($p_header['extra_len'] != 0)
4432
+	  $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']);
4433
+	else
4434
+	  $p_header['extra'] = '';
4435
+
4436
+	// ----- Get comment
4437
+	if ($p_header['comment_len'] != 0)
4438
+	  $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']);
4439
+	else
4440
+	  $p_header['comment'] = '';
4441
+
4442
+	// ----- Extract properties
4443
+
4444
+	// ----- Recuperate date in UNIX format
4445
+	//if ($p_header['mdate'] && $p_header['mtime'])
4446
+	// TBC : bug : this was ignoring time with 0/0/0
4447
+	if (1)
4448
+	{
4449
+	  // ----- Extract time
4450
+	  $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
4451
+	  $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
4452
+	  $v_seconde = ($p_header['mtime'] & 0x001F)*2;
4453
+
4454
+	  // ----- Extract date
4455
+	  $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
4456
+	  $v_month = ($p_header['mdate'] & 0x01E0) >> 5;
4457
+	  $v_day = $p_header['mdate'] & 0x001F;
4458
+
4459
+	  // ----- Get UNIX date format
4460
+	  $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
4461 4461
 
4462
-    }
4463
-    else
4464
-    {
4465
-      $p_header['mtime'] = time();
4466
-    }
4462
+	}
4463
+	else
4464
+	{
4465
+	  $p_header['mtime'] = time();
4466
+	}
4467 4467
 
4468
-    // ----- Set the stored filename
4469
-    $p_header['stored_filename'] = $p_header['filename'];
4468
+	// ----- Set the stored filename
4469
+	$p_header['stored_filename'] = $p_header['filename'];
4470 4470
 
4471
-    // ----- Set default status to ok
4472
-    $p_header['status'] = 'ok';
4471
+	// ----- Set default status to ok
4472
+	$p_header['status'] = 'ok';
4473 4473
 
4474
-    // ----- Look if it is a directory
4475
-    if (substr($p_header['filename'], -1) == '/') {
4476
-      //$p_header['external'] = 0x41FF0010;
4477
-      $p_header['external'] = 0x00000010;
4478
-    }
4474
+	// ----- Look if it is a directory
4475
+	if (substr($p_header['filename'], -1) == '/') {
4476
+	  //$p_header['external'] = 0x41FF0010;
4477
+	  $p_header['external'] = 0x00000010;
4478
+	}
4479 4479
 
4480 4480
 
4481
-    // ----- Return
4482
-    return $v_result;
4481
+	// ----- Return
4482
+	return $v_result;
4483 4483
   }
4484 4484
   // --------------------------------------------------------------------------------
4485 4485
 
@@ -4493,7 +4493,7 @@  discard block
 block discarded – undo
4493 4493
   // --------------------------------------------------------------------------------
4494 4494
   function privCheckFileHeaders(&$p_local_header, &$p_central_header)
4495 4495
   {
4496
-    $v_result=1;
4496
+	$v_result=1;
4497 4497
 
4498 4498
   	// ----- Check the static values
4499 4499
   	// TBC
@@ -4512,13 +4512,13 @@  discard block
 block discarded – undo
4512 4512
   
4513 4513
   	// ----- Look for flag bit 3
4514 4514
   	if (($p_local_header['flag'] & 8) == 8) {
4515
-          $p_local_header['size'] = $p_central_header['size'];
4516
-          $p_local_header['compressed_size'] = $p_central_header['compressed_size'];
4517
-          $p_local_header['crc'] = $p_central_header['crc'];
4515
+		  $p_local_header['size'] = $p_central_header['size'];
4516
+		  $p_local_header['compressed_size'] = $p_central_header['compressed_size'];
4517
+		  $p_local_header['crc'] = $p_central_header['crc'];
4518 4518
   	}
4519 4519
 
4520
-    // ----- Return
4521
-    return $v_result;
4520
+	// ----- Return
4521
+	return $v_result;
4522 4522
   }
4523 4523
   // --------------------------------------------------------------------------------
4524 4524
 
@@ -4530,152 +4530,152 @@  discard block
 block discarded – undo
4530 4530
   // --------------------------------------------------------------------------------
4531 4531
   function privReadEndCentralDir(&$p_central_dir)
4532 4532
   {
4533
-    $v_result=1;
4534
-
4535
-    // ----- Go to the end of the zip file
4536
-    $v_size = filesize($this->zipname);
4537
-    @fseek($this->zip_fd, $v_size);
4538
-    if (@ftell($this->zip_fd) != $v_size)
4539
-    {
4540
-      // ----- Error log
4541
-      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \''.$this->zipname.'\'');
4542
-
4543
-      // ----- Return
4544
-      return PclZip::errorCode();
4545
-    }
4533
+	$v_result=1;
4534
+
4535
+	// ----- Go to the end of the zip file
4536
+	$v_size = filesize($this->zipname);
4537
+	@fseek($this->zip_fd, $v_size);
4538
+	if (@ftell($this->zip_fd) != $v_size)
4539
+	{
4540
+	  // ----- Error log
4541
+	  PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \''.$this->zipname.'\'');
4542
+
4543
+	  // ----- Return
4544
+	  return PclZip::errorCode();
4545
+	}
4546 4546
 
4547
-    // ----- First try : look if this is an archive with no commentaries (most of the time)
4548
-    // in this case the end of central dir is at 22 bytes of the file end
4549
-    $v_found = 0;
4550
-    if ($v_size > 26) {
4551
-      @fseek($this->zip_fd, $v_size-22);
4552
-      if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22))
4553
-      {
4554
-        // ----- Error log
4555
-        PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
4556
-
4557
-        // ----- Return
4558
-        return PclZip::errorCode();
4559
-      }
4547
+	// ----- First try : look if this is an archive with no commentaries (most of the time)
4548
+	// in this case the end of central dir is at 22 bytes of the file end
4549
+	$v_found = 0;
4550
+	if ($v_size > 26) {
4551
+	  @fseek($this->zip_fd, $v_size-22);
4552
+	  if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22))
4553
+	  {
4554
+		// ----- Error log
4555
+		PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
4556
+
4557
+		// ----- Return
4558
+		return PclZip::errorCode();
4559
+	  }
4560 4560
 
4561
-      // ----- Read for bytes
4562
-      $v_binary_data = @fread($this->zip_fd, 4);
4563
-      $v_data = @unpack('Vid', $v_binary_data);
4561
+	  // ----- Read for bytes
4562
+	  $v_binary_data = @fread($this->zip_fd, 4);
4563
+	  $v_data = @unpack('Vid', $v_binary_data);
4564 4564
 
4565
-      // ----- Check signature
4566
-      if ($v_data['id'] == 0x06054b50) {
4567
-        $v_found = 1;
4568
-      }
4565
+	  // ----- Check signature
4566
+	  if ($v_data['id'] == 0x06054b50) {
4567
+		$v_found = 1;
4568
+	  }
4569 4569
 
4570
-      $v_pos = ftell($this->zip_fd);
4571
-    }
4570
+	  $v_pos = ftell($this->zip_fd);
4571
+	}
4572 4572
 
4573
-    // ----- Go back to the maximum possible size of the Central Dir End Record
4574
-    if (!$v_found) {
4575
-      $v_maximum_size = 65557; // 0xFFFF + 22;
4576
-      if ($v_maximum_size > $v_size)
4577
-        $v_maximum_size = $v_size;
4578
-      @fseek($this->zip_fd, $v_size-$v_maximum_size);
4579
-      if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size))
4580
-      {
4581
-        // ----- Error log
4582
-        PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
4583
-
4584
-        // ----- Return
4585
-        return PclZip::errorCode();
4586
-      }
4573
+	// ----- Go back to the maximum possible size of the Central Dir End Record
4574
+	if (!$v_found) {
4575
+	  $v_maximum_size = 65557; // 0xFFFF + 22;
4576
+	  if ($v_maximum_size > $v_size)
4577
+		$v_maximum_size = $v_size;
4578
+	  @fseek($this->zip_fd, $v_size-$v_maximum_size);
4579
+	  if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size))
4580
+	  {
4581
+		// ----- Error log
4582
+		PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
4583
+
4584
+		// ----- Return
4585
+		return PclZip::errorCode();
4586
+	  }
4587 4587
 
4588
-      // ----- Read byte per byte in order to find the signature
4589
-      $v_pos = ftell($this->zip_fd);
4590
-      $v_bytes = 0x00000000;
4591
-      while ($v_pos < $v_size)
4592
-      {
4593
-        // ----- Read a byte
4594
-        $v_byte = @fread($this->zip_fd, 1);
4595
-
4596
-        // -----  Add the byte
4597
-        //$v_bytes = ($v_bytes << 8) | Ord($v_byte);
4598
-        // Note we mask the old value down such that once shifted we can never end up with more than a 32bit number 
4599
-        // Otherwise on systems where we have 64bit integers the check below for the magic number will fail. 
4600
-        $v_bytes = ( ($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte); 
4601
-
4602
-        // ----- Compare the bytes
4603
-        if ($v_bytes == 0x504b0506)
4604
-        {
4605
-          $v_pos++;
4606
-          break;
4607
-        }
4608
-
4609
-        $v_pos++;
4610
-      }
4588
+	  // ----- Read byte per byte in order to find the signature
4589
+	  $v_pos = ftell($this->zip_fd);
4590
+	  $v_bytes = 0x00000000;
4591
+	  while ($v_pos < $v_size)
4592
+	  {
4593
+		// ----- Read a byte
4594
+		$v_byte = @fread($this->zip_fd, 1);
4595
+
4596
+		// -----  Add the byte
4597
+		//$v_bytes = ($v_bytes << 8) | Ord($v_byte);
4598
+		// Note we mask the old value down such that once shifted we can never end up with more than a 32bit number 
4599
+		// Otherwise on systems where we have 64bit integers the check below for the magic number will fail. 
4600
+		$v_bytes = ( ($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte); 
4601
+
4602
+		// ----- Compare the bytes
4603
+		if ($v_bytes == 0x504b0506)
4604
+		{
4605
+		  $v_pos++;
4606
+		  break;
4607
+		}
4608
+
4609
+		$v_pos++;
4610
+	  }
4611 4611
 
4612
-      // ----- Look if not found end of central dir
4613
-      if ($v_pos == $v_size)
4614
-      {
4612
+	  // ----- Look if not found end of central dir
4613
+	  if ($v_pos == $v_size)
4614
+	  {
4615 4615
 
4616
-        // ----- Error log
4617
-        PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Unable to find End of Central Dir Record signature");
4616
+		// ----- Error log
4617
+		PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Unable to find End of Central Dir Record signature");
4618 4618
 
4619
-        // ----- Return
4620
-        return PclZip::errorCode();
4621
-      }
4622
-    }
4619
+		// ----- Return
4620
+		return PclZip::errorCode();
4621
+	  }
4622
+	}
4623 4623
 
4624
-    // ----- Read the first 18 bytes of the header
4625
-    $v_binary_data = fread($this->zip_fd, 18);
4624
+	// ----- Read the first 18 bytes of the header
4625
+	$v_binary_data = fread($this->zip_fd, 18);
4626 4626
 
4627
-    // ----- Look for invalid block size
4628
-    if (strlen($v_binary_data) != 18)
4629
-    {
4627
+	// ----- Look for invalid block size
4628
+	if (strlen($v_binary_data) != 18)
4629
+	{
4630 4630
 
4631
-      // ----- Error log
4632
-      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : ".strlen($v_binary_data));
4631
+	  // ----- Error log
4632
+	  PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : ".strlen($v_binary_data));
4633 4633
 
4634
-      // ----- Return
4635
-      return PclZip::errorCode();
4636
-    }
4634
+	  // ----- Return
4635
+	  return PclZip::errorCode();
4636
+	}
4637 4637
 
4638
-    // ----- Extract the values
4639
-    $v_data = unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size', $v_binary_data);
4638
+	// ----- Extract the values
4639
+	$v_data = unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size', $v_binary_data);
4640 4640
 
4641
-    // ----- Check the global size
4642
-    if (($v_pos + $v_data['comment_size'] + 18) != $v_size) {
4641
+	// ----- Check the global size
4642
+	if (($v_pos + $v_data['comment_size'] + 18) != $v_size) {
4643 4643
 
4644 4644
 	  // ----- Removed in release 2.2 see readme file
4645 4645
 	  // The check of the file size is a little too strict.
4646 4646
 	  // Some bugs where found when a zip is encrypted/decrypted with 'crypt'.
4647 4647
 	  // While decrypted, zip has training 0 bytes
4648 4648
 	  if (0) {
4649
-      // ----- Error log
4650
-      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT,
4651
-	                       'The central dir is not at the end of the archive.'
4649
+	  // ----- Error log
4650
+	  PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT,
4651
+						   'The central dir is not at the end of the archive.'
4652 4652
 						   .' Some trailing bytes exists after the archive.');
4653 4653
 
4654
-      // ----- Return
4655
-      return PclZip::errorCode();
4654
+	  // ----- Return
4655
+	  return PclZip::errorCode();
4656 4656
 	  }
4657
-    }
4657
+	}
4658 4658
 
4659
-    // ----- Get comment
4660
-    if ($v_data['comment_size'] != 0) {
4661
-      $p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']);
4662
-    }
4663
-    else
4664
-      $p_central_dir['comment'] = '';
4665
-
4666
-    $p_central_dir['entries'] = $v_data['entries'];
4667
-    $p_central_dir['disk_entries'] = $v_data['disk_entries'];
4668
-    $p_central_dir['offset'] = $v_data['offset'];
4669
-    $p_central_dir['size'] = $v_data['size'];
4670
-    $p_central_dir['disk'] = $v_data['disk'];
4671
-    $p_central_dir['disk_start'] = $v_data['disk_start'];
4672
-
4673
-    // TBC
4674
-    //for(reset($p_central_dir); $key = key($p_central_dir); next($p_central_dir)) {
4675
-    //}
4676
-
4677
-    // ----- Return
4678
-    return $v_result;
4659
+	// ----- Get comment
4660
+	if ($v_data['comment_size'] != 0) {
4661
+	  $p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']);
4662
+	}
4663
+	else
4664
+	  $p_central_dir['comment'] = '';
4665
+
4666
+	$p_central_dir['entries'] = $v_data['entries'];
4667
+	$p_central_dir['disk_entries'] = $v_data['disk_entries'];
4668
+	$p_central_dir['offset'] = $v_data['offset'];
4669
+	$p_central_dir['size'] = $v_data['size'];
4670
+	$p_central_dir['disk'] = $v_data['disk'];
4671
+	$p_central_dir['disk_start'] = $v_data['disk_start'];
4672
+
4673
+	// TBC
4674
+	//for(reset($p_central_dir); $key = key($p_central_dir); next($p_central_dir)) {
4675
+	//}
4676
+
4677
+	// ----- Return
4678
+	return $v_result;
4679 4679
   }
4680 4680
   // --------------------------------------------------------------------------------
4681 4681
 
@@ -4687,96 +4687,96 @@  discard block
 block discarded – undo
4687 4687
   // --------------------------------------------------------------------------------
4688 4688
   function privDeleteByRule(&$p_result_list, &$p_options)
4689 4689
   {
4690
-    $v_result=1;
4691
-    $v_list_detail = array();
4692
-
4693
-    // ----- Open the zip file
4694
-    if (($v_result=$this->privOpenFd('rb')) != 1)
4695
-    {
4696
-      // ----- Return
4697
-      return $v_result;
4698
-    }
4690
+	$v_result=1;
4691
+	$v_list_detail = array();
4692
+
4693
+	// ----- Open the zip file
4694
+	if (($v_result=$this->privOpenFd('rb')) != 1)
4695
+	{
4696
+	  // ----- Return
4697
+	  return $v_result;
4698
+	}
4699 4699
 
4700
-    // ----- Read the central directory informations
4701
-    $v_central_dir = array();
4702
-    if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
4703
-    {
4704
-      $this->privCloseFd();
4705
-      return $v_result;
4706
-    }
4700
+	// ----- Read the central directory informations
4701
+	$v_central_dir = array();
4702
+	if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
4703
+	{
4704
+	  $this->privCloseFd();
4705
+	  return $v_result;
4706
+	}
4707 4707
 
4708
-    // ----- Go to beginning of File
4709
-    @rewind($this->zip_fd);
4708
+	// ----- Go to beginning of File
4709
+	@rewind($this->zip_fd);
4710 4710
 
4711
-    // ----- Scan all the files
4712
-    // ----- Start at beginning of Central Dir
4713
-    $v_pos_entry = $v_central_dir['offset'];
4714
-    @rewind($this->zip_fd);
4715
-    if (@fseek($this->zip_fd, $v_pos_entry))
4716
-    {
4717
-      // ----- Close the zip file
4718
-      $this->privCloseFd();
4711
+	// ----- Scan all the files
4712
+	// ----- Start at beginning of Central Dir
4713
+	$v_pos_entry = $v_central_dir['offset'];
4714
+	@rewind($this->zip_fd);
4715
+	if (@fseek($this->zip_fd, $v_pos_entry))
4716
+	{
4717
+	  // ----- Close the zip file
4718
+	  $this->privCloseFd();
4719 4719
 
4720
-      // ----- Error log
4721
-      PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
4720
+	  // ----- Error log
4721
+	  PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
4722 4722
 
4723
-      // ----- Return
4724
-      return PclZip::errorCode();
4725
-    }
4723
+	  // ----- Return
4724
+	  return PclZip::errorCode();
4725
+	}
4726 4726
 
4727
-    // ----- Read each entry
4728
-    $v_header_list = array();
4729
-    $j_start = 0;
4730
-    for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
4731
-    {
4727
+	// ----- Read each entry
4728
+	$v_header_list = array();
4729
+	$j_start = 0;
4730
+	for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
4731
+	{
4732 4732
 
4733
-      // ----- Read the file header
4734
-      $v_header_list[$v_nb_extracted] = array();
4735
-      if (($v_result = $this->privReadCentralFileHeader($v_header_list[$v_nb_extracted])) != 1)
4736
-      {
4737
-        // ----- Close the zip file
4738
-        $this->privCloseFd();
4733
+	  // ----- Read the file header
4734
+	  $v_header_list[$v_nb_extracted] = array();
4735
+	  if (($v_result = $this->privReadCentralFileHeader($v_header_list[$v_nb_extracted])) != 1)
4736
+	  {
4737
+		// ----- Close the zip file
4738
+		$this->privCloseFd();
4739 4739
 
4740
-        return $v_result;
4741
-      }
4740
+		return $v_result;
4741
+	  }
4742 4742
 
4743 4743
 
4744
-      // ----- Store the index
4745
-      $v_header_list[$v_nb_extracted]['index'] = $i;
4746
-
4747
-      // ----- Look for the specific extract rules
4748
-      $v_found = false;
4749
-
4750
-      // ----- Look for extract by name rule
4751
-      if (   (isset($p_options[PCLZIP_OPT_BY_NAME]))
4752
-          && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
4753
-
4754
-          // ----- Look if the filename is in the list
4755
-          for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) {
4756
-
4757
-              // ----- Look for a directory
4758
-              if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
4759
-
4760
-                  // ----- Look if the directory is in the filename path
4761
-                  if (   (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
4762
-                      && (substr($v_header_list[$v_nb_extracted]['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
4763
-                      $v_found = true;
4764
-                  }
4765
-                  elseif (   (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */
4766
-                          && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
4767
-                      $v_found = true;
4768
-                  }
4769
-              }
4770
-              // ----- Look for a filename
4771
-              elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
4772
-                  $v_found = true;
4773
-              }
4774
-          }
4775
-      }
4744
+	  // ----- Store the index
4745
+	  $v_header_list[$v_nb_extracted]['index'] = $i;
4746
+
4747
+	  // ----- Look for the specific extract rules
4748
+	  $v_found = false;
4749
+
4750
+	  // ----- Look for extract by name rule
4751
+	  if (   (isset($p_options[PCLZIP_OPT_BY_NAME]))
4752
+		  && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
4753
+
4754
+		  // ----- Look if the filename is in the list
4755
+		  for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) {
4756
+
4757
+			  // ----- Look for a directory
4758
+			  if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
4759
+
4760
+				  // ----- Look if the directory is in the filename path
4761
+				  if (   (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
4762
+					  && (substr($v_header_list[$v_nb_extracted]['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
4763
+					  $v_found = true;
4764
+				  }
4765
+				  elseif (   (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */
4766
+						  && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
4767
+					  $v_found = true;
4768
+				  }
4769
+			  }
4770
+			  // ----- Look for a filename
4771
+			  elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
4772
+				  $v_found = true;
4773
+			  }
4774
+		  }
4775
+	  }
4776 4776
 
4777
-      // ----- Look for extract by ereg rule
4778
-      // ereg() is deprecated with PHP 5.3
4779
-      /*
4777
+	  // ----- Look for extract by ereg rule
4778
+	  // ereg() is deprecated with PHP 5.3
4779
+	  /*
4780 4780
       else if (   (isset($p_options[PCLZIP_OPT_BY_EREG]))
4781 4781
                && ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
4782 4782
 
@@ -4786,201 +4786,201 @@  discard block
 block discarded – undo
4786 4786
       }
4787 4787
       */
4788 4788
 
4789
-      // ----- Look for extract by preg rule
4790
-      else if (   (isset($p_options[PCLZIP_OPT_BY_PREG]))
4791
-               && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
4789
+	  // ----- Look for extract by preg rule
4790
+	  else if (   (isset($p_options[PCLZIP_OPT_BY_PREG]))
4791
+			   && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
4792 4792
 
4793
-          if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
4794
-              $v_found = true;
4795
-          }
4796
-      }
4793
+		  if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
4794
+			  $v_found = true;
4795
+		  }
4796
+	  }
4797 4797
 
4798
-      // ----- Look for extract by index rule
4799
-      else if (   (isset($p_options[PCLZIP_OPT_BY_INDEX]))
4800
-               && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
4798
+	  // ----- Look for extract by index rule
4799
+	  else if (   (isset($p_options[PCLZIP_OPT_BY_INDEX]))
4800
+			   && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
4801 4801
 
4802
-          // ----- Look if the index is in the list
4803
-          for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) {
4802
+		  // ----- Look if the index is in the list
4803
+		  for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) {
4804 4804
 
4805
-              if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
4806
-                  $v_found = true;
4807
-              }
4808
-              if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
4809
-                  $j_start = $j+1;
4810
-              }
4805
+			  if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
4806
+				  $v_found = true;
4807
+			  }
4808
+			  if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
4809
+				  $j_start = $j+1;
4810
+			  }
4811 4811
 
4812
-              if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
4813
-                  break;
4814
-              }
4815
-          }
4816
-      }
4817
-      else {
4818
-      	$v_found = true;
4819
-      }
4812
+			  if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
4813
+				  break;
4814
+			  }
4815
+		  }
4816
+	  }
4817
+	  else {
4818
+	  	$v_found = true;
4819
+	  }
4820 4820
 
4821
-      // ----- Look for deletion
4822
-      if ($v_found)
4823
-      {
4824
-        unset($v_header_list[$v_nb_extracted]);
4825
-      }
4826
-      else
4827
-      {
4828
-        $v_nb_extracted++;
4829
-      }
4830
-    }
4821
+	  // ----- Look for deletion
4822
+	  if ($v_found)
4823
+	  {
4824
+		unset($v_header_list[$v_nb_extracted]);
4825
+	  }
4826
+	  else
4827
+	  {
4828
+		$v_nb_extracted++;
4829
+	  }
4830
+	}
4831 4831
 
4832
-    // ----- Look if something need to be deleted
4833
-    if ($v_nb_extracted > 0) {
4832
+	// ----- Look if something need to be deleted
4833
+	if ($v_nb_extracted > 0) {
4834 4834
 
4835
-        // ----- Creates a temporay file
4836
-        $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
4835
+		// ----- Creates a temporay file
4836
+		$v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
4837 4837
 
4838
-        // ----- Creates a temporary zip archive
4839
-        $v_temp_zip = new PclZip($v_zip_temp_name);
4838
+		// ----- Creates a temporary zip archive
4839
+		$v_temp_zip = new PclZip($v_zip_temp_name);
4840 4840
 
4841
-        // ----- Open the temporary zip file in write mode
4842
-        if (($v_result = $v_temp_zip->privOpenFd('wb')) != 1) {
4843
-            $this->privCloseFd();
4841
+		// ----- Open the temporary zip file in write mode
4842
+		if (($v_result = $v_temp_zip->privOpenFd('wb')) != 1) {
4843
+			$this->privCloseFd();
4844 4844
 
4845
-            // ----- Return
4846
-            return $v_result;
4847
-        }
4845
+			// ----- Return
4846
+			return $v_result;
4847
+		}
4848 4848
 
4849
-        // ----- Look which file need to be kept
4850
-        for ($i=0; $i<sizeof($v_header_list); $i++) {
4849
+		// ----- Look which file need to be kept
4850
+		for ($i=0; $i<sizeof($v_header_list); $i++) {
4851 4851
 
4852
-            // ----- Calculate the position of the header
4853
-            @rewind($this->zip_fd);
4854
-            if (@fseek($this->zip_fd,  $v_header_list[$i]['offset'])) {
4855
-                // ----- Close the zip file
4856
-                $this->privCloseFd();
4857
-                $v_temp_zip->privCloseFd();
4858
-                @unlink($v_zip_temp_name);
4852
+			// ----- Calculate the position of the header
4853
+			@rewind($this->zip_fd);
4854
+			if (@fseek($this->zip_fd,  $v_header_list[$i]['offset'])) {
4855
+				// ----- Close the zip file
4856
+				$this->privCloseFd();
4857
+				$v_temp_zip->privCloseFd();
4858
+				@unlink($v_zip_temp_name);
4859 4859
 
4860
-                // ----- Error log
4861
-                PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
4860
+				// ----- Error log
4861
+				PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
4862 4862
 
4863
-                // ----- Return
4864
-                return PclZip::errorCode();
4865
-            }
4863
+				// ----- Return
4864
+				return PclZip::errorCode();
4865
+			}
4866 4866
 
4867
-            // ----- Read the file header
4868
-            $v_local_header = array();
4869
-            if (($v_result = $this->privReadFileHeader($v_local_header)) != 1) {
4870
-                // ----- Close the zip file
4871
-                $this->privCloseFd();
4872
-                $v_temp_zip->privCloseFd();
4873
-                @unlink($v_zip_temp_name);
4867
+			// ----- Read the file header
4868
+			$v_local_header = array();
4869
+			if (($v_result = $this->privReadFileHeader($v_local_header)) != 1) {
4870
+				// ----- Close the zip file
4871
+				$this->privCloseFd();
4872
+				$v_temp_zip->privCloseFd();
4873
+				@unlink($v_zip_temp_name);
4874 4874
 
4875
-                // ----- Return
4876
-                return $v_result;
4877
-            }
4875
+				// ----- Return
4876
+				return $v_result;
4877
+			}
4878 4878
             
4879
-            // ----- Check that local file header is same as central file header
4880
-            if ($this->privCheckFileHeaders($v_local_header,
4881
-			                                $v_header_list[$i]) != 1) {
4882
-                // TBC
4883
-            }
4884
-            unset($v_local_header);
4885
-
4886
-            // ----- Write the file header
4887
-            if (($v_result = $v_temp_zip->privWriteFileHeader($v_header_list[$i])) != 1) {
4888
-                // ----- Close the zip file
4889
-                $this->privCloseFd();
4890
-                $v_temp_zip->privCloseFd();
4891
-                @unlink($v_zip_temp_name);
4892
-
4893
-                // ----- Return
4894
-                return $v_result;
4895
-            }
4896
-
4897
-            // ----- Read/write the data block
4898
-            if (($v_result = PclZipUtilCopyBlock($this->zip_fd, $v_temp_zip->zip_fd, $v_header_list[$i]['compressed_size'])) != 1) {
4899
-                // ----- Close the zip file
4900
-                $this->privCloseFd();
4901
-                $v_temp_zip->privCloseFd();
4902
-                @unlink($v_zip_temp_name);
4903
-
4904
-                // ----- Return
4905
-                return $v_result;
4906
-            }
4907
-        }
4908
-
4909
-        // ----- Store the offset of the central dir
4910
-        $v_offset = @ftell($v_temp_zip->zip_fd);
4911
-
4912
-        // ----- Re-Create the Central Dir files header
4913
-        for ($i=0; $i<sizeof($v_header_list); $i++) {
4914
-            // ----- Create the file header
4915
-            if (($v_result = $v_temp_zip->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
4916
-                $v_temp_zip->privCloseFd();
4917
-                $this->privCloseFd();
4918
-                @unlink($v_zip_temp_name);
4919
-
4920
-                // ----- Return
4921
-                return $v_result;
4922
-            }
4923
-
4924
-            // ----- Transform the header to a 'usable' info
4925
-            $v_temp_zip->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
4926
-        }
4927
-
4928
-
4929
-        // ----- Zip file comment
4930
-        $v_comment = '';
4931
-        if (isset($p_options[PCLZIP_OPT_COMMENT])) {
4932
-          $v_comment = $p_options[PCLZIP_OPT_COMMENT];
4933
-        }
4934
-
4935
-        // ----- Calculate the size of the central header
4936
-        $v_size = @ftell($v_temp_zip->zip_fd)-$v_offset;
4937
-
4938
-        // ----- Create the central dir footer
4939
-        if (($v_result = $v_temp_zip->privWriteCentralHeader(sizeof($v_header_list), $v_size, $v_offset, $v_comment)) != 1) {
4940
-            // ----- Reset the file list
4941
-            unset($v_header_list);
4942
-            $v_temp_zip->privCloseFd();
4943
-            $this->privCloseFd();
4944
-            @unlink($v_zip_temp_name);
4945
-
4946
-            // ----- Return
4947
-            return $v_result;
4948
-        }
4949
-
4950
-        // ----- Close
4951
-        $v_temp_zip->privCloseFd();
4952
-        $this->privCloseFd();
4953
-
4954
-        // ----- Delete the zip file
4955
-        // TBC : I should test the result ...
4956
-        @unlink($this->zipname);
4957
-
4958
-        // ----- Rename the temporary file
4959
-        // TBC : I should test the result ...
4960
-        //@rename($v_zip_temp_name, $this->zipname);
4961
-        PclZipUtilRename($v_zip_temp_name, $this->zipname);
4879
+			// ----- Check that local file header is same as central file header
4880
+			if ($this->privCheckFileHeaders($v_local_header,
4881
+											$v_header_list[$i]) != 1) {
4882
+				// TBC
4883
+			}
4884
+			unset($v_local_header);
4885
+
4886
+			// ----- Write the file header
4887
+			if (($v_result = $v_temp_zip->privWriteFileHeader($v_header_list[$i])) != 1) {
4888
+				// ----- Close the zip file
4889
+				$this->privCloseFd();
4890
+				$v_temp_zip->privCloseFd();
4891
+				@unlink($v_zip_temp_name);
4892
+
4893
+				// ----- Return
4894
+				return $v_result;
4895
+			}
4896
+
4897
+			// ----- Read/write the data block
4898
+			if (($v_result = PclZipUtilCopyBlock($this->zip_fd, $v_temp_zip->zip_fd, $v_header_list[$i]['compressed_size'])) != 1) {
4899
+				// ----- Close the zip file
4900
+				$this->privCloseFd();
4901
+				$v_temp_zip->privCloseFd();
4902
+				@unlink($v_zip_temp_name);
4903
+
4904
+				// ----- Return
4905
+				return $v_result;
4906
+			}
4907
+		}
4908
+
4909
+		// ----- Store the offset of the central dir
4910
+		$v_offset = @ftell($v_temp_zip->zip_fd);
4911
+
4912
+		// ----- Re-Create the Central Dir files header
4913
+		for ($i=0; $i<sizeof($v_header_list); $i++) {
4914
+			// ----- Create the file header
4915
+			if (($v_result = $v_temp_zip->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
4916
+				$v_temp_zip->privCloseFd();
4917
+				$this->privCloseFd();
4918
+				@unlink($v_zip_temp_name);
4919
+
4920
+				// ----- Return
4921
+				return $v_result;
4922
+			}
4923
+
4924
+			// ----- Transform the header to a 'usable' info
4925
+			$v_temp_zip->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
4926
+		}
4927
+
4928
+
4929
+		// ----- Zip file comment
4930
+		$v_comment = '';
4931
+		if (isset($p_options[PCLZIP_OPT_COMMENT])) {
4932
+		  $v_comment = $p_options[PCLZIP_OPT_COMMENT];
4933
+		}
4934
+
4935
+		// ----- Calculate the size of the central header
4936
+		$v_size = @ftell($v_temp_zip->zip_fd)-$v_offset;
4937
+
4938
+		// ----- Create the central dir footer
4939
+		if (($v_result = $v_temp_zip->privWriteCentralHeader(sizeof($v_header_list), $v_size, $v_offset, $v_comment)) != 1) {
4940
+			// ----- Reset the file list
4941
+			unset($v_header_list);
4942
+			$v_temp_zip->privCloseFd();
4943
+			$this->privCloseFd();
4944
+			@unlink($v_zip_temp_name);
4945
+
4946
+			// ----- Return
4947
+			return $v_result;
4948
+		}
4949
+
4950
+		// ----- Close
4951
+		$v_temp_zip->privCloseFd();
4952
+		$this->privCloseFd();
4953
+
4954
+		// ----- Delete the zip file
4955
+		// TBC : I should test the result ...
4956
+		@unlink($this->zipname);
4957
+
4958
+		// ----- Rename the temporary file
4959
+		// TBC : I should test the result ...
4960
+		//@rename($v_zip_temp_name, $this->zipname);
4961
+		PclZipUtilRename($v_zip_temp_name, $this->zipname);
4962 4962
     
4963
-        // ----- Destroy the temporary archive
4964
-        unset($v_temp_zip);
4965
-    }
4963
+		// ----- Destroy the temporary archive
4964
+		unset($v_temp_zip);
4965
+	}
4966 4966
     
4967
-    // ----- Remove every files : reset the file
4968
-    else if ($v_central_dir['entries'] != 0) {
4969
-        $this->privCloseFd();
4967
+	// ----- Remove every files : reset the file
4968
+	else if ($v_central_dir['entries'] != 0) {
4969
+		$this->privCloseFd();
4970 4970
 
4971
-        if (($v_result = $this->privOpenFd('wb')) != 1) {
4972
-          return $v_result;
4973
-        }
4971
+		if (($v_result = $this->privOpenFd('wb')) != 1) {
4972
+		  return $v_result;
4973
+		}
4974 4974
 
4975
-        if (($v_result = $this->privWriteCentralHeader(0, 0, 0, '')) != 1) {
4976
-          return $v_result;
4977
-        }
4975
+		if (($v_result = $this->privWriteCentralHeader(0, 0, 0, '')) != 1) {
4976
+		  return $v_result;
4977
+		}
4978 4978
 
4979
-        $this->privCloseFd();
4980
-    }
4979
+		$this->privCloseFd();
4980
+	}
4981 4981
 
4982
-    // ----- Return
4983
-    return $v_result;
4982
+	// ----- Return
4983
+	return $v_result;
4984 4984
   }
4985 4985
   // --------------------------------------------------------------------------------
4986 4986
 
@@ -4997,49 +4997,49 @@  discard block
 block discarded – undo
4997 4997
   // --------------------------------------------------------------------------------
4998 4998
   function privDirCheck($p_dir, $p_is_dir=false)
4999 4999
   {
5000
-    $v_result = 1;
5000
+	$v_result = 1;
5001 5001
 
5002 5002
 
5003
-    // ----- Remove the final '/'
5004
-    if (($p_is_dir) && (substr($p_dir, -1)=='/'))
5005
-    {
5006
-      $p_dir = substr($p_dir, 0, strlen($p_dir)-1);
5007
-    }
5003
+	// ----- Remove the final '/'
5004
+	if (($p_is_dir) && (substr($p_dir, -1)=='/'))
5005
+	{
5006
+	  $p_dir = substr($p_dir, 0, strlen($p_dir)-1);
5007
+	}
5008 5008
 
5009
-    // ----- Check the directory availability
5010
-    if ((is_dir($p_dir)) || ($p_dir == ""))
5011
-    {
5012
-      return 1;
5013
-    }
5009
+	// ----- Check the directory availability
5010
+	if ((is_dir($p_dir)) || ($p_dir == ""))
5011
+	{
5012
+	  return 1;
5013
+	}
5014 5014
 
5015
-    // ----- Extract parent directory
5016
-    $p_parent_dir = dirname($p_dir);
5017
-
5018
-    // ----- Just a check
5019
-    if ($p_parent_dir != $p_dir)
5020
-    {
5021
-      // ----- Look for parent directory
5022
-      if ($p_parent_dir != "")
5023
-      {
5024
-        if (($v_result = $this->privDirCheck($p_parent_dir)) != 1)
5025
-        {
5026
-          return $v_result;
5027
-        }
5028
-      }
5029
-    }
5015
+	// ----- Extract parent directory
5016
+	$p_parent_dir = dirname($p_dir);
5017
+
5018
+	// ----- Just a check
5019
+	if ($p_parent_dir != $p_dir)
5020
+	{
5021
+	  // ----- Look for parent directory
5022
+	  if ($p_parent_dir != "")
5023
+	  {
5024
+		if (($v_result = $this->privDirCheck($p_parent_dir)) != 1)
5025
+		{
5026
+		  return $v_result;
5027
+		}
5028
+	  }
5029
+	}
5030 5030
 
5031
-    // ----- Create the directory
5032
-    if (!@mkdir($p_dir, 0777))
5033
-    {
5034
-      // ----- Error log
5035
-      PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'");
5031
+	// ----- Create the directory
5032
+	if (!@mkdir($p_dir, 0777))
5033
+	{
5034
+	  // ----- Error log
5035
+	  PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'");
5036 5036
 
5037
-      // ----- Return
5038
-      return PclZip::errorCode();
5039
-    }
5037
+	  // ----- Return
5038
+	  return PclZip::errorCode();
5039
+	}
5040 5040
 
5041
-    // ----- Return
5042
-    return $v_result;
5041
+	// ----- Return
5042
+	return $v_result;
5043 5043
   }
5044 5044
   // --------------------------------------------------------------------------------
5045 5045
 
@@ -5052,180 +5052,180 @@  discard block
 block discarded – undo
5052 5052
   // --------------------------------------------------------------------------------
5053 5053
   function privMerge(&$p_archive_to_add)
5054 5054
   {
5055
-    $v_result=1;
5055
+	$v_result=1;
5056 5056
 
5057
-    // ----- Look if the archive_to_add exists
5058
-    if (!is_file($p_archive_to_add->zipname))
5059
-    {
5057
+	// ----- Look if the archive_to_add exists
5058
+	if (!is_file($p_archive_to_add->zipname))
5059
+	{
5060 5060
 
5061
-      // ----- Nothing to merge, so merge is a success
5062
-      $v_result = 1;
5061
+	  // ----- Nothing to merge, so merge is a success
5062
+	  $v_result = 1;
5063 5063
 
5064
-      // ----- Return
5065
-      return $v_result;
5066
-    }
5064
+	  // ----- Return
5065
+	  return $v_result;
5066
+	}
5067 5067
 
5068
-    // ----- Look if the archive exists
5069
-    if (!is_file($this->zipname))
5070
-    {
5068
+	// ----- Look if the archive exists
5069
+	if (!is_file($this->zipname))
5070
+	{
5071 5071
 
5072
-      // ----- Do a duplicate
5073
-      $v_result = $this->privDuplicate($p_archive_to_add->zipname);
5072
+	  // ----- Do a duplicate
5073
+	  $v_result = $this->privDuplicate($p_archive_to_add->zipname);
5074 5074
 
5075
-      // ----- Return
5076
-      return $v_result;
5077
-    }
5075
+	  // ----- Return
5076
+	  return $v_result;
5077
+	}
5078 5078
 
5079
-    // ----- Open the zip file
5080
-    if (($v_result=$this->privOpenFd('rb')) != 1)
5081
-    {
5082
-      // ----- Return
5083
-      return $v_result;
5084
-    }
5079
+	// ----- Open the zip file
5080
+	if (($v_result=$this->privOpenFd('rb')) != 1)
5081
+	{
5082
+	  // ----- Return
5083
+	  return $v_result;
5084
+	}
5085 5085
 
5086
-    // ----- Read the central directory informations
5087
-    $v_central_dir = array();
5088
-    if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
5089
-    {
5090
-      $this->privCloseFd();
5091
-      return $v_result;
5092
-    }
5086
+	// ----- Read the central directory informations
5087
+	$v_central_dir = array();
5088
+	if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
5089
+	{
5090
+	  $this->privCloseFd();
5091
+	  return $v_result;
5092
+	}
5093 5093
 
5094
-    // ----- Go to beginning of File
5095
-    @rewind($this->zip_fd);
5094
+	// ----- Go to beginning of File
5095
+	@rewind($this->zip_fd);
5096 5096
 
5097
-    // ----- Open the archive_to_add file
5098
-    if (($v_result=$p_archive_to_add->privOpenFd('rb')) != 1)
5099
-    {
5100
-      $this->privCloseFd();
5097
+	// ----- Open the archive_to_add file
5098
+	if (($v_result=$p_archive_to_add->privOpenFd('rb')) != 1)
5099
+	{
5100
+	  $this->privCloseFd();
5101 5101
 
5102
-      // ----- Return
5103
-      return $v_result;
5104
-    }
5102
+	  // ----- Return
5103
+	  return $v_result;
5104
+	}
5105 5105
 
5106
-    // ----- Read the central directory informations
5107
-    $v_central_dir_to_add = array();
5108
-    if (($v_result = $p_archive_to_add->privReadEndCentralDir($v_central_dir_to_add)) != 1)
5109
-    {
5110
-      $this->privCloseFd();
5111
-      $p_archive_to_add->privCloseFd();
5106
+	// ----- Read the central directory informations
5107
+	$v_central_dir_to_add = array();
5108
+	if (($v_result = $p_archive_to_add->privReadEndCentralDir($v_central_dir_to_add)) != 1)
5109
+	{
5110
+	  $this->privCloseFd();
5111
+	  $p_archive_to_add->privCloseFd();
5112 5112
 
5113
-      return $v_result;
5114
-    }
5113
+	  return $v_result;
5114
+	}
5115 5115
 
5116
-    // ----- Go to beginning of File
5117
-    @rewind($p_archive_to_add->zip_fd);
5116
+	// ----- Go to beginning of File
5117
+	@rewind($p_archive_to_add->zip_fd);
5118 5118
 
5119
-    // ----- Creates a temporay file
5120
-    $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
5119
+	// ----- Creates a temporay file
5120
+	$v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
5121 5121
 
5122
-    // ----- Open the temporary file in write mode
5123
-    if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
5124
-    {
5125
-      $this->privCloseFd();
5126
-      $p_archive_to_add->privCloseFd();
5122
+	// ----- Open the temporary file in write mode
5123
+	if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
5124
+	{
5125
+	  $this->privCloseFd();
5126
+	  $p_archive_to_add->privCloseFd();
5127 5127
 
5128
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
5128
+	  PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
5129 5129
 
5130
-      // ----- Return
5131
-      return PclZip::errorCode();
5132
-    }
5130
+	  // ----- Return
5131
+	  return PclZip::errorCode();
5132
+	}
5133 5133
 
5134
-    // ----- Copy the files from the archive to the temporary file
5135
-    // TBC : Here I should better append the file and go back to erase the central dir
5136
-    $v_size = $v_central_dir['offset'];
5137
-    while ($v_size != 0)
5138
-    {
5139
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5140
-      $v_buffer = fread($this->zip_fd, $v_read_size);
5141
-      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5142
-      $v_size -= $v_read_size;
5143
-    }
5134
+	// ----- Copy the files from the archive to the temporary file
5135
+	// TBC : Here I should better append the file and go back to erase the central dir
5136
+	$v_size = $v_central_dir['offset'];
5137
+	while ($v_size != 0)
5138
+	{
5139
+	  $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5140
+	  $v_buffer = fread($this->zip_fd, $v_read_size);
5141
+	  @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5142
+	  $v_size -= $v_read_size;
5143
+	}
5144 5144
 
5145
-    // ----- Copy the files from the archive_to_add into the temporary file
5146
-    $v_size = $v_central_dir_to_add['offset'];
5147
-    while ($v_size != 0)
5148
-    {
5149
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5150
-      $v_buffer = fread($p_archive_to_add->zip_fd, $v_read_size);
5151
-      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5152
-      $v_size -= $v_read_size;
5153
-    }
5145
+	// ----- Copy the files from the archive_to_add into the temporary file
5146
+	$v_size = $v_central_dir_to_add['offset'];
5147
+	while ($v_size != 0)
5148
+	{
5149
+	  $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5150
+	  $v_buffer = fread($p_archive_to_add->zip_fd, $v_read_size);
5151
+	  @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5152
+	  $v_size -= $v_read_size;
5153
+	}
5154 5154
 
5155
-    // ----- Store the offset of the central dir
5156
-    $v_offset = @ftell($v_zip_temp_fd);
5157
-
5158
-    // ----- Copy the block of file headers from the old archive
5159
-    $v_size = $v_central_dir['size'];
5160
-    while ($v_size != 0)
5161
-    {
5162
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5163
-      $v_buffer = @fread($this->zip_fd, $v_read_size);
5164
-      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5165
-      $v_size -= $v_read_size;
5166
-    }
5155
+	// ----- Store the offset of the central dir
5156
+	$v_offset = @ftell($v_zip_temp_fd);
5157
+
5158
+	// ----- Copy the block of file headers from the old archive
5159
+	$v_size = $v_central_dir['size'];
5160
+	while ($v_size != 0)
5161
+	{
5162
+	  $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5163
+	  $v_buffer = @fread($this->zip_fd, $v_read_size);
5164
+	  @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5165
+	  $v_size -= $v_read_size;
5166
+	}
5167 5167
 
5168
-    // ----- Copy the block of file headers from the archive_to_add
5169
-    $v_size = $v_central_dir_to_add['size'];
5170
-    while ($v_size != 0)
5171
-    {
5172
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5173
-      $v_buffer = @fread($p_archive_to_add->zip_fd, $v_read_size);
5174
-      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5175
-      $v_size -= $v_read_size;
5176
-    }
5168
+	// ----- Copy the block of file headers from the archive_to_add
5169
+	$v_size = $v_central_dir_to_add['size'];
5170
+	while ($v_size != 0)
5171
+	{
5172
+	  $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5173
+	  $v_buffer = @fread($p_archive_to_add->zip_fd, $v_read_size);
5174
+	  @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5175
+	  $v_size -= $v_read_size;
5176
+	}
5177 5177
 
5178
-    // ----- Merge the file comments
5179
-    $v_comment = $v_central_dir['comment'].' '.$v_central_dir_to_add['comment'];
5178
+	// ----- Merge the file comments
5179
+	$v_comment = $v_central_dir['comment'].' '.$v_central_dir_to_add['comment'];
5180 5180
 
5181
-    // ----- Calculate the size of the (new) central header
5182
-    $v_size = @ftell($v_zip_temp_fd)-$v_offset;
5181
+	// ----- Calculate the size of the (new) central header
5182
+	$v_size = @ftell($v_zip_temp_fd)-$v_offset;
5183 5183
 
5184
-    // ----- Swap the file descriptor
5185
-    // Here is a trick : I swap the temporary fd with the zip fd, in order to use
5186
-    // the following methods on the temporary fil and not the real archive fd
5187
-    $v_swap = $this->zip_fd;
5188
-    $this->zip_fd = $v_zip_temp_fd;
5189
-    $v_zip_temp_fd = $v_swap;
5184
+	// ----- Swap the file descriptor
5185
+	// Here is a trick : I swap the temporary fd with the zip fd, in order to use
5186
+	// the following methods on the temporary fil and not the real archive fd
5187
+	$v_swap = $this->zip_fd;
5188
+	$this->zip_fd = $v_zip_temp_fd;
5189
+	$v_zip_temp_fd = $v_swap;
5190 5190
 
5191
-    // ----- Create the central dir footer
5192
-    if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries']+$v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1)
5193
-    {
5194
-      $this->privCloseFd();
5195
-      $p_archive_to_add->privCloseFd();
5196
-      @fclose($v_zip_temp_fd);
5197
-      $this->zip_fd = null;
5191
+	// ----- Create the central dir footer
5192
+	if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries']+$v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1)
5193
+	{
5194
+	  $this->privCloseFd();
5195
+	  $p_archive_to_add->privCloseFd();
5196
+	  @fclose($v_zip_temp_fd);
5197
+	  $this->zip_fd = null;
5198 5198
 
5199
-      // ----- Reset the file list
5200
-      unset($v_header_list);
5199
+	  // ----- Reset the file list
5200
+	  unset($v_header_list);
5201 5201
 
5202
-      // ----- Return
5203
-      return $v_result;
5204
-    }
5202
+	  // ----- Return
5203
+	  return $v_result;
5204
+	}
5205 5205
 
5206
-    // ----- Swap back the file descriptor
5207
-    $v_swap = $this->zip_fd;
5208
-    $this->zip_fd = $v_zip_temp_fd;
5209
-    $v_zip_temp_fd = $v_swap;
5206
+	// ----- Swap back the file descriptor
5207
+	$v_swap = $this->zip_fd;
5208
+	$this->zip_fd = $v_zip_temp_fd;
5209
+	$v_zip_temp_fd = $v_swap;
5210 5210
 
5211
-    // ----- Close
5212
-    $this->privCloseFd();
5213
-    $p_archive_to_add->privCloseFd();
5211
+	// ----- Close
5212
+	$this->privCloseFd();
5213
+	$p_archive_to_add->privCloseFd();
5214 5214
 
5215
-    // ----- Close the temporary file
5216
-    @fclose($v_zip_temp_fd);
5215
+	// ----- Close the temporary file
5216
+	@fclose($v_zip_temp_fd);
5217 5217
 
5218
-    // ----- Delete the zip file
5219
-    // TBC : I should test the result ...
5220
-    @unlink($this->zipname);
5218
+	// ----- Delete the zip file
5219
+	// TBC : I should test the result ...
5220
+	@unlink($this->zipname);
5221 5221
 
5222
-    // ----- Rename the temporary file
5223
-    // TBC : I should test the result ...
5224
-    //@rename($v_zip_temp_name, $this->zipname);
5225
-    PclZipUtilRename($v_zip_temp_name, $this->zipname);
5222
+	// ----- Rename the temporary file
5223
+	// TBC : I should test the result ...
5224
+	//@rename($v_zip_temp_name, $this->zipname);
5225
+	PclZipUtilRename($v_zip_temp_name, $this->zipname);
5226 5226
 
5227
-    // ----- Return
5228
-    return $v_result;
5227
+	// ----- Return
5228
+	return $v_result;
5229 5229
   }
5230 5230
   // --------------------------------------------------------------------------------
5231 5231
 
@@ -5237,56 +5237,56 @@  discard block
 block discarded – undo
5237 5237
   // --------------------------------------------------------------------------------
5238 5238
   function privDuplicate($p_archive_filename)
5239 5239
   {
5240
-    $v_result=1;
5240
+	$v_result=1;
5241 5241
 
5242
-    // ----- Look if the $p_archive_filename exists
5243
-    if (!is_file($p_archive_filename))
5244
-    {
5242
+	// ----- Look if the $p_archive_filename exists
5243
+	if (!is_file($p_archive_filename))
5244
+	{
5245 5245
 
5246
-      // ----- Nothing to duplicate, so duplicate is a success.
5247
-      $v_result = 1;
5246
+	  // ----- Nothing to duplicate, so duplicate is a success.
5247
+	  $v_result = 1;
5248 5248
 
5249
-      // ----- Return
5250
-      return $v_result;
5251
-    }
5249
+	  // ----- Return
5250
+	  return $v_result;
5251
+	}
5252 5252
 
5253
-    // ----- Open the zip file
5254
-    if (($v_result=$this->privOpenFd('wb')) != 1)
5255
-    {
5256
-      // ----- Return
5257
-      return $v_result;
5258
-    }
5253
+	// ----- Open the zip file
5254
+	if (($v_result=$this->privOpenFd('wb')) != 1)
5255
+	{
5256
+	  // ----- Return
5257
+	  return $v_result;
5258
+	}
5259 5259
 
5260
-    // ----- Open the temporary file in write mode
5261
-    if (($v_zip_temp_fd = @fopen($p_archive_filename, 'rb')) == 0)
5262
-    {
5263
-      $this->privCloseFd();
5260
+	// ----- Open the temporary file in write mode
5261
+	if (($v_zip_temp_fd = @fopen($p_archive_filename, 'rb')) == 0)
5262
+	{
5263
+	  $this->privCloseFd();
5264 5264
 
5265
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \''.$p_archive_filename.'\' in binary write mode');
5265
+	  PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \''.$p_archive_filename.'\' in binary write mode');
5266 5266
 
5267
-      // ----- Return
5268
-      return PclZip::errorCode();
5269
-    }
5267
+	  // ----- Return
5268
+	  return PclZip::errorCode();
5269
+	}
5270 5270
 
5271
-    // ----- Copy the files from the archive to the temporary file
5272
-    // TBC : Here I should better append the file and go back to erase the central dir
5273
-    $v_size = filesize($p_archive_filename);
5274
-    while ($v_size != 0)
5275
-    {
5276
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5277
-      $v_buffer = fread($v_zip_temp_fd, $v_read_size);
5278
-      @fwrite($this->zip_fd, $v_buffer, $v_read_size);
5279
-      $v_size -= $v_read_size;
5280
-    }
5271
+	// ----- Copy the files from the archive to the temporary file
5272
+	// TBC : Here I should better append the file and go back to erase the central dir
5273
+	$v_size = filesize($p_archive_filename);
5274
+	while ($v_size != 0)
5275
+	{
5276
+	  $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5277
+	  $v_buffer = fread($v_zip_temp_fd, $v_read_size);
5278
+	  @fwrite($this->zip_fd, $v_buffer, $v_read_size);
5279
+	  $v_size -= $v_read_size;
5280
+	}
5281 5281
 
5282
-    // ----- Close
5283
-    $this->privCloseFd();
5282
+	// ----- Close
5283
+	$this->privCloseFd();
5284 5284
 
5285
-    // ----- Close the temporary file
5286
-    @fclose($v_zip_temp_fd);
5285
+	// ----- Close the temporary file
5286
+	@fclose($v_zip_temp_fd);
5287 5287
 
5288
-    // ----- Return
5289
-    return $v_result;
5288
+	// ----- Return
5289
+	return $v_result;
5290 5290
   }
5291 5291
   // --------------------------------------------------------------------------------
5292 5292
 
@@ -5297,13 +5297,13 @@  discard block
 block discarded – undo
5297 5297
   // --------------------------------------------------------------------------------
5298 5298
   function privErrorLog($p_error_code=0, $p_error_string='')
5299 5299
   {
5300
-    if (PCLZIP_ERROR_EXTERNAL == 1) {
5301
-      PclError($p_error_code, $p_error_string);
5302
-    }
5303
-    else {
5304
-      $this->error_code = $p_error_code;
5305
-      $this->error_string = $p_error_string;
5306
-    }
5300
+	if (PCLZIP_ERROR_EXTERNAL == 1) {
5301
+	  PclError($p_error_code, $p_error_string);
5302
+	}
5303
+	else {
5304
+	  $this->error_code = $p_error_code;
5305
+	  $this->error_string = $p_error_string;
5306
+	}
5307 5307
   }
5308 5308
   // --------------------------------------------------------------------------------
5309 5309
 
@@ -5314,13 +5314,13 @@  discard block
 block discarded – undo
5314 5314
   // --------------------------------------------------------------------------------
5315 5315
   function privErrorReset()
5316 5316
   {
5317
-    if (PCLZIP_ERROR_EXTERNAL == 1) {
5318
-      PclErrorReset();
5319
-    }
5320
-    else {
5321
-      $this->error_code = 0;
5322
-      $this->error_string = '';
5323
-    }
5317
+	if (PCLZIP_ERROR_EXTERNAL == 1) {
5318
+	  PclErrorReset();
5319
+	}
5320
+	else {
5321
+	  $this->error_code = 0;
5322
+	  $this->error_string = '';
5323
+	}
5324 5324
   }
5325 5325
   // --------------------------------------------------------------------------------
5326 5326
 
@@ -5332,17 +5332,17 @@  discard block
 block discarded – undo
5332 5332
   // --------------------------------------------------------------------------------
5333 5333
   function privDisableMagicQuotes()
5334 5334
   {
5335
-    $v_result=1;
5335
+	$v_result=1;
5336 5336
 
5337
-    // ----- Look if function exists
5338
-    if (   (!function_exists("get_magic_quotes_runtime"))
5339
-	    || (!function_exists("set_magic_quotes_runtime"))) {
5340
-      return $v_result;
5337
+	// ----- Look if function exists
5338
+	if (   (!function_exists("get_magic_quotes_runtime"))
5339
+		|| (!function_exists("set_magic_quotes_runtime"))) {
5340
+	  return $v_result;
5341 5341
 	}
5342 5342
 
5343
-    // ----- Look if already done
5344
-    if ($this->magic_quotes_status != -1) {
5345
-      return $v_result;
5343
+	// ----- Look if already done
5344
+	if ($this->magic_quotes_status != -1) {
5345
+	  return $v_result;
5346 5346
 	}
5347 5347
 
5348 5348
 	// ----- Get and memorize the magic_quote value
@@ -5353,8 +5353,8 @@  discard block
 block discarded – undo
5353 5353
 	  @set_magic_quotes_runtime(0);
5354 5354
 	}
5355 5355
 
5356
-    // ----- Return
5357
-    return $v_result;
5356
+	// ----- Return
5357
+	return $v_result;
5358 5358
   }
5359 5359
   // --------------------------------------------------------------------------------
5360 5360
 
@@ -5366,17 +5366,17 @@  discard block
 block discarded – undo
5366 5366
   // --------------------------------------------------------------------------------
5367 5367
   function privSwapBackMagicQuotes()
5368 5368
   {
5369
-    $v_result=1;
5369
+	$v_result=1;
5370 5370
 
5371
-    // ----- Look if function exists
5372
-    if (   (!function_exists("get_magic_quotes_runtime"))
5373
-	    || (!function_exists("set_magic_quotes_runtime"))) {
5374
-      return $v_result;
5371
+	// ----- Look if function exists
5372
+	if (   (!function_exists("get_magic_quotes_runtime"))
5373
+		|| (!function_exists("set_magic_quotes_runtime"))) {
5374
+	  return $v_result;
5375 5375
 	}
5376 5376
 
5377
-    // ----- Look if something to do
5378
-    if ($this->magic_quotes_status != -1) {
5379
-      return $v_result;
5377
+	// ----- Look if something to do
5378
+	if ($this->magic_quotes_status != -1) {
5379
+	  return $v_result;
5380 5380
 	}
5381 5381
 
5382 5382
 	// ----- Swap back magic_quotes
@@ -5384,8 +5384,8 @@  discard block
 block discarded – undo
5384 5384
   	  @set_magic_quotes_runtime($this->magic_quotes_status);
5385 5385
 	}
5386 5386
 
5387
-    // ----- Return
5388
-    return $v_result;
5387
+	// ----- Return
5388
+	return $v_result;
5389 5389
   }
5390 5390
   // --------------------------------------------------------------------------------
5391 5391
 
@@ -5401,67 +5401,67 @@  discard block
 block discarded – undo
5401 5401
   // --------------------------------------------------------------------------------
5402 5402
   function PclZipUtilPathReduction($p_dir)
5403 5403
   {
5404
-    $v_result = "";
5405
-
5406
-    // ----- Look for not empty path
5407
-    if ($p_dir != "") {
5408
-      // ----- Explode path by directory names
5409
-      $v_list = explode("/", $p_dir);
5410
-
5411
-      // ----- Study directories from last to first
5412
-      $v_skip = 0;
5413
-      for ($i=sizeof($v_list)-1; $i>=0; $i--) {
5414
-        // ----- Look for current path
5415
-        if ($v_list[$i] == ".") {
5416
-          // ----- Ignore this directory
5417
-          // Should be the first $i=0, but no check is done
5418
-        }
5419
-        else if ($v_list[$i] == "..") {
5404
+	$v_result = "";
5405
+
5406
+	// ----- Look for not empty path
5407
+	if ($p_dir != "") {
5408
+	  // ----- Explode path by directory names
5409
+	  $v_list = explode("/", $p_dir);
5410
+
5411
+	  // ----- Study directories from last to first
5412
+	  $v_skip = 0;
5413
+	  for ($i=sizeof($v_list)-1; $i>=0; $i--) {
5414
+		// ----- Look for current path
5415
+		if ($v_list[$i] == ".") {
5416
+		  // ----- Ignore this directory
5417
+		  // Should be the first $i=0, but no check is done
5418
+		}
5419
+		else if ($v_list[$i] == "..") {
5420 5420
 		  $v_skip++;
5421
-        }
5422
-        else if ($v_list[$i] == "") {
5421
+		}
5422
+		else if ($v_list[$i] == "") {
5423 5423
 		  // ----- First '/' i.e. root slash
5424 5424
 		  if ($i == 0) {
5425
-            $v_result = "/".$v_result;
5426
-		    if ($v_skip > 0) {
5427
-		        // ----- It is an invalid path, so the path is not modified
5428
-		        // TBC
5429
-		        $v_result = $p_dir;
5430
-                $v_skip = 0;
5431
-		    }
5425
+			$v_result = "/".$v_result;
5426
+			if ($v_skip > 0) {
5427
+				// ----- It is an invalid path, so the path is not modified
5428
+				// TBC
5429
+				$v_result = $p_dir;
5430
+				$v_skip = 0;
5431
+			}
5432 5432
 		  }
5433 5433
 		  // ----- Last '/' i.e. indicates a directory
5434 5434
 		  else if ($i == (sizeof($v_list)-1)) {
5435
-            $v_result = $v_list[$i];
5435
+			$v_result = $v_list[$i];
5436 5436
 		  }
5437 5437
 		  // ----- Double '/' inside the path
5438 5438
 		  else {
5439
-            // ----- Ignore only the double '//' in path,
5440
-            // but not the first and last '/'
5439
+			// ----- Ignore only the double '//' in path,
5440
+			// but not the first and last '/'
5441 5441
 		  }
5442
-        }
5443
-        else {
5442
+		}
5443
+		else {
5444 5444
 		  // ----- Look for item to skip
5445 5445
 		  if ($v_skip > 0) {
5446
-		    $v_skip--;
5446
+			$v_skip--;
5447 5447
 		  }
5448 5448
 		  else {
5449
-            $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:"");
5449
+			$v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:"");
5450 5450
 		  }
5451
-        }
5452
-      }
5451
+		}
5452
+	  }
5453 5453
       
5454
-      // ----- Look for skip
5455
-      if ($v_skip > 0) {
5456
-        while ($v_skip > 0) {
5457
-            $v_result = '../'.$v_result;
5458
-            $v_skip--;
5459
-        }
5460
-      }
5461
-    }
5454
+	  // ----- Look for skip
5455
+	  if ($v_skip > 0) {
5456
+		while ($v_skip > 0) {
5457
+			$v_result = '../'.$v_result;
5458
+			$v_skip--;
5459
+		}
5460
+	  }
5461
+	}
5462 5462
 
5463
-    // ----- Return
5464
-    return $v_result;
5463
+	// ----- Return
5464
+	return $v_result;
5465 5465
   }
5466 5466
   // --------------------------------------------------------------------------------
5467 5467
 
@@ -5482,67 +5482,67 @@  discard block
 block discarded – undo
5482 5482
   // --------------------------------------------------------------------------------
5483 5483
   function PclZipUtilPathInclusion($p_dir, $p_path)
5484 5484
   {
5485
-    $v_result = 1;
5485
+	$v_result = 1;
5486 5486
     
5487
-    // ----- Look for path beginning by ./
5488
-    if (   ($p_dir == '.')
5489
-        || ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) {
5490
-      $p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1);
5491
-    }
5492
-    if (   ($p_path == '.')
5493
-        || ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) {
5494
-      $p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1);
5495
-    }
5487
+	// ----- Look for path beginning by ./
5488
+	if (   ($p_dir == '.')
5489
+		|| ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) {
5490
+	  $p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1);
5491
+	}
5492
+	if (   ($p_path == '.')
5493
+		|| ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) {
5494
+	  $p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1);
5495
+	}
5496 5496
 
5497
-    // ----- Explode dir and path by directory separator
5498
-    $v_list_dir = explode("/", $p_dir);
5499
-    $v_list_dir_size = sizeof($v_list_dir);
5500
-    $v_list_path = explode("/", $p_path);
5501
-    $v_list_path_size = sizeof($v_list_path);
5502
-
5503
-    // ----- Study directories paths
5504
-    $i = 0;
5505
-    $j = 0;
5506
-    while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && ($v_result)) {
5507
-
5508
-      // ----- Look for empty dir (path reduction)
5509
-      if ($v_list_dir[$i] == '') {
5510
-        $i++;
5511
-        continue;
5512
-      }
5513
-      if ($v_list_path[$j] == '') {
5514
-        $j++;
5515
-        continue;
5516
-      }
5497
+	// ----- Explode dir and path by directory separator
5498
+	$v_list_dir = explode("/", $p_dir);
5499
+	$v_list_dir_size = sizeof($v_list_dir);
5500
+	$v_list_path = explode("/", $p_path);
5501
+	$v_list_path_size = sizeof($v_list_path);
5502
+
5503
+	// ----- Study directories paths
5504
+	$i = 0;
5505
+	$j = 0;
5506
+	while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && ($v_result)) {
5507
+
5508
+	  // ----- Look for empty dir (path reduction)
5509
+	  if ($v_list_dir[$i] == '') {
5510
+		$i++;
5511
+		continue;
5512
+	  }
5513
+	  if ($v_list_path[$j] == '') {
5514
+		$j++;
5515
+		continue;
5516
+	  }
5517 5517
 
5518
-      // ----- Compare the items
5519
-      if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != ''))  {
5520
-        $v_result = 0;
5521
-      }
5518
+	  // ----- Compare the items
5519
+	  if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != ''))  {
5520
+		$v_result = 0;
5521
+	  }
5522 5522
 
5523
-      // ----- Next items
5524
-      $i++;
5525
-      $j++;
5526
-    }
5523
+	  // ----- Next items
5524
+	  $i++;
5525
+	  $j++;
5526
+	}
5527 5527
 
5528
-    // ----- Look if everything seems to be the same
5529
-    if ($v_result) {
5530
-      // ----- Skip all the empty items
5531
-      while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++;
5532
-      while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++;
5528
+	// ----- Look if everything seems to be the same
5529
+	if ($v_result) {
5530
+	  // ----- Skip all the empty items
5531
+	  while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++;
5532
+	  while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++;
5533 5533
 
5534
-      if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) {
5535
-        // ----- There are exactly the same
5536
-        $v_result = 2;
5537
-      }
5538
-      else if ($i < $v_list_dir_size) {
5539
-        // ----- The path is shorter than the dir
5540
-        $v_result = 0;
5541
-      }
5542
-    }
5534
+	  if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) {
5535
+		// ----- There are exactly the same
5536
+		$v_result = 2;
5537
+	  }
5538
+	  else if ($i < $v_list_dir_size) {
5539
+		// ----- The path is shorter than the dir
5540
+		$v_result = 0;
5541
+	  }
5542
+	}
5543 5543
 
5544
-    // ----- Return
5545
-    return $v_result;
5544
+	// ----- Return
5545
+	return $v_result;
5546 5546
   }
5547 5547
   // --------------------------------------------------------------------------------
5548 5548
 
@@ -5559,51 +5559,51 @@  discard block
 block discarded – undo
5559 5559
   // --------------------------------------------------------------------------------
5560 5560
   function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0)
5561 5561
   {
5562
-    $v_result = 1;
5563
-
5564
-    if ($p_mode==0)
5565
-    {
5566
-      while ($p_size != 0)
5567
-      {
5568
-        $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
5569
-        $v_buffer = @fread($p_src, $v_read_size);
5570
-        @fwrite($p_dest, $v_buffer, $v_read_size);
5571
-        $p_size -= $v_read_size;
5572
-      }
5573
-    }
5574
-    else if ($p_mode==1)
5575
-    {
5576
-      while ($p_size != 0)
5577
-      {
5578
-        $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
5579
-        $v_buffer = @gzread($p_src, $v_read_size);
5580
-        @fwrite($p_dest, $v_buffer, $v_read_size);
5581
-        $p_size -= $v_read_size;
5582
-      }
5583
-    }
5584
-    else if ($p_mode==2)
5585
-    {
5586
-      while ($p_size != 0)
5587
-      {
5588
-        $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
5589
-        $v_buffer = @fread($p_src, $v_read_size);
5590
-        @gzwrite($p_dest, $v_buffer, $v_read_size);
5591
-        $p_size -= $v_read_size;
5592
-      }
5593
-    }
5594
-    else if ($p_mode==3)
5595
-    {
5596
-      while ($p_size != 0)
5597
-      {
5598
-        $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
5599
-        $v_buffer = @gzread($p_src, $v_read_size);
5600
-        @gzwrite($p_dest, $v_buffer, $v_read_size);
5601
-        $p_size -= $v_read_size;
5602
-      }
5603
-    }
5562
+	$v_result = 1;
5563
+
5564
+	if ($p_mode==0)
5565
+	{
5566
+	  while ($p_size != 0)
5567
+	  {
5568
+		$v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
5569
+		$v_buffer = @fread($p_src, $v_read_size);
5570
+		@fwrite($p_dest, $v_buffer, $v_read_size);
5571
+		$p_size -= $v_read_size;
5572
+	  }
5573
+	}
5574
+	else if ($p_mode==1)
5575
+	{
5576
+	  while ($p_size != 0)
5577
+	  {
5578
+		$v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
5579
+		$v_buffer = @gzread($p_src, $v_read_size);
5580
+		@fwrite($p_dest, $v_buffer, $v_read_size);
5581
+		$p_size -= $v_read_size;
5582
+	  }
5583
+	}
5584
+	else if ($p_mode==2)
5585
+	{
5586
+	  while ($p_size != 0)
5587
+	  {
5588
+		$v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
5589
+		$v_buffer = @fread($p_src, $v_read_size);
5590
+		@gzwrite($p_dest, $v_buffer, $v_read_size);
5591
+		$p_size -= $v_read_size;
5592
+	  }
5593
+	}
5594
+	else if ($p_mode==3)
5595
+	{
5596
+	  while ($p_size != 0)
5597
+	  {
5598
+		$v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
5599
+		$v_buffer = @gzread($p_src, $v_read_size);
5600
+		@gzwrite($p_dest, $v_buffer, $v_read_size);
5601
+		$p_size -= $v_read_size;
5602
+	  }
5603
+	}
5604 5604
 
5605
-    // ----- Return
5606
-    return $v_result;
5605
+	// ----- Return
5606
+	return $v_result;
5607 5607
   }
5608 5608
   // --------------------------------------------------------------------------------
5609 5609
 
@@ -5621,22 +5621,22 @@  discard block
 block discarded – undo
5621 5621
   // --------------------------------------------------------------------------------
5622 5622
   function PclZipUtilRename($p_src, $p_dest)
5623 5623
   {
5624
-    $v_result = 1;
5624
+	$v_result = 1;
5625 5625
 
5626
-    // ----- Try to rename the files
5627
-    if (!@rename($p_src, $p_dest)) {
5626
+	// ----- Try to rename the files
5627
+	if (!@rename($p_src, $p_dest)) {
5628 5628
 
5629
-      // ----- Try to copy & unlink the src
5630
-      if (!@copy($p_src, $p_dest)) {
5631
-        $v_result = 0;
5632
-      }
5633
-      else if (!@unlink($p_src)) {
5634
-        $v_result = 0;
5635
-      }
5636
-    }
5629
+	  // ----- Try to copy & unlink the src
5630
+	  if (!@copy($p_src, $p_dest)) {
5631
+		$v_result = 0;
5632
+	  }
5633
+	  else if (!@unlink($p_src)) {
5634
+		$v_result = 0;
5635
+	  }
5636
+	}
5637 5637
 
5638
-    // ----- Return
5639
-    return $v_result;
5638
+	// ----- Return
5639
+	return $v_result;
5640 5640
   }
5641 5641
   // --------------------------------------------------------------------------------
5642 5642
 
@@ -5652,20 +5652,20 @@  discard block
 block discarded – undo
5652 5652
   function PclZipUtilOptionText($p_option)
5653 5653
   {
5654 5654
     
5655
-    $v_list = get_defined_constants();
5656
-    for (reset($v_list); $v_key = key($v_list); next($v_list)) {
5657
-	    $v_prefix = substr($v_key, 0, 10);
5658
-	    if ((   ($v_prefix == 'PCLZIP_OPT')
5659
-           || ($v_prefix == 'PCLZIP_CB_')
5660
-           || ($v_prefix == 'PCLZIP_ATT'))
5661
-	        && ($v_list[$v_key] == $p_option)) {
5662
-        return $v_key;
5663
-	    }
5664
-    }
5655
+	$v_list = get_defined_constants();
5656
+	for (reset($v_list); $v_key = key($v_list); next($v_list)) {
5657
+		$v_prefix = substr($v_key, 0, 10);
5658
+		if ((   ($v_prefix == 'PCLZIP_OPT')
5659
+		   || ($v_prefix == 'PCLZIP_CB_')
5660
+		   || ($v_prefix == 'PCLZIP_ATT'))
5661
+			&& ($v_list[$v_key] == $p_option)) {
5662
+		return $v_key;
5663
+		}
5664
+	}
5665 5665
     
5666
-    $v_result = 'Unknown';
5666
+	$v_result = 'Unknown';
5667 5667
 
5668
-    return $v_result;
5668
+	return $v_result;
5669 5669
   }
5670 5670
   // --------------------------------------------------------------------------------
5671 5671
 
@@ -5682,17 +5682,17 @@  discard block
 block discarded – undo
5682 5682
   // --------------------------------------------------------------------------------
5683 5683
   function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter=true)
5684 5684
   {
5685
-    if (stristr(php_uname(), 'windows')) {
5686
-      // ----- Look for potential disk letter
5687
-      if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) {
5688
-          $p_path = substr($p_path, $v_position+1);
5689
-      }
5690
-      // ----- Change potential windows directory separator
5691
-      if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) {
5692
-          $p_path = strtr($p_path, '\\', '/');
5693
-      }
5694
-    }
5695
-    return $p_path;
5685
+	if (stristr(php_uname(), 'windows')) {
5686
+	  // ----- Look for potential disk letter
5687
+	  if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) {
5688
+		  $p_path = substr($p_path, $v_position+1);
5689
+	  }
5690
+	  // ----- Change potential windows directory separator
5691
+	  if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) {
5692
+		  $p_path = strtr($p_path, '\\', '/');
5693
+	  }
5694
+	}
5695
+	return $p_path;
5696 5696
   }
5697 5697
   // --------------------------------------------------------------------------------
5698 5698
 
Please login to merge, or discard this patch.
Spacing   +376 added lines, -376 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 // --------------------------------------------------------------------------------
3 3
 // PhpConcept Library - Zip Module 2.8.2
4 4
 // --------------------------------------------------------------------------------
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 
28 28
   // ----- Constants
29 29
   if (!defined('PCLZIP_READ_BLOCK_SIZE')) {
30
-    define( 'PCLZIP_READ_BLOCK_SIZE', 2048 );
30
+    define('PCLZIP_READ_BLOCK_SIZE', 2048);
31 31
   }
32 32
   
33 33
   // ----- File list separator
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
   //define( 'PCLZIP_SEPARATOR', ' ' );
42 42
   // Recommanded values for smart separation of filenames.
43 43
   if (!defined('PCLZIP_SEPARATOR')) {
44
-    define( 'PCLZIP_SEPARATOR', ',' );
44
+    define('PCLZIP_SEPARATOR', ',');
45 45
   }
46 46
 
47 47
   // ----- Error configuration
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
   //     you must ensure that you have included PclError library.
51 51
   // [2,...] : reserved for futur use
52 52
   if (!defined('PCLZIP_ERROR_EXTERNAL')) {
53
-    define( 'PCLZIP_ERROR_EXTERNAL', 0 );
53
+    define('PCLZIP_ERROR_EXTERNAL', 0);
54 54
   }
55 55
 
56 56
   // ----- Optional static temporary directory
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
   // define( 'PCLZIP_TEMPORARY_DIR', '/temp/' );
64 64
   // define( 'PCLZIP_TEMPORARY_DIR', 'C:/Temp/' );
65 65
   if (!defined('PCLZIP_TEMPORARY_DIR')) {
66
-    define( 'PCLZIP_TEMPORARY_DIR', '' );
66
+    define('PCLZIP_TEMPORARY_DIR', '');
67 67
   }
68 68
 
69 69
   // ----- Optional threshold ratio for use of temporary files
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
   //       Samples :
76 76
   // define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.5 );
77 77
   if (!defined('PCLZIP_TEMPORARY_FILE_RATIO')) {
78
-    define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.47 );
78
+    define('PCLZIP_TEMPORARY_FILE_RATIO', 0.47);
79 79
   }
80 80
 
81 81
 // --------------------------------------------------------------------------------
@@ -100,72 +100,72 @@  discard block
 block discarded – undo
100 100
   //  -12 : Unable to rename file (rename)
101 101
   //  -13 : Invalid header checksum
102 102
   //  -14 : Invalid archive size
103
-  define( 'PCLZIP_ERR_USER_ABORTED', 2 );
104
-  define( 'PCLZIP_ERR_NO_ERROR', 0 );
105
-  define( 'PCLZIP_ERR_WRITE_OPEN_FAIL', -1 );
106
-  define( 'PCLZIP_ERR_READ_OPEN_FAIL', -2 );
107
-  define( 'PCLZIP_ERR_INVALID_PARAMETER', -3 );
108
-  define( 'PCLZIP_ERR_MISSING_FILE', -4 );
109
-  define( 'PCLZIP_ERR_FILENAME_TOO_LONG', -5 );
110
-  define( 'PCLZIP_ERR_INVALID_ZIP', -6 );
111
-  define( 'PCLZIP_ERR_BAD_EXTRACTED_FILE', -7 );
112
-  define( 'PCLZIP_ERR_DIR_CREATE_FAIL', -8 );
113
-  define( 'PCLZIP_ERR_BAD_EXTENSION', -9 );
114
-  define( 'PCLZIP_ERR_BAD_FORMAT', -10 );
115
-  define( 'PCLZIP_ERR_DELETE_FILE_FAIL', -11 );
116
-  define( 'PCLZIP_ERR_RENAME_FILE_FAIL', -12 );
117
-  define( 'PCLZIP_ERR_BAD_CHECKSUM', -13 );
118
-  define( 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP', -14 );
119
-  define( 'PCLZIP_ERR_MISSING_OPTION_VALUE', -15 );
120
-  define( 'PCLZIP_ERR_INVALID_OPTION_VALUE', -16 );
121
-  define( 'PCLZIP_ERR_ALREADY_A_DIRECTORY', -17 );
122
-  define( 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION', -18 );
123
-  define( 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION', -19 );
124
-  define( 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE', -20 );
125
-  define( 'PCLZIP_ERR_DIRECTORY_RESTRICTION', -21 );
103
+  define('PCLZIP_ERR_USER_ABORTED', 2);
104
+  define('PCLZIP_ERR_NO_ERROR', 0);
105
+  define('PCLZIP_ERR_WRITE_OPEN_FAIL', -1);
106
+  define('PCLZIP_ERR_READ_OPEN_FAIL', -2);
107
+  define('PCLZIP_ERR_INVALID_PARAMETER', -3);
108
+  define('PCLZIP_ERR_MISSING_FILE', -4);
109
+  define('PCLZIP_ERR_FILENAME_TOO_LONG', -5);
110
+  define('PCLZIP_ERR_INVALID_ZIP', -6);
111
+  define('PCLZIP_ERR_BAD_EXTRACTED_FILE', -7);
112
+  define('PCLZIP_ERR_DIR_CREATE_FAIL', -8);
113
+  define('PCLZIP_ERR_BAD_EXTENSION', -9);
114
+  define('PCLZIP_ERR_BAD_FORMAT', -10);
115
+  define('PCLZIP_ERR_DELETE_FILE_FAIL', -11);
116
+  define('PCLZIP_ERR_RENAME_FILE_FAIL', -12);
117
+  define('PCLZIP_ERR_BAD_CHECKSUM', -13);
118
+  define('PCLZIP_ERR_INVALID_ARCHIVE_ZIP', -14);
119
+  define('PCLZIP_ERR_MISSING_OPTION_VALUE', -15);
120
+  define('PCLZIP_ERR_INVALID_OPTION_VALUE', -16);
121
+  define('PCLZIP_ERR_ALREADY_A_DIRECTORY', -17);
122
+  define('PCLZIP_ERR_UNSUPPORTED_COMPRESSION', -18);
123
+  define('PCLZIP_ERR_UNSUPPORTED_ENCRYPTION', -19);
124
+  define('PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE', -20);
125
+  define('PCLZIP_ERR_DIRECTORY_RESTRICTION', -21);
126 126
 
127 127
   // ----- Options values
128
-  define( 'PCLZIP_OPT_PATH', 77001 );
129
-  define( 'PCLZIP_OPT_ADD_PATH', 77002 );
130
-  define( 'PCLZIP_OPT_REMOVE_PATH', 77003 );
131
-  define( 'PCLZIP_OPT_REMOVE_ALL_PATH', 77004 );
132
-  define( 'PCLZIP_OPT_SET_CHMOD', 77005 );
133
-  define( 'PCLZIP_OPT_EXTRACT_AS_STRING', 77006 );
134
-  define( 'PCLZIP_OPT_NO_COMPRESSION', 77007 );
135
-  define( 'PCLZIP_OPT_BY_NAME', 77008 );
136
-  define( 'PCLZIP_OPT_BY_INDEX', 77009 );
137
-  define( 'PCLZIP_OPT_BY_EREG', 77010 );
138
-  define( 'PCLZIP_OPT_BY_PREG', 77011 );
139
-  define( 'PCLZIP_OPT_COMMENT', 77012 );
140
-  define( 'PCLZIP_OPT_ADD_COMMENT', 77013 );
141
-  define( 'PCLZIP_OPT_PREPEND_COMMENT', 77014 );
142
-  define( 'PCLZIP_OPT_EXTRACT_IN_OUTPUT', 77015 );
143
-  define( 'PCLZIP_OPT_REPLACE_NEWER', 77016 );
144
-  define( 'PCLZIP_OPT_STOP_ON_ERROR', 77017 );
128
+  define('PCLZIP_OPT_PATH', 77001);
129
+  define('PCLZIP_OPT_ADD_PATH', 77002);
130
+  define('PCLZIP_OPT_REMOVE_PATH', 77003);
131
+  define('PCLZIP_OPT_REMOVE_ALL_PATH', 77004);
132
+  define('PCLZIP_OPT_SET_CHMOD', 77005);
133
+  define('PCLZIP_OPT_EXTRACT_AS_STRING', 77006);
134
+  define('PCLZIP_OPT_NO_COMPRESSION', 77007);
135
+  define('PCLZIP_OPT_BY_NAME', 77008);
136
+  define('PCLZIP_OPT_BY_INDEX', 77009);
137
+  define('PCLZIP_OPT_BY_EREG', 77010);
138
+  define('PCLZIP_OPT_BY_PREG', 77011);
139
+  define('PCLZIP_OPT_COMMENT', 77012);
140
+  define('PCLZIP_OPT_ADD_COMMENT', 77013);
141
+  define('PCLZIP_OPT_PREPEND_COMMENT', 77014);
142
+  define('PCLZIP_OPT_EXTRACT_IN_OUTPUT', 77015);
143
+  define('PCLZIP_OPT_REPLACE_NEWER', 77016);
144
+  define('PCLZIP_OPT_STOP_ON_ERROR', 77017);
145 145
   // Having big trouble with crypt. Need to multiply 2 long int
146 146
   // which is not correctly supported by PHP ...
147 147
   //define( 'PCLZIP_OPT_CRYPT', 77018 );
148
-  define( 'PCLZIP_OPT_EXTRACT_DIR_RESTRICTION', 77019 );
149
-  define( 'PCLZIP_OPT_TEMP_FILE_THRESHOLD', 77020 );
150
-  define( 'PCLZIP_OPT_ADD_TEMP_FILE_THRESHOLD', 77020 ); // alias
151
-  define( 'PCLZIP_OPT_TEMP_FILE_ON', 77021 );
152
-  define( 'PCLZIP_OPT_ADD_TEMP_FILE_ON', 77021 ); // alias
153
-  define( 'PCLZIP_OPT_TEMP_FILE_OFF', 77022 );
154
-  define( 'PCLZIP_OPT_ADD_TEMP_FILE_OFF', 77022 ); // alias
148
+  define('PCLZIP_OPT_EXTRACT_DIR_RESTRICTION', 77019);
149
+  define('PCLZIP_OPT_TEMP_FILE_THRESHOLD', 77020);
150
+  define('PCLZIP_OPT_ADD_TEMP_FILE_THRESHOLD', 77020); // alias
151
+  define('PCLZIP_OPT_TEMP_FILE_ON', 77021);
152
+  define('PCLZIP_OPT_ADD_TEMP_FILE_ON', 77021); // alias
153
+  define('PCLZIP_OPT_TEMP_FILE_OFF', 77022);
154
+  define('PCLZIP_OPT_ADD_TEMP_FILE_OFF', 77022); // alias
155 155
   
156 156
   // ----- File description attributes
157
-  define( 'PCLZIP_ATT_FILE_NAME', 79001 );
158
-  define( 'PCLZIP_ATT_FILE_NEW_SHORT_NAME', 79002 );
159
-  define( 'PCLZIP_ATT_FILE_NEW_FULL_NAME', 79003 );
160
-  define( 'PCLZIP_ATT_FILE_MTIME', 79004 );
161
-  define( 'PCLZIP_ATT_FILE_CONTENT', 79005 );
162
-  define( 'PCLZIP_ATT_FILE_COMMENT', 79006 );
157
+  define('PCLZIP_ATT_FILE_NAME', 79001);
158
+  define('PCLZIP_ATT_FILE_NEW_SHORT_NAME', 79002);
159
+  define('PCLZIP_ATT_FILE_NEW_FULL_NAME', 79003);
160
+  define('PCLZIP_ATT_FILE_MTIME', 79004);
161
+  define('PCLZIP_ATT_FILE_CONTENT', 79005);
162
+  define('PCLZIP_ATT_FILE_COMMENT', 79006);
163 163
 
164 164
   // ----- Call backs values
165
-  define( 'PCLZIP_CB_PRE_EXTRACT', 78001 );
166
-  define( 'PCLZIP_CB_POST_EXTRACT', 78002 );
167
-  define( 'PCLZIP_CB_PRE_ADD', 78003 );
168
-  define( 'PCLZIP_CB_POST_ADD', 78004 );
165
+  define('PCLZIP_CB_PRE_EXTRACT', 78001);
166
+  define('PCLZIP_CB_POST_EXTRACT', 78002);
167
+  define('PCLZIP_CB_PRE_ADD', 78003);
168
+  define('PCLZIP_CB_POST_ADD', 78004);
169 169
   /* For futur use
170 170
   define( 'PCLZIP_CB_PRE_LIST', 78005 );
171 171
   define( 'PCLZIP_CB_POST_LIST', 78006 );
@@ -220,9 +220,9 @@  discard block
 block discarded – undo
220 220
     {
221 221
       if (!function_exists('gzopen')
222 222
         && function_exists('gzopen64')) {
223
-        function gzopen($filename , $mode = 'r', $use_include_path = 0 )
223
+        function gzopen($filename, $mode = 'r', $use_include_path = 0)
224 224
         {
225
-            return gzopen64($filename , $mode, $use_include_path);
225
+            return gzopen64($filename, $mode, $use_include_path);
226 226
         }
227 227
       }
228 228
     }
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
   // --------------------------------------------------------------------------------
277 277
   function create($p_filelist)
278 278
   {
279
-    $v_result=1;
279
+    $v_result = 1;
280 280
 
281 281
     // ----- Reset the error handler
282 282
     $this->privErrorReset();
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 
303 303
         // ----- Parse the options
304 304
         $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
305
-                                            array (PCLZIP_OPT_REMOVE_PATH => 'optional',
305
+                                            array(PCLZIP_OPT_REMOVE_PATH => 'optional',
306 306
                                                    PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
307 307
                                                    PCLZIP_OPT_ADD_PATH => 'optional',
308 308
                                                    PCLZIP_CB_PRE_ADD => 'optional',
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
     
389 389
     // ----- For each file in the list check the attributes
390 390
     $v_supported_attributes
391
-    = array ( PCLZIP_ATT_FILE_NAME => 'mandatory'
391
+    = array(PCLZIP_ATT_FILE_NAME => 'mandatory'
392 392
              ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional'
393 393
              ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional'
394 394
              ,PCLZIP_ATT_FILE_MTIME => 'optional'
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
   // --------------------------------------------------------------------------------
460 460
   function add($p_filelist)
461 461
   {
462
-    $v_result=1;
462
+    $v_result = 1;
463 463
 
464 464
     // ----- Reset the error handler
465 465
     $this->privErrorReset();
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
 
486 486
         // ----- Parse the options
487 487
         $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
488
-                                            array (PCLZIP_OPT_REMOVE_PATH => 'optional',
488
+                                            array(PCLZIP_OPT_REMOVE_PATH => 'optional',
489 489
                                                    PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
490 490
                                                    PCLZIP_OPT_ADD_PATH => 'optional',
491 491
                                                    PCLZIP_CB_PRE_ADD => 'optional',
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
 
559 559
     // ----- Invalid variable type for $p_filelist
560 560
     else {
561
-      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '".gettype($p_filelist)."' for p_filelist");
561
+      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '" . gettype($p_filelist) . "' for p_filelist");
562 562
       return 0;
563 563
     }
564 564
     
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
     
572 572
     // ----- For each file in the list check the attributes
573 573
     $v_supported_attributes
574
-    = array ( PCLZIP_ATT_FILE_NAME => 'mandatory'
574
+    = array(PCLZIP_ATT_FILE_NAME => 'mandatory'
575 575
              ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional'
576 576
              ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional'
577 577
              ,PCLZIP_ATT_FILE_MTIME => 'optional'
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
   // --------------------------------------------------------------------------------
649 649
   function listContent()
650 650
   {
651
-    $v_result=1;
651
+    $v_result = 1;
652 652
 
653 653
     // ----- Reset the error handler
654 654
     $this->privErrorReset();
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
   // --------------------------------------------------------------------------------
706 706
   function extract()
707 707
   {
708
-    $v_result=1;
708
+    $v_result = 1;
709 709
 
710 710
     // ----- Reset the error handler
711 711
     $this->privErrorReset();
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
 
739 739
         // ----- Parse the options
740 740
         $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
741
-                                            array (PCLZIP_OPT_PATH => 'optional',
741
+                                            array(PCLZIP_OPT_PATH => 'optional',
742 742
                                                    PCLZIP_OPT_REMOVE_PATH => 'optional',
743 743
                                                    PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
744 744
                                                    PCLZIP_OPT_ADD_PATH => 'optional',
@@ -862,7 +862,7 @@  discard block
 block discarded – undo
862 862
   //function extractByIndex($p_index, options...)
863 863
   function extractByIndex($p_index)
864 864
   {
865
-    $v_result=1;
865
+    $v_result = 1;
866 866
 
867 867
     // ----- Reset the error handler
868 868
     $this->privErrorReset();
@@ -899,7 +899,7 @@  discard block
 block discarded – undo
899 899
 
900 900
         // ----- Parse the options
901 901
         $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
902
-                                            array (PCLZIP_OPT_PATH => 'optional',
902
+                                            array(PCLZIP_OPT_PATH => 'optional',
903 903
                                                    PCLZIP_OPT_REMOVE_PATH => 'optional',
904 904
                                                    PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
905 905
                                                    PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',
@@ -969,10 +969,10 @@  discard block
 block discarded – undo
969 969
     // ----- Trick
970 970
     // Here I want to reuse extractByRule(), so I need to parse the $p_index
971 971
     // with privParseOptions()
972
-    $v_arg_trick = array (PCLZIP_OPT_BY_INDEX, $p_index);
972
+    $v_arg_trick = array(PCLZIP_OPT_BY_INDEX, $p_index);
973 973
     $v_options_trick = array();
974 974
     $v_result = $this->privParseOptions($v_arg_trick, sizeof($v_arg_trick), $v_options_trick,
975
-                                        array (PCLZIP_OPT_BY_INDEX => 'optional' ));
975
+                                        array(PCLZIP_OPT_BY_INDEX => 'optional'));
976 976
     if ($v_result != 1) {
977 977
         return 0;
978 978
     }
@@ -1011,7 +1011,7 @@  discard block
 block discarded – undo
1011 1011
   // --------------------------------------------------------------------------------
1012 1012
   function delete()
1013 1013
   {
1014
-    $v_result=1;
1014
+    $v_result = 1;
1015 1015
 
1016 1016
     // ----- Reset the error handler
1017 1017
     $this->privErrorReset();
@@ -1034,10 +1034,10 @@  discard block
 block discarded – undo
1034 1034
 
1035 1035
       // ----- Parse the options
1036 1036
       $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
1037
-                                        array (PCLZIP_OPT_BY_NAME => 'optional',
1037
+                                        array(PCLZIP_OPT_BY_NAME => 'optional',
1038 1038
                                                PCLZIP_OPT_BY_EREG => 'optional',
1039 1039
                                                PCLZIP_OPT_BY_PREG => 'optional',
1040
-                                               PCLZIP_OPT_BY_INDEX => 'optional' ));
1040
+                                               PCLZIP_OPT_BY_INDEX => 'optional'));
1041 1041
       if ($v_result != 1) {
1042 1042
           return 0;
1043 1043
       }
@@ -1122,7 +1122,7 @@  discard block
 block discarded – undo
1122 1122
         $this->privSwapBackMagicQuotes();
1123 1123
         
1124 1124
         // ----- Error log
1125
-        PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
1125
+        PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \'' . $this->zipname . '\' in binary read mode');
1126 1126
 
1127 1127
         // ----- Return
1128 1128
         return 0;
@@ -1188,7 +1188,7 @@  discard block
 block discarded – undo
1188 1188
       // TBC : Should also check the archive format
1189 1189
       if (!is_file($p_archive)) {
1190 1190
         // ----- Error log
1191
-        PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "No file with filename '".$p_archive."'");
1191
+        PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "No file with filename '" . $p_archive . "'");
1192 1192
         $v_result = PCLZIP_ERR_MISSING_FILE;
1193 1193
       }
1194 1194
       else {
@@ -1291,9 +1291,9 @@  discard block
 block discarded – undo
1291 1291
   // Description :
1292 1292
   // Parameters :
1293 1293
   // --------------------------------------------------------------------------------
1294
-  function errorName($p_with_code=false)
1294
+  function errorName($p_with_code = false)
1295 1295
   {
1296
-    $v_name = array ( PCLZIP_ERR_NO_ERROR => 'PCLZIP_ERR_NO_ERROR',
1296
+    $v_name = array(PCLZIP_ERR_NO_ERROR => 'PCLZIP_ERR_NO_ERROR',
1297 1297
                       PCLZIP_ERR_WRITE_OPEN_FAIL => 'PCLZIP_ERR_WRITE_OPEN_FAIL',
1298 1298
                       PCLZIP_ERR_READ_OPEN_FAIL => 'PCLZIP_ERR_READ_OPEN_FAIL',
1299 1299
                       PCLZIP_ERR_INVALID_PARAMETER => 'PCLZIP_ERR_INVALID_PARAMETER',
@@ -1324,7 +1324,7 @@  discard block
 block discarded – undo
1324 1324
     }
1325 1325
 
1326 1326
     if ($p_with_code) {
1327
-      return($v_value.' ('.$this->error_code.')');
1327
+      return($v_value . ' (' . $this->error_code . ')');
1328 1328
     }
1329 1329
     else {
1330 1330
       return($v_value);
@@ -1337,17 +1337,17 @@  discard block
 block discarded – undo
1337 1337
   // Description :
1338 1338
   // Parameters :
1339 1339
   // --------------------------------------------------------------------------------
1340
-  function errorInfo($p_full=false)
1340
+  function errorInfo($p_full = false)
1341 1341
   {
1342 1342
     if (PCLZIP_ERROR_EXTERNAL == 1) {
1343 1343
       return(PclErrorString());
1344 1344
     }
1345 1345
     else {
1346 1346
       if ($p_full) {
1347
-        return($this->errorName(true)." : ".$this->error_string);
1347
+        return($this->errorName(true) . " : " . $this->error_string);
1348 1348
       }
1349 1349
       else {
1350
-        return($this->error_string." [code ".$this->error_code."]");
1350
+        return($this->error_string . " [code " . $this->error_code . "]");
1351 1351
       }
1352 1352
     }
1353 1353
   }
@@ -1376,7 +1376,7 @@  discard block
 block discarded – undo
1376 1376
   //   true on success,
1377 1377
   //   false on error, the error code is set.
1378 1378
   // --------------------------------------------------------------------------------
1379
-  function privCheckFormat($p_level=0)
1379
+  function privCheckFormat($p_level = 0)
1380 1380
   {
1381 1381
     $v_result = true;
1382 1382
 
@@ -1389,14 +1389,14 @@  discard block
 block discarded – undo
1389 1389
     // ----- Look if the file exits
1390 1390
     if (!is_file($this->zipname)) {
1391 1391
       // ----- Error log
1392
-      PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "Missing archive file '".$this->zipname."'");
1392
+      PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "Missing archive file '" . $this->zipname . "'");
1393 1393
       return(false);
1394 1394
     }
1395 1395
 
1396 1396
     // ----- Check that the file is readeable
1397 1397
     if (!is_readable($this->zipname)) {
1398 1398
       // ----- Error log
1399
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '".$this->zipname."'");
1399
+      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '" . $this->zipname . "'");
1400 1400
       return(false);
1401 1401
     }
1402 1402
 
@@ -1429,18 +1429,18 @@  discard block
 block discarded – undo
1429 1429
   //   1 on success.
1430 1430
   //   0 on failure.
1431 1431
   // --------------------------------------------------------------------------------
1432
-  function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options=false)
1432
+  function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options = false)
1433 1433
   {
1434
-    $v_result=1;
1434
+    $v_result = 1;
1435 1435
     
1436 1436
     // ----- Read the options
1437
-    $i=0;
1438
-    while ($i<$p_size) {
1437
+    $i = 0;
1438
+    while ($i < $p_size) {
1439 1439
 
1440 1440
       // ----- Check if the option is supported
1441 1441
       if (!isset($v_requested_options[$p_options_list[$i]])) {
1442 1442
         // ----- Error log
1443
-        PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid optional parameter '".$p_options_list[$i]."' for this method");
1443
+        PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid optional parameter '" . $p_options_list[$i] . "' for this method");
1444 1444
 
1445 1445
         // ----- Return
1446 1446
         return PclZip::errorCode();
@@ -1453,48 +1453,48 @@  discard block
 block discarded – undo
1453 1453
         case PCLZIP_OPT_REMOVE_PATH :
1454 1454
         case PCLZIP_OPT_ADD_PATH :
1455 1455
           // ----- Check the number of parameters
1456
-          if (($i+1) >= $p_size) {
1456
+          if (($i + 1) >= $p_size) {
1457 1457
             // ----- Error log
1458
-            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1458
+            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'");
1459 1459
 
1460 1460
             // ----- Return
1461 1461
             return PclZip::errorCode();
1462 1462
           }
1463 1463
 
1464 1464
           // ----- Get the value
1465
-          $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE);
1465
+          $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i + 1], FALSE);
1466 1466
           $i++;
1467 1467
         break;
1468 1468
 
1469 1469
         case PCLZIP_OPT_TEMP_FILE_THRESHOLD :
1470 1470
           // ----- Check the number of parameters
1471
-          if (($i+1) >= $p_size) {
1472
-            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1471
+          if (($i + 1) >= $p_size) {
1472
+            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'");
1473 1473
             return PclZip::errorCode();
1474 1474
           }
1475 1475
           
1476 1476
           // ----- Check for incompatible options
1477 1477
           if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) {
1478
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'");
1478
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '" . PclZipUtilOptionText($p_options_list[$i]) . "' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'");
1479 1479
             return PclZip::errorCode();
1480 1480
           }
1481 1481
           
1482 1482
           // ----- Check the value
1483
-          $v_value = $p_options_list[$i+1];
1484
-          if ((!is_integer($v_value)) || ($v_value<0)) {
1485
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Integer expected for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1483
+          $v_value = $p_options_list[$i + 1];
1484
+          if ((!is_integer($v_value)) || ($v_value < 0)) {
1485
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Integer expected for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'");
1486 1486
             return PclZip::errorCode();
1487 1487
           }
1488 1488
 
1489 1489
           // ----- Get the value (and convert it in bytes)
1490
-          $v_result_list[$p_options_list[$i]] = $v_value*1048576;
1490
+          $v_result_list[$p_options_list[$i]] = $v_value * 1048576;
1491 1491
           $i++;
1492 1492
         break;
1493 1493
 
1494 1494
         case PCLZIP_OPT_TEMP_FILE_ON :
1495 1495
           // ----- Check for incompatible options
1496 1496
           if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) {
1497
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'");
1497
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '" . PclZipUtilOptionText($p_options_list[$i]) . "' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'");
1498 1498
             return PclZip::errorCode();
1499 1499
           }
1500 1500
           
@@ -1504,12 +1504,12 @@  discard block
 block discarded – undo
1504 1504
         case PCLZIP_OPT_TEMP_FILE_OFF :
1505 1505
           // ----- Check for incompatible options
1506 1506
           if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_ON])) {
1507
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_ON'");
1507
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '" . PclZipUtilOptionText($p_options_list[$i]) . "' can not be used with option 'PCLZIP_OPT_TEMP_FILE_ON'");
1508 1508
             return PclZip::errorCode();
1509 1509
           }
1510 1510
           // ----- Check for incompatible options
1511 1511
           if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) {
1512
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_THRESHOLD'");
1512
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '" . PclZipUtilOptionText($p_options_list[$i]) . "' can not be used with option 'PCLZIP_OPT_TEMP_FILE_THRESHOLD'");
1513 1513
             return PclZip::errorCode();
1514 1514
           }
1515 1515
           
@@ -1518,18 +1518,18 @@  discard block
 block discarded – undo
1518 1518
 
1519 1519
         case PCLZIP_OPT_EXTRACT_DIR_RESTRICTION :
1520 1520
           // ----- Check the number of parameters
1521
-          if (($i+1) >= $p_size) {
1521
+          if (($i + 1) >= $p_size) {
1522 1522
             // ----- Error log
1523
-            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1523
+            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'");
1524 1524
 
1525 1525
             // ----- Return
1526 1526
             return PclZip::errorCode();
1527 1527
           }
1528 1528
 
1529 1529
           // ----- Get the value
1530
-          if (   is_string($p_options_list[$i+1])
1531
-              && ($p_options_list[$i+1] != '')) {
1532
-            $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE);
1530
+          if (is_string($p_options_list[$i + 1])
1531
+              && ($p_options_list[$i + 1] != '')) {
1532
+            $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i + 1], FALSE);
1533 1533
             $i++;
1534 1534
           }
1535 1535
           else {
@@ -1539,24 +1539,24 @@  discard block
 block discarded – undo
1539 1539
         // ----- Look for options that request an array of string for value
1540 1540
         case PCLZIP_OPT_BY_NAME :
1541 1541
           // ----- Check the number of parameters
1542
-          if (($i+1) >= $p_size) {
1542
+          if (($i + 1) >= $p_size) {
1543 1543
             // ----- Error log
1544
-            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1544
+            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'");
1545 1545
 
1546 1546
             // ----- Return
1547 1547
             return PclZip::errorCode();
1548 1548
           }
1549 1549
 
1550 1550
           // ----- Get the value
1551
-          if (is_string($p_options_list[$i+1])) {
1552
-              $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i+1];
1551
+          if (is_string($p_options_list[$i + 1])) {
1552
+              $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i + 1];
1553 1553
           }
1554
-          else if (is_array($p_options_list[$i+1])) {
1555
-              $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1554
+          else if (is_array($p_options_list[$i + 1])) {
1555
+              $v_result_list[$p_options_list[$i]] = $p_options_list[$i + 1];
1556 1556
           }
1557 1557
           else {
1558 1558
             // ----- Error log
1559
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1559
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'");
1560 1560
 
1561 1561
             // ----- Return
1562 1562
             return PclZip::errorCode();
@@ -1572,21 +1572,21 @@  discard block
 block discarded – undo
1572 1572
         case PCLZIP_OPT_BY_PREG :
1573 1573
         //case PCLZIP_OPT_CRYPT :
1574 1574
           // ----- Check the number of parameters
1575
-          if (($i+1) >= $p_size) {
1575
+          if (($i + 1) >= $p_size) {
1576 1576
             // ----- Error log
1577
-            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1577
+            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'");
1578 1578
 
1579 1579
             // ----- Return
1580 1580
             return PclZip::errorCode();
1581 1581
           }
1582 1582
 
1583 1583
           // ----- Get the value
1584
-          if (is_string($p_options_list[$i+1])) {
1585
-              $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1584
+          if (is_string($p_options_list[$i + 1])) {
1585
+              $v_result_list[$p_options_list[$i]] = $p_options_list[$i + 1];
1586 1586
           }
1587 1587
           else {
1588 1588
             // ----- Error log
1589
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1589
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'");
1590 1590
 
1591 1591
             // ----- Return
1592 1592
             return PclZip::errorCode();
@@ -1599,7 +1599,7 @@  discard block
 block discarded – undo
1599 1599
         case PCLZIP_OPT_ADD_COMMENT :
1600 1600
         case PCLZIP_OPT_PREPEND_COMMENT :
1601 1601
           // ----- Check the number of parameters
1602
-          if (($i+1) >= $p_size) {
1602
+          if (($i + 1) >= $p_size) {
1603 1603
             // ----- Error log
1604 1604
             PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE,
1605 1605
 			                     "Missing parameter value for option '"
@@ -1611,8 +1611,8 @@  discard block
 block discarded – undo
1611 1611
           }
1612 1612
 
1613 1613
           // ----- Get the value
1614
-          if (is_string($p_options_list[$i+1])) {
1615
-              $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1614
+          if (is_string($p_options_list[$i + 1])) {
1615
+              $v_result_list[$p_options_list[$i]] = $p_options_list[$i + 1];
1616 1616
           }
1617 1617
           else {
1618 1618
             // ----- Error log
@@ -1630,9 +1630,9 @@  discard block
 block discarded – undo
1630 1630
         // ----- Look for options that request an array of index
1631 1631
         case PCLZIP_OPT_BY_INDEX :
1632 1632
           // ----- Check the number of parameters
1633
-          if (($i+1) >= $p_size) {
1633
+          if (($i + 1) >= $p_size) {
1634 1634
             // ----- Error log
1635
-            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1635
+            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'");
1636 1636
 
1637 1637
             // ----- Return
1638 1638
             return PclZip::errorCode();
@@ -1640,23 +1640,23 @@  discard block
 block discarded – undo
1640 1640
 
1641 1641
           // ----- Get the value
1642 1642
           $v_work_list = array();
1643
-          if (is_string($p_options_list[$i+1])) {
1643
+          if (is_string($p_options_list[$i + 1])) {
1644 1644
 
1645 1645
               // ----- Remove spaces
1646
-              $p_options_list[$i+1] = strtr($p_options_list[$i+1], ' ', '');
1646
+              $p_options_list[$i + 1] = strtr($p_options_list[$i + 1], ' ', '');
1647 1647
 
1648 1648
               // ----- Parse items
1649
-              $v_work_list = explode(",", $p_options_list[$i+1]);
1649
+              $v_work_list = explode(",", $p_options_list[$i + 1]);
1650 1650
           }
1651
-          else if (is_integer($p_options_list[$i+1])) {
1652
-              $v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1];
1651
+          else if (is_integer($p_options_list[$i + 1])) {
1652
+              $v_work_list[0] = $p_options_list[$i + 1] . '-' . $p_options_list[$i + 1];
1653 1653
           }
1654
-          else if (is_array($p_options_list[$i+1])) {
1655
-              $v_work_list = $p_options_list[$i+1];
1654
+          else if (is_array($p_options_list[$i + 1])) {
1655
+              $v_work_list = $p_options_list[$i + 1];
1656 1656
           }
1657 1657
           else {
1658 1658
             // ----- Error log
1659
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1659
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'");
1660 1660
 
1661 1661
             // ----- Return
1662 1662
             return PclZip::errorCode();
@@ -1666,9 +1666,9 @@  discard block
 block discarded – undo
1666 1666
           // each index item in the list must be a couple with a start and
1667 1667
           // an end value : [0,3], [5-5], [8-10], ...
1668 1668
           // ----- Check the format of each item
1669
-          $v_sort_flag=false;
1670
-          $v_sort_value=0;
1671
-          for ($j=0; $j<sizeof($v_work_list); $j++) {
1669
+          $v_sort_flag = false;
1670
+          $v_sort_value = 0;
1671
+          for ($j = 0; $j < sizeof($v_work_list); $j++) {
1672 1672
               // ----- Explode the item
1673 1673
               $v_item_list = explode("-", $v_work_list[$j]);
1674 1674
               $v_size_item_list = sizeof($v_item_list);
@@ -1689,7 +1689,7 @@  discard block
 block discarded – undo
1689 1689
               }
1690 1690
               else {
1691 1691
                   // ----- Error log
1692
-                  PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Too many values in index range for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1692
+                  PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Too many values in index range for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'");
1693 1693
 
1694 1694
                   // ----- Return
1695 1695
                   return PclZip::errorCode();
@@ -1698,11 +1698,11 @@  discard block
 block discarded – undo
1698 1698
 
1699 1699
               // ----- Look for list sort
1700 1700
               if ($v_result_list[$p_options_list[$i]][$j]['start'] < $v_sort_value) {
1701
-                  $v_sort_flag=true;
1701
+                  $v_sort_flag = true;
1702 1702
 
1703 1703
                   // ----- TBC : An automatic sort should be writen ...
1704 1704
                   // ----- Error log
1705
-                  PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Invalid order of index range for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1705
+                  PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Invalid order of index range for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'");
1706 1706
 
1707 1707
                   // ----- Return
1708 1708
                   return PclZip::errorCode();
@@ -1732,16 +1732,16 @@  discard block
 block discarded – undo
1732 1732
         // ----- Look for options that request an octal value
1733 1733
         case PCLZIP_OPT_SET_CHMOD :
1734 1734
           // ----- Check the number of parameters
1735
-          if (($i+1) >= $p_size) {
1735
+          if (($i + 1) >= $p_size) {
1736 1736
             // ----- Error log
1737
-            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1737
+            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'");
1738 1738
 
1739 1739
             // ----- Return
1740 1740
             return PclZip::errorCode();
1741 1741
           }
1742 1742
 
1743 1743
           // ----- Get the value
1744
-          $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1744
+          $v_result_list[$p_options_list[$i]] = $p_options_list[$i + 1];
1745 1745
           $i++;
1746 1746
         break;
1747 1747
 
@@ -1757,21 +1757,21 @@  discard block
 block discarded – undo
1757 1757
         case PCLZIP_CB_POST_LIST :
1758 1758
         */
1759 1759
           // ----- Check the number of parameters
1760
-          if (($i+1) >= $p_size) {
1760
+          if (($i + 1) >= $p_size) {
1761 1761
             // ----- Error log
1762
-            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1762
+            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'");
1763 1763
 
1764 1764
             // ----- Return
1765 1765
             return PclZip::errorCode();
1766 1766
           }
1767 1767
 
1768 1768
           // ----- Get the value
1769
-          $v_function_name = $p_options_list[$i+1];
1769
+          $v_function_name = $p_options_list[$i + 1];
1770 1770
 
1771 1771
           // ----- Check that the value is a valid existing function
1772 1772
           if (!function_exists($v_function_name)) {
1773 1773
             // ----- Error log
1774
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Function '".$v_function_name."()' is not an existing function for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1774
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Function '" . $v_function_name . "()' is not an existing function for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'");
1775 1775
 
1776 1776
             // ----- Return
1777 1777
             return PclZip::errorCode();
@@ -1786,7 +1786,7 @@  discard block
 block discarded – undo
1786 1786
           // ----- Error log
1787 1787
           PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
1788 1788
 		                       "Unknown parameter '"
1789
-							   .$p_options_list[$i]."'");
1789
+							   .$p_options_list[$i] . "'");
1790 1790
 
1791 1791
           // ----- Return
1792 1792
           return PclZip::errorCode();
@@ -1798,13 +1798,13 @@  discard block
 block discarded – undo
1798 1798
 
1799 1799
     // ----- Look for mandatory options
1800 1800
     if ($v_requested_options !== false) {
1801
-      for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
1801
+      for ($key = reset($v_requested_options); $key = key($v_requested_options); $key = next($v_requested_options)) {
1802 1802
         // ----- Look for mandatory option
1803 1803
         if ($v_requested_options[$key] == 'mandatory') {
1804 1804
           // ----- Look if present
1805 1805
           if (!isset($v_result_list[$key])) {
1806 1806
             // ----- Error log
1807
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
1807
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter " . PclZipUtilOptionText($key) . "(" . $key . ")");
1808 1808
 
1809 1809
             // ----- Return
1810 1810
             return PclZip::errorCode();
@@ -1831,7 +1831,7 @@  discard block
 block discarded – undo
1831 1831
   // --------------------------------------------------------------------------------
1832 1832
   function privOptionDefaultThreshold(&$p_options)
1833 1833
   {
1834
-    $v_result=1;
1834
+    $v_result = 1;
1835 1835
     
1836 1836
     if (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
1837 1837
         || isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) {
@@ -1843,16 +1843,16 @@  discard block
 block discarded – undo
1843 1843
     $v_memory_limit = trim($v_memory_limit);
1844 1844
     $last = strtolower(substr($v_memory_limit, -1));
1845 1845
  
1846
-    if($last == 'g')
1846
+    if ($last == 'g')
1847 1847
         //$v_memory_limit = $v_memory_limit*1024*1024*1024;
1848
-        $v_memory_limit = $v_memory_limit*1073741824;
1849
-    if($last == 'm')
1848
+        $v_memory_limit = $v_memory_limit * 1073741824;
1849
+    if ($last == 'm')
1850 1850
         //$v_memory_limit = $v_memory_limit*1024*1024;
1851
-        $v_memory_limit = $v_memory_limit*1048576;
1852
-    if($last == 'k')
1853
-        $v_memory_limit = $v_memory_limit*1024;
1851
+        $v_memory_limit = $v_memory_limit * 1048576;
1852
+    if ($last == 'k')
1853
+        $v_memory_limit = $v_memory_limit * 1024;
1854 1854
             
1855
-    $p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit*PCLZIP_TEMPORARY_FILE_RATIO);
1855
+    $p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit * PCLZIP_TEMPORARY_FILE_RATIO);
1856 1856
     
1857 1857
 
1858 1858
     // ----- Sanity check : No threshold if value lower than 1M
@@ -1873,9 +1873,9 @@  discard block
 block discarded – undo
1873 1873
   //   1 on success.
1874 1874
   //   0 on failure.
1875 1875
   // --------------------------------------------------------------------------------
1876
-  function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options=false)
1876
+  function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options = false)
1877 1877
   {
1878
-    $v_result=1;
1878
+    $v_result = 1;
1879 1879
     
1880 1880
     // ----- For each file in the list check the attributes
1881 1881
     foreach ($p_file_list as $v_key => $v_value) {
@@ -1883,7 +1883,7 @@  discard block
 block discarded – undo
1883 1883
       // ----- Check if the option is supported
1884 1884
       if (!isset($v_requested_options[$v_key])) {
1885 1885
         // ----- Error log
1886
-        PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file attribute '".$v_key."' for this file");
1886
+        PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file attribute '" . $v_key . "' for this file");
1887 1887
 
1888 1888
         // ----- Return
1889 1889
         return PclZip::errorCode();
@@ -1893,14 +1893,14 @@  discard block
 block discarded – undo
1893 1893
       switch ($v_key) {
1894 1894
         case PCLZIP_ATT_FILE_NAME :
1895 1895
           if (!is_string($v_value)) {
1896
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1896
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type " . gettype($v_value) . ". String expected for attribute '" . PclZipUtilOptionText($v_key) . "'");
1897 1897
             return PclZip::errorCode();
1898 1898
           }
1899 1899
 
1900 1900
           $p_filedescr['filename'] = PclZipUtilPathReduction($v_value);
1901 1901
           
1902 1902
           if ($p_filedescr['filename'] == '') {
1903
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty filename for attribute '".PclZipUtilOptionText($v_key)."'");
1903
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty filename for attribute '" . PclZipUtilOptionText($v_key) . "'");
1904 1904
             return PclZip::errorCode();
1905 1905
           }
1906 1906
 
@@ -1908,28 +1908,28 @@  discard block
 block discarded – undo
1908 1908
 
1909 1909
         case PCLZIP_ATT_FILE_NEW_SHORT_NAME :
1910 1910
           if (!is_string($v_value)) {
1911
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1911
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type " . gettype($v_value) . ". String expected for attribute '" . PclZipUtilOptionText($v_key) . "'");
1912 1912
             return PclZip::errorCode();
1913 1913
           }
1914 1914
 
1915 1915
           $p_filedescr['new_short_name'] = PclZipUtilPathReduction($v_value);
1916 1916
 
1917 1917
           if ($p_filedescr['new_short_name'] == '') {
1918
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty short filename for attribute '".PclZipUtilOptionText($v_key)."'");
1918
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty short filename for attribute '" . PclZipUtilOptionText($v_key) . "'");
1919 1919
             return PclZip::errorCode();
1920 1920
           }
1921 1921
         break;
1922 1922
 
1923 1923
         case PCLZIP_ATT_FILE_NEW_FULL_NAME :
1924 1924
           if (!is_string($v_value)) {
1925
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1925
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type " . gettype($v_value) . ". String expected for attribute '" . PclZipUtilOptionText($v_key) . "'");
1926 1926
             return PclZip::errorCode();
1927 1927
           }
1928 1928
 
1929 1929
           $p_filedescr['new_full_name'] = PclZipUtilPathReduction($v_value);
1930 1930
 
1931 1931
           if ($p_filedescr['new_full_name'] == '') {
1932
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty full filename for attribute '".PclZipUtilOptionText($v_key)."'");
1932
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty full filename for attribute '" . PclZipUtilOptionText($v_key) . "'");
1933 1933
             return PclZip::errorCode();
1934 1934
           }
1935 1935
         break;
@@ -1937,7 +1937,7 @@  discard block
 block discarded – undo
1937 1937
         // ----- Look for options that takes a string
1938 1938
         case PCLZIP_ATT_FILE_COMMENT :
1939 1939
           if (!is_string($v_value)) {
1940
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1940
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type " . gettype($v_value) . ". String expected for attribute '" . PclZipUtilOptionText($v_key) . "'");
1941 1941
             return PclZip::errorCode();
1942 1942
           }
1943 1943
 
@@ -1946,7 +1946,7 @@  discard block
 block discarded – undo
1946 1946
 
1947 1947
         case PCLZIP_ATT_FILE_MTIME :
1948 1948
           if (!is_integer($v_value)) {
1949
-            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". Integer expected for attribute '".PclZipUtilOptionText($v_key)."'");
1949
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type " . gettype($v_value) . ". Integer expected for attribute '" . PclZipUtilOptionText($v_key) . "'");
1950 1950
             return PclZip::errorCode();
1951 1951
           }
1952 1952
 
@@ -1960,7 +1960,7 @@  discard block
 block discarded – undo
1960 1960
         default :
1961 1961
           // ----- Error log
1962 1962
           PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
1963
-		                           "Unknown parameter '".$v_key."'");
1963
+		                           "Unknown parameter '" . $v_key . "'");
1964 1964
 
1965 1965
           // ----- Return
1966 1966
           return PclZip::errorCode();
@@ -1968,12 +1968,12 @@  discard block
 block discarded – undo
1968 1968
 
1969 1969
       // ----- Look for mandatory options
1970 1970
       if ($v_requested_options !== false) {
1971
-        for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
1971
+        for ($key = reset($v_requested_options); $key = key($v_requested_options); $key = next($v_requested_options)) {
1972 1972
           // ----- Look for mandatory option
1973 1973
           if ($v_requested_options[$key] == 'mandatory') {
1974 1974
             // ----- Look if present
1975 1975
             if (!isset($p_file_list[$key])) {
1976
-              PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
1976
+              PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter " . PclZipUtilOptionText($key) . "(" . $key . ")");
1977 1977
               return PclZip::errorCode();
1978 1978
             }
1979 1979
           }
@@ -2004,13 +2004,13 @@  discard block
 block discarded – undo
2004 2004
   // --------------------------------------------------------------------------------
2005 2005
   function privFileDescrExpand(&$p_filedescr_list, &$p_options)
2006 2006
   {
2007
-    $v_result=1;
2007
+    $v_result = 1;
2008 2008
     
2009 2009
     // ----- Create a result list
2010 2010
     $v_result_list = array();
2011 2011
     
2012 2012
     // ----- Look each entry
2013
-    for ($i=0; $i<sizeof($p_filedescr_list); $i++) {
2013
+    for ($i = 0; $i < sizeof($p_filedescr_list); $i++) {
2014 2014
       
2015 2015
       // ----- Get filedescr
2016 2016
       $v_descr = $p_filedescr_list[$i];
@@ -2045,7 +2045,7 @@  discard block
 block discarded – undo
2045 2045
       // ----- Missing file
2046 2046
       else {
2047 2047
         // ----- Error log
2048
-        PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$v_descr['filename']."' does not exist");
2048
+        PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '" . $v_descr['filename'] . "' does not exist");
2049 2049
 
2050 2050
         // ----- Return
2051 2051
         return PclZip::errorCode();
@@ -2071,7 +2071,7 @@  discard block
 block discarded – undo
2071 2071
             }
2072 2072
             
2073 2073
             // ----- Compose the full filename
2074
-            $v_dirlist_descr[$v_dirlist_nb]['filename'] = $v_descr['filename'].'/'.$v_item_handler;
2074
+            $v_dirlist_descr[$v_dirlist_nb]['filename'] = $v_descr['filename'] . '/' . $v_item_handler;
2075 2075
             
2076 2076
             // ----- Look for different stored filename
2077 2077
             // Because the name of the folder was changed, the name of the
@@ -2079,7 +2079,7 @@  discard block
 block discarded – undo
2079 2079
             if (($v_descr['stored_filename'] != $v_descr['filename'])
2080 2080
                  && (!isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))) {
2081 2081
               if ($v_descr['stored_filename'] != '') {
2082
-                $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler;
2082
+                $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'] . '/' . $v_item_handler;
2083 2083
               }
2084 2084
               else {
2085 2085
                 $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_item_handler;
@@ -2129,7 +2129,7 @@  discard block
 block discarded – undo
2129 2129
   // --------------------------------------------------------------------------------
2130 2130
   function privCreate($p_filedescr_list, &$p_result_list, &$p_options)
2131 2131
   {
2132
-    $v_result=1;
2132
+    $v_result = 1;
2133 2133
     $v_list_detail = array();
2134 2134
     
2135 2135
     // ----- Magic quotes trick
@@ -2164,7 +2164,7 @@  discard block
 block discarded – undo
2164 2164
   // --------------------------------------------------------------------------------
2165 2165
   function privAdd($p_filedescr_list, &$p_result_list, &$p_options)
2166 2166
   {
2167
-    $v_result=1;
2167
+    $v_result = 1;
2168 2168
     $v_list_detail = array();
2169 2169
 
2170 2170
     // ----- Look if the archive exists or is empty
@@ -2181,7 +2181,7 @@  discard block
 block discarded – undo
2181 2181
     $this->privDisableMagicQuotes();
2182 2182
 
2183 2183
     // ----- Open the zip file
2184
-    if (($v_result=$this->privOpenFd('rb')) != 1)
2184
+    if (($v_result = $this->privOpenFd('rb')) != 1)
2185 2185
     {
2186 2186
       // ----- Magic quotes trick
2187 2187
       $this->privSwapBackMagicQuotes();
@@ -2203,7 +2203,7 @@  discard block
 block discarded – undo
2203 2203
     @rewind($this->zip_fd);
2204 2204
 
2205 2205
     // ----- Creates a temporay file
2206
-    $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
2206
+    $v_zip_temp_name = PCLZIP_TEMPORARY_DIR . uniqid('pclzip-') . '.tmp';
2207 2207
 
2208 2208
     // ----- Open the temporary file in write mode
2209 2209
     if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
@@ -2211,7 +2211,7 @@  discard block
 block discarded – undo
2211 2211
       $this->privCloseFd();
2212 2212
       $this->privSwapBackMagicQuotes();
2213 2213
 
2214
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
2214
+      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \'' . $v_zip_temp_name . '\' in binary write mode');
2215 2215
 
2216 2216
       // ----- Return
2217 2217
       return PclZip::errorCode();
@@ -2262,7 +2262,7 @@  discard block
 block discarded – undo
2262 2262
     }
2263 2263
 
2264 2264
     // ----- Create the Central Dir files header
2265
-    for ($i=0, $v_count=0; $i<sizeof($v_header_list); $i++)
2265
+    for ($i = 0, $v_count = 0; $i < sizeof($v_header_list); $i++)
2266 2266
     {
2267 2267
       // ----- Create the file header
2268 2268
       if ($v_header_list[$i]['status'] == 'ok') {
@@ -2288,17 +2288,17 @@  discard block
 block discarded – undo
2288 2288
       $v_comment = $p_options[PCLZIP_OPT_COMMENT];
2289 2289
     }
2290 2290
     if (isset($p_options[PCLZIP_OPT_ADD_COMMENT])) {
2291
-      $v_comment = $v_comment.$p_options[PCLZIP_OPT_ADD_COMMENT];
2291
+      $v_comment = $v_comment . $p_options[PCLZIP_OPT_ADD_COMMENT];
2292 2292
     }
2293 2293
     if (isset($p_options[PCLZIP_OPT_PREPEND_COMMENT])) {
2294
-      $v_comment = $p_options[PCLZIP_OPT_PREPEND_COMMENT].$v_comment;
2294
+      $v_comment = $p_options[PCLZIP_OPT_PREPEND_COMMENT] . $v_comment;
2295 2295
     }
2296 2296
 
2297 2297
     // ----- Calculate the size of the central header
2298
-    $v_size = @ftell($this->zip_fd)-$v_offset;
2298
+    $v_size = @ftell($this->zip_fd) - $v_offset;
2299 2299
 
2300 2300
     // ----- Create the central dir footer
2301
-    if (($v_result = $this->privWriteCentralHeader($v_count+$v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1)
2301
+    if (($v_result = $this->privWriteCentralHeader($v_count + $v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1)
2302 2302
     {
2303 2303
       // ----- Reset the file list
2304 2304
       unset($v_header_list);
@@ -2343,13 +2343,13 @@  discard block
 block discarded – undo
2343 2343
   // --------------------------------------------------------------------------------
2344 2344
   function privOpenFd($p_mode)
2345 2345
   {
2346
-    $v_result=1;
2346
+    $v_result = 1;
2347 2347
 
2348 2348
     // ----- Look if already open
2349 2349
     if ($this->zip_fd != 0)
2350 2350
     {
2351 2351
       // ----- Error log
2352
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Zip file \''.$this->zipname.'\' already open');
2352
+      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Zip file \'' . $this->zipname . '\' already open');
2353 2353
 
2354 2354
       // ----- Return
2355 2355
       return PclZip::errorCode();
@@ -2359,7 +2359,7 @@  discard block
 block discarded – undo
2359 2359
     if (($this->zip_fd = @fopen($this->zipname, $p_mode)) == 0)
2360 2360
     {
2361 2361
       // ----- Error log
2362
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in '.$p_mode.' mode');
2362
+      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \'' . $this->zipname . '\' in ' . $p_mode . ' mode');
2363 2363
 
2364 2364
       // ----- Return
2365 2365
       return PclZip::errorCode();
@@ -2377,7 +2377,7 @@  discard block
 block discarded – undo
2377 2377
   // --------------------------------------------------------------------------------
2378 2378
   function privCloseFd()
2379 2379
   {
2380
-    $v_result=1;
2380
+    $v_result = 1;
2381 2381
 
2382 2382
     if ($this->zip_fd != 0)
2383 2383
       @fclose($this->zip_fd);
@@ -2404,7 +2404,7 @@  discard block
 block discarded – undo
2404 2404
 //  function privAddList($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options)
2405 2405
   function privAddList($p_filedescr_list, &$p_result_list, &$p_options)
2406 2406
   {
2407
-    $v_result=1;
2407
+    $v_result = 1;
2408 2408
 
2409 2409
     // ----- Add the files
2410 2410
     $v_header_list = array();
@@ -2418,7 +2418,7 @@  discard block
 block discarded – undo
2418 2418
     $v_offset = @ftell($this->zip_fd);
2419 2419
 
2420 2420
     // ----- Create the Central Dir files header
2421
-    for ($i=0,$v_count=0; $i<sizeof($v_header_list); $i++)
2421
+    for ($i = 0, $v_count = 0; $i < sizeof($v_header_list); $i++)
2422 2422
     {
2423 2423
       // ----- Create the file header
2424 2424
       if ($v_header_list[$i]['status'] == 'ok') {
@@ -2440,7 +2440,7 @@  discard block
 block discarded – undo
2440 2440
     }
2441 2441
 
2442 2442
     // ----- Calculate the size of the central header
2443
-    $v_size = @ftell($this->zip_fd)-$v_offset;
2443
+    $v_size = @ftell($this->zip_fd) - $v_offset;
2444 2444
 
2445 2445
     // ----- Create the central dir footer
2446 2446
     if (($v_result = $this->privWriteCentralHeader($v_count, $v_size, $v_offset, $v_comment)) != 1)
@@ -2468,14 +2468,14 @@  discard block
 block discarded – undo
2468 2468
   // --------------------------------------------------------------------------------
2469 2469
   function privAddFileList($p_filedescr_list, &$p_result_list, &$p_options)
2470 2470
   {
2471
-    $v_result=1;
2471
+    $v_result = 1;
2472 2472
     $v_header = array();
2473 2473
 
2474 2474
     // ----- Recuperate the current number of elt in list
2475 2475
     $v_nb = sizeof($p_result_list);
2476 2476
 
2477 2477
     // ----- Loop on the files
2478
-    for ($j=0; ($j<sizeof($p_filedescr_list)) && ($v_result==1); $j++) {
2478
+    for ($j = 0; ($j < sizeof($p_filedescr_list)) && ($v_result == 1); $j++) {
2479 2479
       // ----- Format the filename
2480 2480
       $p_filedescr_list[$j]['filename']
2481 2481
       = PclZipUtilTranslateWinPath($p_filedescr_list[$j]['filename'], false);
@@ -2488,9 +2488,9 @@  discard block
 block discarded – undo
2488 2488
       }
2489 2489
 
2490 2490
       // ----- Check the filename
2491
-      if (   ($p_filedescr_list[$j]['type'] != 'virtual_file')
2491
+      if (($p_filedescr_list[$j]['type'] != 'virtual_file')
2492 2492
           && (!file_exists($p_filedescr_list[$j]['filename']))) {
2493
-        PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$p_filedescr_list[$j]['filename']."' does not exist");
2493
+        PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '" . $p_filedescr_list[$j]['filename'] . "' does not exist");
2494 2494
         return PclZip::errorCode();
2495 2495
       }
2496 2496
 
@@ -2498,10 +2498,10 @@  discard block
 block discarded – undo
2498 2498
       // or a dir with all its path removed
2499 2499
 //      if (   (is_file($p_filedescr_list[$j]['filename']))
2500 2500
 //          || (   is_dir($p_filedescr_list[$j]['filename'])
2501
-      if (   ($p_filedescr_list[$j]['type'] == 'file')
2501
+      if (($p_filedescr_list[$j]['type'] == 'file')
2502 2502
           || ($p_filedescr_list[$j]['type'] == 'virtual_file')
2503
-          || (   ($p_filedescr_list[$j]['type'] == 'folder')
2504
-              && (   !isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])
2503
+          || (($p_filedescr_list[$j]['type'] == 'folder')
2504
+              && (!isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])
2505 2505
                   || !$p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))
2506 2506
           ) {
2507 2507
 
@@ -2530,7 +2530,7 @@  discard block
 block discarded – undo
2530 2530
   // --------------------------------------------------------------------------------
2531 2531
   function privAddFile($p_filedescr, &$p_header, &$p_options)
2532 2532
   {
2533
-    $v_result=1;
2533
+    $v_result = 1;
2534 2534
     
2535 2535
     // ----- Working variable
2536 2536
     $p_filename = $p_filedescr['filename'];
@@ -2575,13 +2575,13 @@  discard block
 block discarded – undo
2575 2575
     $p_header['index'] = -1;
2576 2576
 
2577 2577
     // ----- Look for regular file
2578
-    if ($p_filedescr['type']=='file') {
2578
+    if ($p_filedescr['type'] == 'file') {
2579 2579
       $p_header['external'] = 0x00000000;
2580 2580
       $p_header['size'] = filesize($p_filename);
2581 2581
     }
2582 2582
     
2583 2583
     // ----- Look for regular folder
2584
-    else if ($p_filedescr['type']=='folder') {
2584
+    else if ($p_filedescr['type'] == 'folder') {
2585 2585
       $p_header['external'] = 0x00000010;
2586 2586
       $p_header['mtime'] = filemtime($p_filename);
2587 2587
       $p_header['size'] = filesize($p_filename);
@@ -2656,10 +2656,10 @@  discard block
 block discarded – undo
2656 2656
       // ----- Look for a file
2657 2657
       if ($p_filedescr['type'] == 'file') {
2658 2658
         // ----- Look for using temporary file to zip
2659
-        if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) 
2659
+        if ((!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) 
2660 2660
             && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON])
2661 2661
                 || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
2662
-                    && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_header['size'])) ) ) {
2662
+                    && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_header['size'])))) {
2663 2663
           $v_result = $this->privAddFileUsingTempFile($p_filedescr, $p_header, $p_options);
2664 2664
           if ($v_result < PCLZIP_ERR_NO_ERROR) {
2665 2665
             return $v_result;
@@ -2759,7 +2759,7 @@  discard block
 block discarded – undo
2759 2759
         // ----- Set the file properties
2760 2760
         $p_header['size'] = 0;
2761 2761
         //$p_header['external'] = 0x41FF0010;   // Value for a folder : to be checked
2762
-        $p_header['external'] = 0x00000010;   // Value for a folder : to be checked
2762
+        $p_header['external'] = 0x00000010; // Value for a folder : to be checked
2763 2763
 
2764 2764
         // ----- Call the header generation
2765 2765
         if (($v_result = $this->privWriteFileHeader($p_header)) != 1)
@@ -2803,7 +2803,7 @@  discard block
 block discarded – undo
2803 2803
   // --------------------------------------------------------------------------------
2804 2804
   function privAddFileUsingTempFile($p_filedescr, &$p_header, &$p_options)
2805 2805
   {
2806
-    $v_result=PCLZIP_ERR_NO_ERROR;
2806
+    $v_result = PCLZIP_ERR_NO_ERROR;
2807 2807
     
2808 2808
     // ----- Working variable
2809 2809
     $p_filename = $p_filedescr['filename'];
@@ -2816,10 +2816,10 @@  discard block
 block discarded – undo
2816 2816
     }
2817 2817
 
2818 2818
     // ----- Creates a compressed temporary file
2819
-    $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
2819
+    $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR . uniqid('pclzip-') . '.gz';
2820 2820
     if (($v_file_compressed = @gzopen($v_gzip_temp_name, "wb")) == 0) {
2821 2821
       fclose($v_file);
2822
-      PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
2822
+      PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \'' . $v_gzip_temp_name . '\' in binary write mode');
2823 2823
       return PclZip::errorCode();
2824 2824
     }
2825 2825
 
@@ -2839,13 +2839,13 @@  discard block
 block discarded – undo
2839 2839
 
2840 2840
     // ----- Check the minimum file size
2841 2841
     if (filesize($v_gzip_temp_name) < 18) {
2842
-      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'gzip temporary file \''.$v_gzip_temp_name.'\' has invalid filesize - should be minimum 18 bytes');
2842
+      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'gzip temporary file \'' . $v_gzip_temp_name . '\' has invalid filesize - should be minimum 18 bytes');
2843 2843
       return PclZip::errorCode();
2844 2844
     }
2845 2845
 
2846 2846
     // ----- Extract the compressed attributes
2847 2847
     if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0) {
2848
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
2848
+      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \'' . $v_gzip_temp_name . '\' in binary read mode');
2849 2849
       return PclZip::errorCode();
2850 2850
     }
2851 2851
 
@@ -2857,7 +2857,7 @@  discard block
 block discarded – undo
2857 2857
     $v_data_header['os'] = bin2hex($v_data_header['os']);
2858 2858
 
2859 2859
     // ----- Read the gzip file footer
2860
-    @fseek($v_file_compressed, filesize($v_gzip_temp_name)-8);
2860
+    @fseek($v_file_compressed, filesize($v_gzip_temp_name) - 8);
2861 2861
     $v_binary_data = @fread($v_file_compressed, 8);
2862 2862
     $v_data_footer = unpack('Vcrc/Vcompressed_size', $v_binary_data);
2863 2863
 
@@ -2865,7 +2865,7 @@  discard block
 block discarded – undo
2865 2865
     $p_header['compression'] = ord($v_data_header['cm']);
2866 2866
     //$p_header['mtime'] = $v_data_header['mtime'];
2867 2867
     $p_header['crc'] = $v_data_footer['crc'];
2868
-    $p_header['compressed_size'] = filesize($v_gzip_temp_name)-18;
2868
+    $p_header['compressed_size'] = filesize($v_gzip_temp_name) - 18;
2869 2869
 
2870 2870
     // ----- Close the file
2871 2871
     @fclose($v_file_compressed);
@@ -2878,7 +2878,7 @@  discard block
 block discarded – undo
2878 2878
     // ----- Add the compressed data
2879 2879
     if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0)
2880 2880
     {
2881
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
2881
+      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \'' . $v_gzip_temp_name . '\' in binary read mode');
2882 2882
       return PclZip::errorCode();
2883 2883
     }
2884 2884
 
@@ -2915,7 +2915,7 @@  discard block
 block discarded – undo
2915 2915
   // --------------------------------------------------------------------------------
2916 2916
   function privCalculateStoredFilename(&$p_filedescr, &$p_options)
2917 2917
   {
2918
-    $v_result=1;
2918
+    $v_result = 1;
2919 2919
     
2920 2920
     // ----- Working variables
2921 2921
     $p_filename = $p_filedescr['filename'];
@@ -2954,9 +2954,9 @@  discard block
 block discarded – undo
2954 2954
         $v_path_info = pathinfo($p_filename);
2955 2955
         $v_dir = '';
2956 2956
         if ($v_path_info['dirname'] != '') {
2957
-          $v_dir = $v_path_info['dirname'].'/';
2957
+          $v_dir = $v_path_info['dirname'] . '/';
2958 2958
         }
2959
-        $v_stored_filename = $v_dir.$p_filedescr['new_short_name'];
2959
+        $v_stored_filename = $v_dir . $p_filedescr['new_short_name'];
2960 2960
       }
2961 2961
       else {
2962 2962
         // ----- Calculate the stored filename
@@ -2972,14 +2972,14 @@  discard block
 block discarded – undo
2972 2972
         if (substr($p_remove_dir, -1) != '/')
2973 2973
           $p_remove_dir .= "/";
2974 2974
 
2975
-        if (   (substr($p_filename, 0, 2) == "./")
2975
+        if ((substr($p_filename, 0, 2) == "./")
2976 2976
             || (substr($p_remove_dir, 0, 2) == "./")) {
2977 2977
             
2978
-          if (   (substr($p_filename, 0, 2) == "./")
2978
+          if ((substr($p_filename, 0, 2) == "./")
2979 2979
               && (substr($p_remove_dir, 0, 2) != "./")) {
2980
-            $p_remove_dir = "./".$p_remove_dir;
2980
+            $p_remove_dir = "./" . $p_remove_dir;
2981 2981
           }
2982
-          if (   (substr($p_filename, 0, 2) != "./")
2982
+          if ((substr($p_filename, 0, 2) != "./")
2983 2983
               && (substr($p_remove_dir, 0, 2) == "./")) {
2984 2984
             $p_remove_dir = substr($p_remove_dir, 2);
2985 2985
           }
@@ -3004,9 +3004,9 @@  discard block
 block discarded – undo
3004 3004
       // ----- Look for path to add
3005 3005
       if ($p_add_dir != "") {
3006 3006
         if (substr($p_add_dir, -1) == "/")
3007
-          $v_stored_filename = $p_add_dir.$v_stored_filename;
3007
+          $v_stored_filename = $p_add_dir . $v_stored_filename;
3008 3008
         else
3009
-          $v_stored_filename = $p_add_dir."/".$v_stored_filename;
3009
+          $v_stored_filename = $p_add_dir . "/" . $v_stored_filename;
3010 3010
       }
3011 3011
     }
3012 3012
 
@@ -3027,15 +3027,15 @@  discard block
 block discarded – undo
3027 3027
   // --------------------------------------------------------------------------------
3028 3028
   function privWriteFileHeader(&$p_header)
3029 3029
   {
3030
-    $v_result=1;
3030
+    $v_result = 1;
3031 3031
 
3032 3032
     // ----- Store the offset position of the file
3033 3033
     $p_header['offset'] = ftell($this->zip_fd);
3034 3034
 
3035 3035
     // ----- Transform UNIX mtime to DOS format mdate/mtime
3036 3036
     $v_date = getdate($p_header['mtime']);
3037
-    $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
3038
-    $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
3037
+    $v_mtime = ($v_date['hours'] << 11) + ($v_date['minutes'] << 5) + $v_date['seconds'] / 2;
3038
+    $v_mdate = (($v_date['year'] - 1980) << 9) + ($v_date['mon'] << 5) + $v_date['mday'];
3039 3039
 
3040 3040
     // ----- Packed data
3041 3041
     $v_binary_data = pack("VvvvvvVVVvv", 0x04034b50,
@@ -3072,7 +3072,7 @@  discard block
 block discarded – undo
3072 3072
   // --------------------------------------------------------------------------------
3073 3073
   function privWriteCentralFileHeader(&$p_header)
3074 3074
   {
3075
-    $v_result=1;
3075
+    $v_result = 1;
3076 3076
 
3077 3077
     // TBC
3078 3078
     //for(reset($p_header); $key = key($p_header); next($p_header)) {
@@ -3080,8 +3080,8 @@  discard block
 block discarded – undo
3080 3080
 
3081 3081
     // ----- Transform UNIX mtime to DOS format mdate/mtime
3082 3082
     $v_date = getdate($p_header['mtime']);
3083
-    $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
3084
-    $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
3083
+    $v_mtime = ($v_date['hours'] << 11) + ($v_date['minutes'] << 5) + $v_date['seconds'] / 2;
3084
+    $v_mdate = (($v_date['year'] - 1980) << 9) + ($v_date['mon'] << 5) + $v_date['mday'];
3085 3085
 
3086 3086
 
3087 3087
     // ----- Packed data
@@ -3125,7 +3125,7 @@  discard block
 block discarded – undo
3125 3125
   // --------------------------------------------------------------------------------
3126 3126
   function privWriteCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment)
3127 3127
   {
3128
-    $v_result=1;
3128
+    $v_result = 1;
3129 3129
 
3130 3130
     // ----- Packed data
3131 3131
     $v_binary_data = pack("VvvvvVVv", 0x06054b50, 0, 0, $p_nb_entries,
@@ -3154,7 +3154,7 @@  discard block
 block discarded – undo
3154 3154
   // --------------------------------------------------------------------------------
3155 3155
   function privList(&$p_list)
3156 3156
   {
3157
-    $v_result=1;
3157
+    $v_result = 1;
3158 3158
 
3159 3159
     // ----- Magic quotes trick
3160 3160
     $this->privDisableMagicQuotes();
@@ -3166,7 +3166,7 @@  discard block
 block discarded – undo
3166 3166
       $this->privSwapBackMagicQuotes();
3167 3167
       
3168 3168
       // ----- Error log
3169
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
3169
+      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \'' . $this->zipname . '\' in binary read mode');
3170 3170
 
3171 3171
       // ----- Return
3172 3172
       return PclZip::errorCode();
@@ -3194,7 +3194,7 @@  discard block
 block discarded – undo
3194 3194
     }
3195 3195
 
3196 3196
     // ----- Read each entry
3197
-    for ($i=0; $i<$v_central_dir['entries']; $i++)
3197
+    for ($i = 0; $i < $v_central_dir['entries']; $i++)
3198 3198
     {
3199 3199
       // ----- Read the file header
3200 3200
       if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
@@ -3241,7 +3241,7 @@  discard block
 block discarded – undo
3241 3241
   // --------------------------------------------------------------------------------
3242 3242
   function privConvertHeader2FileInfo($p_header, &$p_info)
3243 3243
   {
3244
-    $v_result=1;
3244
+    $v_result = 1;
3245 3245
 
3246 3246
     // ----- Get the interesting attributes
3247 3247
     $v_temp_path = PclZipUtilPathReduction($p_header['filename']);
@@ -3252,7 +3252,7 @@  discard block
 block discarded – undo
3252 3252
     $p_info['compressed_size'] = $p_header['compressed_size'];
3253 3253
     $p_info['mtime'] = $p_header['mtime'];
3254 3254
     $p_info['comment'] = $p_header['comment'];
3255
-    $p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010);
3255
+    $p_info['folder'] = (($p_header['external'] & 0x00000010) == 0x00000010);
3256 3256
     $p_info['index'] = $p_header['index'];
3257 3257
     $p_info['status'] = $p_header['status'];
3258 3258
     $p_info['crc'] = $p_header['crc'];
@@ -3280,17 +3280,17 @@  discard block
 block discarded – undo
3280 3280
   // --------------------------------------------------------------------------------
3281 3281
   function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
3282 3282
   {
3283
-    $v_result=1;
3283
+    $v_result = 1;
3284 3284
 
3285 3285
     // ----- Magic quotes trick
3286 3286
     $this->privDisableMagicQuotes();
3287 3287
 
3288 3288
     // ----- Check the path
3289
-    if (   ($p_path == "")
3290
-	    || (   (substr($p_path, 0, 1) != "/")
3289
+    if (($p_path == "")
3290
+	    || ((substr($p_path, 0, 1) != "/")
3291 3291
 		    && (substr($p_path, 0, 3) != "../")
3292
-			&& (substr($p_path,1,2)!=":/")))
3293
-      $p_path = "./".$p_path;
3292
+			&& (substr($p_path, 1, 2) != ":/")))
3293
+      $p_path = "./" . $p_path;
3294 3294
 
3295 3295
     // ----- Reduce the path last (and duplicated) '/'
3296 3296
     if (($p_path != "./") && ($p_path != "/"))
@@ -3298,7 +3298,7 @@  discard block
 block discarded – undo
3298 3298
       // ----- Look for the path end '/'
3299 3299
       while (substr($p_path, -1) == "/")
3300 3300
       {
3301
-        $p_path = substr($p_path, 0, strlen($p_path)-1);
3301
+        $p_path = substr($p_path, 0, strlen($p_path) - 1);
3302 3302
       }
3303 3303
     }
3304 3304
 
@@ -3332,7 +3332,7 @@  discard block
 block discarded – undo
3332 3332
 
3333 3333
     // ----- Read each entry
3334 3334
     $j_start = 0;
3335
-    for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
3335
+    for ($i = 0, $v_nb_extracted = 0; $i < $v_central_dir['entries']; $i++)
3336 3336
     {
3337 3337
 
3338 3338
       // ----- Read next Central dir entry
@@ -3371,17 +3371,17 @@  discard block
 block discarded – undo
3371 3371
       $v_extract = false;
3372 3372
 
3373 3373
       // ----- Look for extract by name rule
3374
-      if (   (isset($p_options[PCLZIP_OPT_BY_NAME]))
3374
+      if ((isset($p_options[PCLZIP_OPT_BY_NAME]))
3375 3375
           && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
3376 3376
 
3377 3377
           // ----- Look if the filename is in the list
3378
-          for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) {
3378
+          for ($j = 0; ($j < sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) {
3379 3379
 
3380 3380
               // ----- Look for a directory
3381 3381
               if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
3382 3382
 
3383 3383
                   // ----- Look if the directory is in the filename path
3384
-                  if (   (strlen($v_header['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
3384
+                  if ((strlen($v_header['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
3385 3385
                       && (substr($v_header['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
3386 3386
                       $v_extract = true;
3387 3387
                   }
@@ -3406,7 +3406,7 @@  discard block
 block discarded – undo
3406 3406
       */
3407 3407
 
3408 3408
       // ----- Look for extract by preg rule
3409
-      else if (   (isset($p_options[PCLZIP_OPT_BY_PREG]))
3409
+      else if ((isset($p_options[PCLZIP_OPT_BY_PREG]))
3410 3410
                && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
3411 3411
 
3412 3412
           if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) {
@@ -3415,20 +3415,20 @@  discard block
 block discarded – undo
3415 3415
       }
3416 3416
 
3417 3417
       // ----- Look for extract by index rule
3418
-      else if (   (isset($p_options[PCLZIP_OPT_BY_INDEX]))
3418
+      else if ((isset($p_options[PCLZIP_OPT_BY_INDEX]))
3419 3419
                && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
3420 3420
           
3421 3421
           // ----- Look if the index is in the list
3422
-          for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) {
3422
+          for ($j = $j_start; ($j < sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) {
3423 3423
 
3424
-              if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
3424
+              if (($i >= $p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i <= $p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
3425 3425
                   $v_extract = true;
3426 3426
               }
3427
-              if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
3428
-                  $j_start = $j+1;
3427
+              if ($i >= $p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
3428
+                  $j_start = $j + 1;
3429 3429
               }
3430 3430
 
3431
-              if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
3431
+              if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start'] > $i) {
3432 3432
                   break;
3433 3433
               }
3434 3434
           }
@@ -3440,21 +3440,21 @@  discard block
 block discarded – undo
3440 3440
       }
3441 3441
 
3442 3442
 	  // ----- Check compression method
3443
-	  if (   ($v_extract)
3444
-	      && (   ($v_header['compression'] != 8)
3443
+	  if (($v_extract)
3444
+	      && (($v_header['compression'] != 8)
3445 3445
 		      && ($v_header['compression'] != 0))) {
3446 3446
           $v_header['status'] = 'unsupported_compression';
3447 3447
 
3448 3448
           // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3449
-          if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3450
-		      && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3449
+          if ((isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3450
+		      && ($p_options[PCLZIP_OPT_STOP_ON_ERROR] === true)) {
3451 3451
 
3452 3452
               $this->privSwapBackMagicQuotes();
3453 3453
               
3454 3454
               PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION,
3455
-			                       "Filename '".$v_header['stored_filename']."' is "
3455
+			                       "Filename '" . $v_header['stored_filename'] . "' is "
3456 3456
 				  	    	  	   ."compressed by an unsupported compression "
3457
-				  	    	  	   ."method (".$v_header['compression'].") ");
3457
+				  	    	  	   ."method (" . $v_header['compression'] . ") ");
3458 3458
 
3459 3459
               return PclZip::errorCode();
3460 3460
 		  }
@@ -3465,14 +3465,14 @@  discard block
 block discarded – undo
3465 3465
           $v_header['status'] = 'unsupported_encryption';
3466 3466
 
3467 3467
           // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3468
-          if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3469
-		      && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3468
+          if ((isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3469
+		      && ($p_options[PCLZIP_OPT_STOP_ON_ERROR] === true)) {
3470 3470
 
3471 3471
               $this->privSwapBackMagicQuotes();
3472 3472
 
3473 3473
               PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION,
3474 3474
 			                       "Unsupported encryption for "
3475
-				  	    	  	   ." filename '".$v_header['stored_filename']
3475
+				  	    	  	   ." filename '" . $v_header['stored_filename']
3476 3476
 								   ."'");
3477 3477
 
3478 3478
               return PclZip::errorCode();
@@ -3547,7 +3547,7 @@  discard block
 block discarded – undo
3547 3547
           }
3548 3548
         }
3549 3549
         // ----- Look for extraction in standard output
3550
-        elseif (   (isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT]))
3550
+        elseif ((isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT]))
3551 3551
 		        && ($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) {
3552 3552
           // ----- Extracting the file in standard output
3553 3553
           $v_result1 = $this->privExtractFileInOutput($v_header, $p_options);
@@ -3620,7 +3620,7 @@  discard block
 block discarded – undo
3620 3620
   // --------------------------------------------------------------------------------
3621 3621
   function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
3622 3622
   {
3623
-    $v_result=1;
3623
+    $v_result = 1;
3624 3624
 
3625 3625
     // ----- Read the file header
3626 3626
     if (($v_result = $this->privReadFileHeader($v_header)) != 1)
@@ -3638,7 +3638,7 @@  discard block
 block discarded – undo
3638 3638
     // ----- Look for all path to remove
3639 3639
     if ($p_remove_all_path == true) {
3640 3640
         // ----- Look for folder entry that not need to be extracted
3641
-        if (($p_entry['external']&0x00000010)==0x00000010) {
3641
+        if (($p_entry['external'] & 0x00000010) == 0x00000010) {
3642 3642
 
3643 3643
             $p_entry['status'] = "filtered";
3644 3644
 
@@ -3674,7 +3674,7 @@  discard block
 block discarded – undo
3674 3674
 
3675 3675
     // ----- Add the path
3676 3676
     if ($p_path != '') {
3677
-      $p_entry['filename'] = $p_path."/".$p_entry['filename'];
3677
+      $p_entry['filename'] = $p_path . "/" . $p_entry['filename'];
3678 3678
     }
3679 3679
     
3680 3680
     // ----- Check a base_dir_restriction
@@ -3685,7 +3685,7 @@  discard block
 block discarded – undo
3685 3685
       if ($v_inclusion == 0) {
3686 3686
 
3687 3687
         PclZip::privErrorLog(PCLZIP_ERR_DIRECTORY_RESTRICTION,
3688
-			                     "Filename '".$p_entry['filename']."' is "
3688
+			                     "Filename '" . $p_entry['filename'] . "' is "
3689 3689
 								 ."outside PCLZIP_OPT_EXTRACT_DIR_RESTRICTION");
3690 3690
 
3691 3691
         return PclZip::errorCode();
@@ -3740,11 +3740,11 @@  discard block
 block discarded – undo
3740 3740
         // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3741 3741
         // For historical reason first PclZip implementation does not stop
3742 3742
         // when this kind of error occurs.
3743
-        if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3744
-		    && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3743
+        if ((isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3744
+		    && ($p_options[PCLZIP_OPT_STOP_ON_ERROR] === true)) {
3745 3745
 
3746 3746
             PclZip::privErrorLog(PCLZIP_ERR_ALREADY_A_DIRECTORY,
3747
-			                     "Filename '".$p_entry['filename']."' is "
3747
+			                     "Filename '" . $p_entry['filename'] . "' is "
3748 3748
 								 ."already used by an existing directory");
3749 3749
 
3750 3750
             return PclZip::errorCode();
@@ -3760,11 +3760,11 @@  discard block
 block discarded – undo
3760 3760
         // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3761 3761
         // For historical reason first PclZip implementation does not stop
3762 3762
         // when this kind of error occurs.
3763
-        if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3764
-		    && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3763
+        if ((isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3764
+		    && ($p_options[PCLZIP_OPT_STOP_ON_ERROR] === true)) {
3765 3765
 
3766 3766
             PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
3767
-			                     "Filename '".$p_entry['filename']."' exists "
3767
+			                     "Filename '" . $p_entry['filename'] . "' exists "
3768 3768
 								 ."and is write protected");
3769 3769
 
3770 3770
             return PclZip::errorCode();
@@ -3775,8 +3775,8 @@  discard block
 block discarded – undo
3775 3775
       else if (filemtime($p_entry['filename']) > $p_entry['mtime'])
3776 3776
       {
3777 3777
         // ----- Change the file status
3778
-        if (   (isset($p_options[PCLZIP_OPT_REPLACE_NEWER]))
3779
-		    && ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) {
3778
+        if ((isset($p_options[PCLZIP_OPT_REPLACE_NEWER]))
3779
+		    && ($p_options[PCLZIP_OPT_REPLACE_NEWER] === true)) {
3780 3780
 	  	  }
3781 3781
 		    else {
3782 3782
             $p_entry['status'] = "newer_exist";
@@ -3784,11 +3784,11 @@  discard block
 block discarded – undo
3784 3784
             // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3785 3785
             // For historical reason first PclZip implementation does not stop
3786 3786
             // when this kind of error occurs.
3787
-            if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3788
-		        && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3787
+            if ((isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3788
+		        && ($p_options[PCLZIP_OPT_STOP_ON_ERROR] === true)) {
3789 3789
 
3790 3790
                 PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
3791
-			             "Newer version of '".$p_entry['filename']."' exists "
3791
+			             "Newer version of '" . $p_entry['filename'] . "' exists "
3792 3792
 					    ."and option PCLZIP_OPT_REPLACE_NEWER is not selected");
3793 3793
 
3794 3794
                 return PclZip::errorCode();
@@ -3801,14 +3801,14 @@  discard block
 block discarded – undo
3801 3801
 
3802 3802
     // ----- Check the directory availability and create it if necessary
3803 3803
     else {
3804
-      if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/'))
3804
+      if ((($p_entry['external'] & 0x00000010) == 0x00000010) || (substr($p_entry['filename'], -1) == '/'))
3805 3805
         $v_dir_to_check = $p_entry['filename'];
3806 3806
       else if (!strstr($p_entry['filename'], "/"))
3807 3807
         $v_dir_to_check = "";
3808 3808
       else
3809 3809
         $v_dir_to_check = dirname($p_entry['filename']);
3810 3810
 
3811
-        if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) {
3811
+        if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external'] & 0x00000010) == 0x00000010))) != 1) {
3812 3812
   
3813 3813
           // ----- Change the file status
3814 3814
           $p_entry['status'] = "path_creation_fail";
@@ -3824,7 +3824,7 @@  discard block
 block discarded – undo
3824 3824
     if ($p_entry['status'] == 'ok') {
3825 3825
 
3826 3826
       // ----- Do the extraction (if not a folder)
3827
-      if (!(($p_entry['external']&0x00000010)==0x00000010))
3827
+      if (!(($p_entry['external'] & 0x00000010) == 0x00000010))
3828 3828
       {
3829 3829
         // ----- Look for not compressed file
3830 3830
         if ($p_entry['compression'] == 0) {
@@ -3867,16 +3867,16 @@  discard block
 block discarded – undo
3867 3867
           // ----- TBC
3868 3868
           // Need to be finished
3869 3869
           if (($p_entry['flag'] & 1) == 1) {
3870
-            PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, 'File \''.$p_entry['filename'].'\' is encrypted. Encrypted files are not supported.');
3870
+            PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, 'File \'' . $p_entry['filename'] . '\' is encrypted. Encrypted files are not supported.');
3871 3871
             return PclZip::errorCode();
3872 3872
           }
3873 3873
 
3874 3874
 
3875 3875
           // ----- Look for using temporary file to unzip
3876
-          if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) 
3876
+          if ((!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) 
3877 3877
               && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON])
3878 3878
                   || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
3879
-                      && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_entry['size'])) ) ) {
3879
+                      && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_entry['size'])))) {
3880 3880
             $v_result = $this->privExtractFileUsingTempFile($p_entry, $p_options);
3881 3881
             if ($v_result < PCLZIP_ERR_NO_ERROR) {
3882 3882
               return $v_result;
@@ -3971,13 +3971,13 @@  discard block
 block discarded – undo
3971 3971
   // --------------------------------------------------------------------------------
3972 3972
   function privExtractFileUsingTempFile(&$p_entry, &$p_options)
3973 3973
   {
3974
-    $v_result=1;
3974
+    $v_result = 1;
3975 3975
         
3976 3976
     // ----- Creates a temporary file
3977
-    $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
3977
+    $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR . uniqid('pclzip-') . '.gz';
3978 3978
     if (($v_dest_file = @fopen($v_gzip_temp_name, "wb")) == 0) {
3979 3979
       fclose($v_file);
3980
-      PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
3980
+      PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \'' . $v_gzip_temp_name . '\' in binary write mode');
3981 3981
       return PclZip::errorCode();
3982 3982
     }
3983 3983
 
@@ -4014,7 +4014,7 @@  discard block
 block discarded – undo
4014 4014
     if (($v_src_file = @gzopen($v_gzip_temp_name, 'rb')) == 0) {
4015 4015
       @fclose($v_dest_file);
4016 4016
       $p_entry['status'] = "read_error";
4017
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
4017
+      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \'' . $v_gzip_temp_name . '\' in binary read mode');
4018 4018
       return PclZip::errorCode();
4019 4019
     }
4020 4020
 
@@ -4047,7 +4047,7 @@  discard block
 block discarded – undo
4047 4047
   // --------------------------------------------------------------------------------
4048 4048
   function privExtractFileInOutput(&$p_entry, &$p_options)
4049 4049
   {
4050
-    $v_result=1;
4050
+    $v_result = 1;
4051 4051
 
4052 4052
     // ----- Read the file header
4053 4053
     if (($v_result = $this->privReadFileHeader($v_header)) != 1) {
@@ -4096,7 +4096,7 @@  discard block
 block discarded – undo
4096 4096
     if ($p_entry['status'] == 'ok') {
4097 4097
 
4098 4098
       // ----- Do the extraction (if not a folder)
4099
-      if (!(($p_entry['external']&0x00000010)==0x00000010)) {
4099
+      if (!(($p_entry['external'] & 0x00000010) == 0x00000010)) {
4100 4100
         // ----- Look for not compressed file
4101 4101
         if ($p_entry['compressed_size'] == $p_entry['size']) {
4102 4102
 
@@ -4159,7 +4159,7 @@  discard block
 block discarded – undo
4159 4159
   // --------------------------------------------------------------------------------
4160 4160
   function privExtractFileAsString(&$p_entry, &$p_string, &$p_options)
4161 4161
   {
4162
-    $v_result=1;
4162
+    $v_result = 1;
4163 4163
 
4164 4164
     // ----- Read the file header
4165 4165
     $v_header = array();
@@ -4210,7 +4210,7 @@  discard block
 block discarded – undo
4210 4210
     if ($p_entry['status'] == 'ok') {
4211 4211
 
4212 4212
       // ----- Do the extraction (if not a folder)
4213
-      if (!(($p_entry['external']&0x00000010)==0x00000010)) {
4213
+      if (!(($p_entry['external'] & 0x00000010) == 0x00000010)) {
4214 4214
         // ----- Look for not compressed file
4215 4215
   //      if ($p_entry['compressed_size'] == $p_entry['size'])
4216 4216
         if ($p_entry['compression'] == 0) {
@@ -4282,7 +4282,7 @@  discard block
 block discarded – undo
4282 4282
   // --------------------------------------------------------------------------------
4283 4283
   function privReadFileHeader(&$p_header)
4284 4284
   {
4285
-    $v_result=1;
4285
+    $v_result = 1;
4286 4286
 
4287 4287
     // ----- Read the 4 bytes signature
4288 4288
     $v_binary_data = @fread($this->zip_fd, 4);
@@ -4309,7 +4309,7 @@  discard block
 block discarded – undo
4309 4309
       $p_header['status'] = "invalid_header";
4310 4310
 
4311 4311
       // ----- Error log
4312
-      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
4312
+      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : " . strlen($v_binary_data));
4313 4313
 
4314 4314
       // ----- Return
4315 4315
       return PclZip::errorCode();
@@ -4346,7 +4346,7 @@  discard block
 block discarded – undo
4346 4346
       // ----- Extract time
4347 4347
       $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
4348 4348
       $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
4349
-      $v_seconde = ($p_header['mtime'] & 0x001F)*2;
4349
+      $v_seconde = ($p_header['mtime'] & 0x001F) * 2;
4350 4350
 
4351 4351
       // ----- Extract date
4352 4352
       $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
@@ -4385,7 +4385,7 @@  discard block
 block discarded – undo
4385 4385
   // --------------------------------------------------------------------------------
4386 4386
   function privReadCentralFileHeader(&$p_header)
4387 4387
   {
4388
-    $v_result=1;
4388
+    $v_result = 1;
4389 4389
 
4390 4390
     // ----- Read the 4 bytes signature
4391 4391
     $v_binary_data = @fread($this->zip_fd, 4);
@@ -4412,7 +4412,7 @@  discard block
 block discarded – undo
4412 4412
       $p_header['status'] = "invalid_header";
4413 4413
 
4414 4414
       // ----- Error log
4415
-      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
4415
+      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : " . strlen($v_binary_data));
4416 4416
 
4417 4417
       // ----- Return
4418 4418
       return PclZip::errorCode();
@@ -4449,7 +4449,7 @@  discard block
 block discarded – undo
4449 4449
       // ----- Extract time
4450 4450
       $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
4451 4451
       $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
4452
-      $v_seconde = ($p_header['mtime'] & 0x001F)*2;
4452
+      $v_seconde = ($p_header['mtime'] & 0x001F) * 2;
4453 4453
 
4454 4454
       // ----- Extract date
4455 4455
       $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
@@ -4493,7 +4493,7 @@  discard block
 block discarded – undo
4493 4493
   // --------------------------------------------------------------------------------
4494 4494
   function privCheckFileHeaders(&$p_local_header, &$p_central_header)
4495 4495
   {
4496
-    $v_result=1;
4496
+    $v_result = 1;
4497 4497
 
4498 4498
   	// ----- Check the static values
4499 4499
   	// TBC
@@ -4530,7 +4530,7 @@  discard block
 block discarded – undo
4530 4530
   // --------------------------------------------------------------------------------
4531 4531
   function privReadEndCentralDir(&$p_central_dir)
4532 4532
   {
4533
-    $v_result=1;
4533
+    $v_result = 1;
4534 4534
 
4535 4535
     // ----- Go to the end of the zip file
4536 4536
     $v_size = filesize($this->zipname);
@@ -4538,7 +4538,7 @@  discard block
 block discarded – undo
4538 4538
     if (@ftell($this->zip_fd) != $v_size)
4539 4539
     {
4540 4540
       // ----- Error log
4541
-      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \''.$this->zipname.'\'');
4541
+      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \'' . $this->zipname . '\'');
4542 4542
 
4543 4543
       // ----- Return
4544 4544
       return PclZip::errorCode();
@@ -4548,11 +4548,11 @@  discard block
 block discarded – undo
4548 4548
     // in this case the end of central dir is at 22 bytes of the file end
4549 4549
     $v_found = 0;
4550 4550
     if ($v_size > 26) {
4551
-      @fseek($this->zip_fd, $v_size-22);
4552
-      if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22))
4551
+      @fseek($this->zip_fd, $v_size - 22);
4552
+      if (($v_pos = @ftell($this->zip_fd)) != ($v_size - 22))
4553 4553
       {
4554 4554
         // ----- Error log
4555
-        PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
4555
+        PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \'' . $this->zipname . '\'');
4556 4556
 
4557 4557
         // ----- Return
4558 4558
         return PclZip::errorCode();
@@ -4575,11 +4575,11 @@  discard block
 block discarded – undo
4575 4575
       $v_maximum_size = 65557; // 0xFFFF + 22;
4576 4576
       if ($v_maximum_size > $v_size)
4577 4577
         $v_maximum_size = $v_size;
4578
-      @fseek($this->zip_fd, $v_size-$v_maximum_size);
4579
-      if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size))
4578
+      @fseek($this->zip_fd, $v_size - $v_maximum_size);
4579
+      if (@ftell($this->zip_fd) != ($v_size - $v_maximum_size))
4580 4580
       {
4581 4581
         // ----- Error log
4582
-        PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
4582
+        PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \'' . $this->zipname . '\'');
4583 4583
 
4584 4584
         // ----- Return
4585 4585
         return PclZip::errorCode();
@@ -4597,7 +4597,7 @@  discard block
 block discarded – undo
4597 4597
         //$v_bytes = ($v_bytes << 8) | Ord($v_byte);
4598 4598
         // Note we mask the old value down such that once shifted we can never end up with more than a 32bit number 
4599 4599
         // Otherwise on systems where we have 64bit integers the check below for the magic number will fail. 
4600
-        $v_bytes = ( ($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte); 
4600
+        $v_bytes = (($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte); 
4601 4601
 
4602 4602
         // ----- Compare the bytes
4603 4603
         if ($v_bytes == 0x504b0506)
@@ -4629,7 +4629,7 @@  discard block
 block discarded – undo
4629 4629
     {
4630 4630
 
4631 4631
       // ----- Error log
4632
-      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : ".strlen($v_binary_data));
4632
+      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : " . strlen($v_binary_data));
4633 4633
 
4634 4634
       // ----- Return
4635 4635
       return PclZip::errorCode();
@@ -4687,11 +4687,11 @@  discard block
 block discarded – undo
4687 4687
   // --------------------------------------------------------------------------------
4688 4688
   function privDeleteByRule(&$p_result_list, &$p_options)
4689 4689
   {
4690
-    $v_result=1;
4690
+    $v_result = 1;
4691 4691
     $v_list_detail = array();
4692 4692
 
4693 4693
     // ----- Open the zip file
4694
-    if (($v_result=$this->privOpenFd('rb')) != 1)
4694
+    if (($v_result = $this->privOpenFd('rb')) != 1)
4695 4695
     {
4696 4696
       // ----- Return
4697 4697
       return $v_result;
@@ -4727,7 +4727,7 @@  discard block
 block discarded – undo
4727 4727
     // ----- Read each entry
4728 4728
     $v_header_list = array();
4729 4729
     $j_start = 0;
4730
-    for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
4730
+    for ($i = 0, $v_nb_extracted = 0; $i < $v_central_dir['entries']; $i++)
4731 4731
     {
4732 4732
 
4733 4733
       // ----- Read the file header
@@ -4748,22 +4748,22 @@  discard block
 block discarded – undo
4748 4748
       $v_found = false;
4749 4749
 
4750 4750
       // ----- Look for extract by name rule
4751
-      if (   (isset($p_options[PCLZIP_OPT_BY_NAME]))
4751
+      if ((isset($p_options[PCLZIP_OPT_BY_NAME]))
4752 4752
           && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
4753 4753
 
4754 4754
           // ----- Look if the filename is in the list
4755
-          for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) {
4755
+          for ($j = 0; ($j < sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) {
4756 4756
 
4757 4757
               // ----- Look for a directory
4758 4758
               if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
4759 4759
 
4760 4760
                   // ----- Look if the directory is in the filename path
4761
-                  if (   (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
4761
+                  if ((strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
4762 4762
                       && (substr($v_header_list[$v_nb_extracted]['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
4763 4763
                       $v_found = true;
4764 4764
                   }
4765
-                  elseif (   (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */
4766
-                          && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
4765
+                  elseif ((($v_header_list[$v_nb_extracted]['external'] & 0x00000010) == 0x00000010) /* Indicates a folder */
4766
+                          && ($v_header_list[$v_nb_extracted]['stored_filename'] . '/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
4767 4767
                       $v_found = true;
4768 4768
                   }
4769 4769
               }
@@ -4787,7 +4787,7 @@  discard block
 block discarded – undo
4787 4787
       */
4788 4788
 
4789 4789
       // ----- Look for extract by preg rule
4790
-      else if (   (isset($p_options[PCLZIP_OPT_BY_PREG]))
4790
+      else if ((isset($p_options[PCLZIP_OPT_BY_PREG]))
4791 4791
                && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
4792 4792
 
4793 4793
           if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
@@ -4796,20 +4796,20 @@  discard block
 block discarded – undo
4796 4796
       }
4797 4797
 
4798 4798
       // ----- Look for extract by index rule
4799
-      else if (   (isset($p_options[PCLZIP_OPT_BY_INDEX]))
4799
+      else if ((isset($p_options[PCLZIP_OPT_BY_INDEX]))
4800 4800
                && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
4801 4801
 
4802 4802
           // ----- Look if the index is in the list
4803
-          for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) {
4803
+          for ($j = $j_start; ($j < sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) {
4804 4804
 
4805
-              if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
4805
+              if (($i >= $p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i <= $p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
4806 4806
                   $v_found = true;
4807 4807
               }
4808
-              if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
4809
-                  $j_start = $j+1;
4808
+              if ($i >= $p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
4809
+                  $j_start = $j + 1;
4810 4810
               }
4811 4811
 
4812
-              if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
4812
+              if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start'] > $i) {
4813 4813
                   break;
4814 4814
               }
4815 4815
           }
@@ -4833,7 +4833,7 @@  discard block
 block discarded – undo
4833 4833
     if ($v_nb_extracted > 0) {
4834 4834
 
4835 4835
         // ----- Creates a temporay file
4836
-        $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
4836
+        $v_zip_temp_name = PCLZIP_TEMPORARY_DIR . uniqid('pclzip-') . '.tmp';
4837 4837
 
4838 4838
         // ----- Creates a temporary zip archive
4839 4839
         $v_temp_zip = new PclZip($v_zip_temp_name);
@@ -4847,11 +4847,11 @@  discard block
 block discarded – undo
4847 4847
         }
4848 4848
 
4849 4849
         // ----- Look which file need to be kept
4850
-        for ($i=0; $i<sizeof($v_header_list); $i++) {
4850
+        for ($i = 0; $i < sizeof($v_header_list); $i++) {
4851 4851
 
4852 4852
             // ----- Calculate the position of the header
4853 4853
             @rewind($this->zip_fd);
4854
-            if (@fseek($this->zip_fd,  $v_header_list[$i]['offset'])) {
4854
+            if (@fseek($this->zip_fd, $v_header_list[$i]['offset'])) {
4855 4855
                 // ----- Close the zip file
4856 4856
                 $this->privCloseFd();
4857 4857
                 $v_temp_zip->privCloseFd();
@@ -4910,7 +4910,7 @@  discard block
 block discarded – undo
4910 4910
         $v_offset = @ftell($v_temp_zip->zip_fd);
4911 4911
 
4912 4912
         // ----- Re-Create the Central Dir files header
4913
-        for ($i=0; $i<sizeof($v_header_list); $i++) {
4913
+        for ($i = 0; $i < sizeof($v_header_list); $i++) {
4914 4914
             // ----- Create the file header
4915 4915
             if (($v_result = $v_temp_zip->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
4916 4916
                 $v_temp_zip->privCloseFd();
@@ -4933,7 +4933,7 @@  discard block
 block discarded – undo
4933 4933
         }
4934 4934
 
4935 4935
         // ----- Calculate the size of the central header
4936
-        $v_size = @ftell($v_temp_zip->zip_fd)-$v_offset;
4936
+        $v_size = @ftell($v_temp_zip->zip_fd) - $v_offset;
4937 4937
 
4938 4938
         // ----- Create the central dir footer
4939 4939
         if (($v_result = $v_temp_zip->privWriteCentralHeader(sizeof($v_header_list), $v_size, $v_offset, $v_comment)) != 1) {
@@ -4995,15 +4995,15 @@  discard block
 block discarded – undo
4995 4995
   //    1 : OK
4996 4996
   //   -1 : Unable to create directory
4997 4997
   // --------------------------------------------------------------------------------
4998
-  function privDirCheck($p_dir, $p_is_dir=false)
4998
+  function privDirCheck($p_dir, $p_is_dir = false)
4999 4999
   {
5000 5000
     $v_result = 1;
5001 5001
 
5002 5002
 
5003 5003
     // ----- Remove the final '/'
5004
-    if (($p_is_dir) && (substr($p_dir, -1)=='/'))
5004
+    if (($p_is_dir) && (substr($p_dir, -1) == '/'))
5005 5005
     {
5006
-      $p_dir = substr($p_dir, 0, strlen($p_dir)-1);
5006
+      $p_dir = substr($p_dir, 0, strlen($p_dir) - 1);
5007 5007
     }
5008 5008
 
5009 5009
     // ----- Check the directory availability
@@ -5052,7 +5052,7 @@  discard block
 block discarded – undo
5052 5052
   // --------------------------------------------------------------------------------
5053 5053
   function privMerge(&$p_archive_to_add)
5054 5054
   {
5055
-    $v_result=1;
5055
+    $v_result = 1;
5056 5056
 
5057 5057
     // ----- Look if the archive_to_add exists
5058 5058
     if (!is_file($p_archive_to_add->zipname))
@@ -5077,7 +5077,7 @@  discard block
 block discarded – undo
5077 5077
     }
5078 5078
 
5079 5079
     // ----- Open the zip file
5080
-    if (($v_result=$this->privOpenFd('rb')) != 1)
5080
+    if (($v_result = $this->privOpenFd('rb')) != 1)
5081 5081
     {
5082 5082
       // ----- Return
5083 5083
       return $v_result;
@@ -5095,7 +5095,7 @@  discard block
 block discarded – undo
5095 5095
     @rewind($this->zip_fd);
5096 5096
 
5097 5097
     // ----- Open the archive_to_add file
5098
-    if (($v_result=$p_archive_to_add->privOpenFd('rb')) != 1)
5098
+    if (($v_result = $p_archive_to_add->privOpenFd('rb')) != 1)
5099 5099
     {
5100 5100
       $this->privCloseFd();
5101 5101
 
@@ -5117,7 +5117,7 @@  discard block
 block discarded – undo
5117 5117
     @rewind($p_archive_to_add->zip_fd);
5118 5118
 
5119 5119
     // ----- Creates a temporay file
5120
-    $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
5120
+    $v_zip_temp_name = PCLZIP_TEMPORARY_DIR . uniqid('pclzip-') . '.tmp';
5121 5121
 
5122 5122
     // ----- Open the temporary file in write mode
5123 5123
     if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
@@ -5125,7 +5125,7 @@  discard block
 block discarded – undo
5125 5125
       $this->privCloseFd();
5126 5126
       $p_archive_to_add->privCloseFd();
5127 5127
 
5128
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
5128
+      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \'' . $v_zip_temp_name . '\' in binary write mode');
5129 5129
 
5130 5130
       // ----- Return
5131 5131
       return PclZip::errorCode();
@@ -5176,10 +5176,10 @@  discard block
 block discarded – undo
5176 5176
     }
5177 5177
 
5178 5178
     // ----- Merge the file comments
5179
-    $v_comment = $v_central_dir['comment'].' '.$v_central_dir_to_add['comment'];
5179
+    $v_comment = $v_central_dir['comment'] . ' ' . $v_central_dir_to_add['comment'];
5180 5180
 
5181 5181
     // ----- Calculate the size of the (new) central header
5182
-    $v_size = @ftell($v_zip_temp_fd)-$v_offset;
5182
+    $v_size = @ftell($v_zip_temp_fd) - $v_offset;
5183 5183
 
5184 5184
     // ----- Swap the file descriptor
5185 5185
     // Here is a trick : I swap the temporary fd with the zip fd, in order to use
@@ -5189,7 +5189,7 @@  discard block
 block discarded – undo
5189 5189
     $v_zip_temp_fd = $v_swap;
5190 5190
 
5191 5191
     // ----- Create the central dir footer
5192
-    if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries']+$v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1)
5192
+    if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries'] + $v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1)
5193 5193
     {
5194 5194
       $this->privCloseFd();
5195 5195
       $p_archive_to_add->privCloseFd();
@@ -5237,7 +5237,7 @@  discard block
 block discarded – undo
5237 5237
   // --------------------------------------------------------------------------------
5238 5238
   function privDuplicate($p_archive_filename)
5239 5239
   {
5240
-    $v_result=1;
5240
+    $v_result = 1;
5241 5241
 
5242 5242
     // ----- Look if the $p_archive_filename exists
5243 5243
     if (!is_file($p_archive_filename))
@@ -5251,7 +5251,7 @@  discard block
 block discarded – undo
5251 5251
     }
5252 5252
 
5253 5253
     // ----- Open the zip file
5254
-    if (($v_result=$this->privOpenFd('wb')) != 1)
5254
+    if (($v_result = $this->privOpenFd('wb')) != 1)
5255 5255
     {
5256 5256
       // ----- Return
5257 5257
       return $v_result;
@@ -5262,7 +5262,7 @@  discard block
 block discarded – undo
5262 5262
     {
5263 5263
       $this->privCloseFd();
5264 5264
 
5265
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \''.$p_archive_filename.'\' in binary write mode');
5265
+      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \'' . $p_archive_filename . '\' in binary write mode');
5266 5266
 
5267 5267
       // ----- Return
5268 5268
       return PclZip::errorCode();
@@ -5295,7 +5295,7 @@  discard block
 block discarded – undo
5295 5295
   // Description :
5296 5296
   // Parameters :
5297 5297
   // --------------------------------------------------------------------------------
5298
-  function privErrorLog($p_error_code=0, $p_error_string='')
5298
+  function privErrorLog($p_error_code = 0, $p_error_string = '')
5299 5299
   {
5300 5300
     if (PCLZIP_ERROR_EXTERNAL == 1) {
5301 5301
       PclError($p_error_code, $p_error_string);
@@ -5332,10 +5332,10 @@  discard block
 block discarded – undo
5332 5332
   // --------------------------------------------------------------------------------
5333 5333
   function privDisableMagicQuotes()
5334 5334
   {
5335
-    $v_result=1;
5335
+    $v_result = 1;
5336 5336
 
5337 5337
     // ----- Look if function exists
5338
-    if (   (!function_exists("get_magic_quotes_runtime"))
5338
+    if ((!function_exists("get_magic_quotes_runtime"))
5339 5339
 	    || (!function_exists("set_magic_quotes_runtime"))) {
5340 5340
       return $v_result;
5341 5341
 	}
@@ -5366,10 +5366,10 @@  discard block
 block discarded – undo
5366 5366
   // --------------------------------------------------------------------------------
5367 5367
   function privSwapBackMagicQuotes()
5368 5368
   {
5369
-    $v_result=1;
5369
+    $v_result = 1;
5370 5370
 
5371 5371
     // ----- Look if function exists
5372
-    if (   (!function_exists("get_magic_quotes_runtime"))
5372
+    if ((!function_exists("get_magic_quotes_runtime"))
5373 5373
 	    || (!function_exists("set_magic_quotes_runtime"))) {
5374 5374
       return $v_result;
5375 5375
 	}
@@ -5410,7 +5410,7 @@  discard block
 block discarded – undo
5410 5410
 
5411 5411
       // ----- Study directories from last to first
5412 5412
       $v_skip = 0;
5413
-      for ($i=sizeof($v_list)-1; $i>=0; $i--) {
5413
+      for ($i = sizeof($v_list) - 1; $i >= 0; $i--) {
5414 5414
         // ----- Look for current path
5415 5415
         if ($v_list[$i] == ".") {
5416 5416
           // ----- Ignore this directory
@@ -5422,7 +5422,7 @@  discard block
 block discarded – undo
5422 5422
         else if ($v_list[$i] == "") {
5423 5423
 		  // ----- First '/' i.e. root slash
5424 5424
 		  if ($i == 0) {
5425
-            $v_result = "/".$v_result;
5425
+            $v_result = "/" . $v_result;
5426 5426
 		    if ($v_skip > 0) {
5427 5427
 		        // ----- It is an invalid path, so the path is not modified
5428 5428
 		        // TBC
@@ -5431,7 +5431,7 @@  discard block
 block discarded – undo
5431 5431
 		    }
5432 5432
 		  }
5433 5433
 		  // ----- Last '/' i.e. indicates a directory
5434
-		  else if ($i == (sizeof($v_list)-1)) {
5434
+		  else if ($i == (sizeof($v_list) - 1)) {
5435 5435
             $v_result = $v_list[$i];
5436 5436
 		  }
5437 5437
 		  // ----- Double '/' inside the path
@@ -5446,7 +5446,7 @@  discard block
 block discarded – undo
5446 5446
 		    $v_skip--;
5447 5447
 		  }
5448 5448
 		  else {
5449
-            $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:"");
5449
+            $v_result = $v_list[$i] . ($i != (sizeof($v_list) - 1) ? "/" . $v_result : "");
5450 5450
 		  }
5451 5451
         }
5452 5452
       }
@@ -5454,7 +5454,7 @@  discard block
 block discarded – undo
5454 5454
       // ----- Look for skip
5455 5455
       if ($v_skip > 0) {
5456 5456
         while ($v_skip > 0) {
5457
-            $v_result = '../'.$v_result;
5457
+            $v_result = '../' . $v_result;
5458 5458
             $v_skip--;
5459 5459
         }
5460 5460
       }
@@ -5485,13 +5485,13 @@  discard block
 block discarded – undo
5485 5485
     $v_result = 1;
5486 5486
     
5487 5487
     // ----- Look for path beginning by ./
5488
-    if (   ($p_dir == '.')
5489
-        || ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) {
5490
-      $p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1);
5488
+    if (($p_dir == '.')
5489
+        || ((strlen($p_dir) >= 2) && (substr($p_dir, 0, 2) == './'))) {
5490
+      $p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE) . '/' . substr($p_dir, 1);
5491 5491
     }
5492
-    if (   ($p_path == '.')
5493
-        || ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) {
5494
-      $p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1);
5492
+    if (($p_path == '.')
5493
+        || ((strlen($p_path) >= 2) && (substr($p_path, 0, 2) == './'))) {
5494
+      $p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE) . '/' . substr($p_path, 1);
5495 5495
     }
5496 5496
 
5497 5497
     // ----- Explode dir and path by directory separator
@@ -5516,7 +5516,7 @@  discard block
 block discarded – undo
5516 5516
       }
5517 5517
 
5518 5518
       // ----- Compare the items
5519
-      if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != ''))  {
5519
+      if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ($v_list_path[$j] != '')) {
5520 5520
         $v_result = 0;
5521 5521
       }
5522 5522
 
@@ -5557,11 +5557,11 @@  discard block
 block discarded – undo
5557 5557
   //             3 : src & dest gzip
5558 5558
   // Return Values :
5559 5559
   // --------------------------------------------------------------------------------
5560
-  function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0)
5560
+  function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode = 0)
5561 5561
   {
5562 5562
     $v_result = 1;
5563 5563
 
5564
-    if ($p_mode==0)
5564
+    if ($p_mode == 0)
5565 5565
     {
5566 5566
       while ($p_size != 0)
5567 5567
       {
@@ -5571,7 +5571,7 @@  discard block
 block discarded – undo
5571 5571
         $p_size -= $v_read_size;
5572 5572
       }
5573 5573
     }
5574
-    else if ($p_mode==1)
5574
+    else if ($p_mode == 1)
5575 5575
     {
5576 5576
       while ($p_size != 0)
5577 5577
       {
@@ -5581,7 +5581,7 @@  discard block
 block discarded – undo
5581 5581
         $p_size -= $v_read_size;
5582 5582
       }
5583 5583
     }
5584
-    else if ($p_mode==2)
5584
+    else if ($p_mode == 2)
5585 5585
     {
5586 5586
       while ($p_size != 0)
5587 5587
       {
@@ -5591,7 +5591,7 @@  discard block
 block discarded – undo
5591 5591
         $p_size -= $v_read_size;
5592 5592
       }
5593 5593
     }
5594
-    else if ($p_mode==3)
5594
+    else if ($p_mode == 3)
5595 5595
     {
5596 5596
       while ($p_size != 0)
5597 5597
       {
@@ -5655,7 +5655,7 @@  discard block
 block discarded – undo
5655 5655
     $v_list = get_defined_constants();
5656 5656
     for (reset($v_list); $v_key = key($v_list); next($v_list)) {
5657 5657
 	    $v_prefix = substr($v_key, 0, 10);
5658
-	    if ((   ($v_prefix == 'PCLZIP_OPT')
5658
+	    if ((($v_prefix == 'PCLZIP_OPT')
5659 5659
            || ($v_prefix == 'PCLZIP_CB_')
5660 5660
            || ($v_prefix == 'PCLZIP_ATT'))
5661 5661
 	        && ($v_list[$v_key] == $p_option)) {
@@ -5680,15 +5680,15 @@  discard block
 block discarded – undo
5680 5680
   // Return Values :
5681 5681
   //   The path translated.
5682 5682
   // --------------------------------------------------------------------------------
5683
-  function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter=true)
5683
+  function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter = true)
5684 5684
   {
5685 5685
     if (stristr(php_uname(), 'windows')) {
5686 5686
       // ----- Look for potential disk letter
5687 5687
       if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) {
5688
-          $p_path = substr($p_path, $v_position+1);
5688
+          $p_path = substr($p_path, $v_position + 1);
5689 5689
       }
5690 5690
       // ----- Change potential windows directory separator
5691
-      if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) {
5691
+      if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0, 1) == '\\')) {
5692 5692
           $p_path = strtr($p_path, '\\', '/');
5693 5693
       }
5694 5694
     }
Please login to merge, or discard this patch.
Braces   +118 added lines, -159 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 // --------------------------------------------------------------------------------
3 5
 // PhpConcept Library - Zip Module 2.8.2
4 6
 // --------------------------------------------------------------------------------
@@ -330,8 +332,7 @@  discard block
 block discarded – undo
330 332
         // ----- Look for the optional second argument
331 333
         if ($v_size == 2) {
332 334
           $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
333
-        }
334
-        else if ($v_size > 2) {
335
+        } else if ($v_size > 2) {
335 336
           PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
336 337
 		                       "Invalid number / type of arguments");
337 338
           return 0;
@@ -380,8 +381,7 @@  discard block
 block discarded – undo
380 381
       foreach ($v_string_list as $v_string) {
381 382
         if ($v_string != '') {
382 383
           $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
383
-        }
384
-        else {
384
+        } else {
385 385
         }
386 386
       }
387 387
     }
@@ -515,8 +515,7 @@  discard block
 block discarded – undo
515 515
         // ----- Look for the optional second argument
516 516
         if ($v_size == 2) {
517 517
           $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
518
-        }
519
-        else if ($v_size > 2) {
518
+        } else if ($v_size > 2) {
520 519
           // ----- Error log
521 520
           PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
522 521
 
@@ -792,8 +791,7 @@  discard block
 block discarded – undo
792 791
         // ----- Look for the optional second argument
793 792
         if ($v_size == 2) {
794 793
           $v_remove_path = $v_arg_list[1];
795
-        }
796
-        else if ($v_size > 2) {
794
+        } else if ($v_size > 2) {
797 795
           // ----- Error log
798 796
           PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
799 797
 
@@ -937,8 +935,7 @@  discard block
 block discarded – undo
937 935
         }
938 936
         if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) {
939 937
           $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
940
-        }
941
-        else {
938
+        } else {
942 939
         }
943 940
       }
944 941
 
@@ -953,8 +950,7 @@  discard block
 block discarded – undo
953 950
         // ----- Look for the optional second argument
954 951
         if ($v_size == 2) {
955 952
           $v_remove_path = $v_arg_list[1];
956
-        }
957
-        else if ($v_size > 2) {
953
+        } else if ($v_size > 2) {
958 954
           // ----- Error log
959 955
           PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
960 956
 
@@ -1190,8 +1186,7 @@  discard block
 block discarded – undo
1190 1186
         // ----- Error log
1191 1187
         PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "No file with filename '".$p_archive."'");
1192 1188
         $v_result = PCLZIP_ERR_MISSING_FILE;
1193
-      }
1194
-      else {
1189
+      } else {
1195 1190
         // ----- Duplicate the archive
1196 1191
         $v_result = $this->privDuplicate($p_archive);
1197 1192
       }
@@ -1279,8 +1274,7 @@  discard block
 block discarded – undo
1279 1274
   {
1280 1275
     if (PCLZIP_ERROR_EXTERNAL == 1) {
1281 1276
       return(PclErrorCode());
1282
-    }
1283
-    else {
1277
+    } else {
1284 1278
       return($this->error_code);
1285 1279
     }
1286 1280
   }
@@ -1318,15 +1312,13 @@  discard block
 block discarded – undo
1318 1312
 
1319 1313
     if (isset($v_name[$this->error_code])) {
1320 1314
       $v_value = $v_name[$this->error_code];
1321
-    }
1322
-    else {
1315
+    } else {
1323 1316
       $v_value = 'NoName';
1324 1317
     }
1325 1318
 
1326 1319
     if ($p_with_code) {
1327 1320
       return($v_value.' ('.$this->error_code.')');
1328
-    }
1329
-    else {
1321
+    } else {
1330 1322
       return($v_value);
1331 1323
     }
1332 1324
   }
@@ -1341,12 +1333,10 @@  discard block
 block discarded – undo
1341 1333
   {
1342 1334
     if (PCLZIP_ERROR_EXTERNAL == 1) {
1343 1335
       return(PclErrorString());
1344
-    }
1345
-    else {
1336
+    } else {
1346 1337
       if ($p_full) {
1347 1338
         return($this->errorName(true)." : ".$this->error_string);
1348
-      }
1349
-      else {
1339
+      } else {
1350 1340
         return($this->error_string." [code ".$this->error_code."]");
1351 1341
       }
1352 1342
     }
@@ -1531,8 +1521,7 @@  discard block
 block discarded – undo
1531 1521
               && ($p_options_list[$i+1] != '')) {
1532 1522
             $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE);
1533 1523
             $i++;
1534
-          }
1535
-          else {
1524
+          } else {
1536 1525
           }
1537 1526
         break;
1538 1527
 
@@ -1550,11 +1539,9 @@  discard block
 block discarded – undo
1550 1539
           // ----- Get the value
1551 1540
           if (is_string($p_options_list[$i+1])) {
1552 1541
               $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i+1];
1553
-          }
1554
-          else if (is_array($p_options_list[$i+1])) {
1542
+          } else if (is_array($p_options_list[$i+1])) {
1555 1543
               $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1556
-          }
1557
-          else {
1544
+          } else {
1558 1545
             // ----- Error log
1559 1546
             PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1560 1547
 
@@ -1583,8 +1570,7 @@  discard block
 block discarded – undo
1583 1570
           // ----- Get the value
1584 1571
           if (is_string($p_options_list[$i+1])) {
1585 1572
               $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1586
-          }
1587
-          else {
1573
+          } else {
1588 1574
             // ----- Error log
1589 1575
             PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1590 1576
 
@@ -1613,8 +1599,7 @@  discard block
 block discarded – undo
1613 1599
           // ----- Get the value
1614 1600
           if (is_string($p_options_list[$i+1])) {
1615 1601
               $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1616
-          }
1617
-          else {
1602
+          } else {
1618 1603
             // ----- Error log
1619 1604
             PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE,
1620 1605
 			                     "Wrong parameter value for option '"
@@ -1647,14 +1632,11 @@  discard block
 block discarded – undo
1647 1632
 
1648 1633
               // ----- Parse items
1649 1634
               $v_work_list = explode(",", $p_options_list[$i+1]);
1650
-          }
1651
-          else if (is_integer($p_options_list[$i+1])) {
1635
+          } else if (is_integer($p_options_list[$i+1])) {
1652 1636
               $v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1];
1653
-          }
1654
-          else if (is_array($p_options_list[$i+1])) {
1637
+          } else if (is_array($p_options_list[$i+1])) {
1655 1638
               $v_work_list = $p_options_list[$i+1];
1656
-          }
1657
-          else {
1639
+          } else {
1658 1640
             // ----- Error log
1659 1641
             PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1660 1642
 
@@ -1681,13 +1663,11 @@  discard block
 block discarded – undo
1681 1663
                   // ----- Set the option value
1682 1664
                   $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0];
1683 1665
                   $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[0];
1684
-              }
1685
-              elseif ($v_size_item_list == 2) {
1666
+              } elseif ($v_size_item_list == 2) {
1686 1667
                   // ----- Set the option value
1687 1668
                   $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0];
1688 1669
                   $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[1];
1689
-              }
1690
-              else {
1670
+              } else {
1691 1671
                   // ----- Error log
1692 1672
                   PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Too many values in index range for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1693 1673
 
@@ -1843,14 +1823,17 @@  discard block
 block discarded – undo
1843 1823
     $v_memory_limit = trim($v_memory_limit);
1844 1824
     $last = strtolower(substr($v_memory_limit, -1));
1845 1825
  
1846
-    if($last == 'g')
1847
-        //$v_memory_limit = $v_memory_limit*1024*1024*1024;
1826
+    if($last == 'g') {
1827
+            //$v_memory_limit = $v_memory_limit*1024*1024*1024;
1848 1828
         $v_memory_limit = $v_memory_limit*1073741824;
1849
-    if($last == 'm')
1850
-        //$v_memory_limit = $v_memory_limit*1024*1024;
1829
+    }
1830
+    if($last == 'm') {
1831
+            //$v_memory_limit = $v_memory_limit*1024*1024;
1851 1832
         $v_memory_limit = $v_memory_limit*1048576;
1852
-    if($last == 'k')
1853
-        $v_memory_limit = $v_memory_limit*1024;
1833
+    }
1834
+    if($last == 'k') {
1835
+            $v_memory_limit = $v_memory_limit*1024;
1836
+    }
1854 1837
             
1855 1838
     $p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit*PCLZIP_TEMPORARY_FILE_RATIO);
1856 1839
     
@@ -2023,15 +2006,12 @@  discard block
 block discarded – undo
2023 2006
       if (file_exists($v_descr['filename'])) {
2024 2007
         if (@is_file($v_descr['filename'])) {
2025 2008
           $v_descr['type'] = 'file';
2026
-        }
2027
-        else if (@is_dir($v_descr['filename'])) {
2009
+        } else if (@is_dir($v_descr['filename'])) {
2028 2010
           $v_descr['type'] = 'folder';
2029
-        }
2030
-        else if (@is_link($v_descr['filename'])) {
2011
+        } else if (@is_link($v_descr['filename'])) {
2031 2012
           // skip
2032 2013
           continue;
2033
-        }
2034
-        else {
2014
+        } else {
2035 2015
           // skip
2036 2016
           continue;
2037 2017
         }
@@ -2080,8 +2060,7 @@  discard block
 block discarded – undo
2080 2060
                  && (!isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))) {
2081 2061
               if ($v_descr['stored_filename'] != '') {
2082 2062
                 $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler;
2083
-              }
2084
-              else {
2063
+              } else {
2085 2064
                 $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_item_handler;
2086 2065
               }
2087 2066
             }
@@ -2090,8 +2069,7 @@  discard block
 block discarded – undo
2090 2069
           }
2091 2070
           
2092 2071
           @closedir($v_folder_handler);
2093
-        }
2094
-        else {
2072
+        } else {
2095 2073
           // TBC : unable to open folder in read mode
2096 2074
         }
2097 2075
         
@@ -2104,8 +2082,7 @@  discard block
 block discarded – undo
2104 2082
           
2105 2083
           // ----- Concat the resulting list
2106 2084
           $v_result_list = array_merge($v_result_list, $v_dirlist_descr);
2107
-        }
2108
-        else {
2085
+        } else {
2109 2086
         }
2110 2087
           
2111 2088
         // ----- Free local array
@@ -2379,8 +2356,9 @@  discard block
 block discarded – undo
2379 2356
   {
2380 2357
     $v_result=1;
2381 2358
 
2382
-    if ($this->zip_fd != 0)
2383
-      @fclose($this->zip_fd);
2359
+    if ($this->zip_fd != 0) {
2360
+          @fclose($this->zip_fd);
2361
+    }
2384 2362
     $this->zip_fd = 0;
2385 2363
 
2386 2364
     // ----- Return
@@ -2597,11 +2575,9 @@  discard block
 block discarded – undo
2597 2575
     // ----- Look for filetime
2598 2576
     if (isset($p_filedescr['mtime'])) {
2599 2577
       $p_header['mtime'] = $p_filedescr['mtime'];
2600
-    }
2601
-    else if ($p_filedescr['type'] == 'virtual_file') {
2578
+    } else if ($p_filedescr['type'] == 'virtual_file') {
2602 2579
       $p_header['mtime'] = time();
2603
-    }
2604
-    else {
2580
+    } else {
2605 2581
       $p_header['mtime'] = filemtime($p_filename);
2606 2582
     }
2607 2583
 
@@ -2609,8 +2585,7 @@  discard block
 block discarded – undo
2609 2585
     if (isset($p_filedescr['comment'])) {
2610 2586
       $p_header['comment_len'] = strlen($p_filedescr['comment']);
2611 2587
       $p_header['comment'] = $p_filedescr['comment'];
2612
-    }
2613
-    else {
2588
+    } else {
2614 2589
       $p_header['comment_len'] = 0;
2615 2590
       $p_header['comment'] = '';
2616 2591
     }
@@ -2921,20 +2896,17 @@  discard block
 block discarded – undo
2921 2896
     $p_filename = $p_filedescr['filename'];
2922 2897
     if (isset($p_options[PCLZIP_OPT_ADD_PATH])) {
2923 2898
       $p_add_dir = $p_options[PCLZIP_OPT_ADD_PATH];
2924
-    }
2925
-    else {
2899
+    } else {
2926 2900
       $p_add_dir = '';
2927 2901
     }
2928 2902
     if (isset($p_options[PCLZIP_OPT_REMOVE_PATH])) {
2929 2903
       $p_remove_dir = $p_options[PCLZIP_OPT_REMOVE_PATH];
2930
-    }
2931
-    else {
2904
+    } else {
2932 2905
       $p_remove_dir = '';
2933 2906
     }
2934 2907
     if (isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
2935 2908
       $p_remove_all_dir = $p_options[PCLZIP_OPT_REMOVE_ALL_PATH];
2936
-    }
2937
-    else {
2909
+    } else {
2938 2910
       $p_remove_all_dir = 0;
2939 2911
     }
2940 2912
 
@@ -2957,8 +2929,7 @@  discard block
 block discarded – undo
2957 2929
           $v_dir = $v_path_info['dirname'].'/';
2958 2930
         }
2959 2931
         $v_stored_filename = $v_dir.$p_filedescr['new_short_name'];
2960
-      }
2961
-      else {
2932
+      } else {
2962 2933
         // ----- Calculate the stored filename
2963 2934
         $v_stored_filename = $p_filename;
2964 2935
       }
@@ -2969,8 +2940,9 @@  discard block
 block discarded – undo
2969 2940
       }
2970 2941
       // ----- Look for partial path remove
2971 2942
       else if ($p_remove_dir != "") {
2972
-        if (substr($p_remove_dir, -1) != '/')
2973
-          $p_remove_dir .= "/";
2943
+        if (substr($p_remove_dir, -1) != '/') {
2944
+                  $p_remove_dir .= "/";
2945
+        }
2974 2946
 
2975 2947
         if (   (substr($p_filename, 0, 2) == "./")
2976 2948
             || (substr($p_remove_dir, 0, 2) == "./")) {
@@ -2990,8 +2962,7 @@  discard block
 block discarded – undo
2990 2962
         if ($v_compare > 0) {
2991 2963
           if ($v_compare == 2) {
2992 2964
             $v_stored_filename = "";
2993
-          }
2994
-          else {
2965
+          } else {
2995 2966
             $v_stored_filename = substr($v_stored_filename,
2996 2967
                                         strlen($p_remove_dir));
2997 2968
           }
@@ -3003,10 +2974,11 @@  discard block
 block discarded – undo
3003 2974
       
3004 2975
       // ----- Look for path to add
3005 2976
       if ($p_add_dir != "") {
3006
-        if (substr($p_add_dir, -1) == "/")
3007
-          $v_stored_filename = $p_add_dir.$v_stored_filename;
3008
-        else
3009
-          $v_stored_filename = $p_add_dir."/".$v_stored_filename;
2977
+        if (substr($p_add_dir, -1) == "/") {
2978
+                  $v_stored_filename = $p_add_dir.$v_stored_filename;
2979
+        } else {
2980
+                  $v_stored_filename = $p_add_dir."/".$v_stored_filename;
2981
+        }
3010 2982
       }
3011 2983
     }
3012 2984
 
@@ -3289,8 +3261,9 @@  discard block
 block discarded – undo
3289 3261
     if (   ($p_path == "")
3290 3262
 	    || (   (substr($p_path, 0, 1) != "/")
3291 3263
 		    && (substr($p_path, 0, 3) != "../")
3292
-			&& (substr($p_path,1,2)!=":/")))
3293
-      $p_path = "./".$p_path;
3264
+			&& (substr($p_path,1,2)!=":/"))) {
3265
+          $p_path = "./".$p_path;
3266
+    }
3294 3267
 
3295 3268
     // ----- Reduce the path last (and duplicated) '/'
3296 3269
     if (($p_path != "./") && ($p_path != "/"))
@@ -3777,8 +3750,7 @@  discard block
 block discarded – undo
3777 3750
         // ----- Change the file status
3778 3751
         if (   (isset($p_options[PCLZIP_OPT_REPLACE_NEWER]))
3779 3752
 		    && ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) {
3780
-	  	  }
3781
-		    else {
3753
+	  	  } else {
3782 3754
             $p_entry['status'] = "newer_exist";
3783 3755
 
3784 3756
             // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
@@ -3794,19 +3766,19 @@  discard block
 block discarded – undo
3794 3766
                 return PclZip::errorCode();
3795 3767
 		      }
3796 3768
 		    }
3797
-      }
3798
-      else {
3769
+      } else {
3799 3770
       }
3800 3771
     }
3801 3772
 
3802 3773
     // ----- Check the directory availability and create it if necessary
3803 3774
     else {
3804
-      if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/'))
3805
-        $v_dir_to_check = $p_entry['filename'];
3806
-      else if (!strstr($p_entry['filename'], "/"))
3807
-        $v_dir_to_check = "";
3808
-      else
3809
-        $v_dir_to_check = dirname($p_entry['filename']);
3775
+      if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/')) {
3776
+              $v_dir_to_check = $p_entry['filename'];
3777
+      } else if (!strstr($p_entry['filename'], "/")) {
3778
+              $v_dir_to_check = "";
3779
+      } else {
3780
+              $v_dir_to_check = dirname($p_entry['filename']);
3781
+      }
3810 3782
 
3811 3783
         if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) {
3812 3784
   
@@ -3862,8 +3834,7 @@  discard block
 block discarded – undo
3862 3834
           touch($p_entry['filename'], $p_entry['mtime']);
3863 3835
           
3864 3836
 
3865
-        }
3866
-        else {
3837
+        } else {
3867 3838
           // ----- TBC
3868 3839
           // Need to be finished
3869 3840
           if (($p_entry['flag'] & 1) == 1) {
@@ -4106,8 +4077,7 @@  discard block
 block discarded – undo
4106 4077
           // ----- Send the file to the output
4107 4078
           echo $v_buffer;
4108 4079
           unset($v_buffer);
4109
-        }
4110
-        else {
4080
+        } else {
4111 4081
 
4112 4082
           // ----- Read the compressed file in a buffer (one shot)
4113 4083
           $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
@@ -4217,8 +4187,7 @@  discard block
 block discarded – undo
4217 4187
   
4218 4188
           // ----- Reading the file
4219 4189
           $p_string = @fread($this->zip_fd, $p_entry['compressed_size']);
4220
-        }
4221
-        else {
4190
+        } else {
4222 4191
   
4223 4192
           // ----- Reading the file
4224 4193
           $v_data = @fread($this->zip_fd, $p_entry['compressed_size']);
@@ -4230,8 +4199,7 @@  discard block
 block discarded – undo
4230 4199
         }
4231 4200
   
4232 4201
         // ----- Trace
4233
-      }
4234
-      else {
4202
+      } else {
4235 4203
           // TBC : error : can not extract a folder in a string
4236 4204
       }
4237 4205
       
@@ -4324,8 +4292,7 @@  discard block
 block discarded – undo
4324 4292
     // ----- Get extra_fields
4325 4293
     if ($v_data['extra_len'] != 0) {
4326 4294
       $p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']);
4327
-    }
4328
-    else {
4295
+    } else {
4329 4296
       $p_header['extra'] = '';
4330 4297
     }
4331 4298
 
@@ -4356,8 +4323,7 @@  discard block
 block discarded – undo
4356 4323
       // ----- Get UNIX date format
4357 4324
       $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
4358 4325
 
4359
-    }
4360
-    else
4326
+    } else
4361 4327
     {
4362 4328
       $p_header['mtime'] = time();
4363 4329
     }
@@ -4422,22 +4388,25 @@  discard block
 block discarded – undo
4422 4388
     $p_header = unpack('vversion/vversion_extracted/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len/vcomment_len/vdisk/vinternal/Vexternal/Voffset', $v_binary_data);
4423 4389
 
4424 4390
     // ----- Get filename
4425
-    if ($p_header['filename_len'] != 0)
4426
-      $p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']);
4427
-    else
4428
-      $p_header['filename'] = '';
4391
+    if ($p_header['filename_len'] != 0) {
4392
+          $p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']);
4393
+    } else {
4394
+          $p_header['filename'] = '';
4395
+    }
4429 4396
 
4430 4397
     // ----- Get extra
4431
-    if ($p_header['extra_len'] != 0)
4432
-      $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']);
4433
-    else
4434
-      $p_header['extra'] = '';
4398
+    if ($p_header['extra_len'] != 0) {
4399
+          $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']);
4400
+    } else {
4401
+          $p_header['extra'] = '';
4402
+    }
4435 4403
 
4436 4404
     // ----- Get comment
4437
-    if ($p_header['comment_len'] != 0)
4438
-      $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']);
4439
-    else
4440
-      $p_header['comment'] = '';
4405
+    if ($p_header['comment_len'] != 0) {
4406
+          $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']);
4407
+    } else {
4408
+          $p_header['comment'] = '';
4409
+    }
4441 4410
 
4442 4411
     // ----- Extract properties
4443 4412
 
@@ -4459,8 +4428,7 @@  discard block
 block discarded – undo
4459 4428
       // ----- Get UNIX date format
4460 4429
       $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
4461 4430
 
4462
-    }
4463
-    else
4431
+    } else
4464 4432
     {
4465 4433
       $p_header['mtime'] = time();
4466 4434
     }
@@ -4573,8 +4541,9 @@  discard block
 block discarded – undo
4573 4541
     // ----- Go back to the maximum possible size of the Central Dir End Record
4574 4542
     if (!$v_found) {
4575 4543
       $v_maximum_size = 65557; // 0xFFFF + 22;
4576
-      if ($v_maximum_size > $v_size)
4577
-        $v_maximum_size = $v_size;
4544
+      if ($v_maximum_size > $v_size) {
4545
+              $v_maximum_size = $v_size;
4546
+      }
4578 4547
       @fseek($this->zip_fd, $v_size-$v_maximum_size);
4579 4548
       if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size))
4580 4549
       {
@@ -4659,9 +4628,9 @@  discard block
 block discarded – undo
4659 4628
     // ----- Get comment
4660 4629
     if ($v_data['comment_size'] != 0) {
4661 4630
       $p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']);
4631
+    } else {
4632
+          $p_central_dir['comment'] = '';
4662 4633
     }
4663
-    else
4664
-      $p_central_dir['comment'] = '';
4665 4634
 
4666 4635
     $p_central_dir['entries'] = $v_data['entries'];
4667 4636
     $p_central_dir['disk_entries'] = $v_data['disk_entries'];
@@ -4761,8 +4730,7 @@  discard block
 block discarded – undo
4761 4730
                   if (   (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
4762 4731
                       && (substr($v_header_list[$v_nb_extracted]['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
4763 4732
                       $v_found = true;
4764
-                  }
4765
-                  elseif (   (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */
4733
+                  } elseif (   (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */
4766 4734
                           && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
4767 4735
                       $v_found = true;
4768 4736
                   }
@@ -4813,8 +4781,7 @@  discard block
 block discarded – undo
4813 4781
                   break;
4814 4782
               }
4815 4783
           }
4816
-      }
4817
-      else {
4784
+      } else {
4818 4785
       	$v_found = true;
4819 4786
       }
4820 4787
 
@@ -4822,8 +4789,7 @@  discard block
 block discarded – undo
4822 4789
       if ($v_found)
4823 4790
       {
4824 4791
         unset($v_header_list[$v_nb_extracted]);
4825
-      }
4826
-      else
4792
+      } else
4827 4793
       {
4828 4794
         $v_nb_extracted++;
4829 4795
       }
@@ -5299,8 +5265,7 @@  discard block
 block discarded – undo
5299 5265
   {
5300 5266
     if (PCLZIP_ERROR_EXTERNAL == 1) {
5301 5267
       PclError($p_error_code, $p_error_string);
5302
-    }
5303
-    else {
5268
+    } else {
5304 5269
       $this->error_code = $p_error_code;
5305 5270
       $this->error_string = $p_error_string;
5306 5271
     }
@@ -5316,8 +5281,7 @@  discard block
 block discarded – undo
5316 5281
   {
5317 5282
     if (PCLZIP_ERROR_EXTERNAL == 1) {
5318 5283
       PclErrorReset();
5319
-    }
5320
-    else {
5284
+    } else {
5321 5285
       $this->error_code = 0;
5322 5286
       $this->error_string = '';
5323 5287
     }
@@ -5415,11 +5379,9 @@  discard block
 block discarded – undo
5415 5379
         if ($v_list[$i] == ".") {
5416 5380
           // ----- Ignore this directory
5417 5381
           // Should be the first $i=0, but no check is done
5418
-        }
5419
-        else if ($v_list[$i] == "..") {
5382
+        } else if ($v_list[$i] == "..") {
5420 5383
 		  $v_skip++;
5421
-        }
5422
-        else if ($v_list[$i] == "") {
5384
+        } else if ($v_list[$i] == "") {
5423 5385
 		  // ----- First '/' i.e. root slash
5424 5386
 		  if ($i == 0) {
5425 5387
             $v_result = "/".$v_result;
@@ -5439,13 +5401,11 @@  discard block
 block discarded – undo
5439 5401
             // ----- Ignore only the double '//' in path,
5440 5402
             // but not the first and last '/'
5441 5403
 		  }
5442
-        }
5443
-        else {
5404
+        } else {
5444 5405
 		  // ----- Look for item to skip
5445 5406
 		  if ($v_skip > 0) {
5446 5407
 		    $v_skip--;
5447
-		  }
5448
-		  else {
5408
+		  } else {
5449 5409
             $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:"");
5450 5410
 		  }
5451 5411
         }
@@ -5528,14 +5488,17 @@  discard block
 block discarded – undo
5528 5488
     // ----- Look if everything seems to be the same
5529 5489
     if ($v_result) {
5530 5490
       // ----- Skip all the empty items
5531
-      while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++;
5532
-      while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++;
5491
+      while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) {
5492
+      	$j++;
5493
+      }
5494
+      while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) {
5495
+      	$i++;
5496
+      }
5533 5497
 
5534 5498
       if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) {
5535 5499
         // ----- There are exactly the same
5536 5500
         $v_result = 2;
5537
-      }
5538
-      else if ($i < $v_list_dir_size) {
5501
+      } else if ($i < $v_list_dir_size) {
5539 5502
         // ----- The path is shorter than the dir
5540 5503
         $v_result = 0;
5541 5504
       }
@@ -5570,8 +5533,7 @@  discard block
 block discarded – undo
5570 5533
         @fwrite($p_dest, $v_buffer, $v_read_size);
5571 5534
         $p_size -= $v_read_size;
5572 5535
       }
5573
-    }
5574
-    else if ($p_mode==1)
5536
+    } else if ($p_mode==1)
5575 5537
     {
5576 5538
       while ($p_size != 0)
5577 5539
       {
@@ -5580,8 +5542,7 @@  discard block
 block discarded – undo
5580 5542
         @fwrite($p_dest, $v_buffer, $v_read_size);
5581 5543
         $p_size -= $v_read_size;
5582 5544
       }
5583
-    }
5584
-    else if ($p_mode==2)
5545
+    } else if ($p_mode==2)
5585 5546
     {
5586 5547
       while ($p_size != 0)
5587 5548
       {
@@ -5590,8 +5551,7 @@  discard block
 block discarded – undo
5590 5551
         @gzwrite($p_dest, $v_buffer, $v_read_size);
5591 5552
         $p_size -= $v_read_size;
5592 5553
       }
5593
-    }
5594
-    else if ($p_mode==3)
5554
+    } else if ($p_mode==3)
5595 5555
     {
5596 5556
       while ($p_size != 0)
5597 5557
       {
@@ -5629,8 +5589,7 @@  discard block
 block discarded – undo
5629 5589
       // ----- Try to copy & unlink the src
5630 5590
       if (!@copy($p_src, $p_dest)) {
5631 5591
         $v_result = 0;
5632
-      }
5633
-      else if (!@unlink($p_src)) {
5592
+      } else if (!@unlink($p_src)) {
5634 5593
         $v_result = 0;
5635 5594
       }
5636 5595
     }
Please login to merge, or discard this patch.
includes/modules/wps_barcode/librairies/odtphp/zip/PclZipProxy.php 4 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 * Open a Zip archive
40 40
 	 * 
41 41
 	 * @param string $filename the name of the archive to open
42
-	 * @return true if openning has succeeded
42
+	 * @return boolean if openning has succeeded
43 43
 	 */	
44 44
 	public function open($filename)
45 45
 	{
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 * 
79 79
 	 * @param string $localname the local path to the file in the archive
80 80
 	 * @param string $contents the content of the file
81
-	 * @return true if the file has been successful added
81
+	 * @return boolean if the file has been successful added
82 82
 	 */	
83 83
 	public function addFromString($localname, $contents)
84 84
 	{
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	 * 
109 109
 	 * @param string $filename the path to the file we want to add
110 110
 	 * @param string $localname the local path to the file in the archive
111
-	 * @return true if the file has been successful added
111
+	 * @return boolean if the file has been successful added
112 112
 	 */	
113 113
 	public function addFile($filename, $localname = null)
114 114
 	{
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	}
142 142
 	/**
143 143
 	 * Close the Zip archive
144
-	 * @return true
144
+	 * @return boolean
145 145
 	 */	
146 146
 	public function close()
147 147
 	{
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 	}
159 159
 	/**
160 160
 	 * Empty the temporary working directory recursively
161
-	 * @param $dir the temporary working directory
161
+	 * @param string $dir the temporary working directory
162 162
 	 * @return void
163 163
 	 */
164 164
 	private function _rrmdir($dir)
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -23,11 +23,11 @@
 block discarded – undo
23 23
 	protected $openned = false;
24 24
 	protected $filename;
25 25
 	protected $pclzip;
26
-    /**
27
-     * Class constructor
28
-     *
29
-     * @throws PclZipProxyException
30
-     */
26
+	/**
27
+	 * Class constructor
28
+	 *
29
+	 * @throws PclZipProxyException
30
+	 */
31 31
 	public function __construct()
32 32
 	{
33 33
 		if (! class_exists('PclZip')) {
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 require_once 'pclzip/pclzip.lib.php';
3 3
 require_once 'ZipInterface.php';
4 4
 class PclZipProxyException extends Exception
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
      */
31 31
 	public function __construct()
32 32
 	{
33
-		if (! class_exists('PclZip')) {
33
+		if (!class_exists('PclZip')) {
34 34
 			throw new PclZipProxyException('PclZip class not loaded - PclZip library
35 35
 			 is required for using PclZipProxy'); ;
36 36
 		}
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 require_once 'pclzip/pclzip.lib.php';
3 5
 require_once 'ZipInterface.php';
4 6
 class PclZipProxyException extends Exception
Please login to merge, or discard this patch.
script/wp-emulator.script.php 3 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -158,12 +158,12 @@  discard block
 block discarded – undo
158 158
 
159 159
 	function trailingslashit( $string )
160 160
 	{
161
-	    return untrailingslashit( $string ) . '/';
161
+		return untrailingslashit( $string ) . '/';
162 162
 	}
163 163
 
164 164
 	function untrailingslashit( $string )
165 165
 	{
166
-	        return rtrim( $string, '/\\' );
166
+			return rtrim( $string, '/\\' );
167 167
 	}
168 168
 
169 169
 	function site_url()
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 		public $term_relationships = "term_relationship";
289 289
 		public $term_taxonomy = "term_taxonomy";
290 290
 
291
-    }
291
+	}
292 292
 
293 293
 	class WP_Widget
294 294
 	{
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -1,30 +1,30 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 	define('ABSPATH', dirname(dirname(dirname(dirname(dirname(__FILE__))))) . DIRECTORY_SEPARATOR);
3
-	define('WP_PLUGIN_DIR', dirname(dirname(dirname(__FILE__))) );
3
+	define('WP_PLUGIN_DIR', dirname(dirname(dirname(__FILE__))));
4 4
 	define('WP_LANG_DIR', 'FR');
5 5
 	define('WP_CONTENT_DIR', 'wp-content');
6 6
 
7
-	function __( $str )
7
+	function __($str)
8 8
 	{
9 9
 		$translate = "Result Testing text";
10 10
 		echo "[+] Requesting __ -> " . $str . PHP_EOL;
11 11
 		return $translate;
12 12
 	}
13 13
 
14
-	function add_action( $init, $object )
14
+	function add_action($init, $object)
15 15
 	{
16 16
 		$length = 0;
17 17
 		$hooked = "";
18 18
 		$oType = gettype($object);
19
-		if($oType == "object" || $oType == "array")
19
+		if ($oType == "object" || $oType == "array")
20 20
 		{
21 21
 			$hooked = "[";
22
-			foreach($object as $hook)
22
+			foreach ($object as $hook)
23 23
 			{
24 24
 				$length++;
25 25
 				$type = gettype($hook);
26 26
 
27
-				switch($type)
27
+				switch ($type)
28 28
 				{
29 29
 					case "integer":
30 30
 					case "boolean":
@@ -37,27 +37,27 @@  discard block
 block discarded – undo
37 37
 						break;
38 38
 				}
39 39
 			}
40
-			if($length > 0) $hooked = rtrim($hooked, ",");
40
+			if ($length > 0) $hooked = rtrim($hooked, ",");
41 41
 			$hooked .= "]";
42 42
 		}
43 43
 		else $hooked .= $object;
44 44
 		echo "[+] Adding action -> " . $init . " in " . $hooked . PHP_EOL;
45 45
 	}
46 46
 
47
-	function register_activation_hook( $file , $object )
47
+	function register_activation_hook($file, $object)
48 48
 	{
49 49
 		$length = 0;
50 50
 		$hooked = "";
51 51
 		$oType = gettype($object);
52
-		if($oType == "object" || $oType == "array")
52
+		if ($oType == "object" || $oType == "array")
53 53
 		{
54 54
 			$hooked = "[";
55
-			foreach($object as $hook)
55
+			foreach ($object as $hook)
56 56
 			{
57 57
 				$length++;
58 58
 				$type = gettype($hook);
59 59
 
60
-				switch($type)
60
+				switch ($type)
61 61
 				{
62 62
 					case "integer":
63 63
 					case "boolean":
@@ -70,27 +70,27 @@  discard block
 block discarded – undo
70 70
 						break;
71 71
 				}
72 72
 			}
73
-			if($length > 0) $hooked = rtrim($hooked, ",");
73
+			if ($length > 0) $hooked = rtrim($hooked, ",");
74 74
 			$hooked .= "]";
75 75
 		}
76 76
 		else $hooked .= $object;
77 77
 		echo "[+] Registering actiovation hook -> " . $file . " in " . $hooked . PHP_EOL;
78 78
 	}
79 79
 
80
-	function register_deactivation_hook( $file , $object )
80
+	function register_deactivation_hook($file, $object)
81 81
 	{
82 82
 		$length = 0;
83 83
 		$hooked = "";
84 84
 		$oType = gettype($object);
85
-		if($oType == "object" || $oType == "array")
85
+		if ($oType == "object" || $oType == "array")
86 86
 		{
87 87
 			$hooked = "[";
88
-			foreach($object as $hook)
88
+			foreach ($object as $hook)
89 89
 			{
90 90
 				$length++;
91 91
 				$type = gettype($hook);
92 92
 
93
-				switch($type)
93
+				switch ($type)
94 94
 				{
95 95
 					case "integer":
96 96
 					case "boolean":
@@ -103,29 +103,29 @@  discard block
 block discarded – undo
103 103
 						break;
104 104
 				}
105 105
 			}
106
-			if($length > 0) $hooked = rtrim($hooked, ",");
106
+			if ($length > 0) $hooked = rtrim($hooked, ",");
107 107
 			$hooked .= "]";
108 108
 		}
109 109
 		else $hooked .= $object;
110 110
 		echo "[+] Registering actiovation hook -> " . $file . " in " . $hooked . PHP_EOL;
111 111
 	}
112 112
 
113
-	function add_filter( $name, $fn, $nbr = "")
113
+	function add_filter($name, $fn, $nbr = "")
114 114
 	{
115 115
 		echo "[+] Adding filter -> " . $name . " X" . $nbr . PHP_EOL;
116 116
 	}
117 117
 
118
-	function add_shortcode( $name )
118
+	function add_shortcode($name)
119 119
 	{
120 120
 		echo "[+] Adding shortcode -> " . $name . PHP_EOL;
121 121
 	}
122 122
 
123
-	function add_option( $name, $conf)
123
+	function add_option($name, $conf)
124 124
 	{
125 125
 		echo "[+] Adding option -> " . $name . " conf:" . $conf . PHP_EOL;
126 126
 	}
127 127
 
128
-	function update_option( $name, $conf)
128
+	function update_option($name, $conf)
129 129
 	{
130 130
 		echo "[+] Updating option -> " . $name . " conf:" . $conf . PHP_EOL;
131 131
 	}
@@ -153,17 +153,17 @@  discard block
 block discarded – undo
153 153
 	function plugin_dir_path($path)
154 154
 	{
155 155
 		echo "[+] Plugin path -> " . $path . PHP_EOL;
156
-		return trailingslashit( dirname( $path ) );
156
+		return trailingslashit(dirname($path));
157 157
 	}
158 158
 
159
-	function trailingslashit( $string )
159
+	function trailingslashit($string)
160 160
 	{
161
-	    return untrailingslashit( $string ) . '/';
161
+	    return untrailingslashit($string) . '/';
162 162
 	}
163 163
 
164
-	function untrailingslashit( $string )
164
+	function untrailingslashit($string)
165 165
 	{
166
-	        return rtrim( $string, '/\\' );
166
+	        return rtrim($string, '/\\');
167 167
 	}
168 168
 
169 169
 	function site_url()
@@ -215,12 +215,12 @@  discard block
 block discarded – undo
215 215
 		return $dir;
216 216
 	}
217 217
 
218
-	function add_theme_support( $theme )
218
+	function add_theme_support($theme)
219 219
 	{
220 220
 		echo "[+] Adding theme support -> " . $theme . PHP_EOL;
221 221
 	}
222 222
 
223
-	function add_image_size( $image, $x, $y, $bool )
223
+	function add_image_size($image, $x, $y, $bool)
224 224
 	{
225 225
 		echo "[+] Adding image size -> " . $image . " x:" . $x . " y:" . $y . " bool:" . $bool . PHP_EOL;
226 226
 	}
@@ -232,24 +232,24 @@  discard block
 block discarded – undo
232 232
 		return $lang;
233 233
 	}
234 234
 
235
-	function load_plugin_textdomain( $name, $bool, $dir)
235
+	function load_plugin_textdomain($name, $bool, $dir)
236 236
 	{
237 237
 		echo "[+] Loading plugin textdomain -> " . $name . " bool:" . $bool . " dir:" . $dir . PHP_EOL;
238 238
 	}
239 239
 
240
-	function get_option( $name, $int = 0 )
240
+	function get_option($name, $int = 0)
241 241
 	{
242 242
 		echo "[+] Getting option -> " . $name . " int:" . $int . PHP_EOL;
243 243
 		return "";
244 244
 	}
245 245
 
246
-	function get_site_option( $name, $int = 0 )
246
+	function get_site_option($name, $int = 0)
247 247
 	{
248 248
 		echo "[+] Getting site option -> " . $name . " int:" . $int . PHP_EOL;
249 249
 		return "";
250 250
 	}
251 251
 
252
-	function current_time( $str )
252
+	function current_time($str)
253 253
 	{
254 254
 		$time = " 2005-08-05 10:41:13";
255 255
 		echo "[+] Requesting current_time -> " . $str . PHP_EOL;
@@ -258,17 +258,17 @@  discard block
 block discarded – undo
258 258
 
259 259
 	class WPDB
260 260
 	{
261
-		function prepare( $request = "" )
261
+		function prepare($request = "")
262 262
 		{
263 263
 			echo "[+] Preparing -> " . $request . PHP_EOL;
264 264
 		}
265 265
 
266
-		public static function get_var( $request = "" )
266
+		public static function get_var($request = "")
267 267
 		{
268 268
 			echo "[+] Requesting get var -> " . $request . PHP_EOL;
269 269
 		}
270 270
 
271
-		public static function get_charset_collate( $request = "" )
271
+		public static function get_charset_collate($request = "")
272 272
 		{
273 273
 			echo "[+] Requesting get charset collate -> " . $request . PHP_EOL;
274 274
 		}
Please login to merge, or discard this patch.
Braces   +15 added lines, -6 removed lines patch added patch discarded remove patch
@@ -37,10 +37,13 @@  discard block
 block discarded – undo
37 37
 						break;
38 38
 				}
39 39
 			}
40
-			if($length > 0) $hooked = rtrim($hooked, ",");
40
+			if($length > 0) {
41
+				$hooked = rtrim($hooked, ",");
42
+			}
41 43
 			$hooked .= "]";
44
+		} else {
45
+			$hooked .= $object;
42 46
 		}
43
-		else $hooked .= $object;
44 47
 		echo "[+] Adding action -> " . $init . " in " . $hooked . PHP_EOL;
45 48
 	}
46 49
 
@@ -70,10 +73,13 @@  discard block
 block discarded – undo
70 73
 						break;
71 74
 				}
72 75
 			}
73
-			if($length > 0) $hooked = rtrim($hooked, ",");
76
+			if($length > 0) {
77
+				$hooked = rtrim($hooked, ",");
78
+			}
74 79
 			$hooked .= "]";
80
+		} else {
81
+			$hooked .= $object;
75 82
 		}
76
-		else $hooked .= $object;
77 83
 		echo "[+] Registering actiovation hook -> " . $file . " in " . $hooked . PHP_EOL;
78 84
 	}
79 85
 
@@ -103,10 +109,13 @@  discard block
 block discarded – undo
103 109
 						break;
104 110
 				}
105 111
 			}
106
-			if($length > 0) $hooked = rtrim($hooked, ",");
112
+			if($length > 0) {
113
+				$hooked = rtrim($hooked, ",");
114
+			}
107 115
 			$hooked .= "]";
116
+		} else {
117
+			$hooked .= $object;
108 118
 		}
109
-		else $hooked .= $object;
110 119
 		echo "[+] Registering actiovation hook -> " . $file . " in " . $hooked . PHP_EOL;
111 120
 	}
112 121
 
Please login to merge, or discard this patch.
script/unit.script.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 $unitList = searchFiles('.' . DIRECTORY_SEPARATOR, END_TEST);
11 11
 
12 12
 // Loop on unitList
13
-foreach($unitList as $test)
13
+foreach ($unitList as $test)
14 14
 {
15 15
 	echo "[+] Testing -> " . $test . PHP_EOL;
16 16
 	include($test);
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	$ite = new RecursiveIteratorIterator($dir);
29 29
 	$files = new RegexIterator($ite, $pattern, RegexIterator::GET_MATCH);
30 30
 	$fileList = array();
31
-	foreach($files as $file)
31
+	foreach ($files as $file)
32 32
 	{
33 33
 		$fileList[] = $file[0];
34 34
 	}
Please login to merge, or discard this patch.
includes/librairies/eav/wp_list_custom_attributes.class.php 3 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 		 * to keep hidden, and a list of columns that are sortable. Each of these
315 315
 		 * can be defined in another method (as we've done here) before being
316 316
 		 * used to build the value for our _column_headers property.
317
-		*/
317
+		 */
318 318
 		$columns = $this->get_columns();
319 319
 		$hidden = array();
320 320
 		$sortable = $this->get_sortable_columns();
@@ -324,13 +324,13 @@  discard block
 block discarded – undo
324 324
 		 * headers. The $this->_column_headers property takes an array which contains
325 325
 		 * 3 other arrays. One for all columns, one for hidden columns, and one
326 326
 		 * for sortable columns.
327
-		*/
327
+		 */
328 328
 		$this->_column_headers = array($columns, $hidden, $sortable);
329 329
 
330 330
 		/**
331 331
 		 * Optional. You can handle your bulk actions however you see fit. In this
332 332
 		 * case, we'll handle them within our package just to keep things clean.
333
-		*/
333
+		 */
334 334
 		$this->process_bulk_action();
335 335
 
336 336
 		/**
@@ -341,14 +341,14 @@  discard block
 block discarded – undo
341 341
 		 * our data. In a real-world implementation, you will probably want to
342 342
 		 * use sort and pagination data to build a custom query instead, as you'll
343 343
 		 * be able to use your precisely-queried data immediately.
344
-		*/
344
+		 */
345 345
 		$data = $this->datas;
346 346
 
347 347
 		/**
348 348
 		 * REQUIRED for pagination. Let's figure out what page the user is currently
349 349
 		 * looking at. We'll need this later, so you should always include it in
350 350
 		 * your own package classes.
351
-		*/
351
+		 */
352 352
 		$current_page = $this->get_pagenum();
353 353
 
354 354
 		/**
@@ -356,20 +356,20 @@  discard block
 block discarded – undo
356 356
 		 * In real-world use, this would be the total number of items in your database,
357 357
 		 * without filtering. We'll need this later, so you should always include it
358 358
 		 * in your own package classes.
359
-		*/
359
+		 */
360 360
 		$total_items = count($data);
361 361
 
362 362
 		/**
363 363
 		 * The WP_List_Table class does not handle pagination for us, so we need
364 364
 		 * to ensure that the data is trimmed to only the current page. We can use
365 365
 		 * array_slice() to
366
-		*/
366
+		 */
367 367
 		$data = array_slice($data,(($current_page-1)*$per_page),$per_page);
368 368
 
369 369
 		/**
370 370
 		 * REQUIRED. Now we can add our *sorted* data to the items property, where
371 371
 		 * it can be used by the rest of the class.
372
-		*/
372
+		 */
373 373
 		$this->items = $data;
374 374
 
375 375
 		/*	REQUIRED. We also have to register our pagination options & calculations.	*/
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 
3 5
 /*	Check if file is include. No direct access possible with file url	*/
4 6
 if ( !defined( 'WPSHOP_VERSION' ) ) {
Please login to merge, or discard this patch.
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 
3 3
 /*	Check if file is include. No direct access possible with file url	*/
4
-if ( !defined( 'WPSHOP_VERSION' ) ) {
5
-	die( __('Access is not allowed by this way', 'wpshop') );
4
+if (!defined('WPSHOP_VERSION')) {
5
+	die(__('Access is not allowed by this way', 'wpshop'));
6 6
 }
7 7
 
8 8
 
@@ -12,38 +12,38 @@  discard block
 block discarded – undo
12 12
  * @package wpshop
13 13
  * @subpackage librairies
14 14
  */
15
-class wpshop_attributes_custom_List_table extends WP_List_Table{
15
+class wpshop_attributes_custom_List_table extends WP_List_Table {
16 16
 	var $datas;
17 17
 
18 18
 	/** ************************************************************************
19 19
 	 * REQUIRED. Set up a constructor that references the parent constructor. We
20 20
 	 * use the parent reference to set some default configs.
21 21
 	 ***************************************************************************/
22
-	function __construct(){
22
+	function __construct() {
23 23
 		global $status, $page;
24 24
 
25 25
 		//Set parent defaults
26
-		parent::__construct( array(
27
-			'singular'  => __('attribute\'s', 'wpshop'),    //singular name of the listed records
28
-			'plural'    => __('attributes\'', 'wpshop'),    //plural name of the listed records
26
+		parent::__construct(array(
27
+			'singular'  => __('attribute\'s', 'wpshop'), //singular name of the listed records
28
+			'plural'    => __('attributes\'', 'wpshop'), //plural name of the listed records
29 29
 			'ajax'     => true       //does this table support ajax?
30
-		) );
30
+		));
31 31
 	}
32 32
 
33 33
 	/*	Allows to set different listings for attributes	*/
34
-	function get_views(){
34
+	function get_views() {
35 35
 		$wpshop_attribute_links = array();
36 36
 
37 37
 		$active_nb = wpshop_attributes::getElement('', "'valid'");
38 38
 		$unactive_nb = wpshop_attributes::getElement('', "'moderated', 'notused'");
39 39
 		$deleted_nb = wpshop_attributes::getElement('', "'deleted'");
40 40
 
41
-		$attribute_status = !empty( $_REQUEST['attribute_status'] ) ? sanitize_text_field( $_REQUEST['attribute_status'] ) : '';
41
+		$attribute_status = !empty($_REQUEST['attribute_status']) ? sanitize_text_field($_REQUEST['attribute_status']) : '';
42 42
 
43
-		$wpshop_attribute_links['wpshop_attributes_links wpshop_attributes_links_valid'.(empty($attribute_status)?' current':'')] = '<a href="'.admin_url('admin.php?page=' . WPSHOP_URL_SLUG_ATTRIBUTE_LISTING).'" >'.__('Used attributes', 'wpshop').' ('.count($active_nb).')</a>';
44
-		$wpshop_attribute_links['wpshop_attributes_links wpshop_attributes_links_moderated'.(!empty($attribute_status) && ($attribute_status=='unactive')?' current':'')] = '<a href="'.admin_url('admin.php?page=' . WPSHOP_URL_SLUG_ATTRIBUTE_LISTING.'&attribute_status=unactive').'" >'.__('Unactive attributes', 'wpshop').' ('.count($unactive_nb).')</a>';
45
-		$wpshop_attribute_links['wpshop_attributes_links wpshop_attributes_links_deleted'.(!empty($attribute_status) && ($attribute_status=='deleted')?' current':'')] = '<a href="'.admin_url('admin.php?page=' . WPSHOP_URL_SLUG_ATTRIBUTE_LISTING.'&attribute_status=deleted').'" >'.__('Trashed attributes', 'wpshop').' ('.count($deleted_nb).')</a>';
46
-		$wpshop_attribute_links['unit_management_link'] = '<a href="#" id="wpshop_attribute_unit_manager_opener" data-nonce="' . wp_create_nonce( 'load_unit_interface' ) . '">'.__('Unit management', 'wpshop').'</a>';
43
+		$wpshop_attribute_links['wpshop_attributes_links wpshop_attributes_links_valid' . (empty($attribute_status) ? ' current' : '')] = '<a href="' . admin_url('admin.php?page=' . WPSHOP_URL_SLUG_ATTRIBUTE_LISTING) . '" >' . __('Used attributes', 'wpshop') . ' (' . count($active_nb) . ')</a>';
44
+		$wpshop_attribute_links['wpshop_attributes_links wpshop_attributes_links_moderated' . (!empty($attribute_status) && ($attribute_status == 'unactive') ? ' current' : '')] = '<a href="' . admin_url('admin.php?page=' . WPSHOP_URL_SLUG_ATTRIBUTE_LISTING . '&attribute_status=unactive') . '" >' . __('Unactive attributes', 'wpshop') . ' (' . count($unactive_nb) . ')</a>';
45
+		$wpshop_attribute_links['wpshop_attributes_links wpshop_attributes_links_deleted' . (!empty($attribute_status) && ($attribute_status == 'deleted') ? ' current' : '')] = '<a href="' . admin_url('admin.php?page=' . WPSHOP_URL_SLUG_ATTRIBUTE_LISTING . '&attribute_status=deleted') . '" >' . __('Trashed attributes', 'wpshop') . ' (' . count($deleted_nb) . ')</a>';
46
+		$wpshop_attribute_links['unit_management_link'] = '<a href="#" id="wpshop_attribute_unit_manager_opener" data-nonce="' . wp_create_nonce('load_unit_interface') . '">' . __('Unit management', 'wpshop') . '</a>';
47 47
 		$wpshop_attribute_links['unit_management_dialog'] = '<div id="wpshop_attribute_unit_manager"title="' . __('Unit management', 'wpshop') . '" class="wpshopHide" ><div class="loading_picture_container" id="product_chooser_picture" ><img src="' . WPSHOP_LOADING_ICON . '" alt="loading..." /></div></div>';
48 48
 		return $wpshop_attribute_links;
49 49
 	}
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
 	 * @see WP_List_Table::::single_row_columns()
62 62
 	 * @return array An associative array containing column information: 'slugs'=>'Visible Titles'
63 63
 	 **************************************************************************/
64
-	function get_columns(){
64
+	function get_columns() {
65 65
 		$columns = array(
66
-			'cb'       	=> '',//'<input type="checkbox" />', //Render a checkbox instead of text
66
+			'cb'       	=> '', //'<input type="checkbox" />', //Render a checkbox instead of text
67 67
 			'id'       	=> __('Id.', 'wpshop'),
68 68
 			'name'    	=> __('Name', 'wpshop'),
69 69
 			'status'    => __('Status', 'wpshop'),
@@ -94,10 +94,10 @@  discard block
 block discarded – undo
94 94
 	 * @param array $column_name The name/slug of the column to be processed
95 95
 	 * @return string Text or HTML to be placed inside the column <td>
96 96
 	 **************************************************************************/
97
-	function column_default($item, $column_name){
98
-		switch($column_name){
97
+	function column_default($item, $column_name) {
98
+		switch ($column_name) {
99 99
 			default:
100
-				return print_r($item,true); //Show the whole array for troubleshooting purposes
100
+				return print_r($item, true); //Show the whole array for troubleshooting purposes
101 101
 		}
102 102
 	}
103 103
 
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	 * @param array $item A singular item (one full row's worth of data)
118 118
 	 * @return string Text to be placed inside the column <td> (movie title only)
119 119
 	 **************************************************************************/
120
-	function column_id($item){
120
+	function column_id($item) {
121 121
 		return $item['id'];
122 122
 	}
123 123
 	/** ************************************************************************
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 	 * @param array $item A singular item (one full row's worth of data)
137 137
 	 * @return string Text to be placed inside the column <td> (movie title only)
138 138
 	 **************************************************************************/
139
-	function column_status($item){
139
+	function column_status($item) {
140 140
 		return __($item['status'], 'wpshop');
141 141
 	}
142 142
 	/** ************************************************************************
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	 * @param array $item A singular item (one full row's worth of data)
156 156
 	 * @return string Text to be placed inside the column <td> (movie title only)
157 157
 	 **************************************************************************/
158
-	function column_code($item){
158
+	function column_code($item) {
159 159
 		return $item['code'];
160 160
 	}
161 161
 	/** ************************************************************************
@@ -174,8 +174,8 @@  discard block
 block discarded – undo
174 174
 	 * @param array $item A singular item (one full row's worth of data)
175 175
 	 * @return string Text to be placed inside the column <td> (movie title only)
176 176
 	 **************************************************************************/
177
-	function column_entity($item){
178
-		return __($item['entity'],'wpshop');
177
+	function column_entity($item) {
178
+		return __($item['entity'], 'wpshop');
179 179
 	}
180 180
 	/** ************************************************************************
181 181
 	 * Recommended. This is a custom column method and is responsible for what
@@ -193,28 +193,28 @@  discard block
 block discarded – undo
193 193
 	 * @param array $item A singular item (one full row's worth of data)
194 194
 	 * @return string Text to be placed inside the column <td> (movie title only)
195 195
 	 **************************************************************************/
196
-	function column_name($item){
196
+	function column_name($item) {
197 197
 		$attribute_undeletable = unserialize(WPSHOP_ATTRIBUTE_UNDELETABLE);
198 198
 
199
-		$link_format = admin_url('admin.php').'?page=%2$s&amp;action=%3$s&amp;id=%4$s';
200
-		$default_action='edit';
201
-		$default_action_text=__('Edit', 'wpshop');
202
-		$attribute_status = !empty( $_REQUEST['attribute_status'] ) ? sanitize_text_field( $_REQUEST['attribute_status'] ) : '';
203
-		if(!empty($attribute_status) && ($attribute_status=='deleted')){
204
-			$default_action='activate';
205
-			$default_action_text=__('Restore', 'wpshop');
199
+		$link_format = admin_url('admin.php') . '?page=%2$s&amp;action=%3$s&amp;id=%4$s';
200
+		$default_action = 'edit';
201
+		$default_action_text = __('Edit', 'wpshop');
202
+		$attribute_status = !empty($_REQUEST['attribute_status']) ? sanitize_text_field($_REQUEST['attribute_status']) : '';
203
+		if (!empty($attribute_status) && ($attribute_status == 'deleted')) {
204
+			$default_action = 'activate';
205
+			$default_action_text = __('Restore', 'wpshop');
206 206
 		}
207 207
 		//Build row actions
208 208
 		$actions = array(
209
-			'edit'     => sprintf('<a href="'.$link_format.'">'.$default_action_text.'</a>',WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_LISTING,$default_action,$item['id'])
209
+			'edit'     => sprintf('<a href="' . $link_format . '">' . $default_action_text . '</a>', WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_LISTING, $default_action, $item['id'])
210 210
 		);
211
-		if(empty($attribute_status) && (!in_array($item['code'], $attribute_undeletable))){
212
-			$actions['delete'] = sprintf('<a href="'.$link_format.'">'.__('Delete', 'wpshop').'</a>',WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_LISTING,'delete',$item['id']);
211
+		if (empty($attribute_status) && (!in_array($item['code'], $attribute_undeletable))) {
212
+			$actions['delete'] = sprintf('<a href="' . $link_format . '">' . __('Delete', 'wpshop') . '</a>', WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_LISTING, 'delete', $item['id']);
213 213
 		}
214 214
 
215 215
 		//Return the title contents
216 216
 		return sprintf('%1$s%2$s',
217
-			/*$1%s*/ sprintf('<a href="'.$link_format.'">'.__($item['name'], 'wpshop').'</a>',WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_LISTING,$default_action,$item['id']),
217
+			/*$1%s*/ sprintf('<a href="' . $link_format . '">' . __($item['name'], 'wpshop') . '</a>', WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_LISTING, $default_action, $item['id']),
218 218
 			/*$3%s*/ $this->row_actions($actions)
219 219
 		);
220 220
 	}
@@ -227,11 +227,11 @@  discard block
 block discarded – undo
227 227
 	 * @param array $item A singular item (one full row's worth of data)
228 228
 	 * @return string Text to be placed inside the column <td> (movie title only)
229 229
 	 **************************************************************************/
230
-	function column_cb($item){
230
+	function column_cb($item) {
231 231
 		return '';
232 232
 		return sprintf(
233 233
 			'<input type="checkbox" name="%1$s[]" value="%2$s" />',
234
-			/*$1%s*/ $this->_args['singular'],  //Let's simply repurpose the table's singular label ("movie")
234
+			/*$1%s*/ $this->_args['singular'], //Let's simply repurpose the table's singular label ("movie")
235 235
 			/*$2%s*/ $item['id']             //The value of the checkbox should be the record's id
236 236
 		);
237 237
 	}
@@ -252,8 +252,8 @@  discard block
 block discarded – undo
252 252
 	 **************************************************************************/
253 253
 	function get_sortable_columns() {
254 254
 		$sortable_columns = array(
255
-			'name'    => array('frontend_label',true),    //true means its already sorted
256
-			'status'  => array('status',true)
255
+			'name'    => array('frontend_label', true), //true means its already sorted
256
+			'status'  => array('status', true)
257 257
 		);
258 258
 		return $sortable_columns;
259 259
 	}
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 	 **************************************************************************/
289 289
 	function process_bulk_action() {
290 290
 		//Detect when a bulk action is being triggered...
291
-		if( 'delete'===$this->current_action() ) {
291
+		if ('delete' === $this->current_action()) {
292 292
 			wp_die('Items deleted (or they would be if we had items to delete)!');
293 293
 		}
294 294
 	}
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 	 **************************************************************************/
310 310
 	function prepare_items() {
311 311
 		/*	First, lets decide how many records per page to show	*/
312
-		$per_page = 10;//$this->get_items_per_page('attributes_per_page', 10);
312
+		$per_page = 10; //$this->get_items_per_page('attributes_per_page', 10);
313 313
 
314 314
 		/**
315 315
 		 * REQUIRED. Now we need to define our column headers. This includes a complete
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
 		 * to ensure that the data is trimmed to only the current page. We can use
368 368
 		 * array_slice() to
369 369
 		*/
370
-		$data = array_slice($data,(($current_page-1)*$per_page),$per_page);
370
+		$data = array_slice($data, (($current_page - 1) * $per_page), $per_page);
371 371
 
372 372
 		/**
373 373
 		 * REQUIRED. Now we can add our *sorted* data to the items property, where
@@ -376,10 +376,10 @@  discard block
 block discarded – undo
376 376
 		$this->items = $data;
377 377
 
378 378
 		/*	REQUIRED. We also have to register our pagination options & calculations.	*/
379
-		$this->set_pagination_args( array(
380
-			'total_items' => $total_items,               		//WE have to calculate the total number of items
381
-			'per_page'    => $per_page,                 		//WE have to determine how many items to show on a page
382
-			'total_pages' => ceil($total_items/$per_page)   //WE have to calculate the total number of pages
383
-		) );
379
+		$this->set_pagination_args(array(
380
+			'total_items' => $total_items, //WE have to calculate the total number of items
381
+			'per_page'    => $per_page, //WE have to determine how many items to show on a page
382
+			'total_pages' => ceil($total_items / $per_page)   //WE have to calculate the total number of pages
383
+		));
384 384
 	}
385 385
 }
Please login to merge, or discard this patch.
includes/librairies/eav/wp_list_custom_attributes_set.class.php 3 patches
Indentation   +203 added lines, -203 removed lines patch added patch discarded remove patch
@@ -16,9 +16,9 @@  discard block
 block discarded – undo
16 16
 	var $datas;
17 17
 
18 18
 	/** ************************************************************************
19
-	* REQUIRED. Set up a constructor that references the parent constructor. We
20
-	* use the parent reference to set some default configs.
21
-	***************************************************************************/
19
+	 * REQUIRED. Set up a constructor that references the parent constructor. We
20
+	 * use the parent reference to set some default configs.
21
+	 ***************************************************************************/
22 22
 	function __construct(){
23 23
 		global $status, $page;
24 24
 
@@ -44,18 +44,18 @@  discard block
 block discarded – undo
44 44
 	}
45 45
 
46 46
 	/** ************************************************************************
47
-	* REQUIRED! This method dictates the table's columns and titles. This should
48
-	* return an array where the key is the column slug (and class) and the value
49
-	* is the column's title text. If you need a checkbox for bulk actions, refer
50
-	* to the $columns array below.
51
-	*
52
-	* The 'cb' column is treated differently than the rest. If including a checkbox
53
-	* column in your table you must create a column_cb() method. If you don't need
54
-	* bulk actions or checkboxes, simply leave the 'cb' entry out of your array.
55
-	*
56
-	* @see WP_List_Table::::single_row_columns()
57
-	* @return array An associative array containing column information: 'slugs'=>'Visible Titles'
58
-	**************************************************************************/
47
+	 * REQUIRED! This method dictates the table's columns and titles. This should
48
+	 * return an array where the key is the column slug (and class) and the value
49
+	 * is the column's title text. If you need a checkbox for bulk actions, refer
50
+	 * to the $columns array below.
51
+	 *
52
+	 * The 'cb' column is treated differently than the rest. If including a checkbox
53
+	 * column in your table you must create a column_cb() method. If you don't need
54
+	 * bulk actions or checkboxes, simply leave the 'cb' entry out of your array.
55
+	 *
56
+	 * @see WP_List_Table::::single_row_columns()
57
+	 * @return array An associative array containing column information: 'slugs'=>'Visible Titles'
58
+	 **************************************************************************/
59 59
 	function get_columns(){
60 60
 		$columns = array(
61 61
 			'cb'       => '',//'<input type="checkbox" />', //Render a checkbox instead of text
@@ -69,26 +69,26 @@  discard block
 block discarded – undo
69 69
 	}
70 70
 
71 71
 	/** ************************************************************************
72
-	* Recommended. This method is called when the parent class can't find a method
73
-	* specifically build for a given column. Generally, it's recommended to include
74
-	* one method for each column you want to render, keeping your package class
75
-	* neat and organized. For example, if the class needs to process a column
76
-	* named 'title', it would first see if a method named $this->column_title()
77
-	* exists - if it does, that method will be used. If it doesn't, this one will
78
-	* be used. Generally, you should try to use custom column methods as much as
79
-	* possible.
80
-	*
81
-	* Since we have defined a column_title() method later on, this method doesn't
82
-	* need to concern itself with any column with a name of 'title'. Instead, it
83
-	* needs to handle everything else.
84
-	*
85
-	* For more detailed insight into how columns are handled, take a look at
86
-	* WP_List_Table::single_row_columns()
87
-	*
88
-	* @param array $item A singular item (one full row's worth of data)
89
-	* @param array $column_name The name/slug of the column to be processed
90
-	* @return string Text or HTML to be placed inside the column <td>
91
-	**************************************************************************/
72
+	 * Recommended. This method is called when the parent class can't find a method
73
+	 * specifically build for a given column. Generally, it's recommended to include
74
+	 * one method for each column you want to render, keeping your package class
75
+	 * neat and organized. For example, if the class needs to process a column
76
+	 * named 'title', it would first see if a method named $this->column_title()
77
+	 * exists - if it does, that method will be used. If it doesn't, this one will
78
+	 * be used. Generally, you should try to use custom column methods as much as
79
+	 * possible.
80
+	 *
81
+	 * Since we have defined a column_title() method later on, this method doesn't
82
+	 * need to concern itself with any column with a name of 'title'. Instead, it
83
+	 * needs to handle everything else.
84
+	 *
85
+	 * For more detailed insight into how columns are handled, take a look at
86
+	 * WP_List_Table::single_row_columns()
87
+	 *
88
+	 * @param array $item A singular item (one full row's worth of data)
89
+	 * @param array $column_name The name/slug of the column to be processed
90
+	 * @return string Text or HTML to be placed inside the column <td>
91
+	 **************************************************************************/
92 92
 	function column_default($item, $column_name){
93 93
 		switch($column_name){
94 94
 			default:
@@ -97,97 +97,97 @@  discard block
 block discarded – undo
97 97
 	}
98 98
 
99 99
 	/** ************************************************************************
100
-	* Recommended. This is a custom column method and is responsible for what
101
-	* is rendered in any column with a name/slug of 'title'. Every time the class
102
-	* needs to render a column, it first looks for a method named
103
-	* column_{$column_title} - if it exists, that method is run. If it doesn't
104
-	* exist, column_default() is called instead.
105
-	*
106
-	* This example also illustrates how to implement rollover actions. Actions
107
-	* should be an associative array formatted as 'slug'=>'link html' - and you
108
-	* will need to generate the URLs yourself. You could even ensure the links
109
-	*
110
-	*
111
-	* @see WP_List_Table::::single_row_columns()
112
-	* @param array $item A singular item (one full row's worth of data)
113
-	* @return string Text to be placed inside the column <td> (movie title only)
114
-	**************************************************************************/
100
+	 * Recommended. This is a custom column method and is responsible for what
101
+	 * is rendered in any column with a name/slug of 'title'. Every time the class
102
+	 * needs to render a column, it first looks for a method named
103
+	 * column_{$column_title} - if it exists, that method is run. If it doesn't
104
+	 * exist, column_default() is called instead.
105
+	 *
106
+	 * This example also illustrates how to implement rollover actions. Actions
107
+	 * should be an associative array formatted as 'slug'=>'link html' - and you
108
+	 * will need to generate the URLs yourself. You could even ensure the links
109
+	 *
110
+	 *
111
+	 * @see WP_List_Table::::single_row_columns()
112
+	 * @param array $item A singular item (one full row's worth of data)
113
+	 * @return string Text to be placed inside the column <td> (movie title only)
114
+	 **************************************************************************/
115 115
 	function column_id($item){
116 116
 		return $item['id'];
117 117
 	}
118 118
 	/** ************************************************************************
119
-	* Recommended. This is a custom column method and is responsible for what
120
-	* is rendered in any column with a name/slug of 'title'. Every time the class
121
-	* needs to render a column, it first looks for a method named
122
-	* column_{$column_title} - if it exists, that method is run. If it doesn't
123
-	* exist, column_default() is called instead.
124
-	*
125
-	* This example also illustrates how to implement rollover actions. Actions
126
-	* should be an associative array formatted as 'slug'=>'link html' - and you
127
-	* will need to generate the URLs yourself. You could even ensure the links
128
-	*
129
-	*
130
-	* @see WP_List_Table::::single_row_columns()
131
-	* @param array $item A singular item (one full row's worth of data)
132
-	* @return string Text to be placed inside the column <td> (movie title only)
133
-	**************************************************************************/
119
+	 * Recommended. This is a custom column method and is responsible for what
120
+	 * is rendered in any column with a name/slug of 'title'. Every time the class
121
+	 * needs to render a column, it first looks for a method named
122
+	 * column_{$column_title} - if it exists, that method is run. If it doesn't
123
+	 * exist, column_default() is called instead.
124
+	 *
125
+	 * This example also illustrates how to implement rollover actions. Actions
126
+	 * should be an associative array formatted as 'slug'=>'link html' - and you
127
+	 * will need to generate the URLs yourself. You could even ensure the links
128
+	 *
129
+	 *
130
+	 * @see WP_List_Table::::single_row_columns()
131
+	 * @param array $item A singular item (one full row's worth of data)
132
+	 * @return string Text to be placed inside the column <td> (movie title only)
133
+	 **************************************************************************/
134 134
 	function column_status($item){
135 135
 		return __($item['status'], 'wpshop');
136 136
 	}
137 137
 	/** ************************************************************************
138
-	* Recommended. This is a custom column method and is responsible for what
139
-	* is rendered in any column with a name/slug of 'title'. Every time the class
140
-	* needs to render a column, it first looks for a method named
141
-	* column_{$column_title} - if it exists, that method is run. If it doesn't
142
-	* exist, column_default() is called instead.
143
-	*
144
-	* This example also illustrates how to implement rollover actions. Actions
145
-	* should be an associative array formatted as 'slug'=>'link html' - and you
146
-	* will need to generate the URLs yourself. You could even ensure the links
147
-	*
148
-	*
149
-	* @see WP_List_Table::::single_row_columns()
150
-	* @param array $item A singular item (one full row's worth of data)
151
-	* @return string Text to be placed inside the column <td> (movie title only)
152
-	**************************************************************************/
138
+	 * Recommended. This is a custom column method and is responsible for what
139
+	 * is rendered in any column with a name/slug of 'title'. Every time the class
140
+	 * needs to render a column, it first looks for a method named
141
+	 * column_{$column_title} - if it exists, that method is run. If it doesn't
142
+	 * exist, column_default() is called instead.
143
+	 *
144
+	 * This example also illustrates how to implement rollover actions. Actions
145
+	 * should be an associative array formatted as 'slug'=>'link html' - and you
146
+	 * will need to generate the URLs yourself. You could even ensure the links
147
+	 *
148
+	 *
149
+	 * @see WP_List_Table::::single_row_columns()
150
+	 * @param array $item A singular item (one full row's worth of data)
151
+	 * @return string Text to be placed inside the column <td> (movie title only)
152
+	 **************************************************************************/
153 153
 	function column_content($item){
154 154
 		return $item['content'];
155 155
 	}
156 156
 	/** ************************************************************************
157
-	* Recommended. This is a custom column method and is responsible for what
158
-	* is rendered in any column with a name/slug of 'title'. Every time the class
159
-	* needs to render a column, it first looks for a method named
160
-	* column_{$column_title} - if it exists, that method is run. If it doesn't
161
-	* exist, column_default() is called instead.
162
-	*
163
-	* This example also illustrates how to implement rollover actions. Actions
164
-	* should be an associative array formatted as 'slug'=>'link html' - and you
165
-	* will need to generate the URLs yourself. You could even ensure the links
166
-	*
167
-	*
168
-	* @see WP_List_Table::::single_row_columns()
169
-	* @param array $item A singular item (one full row's worth of data)
170
-	* @return string Text to be placed inside the column <td> (movie title only)
171
-	**************************************************************************/
157
+	 * Recommended. This is a custom column method and is responsible for what
158
+	 * is rendered in any column with a name/slug of 'title'. Every time the class
159
+	 * needs to render a column, it first looks for a method named
160
+	 * column_{$column_title} - if it exists, that method is run. If it doesn't
161
+	 * exist, column_default() is called instead.
162
+	 *
163
+	 * This example also illustrates how to implement rollover actions. Actions
164
+	 * should be an associative array formatted as 'slug'=>'link html' - and you
165
+	 * will need to generate the URLs yourself. You could even ensure the links
166
+	 *
167
+	 *
168
+	 * @see WP_List_Table::::single_row_columns()
169
+	 * @param array $item A singular item (one full row's worth of data)
170
+	 * @return string Text to be placed inside the column <td> (movie title only)
171
+	 **************************************************************************/
172 172
 	function column_entity($item){
173 173
 		return __($item['entity'],'wpshop');
174 174
 	}
175 175
 	/** ************************************************************************
176
-	* Recommended. This is a custom column method and is responsible for what
177
-	* is rendered in any column with a name/slug of 'title'. Every time the class
178
-	* needs to render a column, it first looks for a method named
179
-	* column_{$column_title} - if it exists, that method is run. If it doesn't
180
-	* exist, column_default() is called instead.
181
-	*
182
-	* This example also illustrates how to implement rollover actions. Actions
183
-	* should be an associative array formatted as 'slug'=>'link html' - and you
184
-	* will need to generate the URLs yourself. You could even ensure the links
185
-	*
186
-	*
187
-	* @see WP_List_Table::::single_row_columns()
188
-	* @param array $item A singular item (one full row's worth of data)
189
-	* @return string Text to be placed inside the column <td> (movie title only)
190
-	**************************************************************************/
176
+	 * Recommended. This is a custom column method and is responsible for what
177
+	 * is rendered in any column with a name/slug of 'title'. Every time the class
178
+	 * needs to render a column, it first looks for a method named
179
+	 * column_{$column_title} - if it exists, that method is run. If it doesn't
180
+	 * exist, column_default() is called instead.
181
+	 *
182
+	 * This example also illustrates how to implement rollover actions. Actions
183
+	 * should be an associative array formatted as 'slug'=>'link html' - and you
184
+	 * will need to generate the URLs yourself. You could even ensure the links
185
+	 *
186
+	 *
187
+	 * @see WP_List_Table::::single_row_columns()
188
+	 * @param array $item A singular item (one full row's worth of data)
189
+	 * @return string Text to be placed inside the column <td> (movie title only)
190
+	 **************************************************************************/
191 191
 	function column_name($item){
192 192
 		//Build row actions
193 193
 		$default_action='edit';
@@ -208,14 +208,14 @@  discard block
 block discarded – undo
208 208
 		);
209 209
 	}
210 210
 	/** ************************************************************************
211
-	* REQUIRED if displaying checkboxes or using bulk actions! The 'cb' column
212
-	* is given special treatment when columns are processed. It ALWAYS needs to
213
-	* have it's own method.
214
-	*
215
-	* @see WP_List_Table::::single_row_columns()
216
-	* @param array $item A singular item (one full row's worth of data)
217
-	* @return string Text to be placed inside the column <td> (movie title only)
218
-	**************************************************************************/
211
+	 * REQUIRED if displaying checkboxes or using bulk actions! The 'cb' column
212
+	 * is given special treatment when columns are processed. It ALWAYS needs to
213
+	 * have it's own method.
214
+	 *
215
+	 * @see WP_List_Table::::single_row_columns()
216
+	 * @param array $item A singular item (one full row's worth of data)
217
+	 * @return string Text to be placed inside the column <td> (movie title only)
218
+	 **************************************************************************/
219 219
 	function column_cb($item){
220 220
 		return '';
221 221
 		return sprintf(
@@ -226,19 +226,19 @@  discard block
 block discarded – undo
226 226
 	}
227 227
 
228 228
 	/** ************************************************************************
229
-	* Optional. If you want one or more columns to be sortable (ASC/DESC toggle),
230
-	* you will need to register it here. This should return an array where the
231
-	* key is the column that needs to be sortable, and the value is db column to
232
-	* sort by. Often, the key and value will be the same, but this is not always
233
-	* the case (as the value is a column name from the database, not the list table).
234
-	*
235
-	* This method merely defines which columns should be sortable and makes them
236
-	* clickable - it does not handle the actual sorting. You still need to detect
237
-	* the ORDERBY and ORDER querystring variables within prepare_items() and sort
238
-	* your data accordingly (usually by modifying your query).
239
-	*
240
-	* @return array An associative array containing all the columns that should be sortable: 'slugs'=>array('data_values',bool)
241
-	**************************************************************************/
229
+	 * Optional. If you want one or more columns to be sortable (ASC/DESC toggle),
230
+	 * you will need to register it here. This should return an array where the
231
+	 * key is the column that needs to be sortable, and the value is db column to
232
+	 * sort by. Often, the key and value will be the same, but this is not always
233
+	 * the case (as the value is a column name from the database, not the list table).
234
+	 *
235
+	 * This method merely defines which columns should be sortable and makes them
236
+	 * clickable - it does not handle the actual sorting. You still need to detect
237
+	 * the ORDERBY and ORDER querystring variables within prepare_items() and sort
238
+	 * your data accordingly (usually by modifying your query).
239
+	 *
240
+	 * @return array An associative array containing all the columns that should be sortable: 'slugs'=>array('data_values',bool)
241
+	 **************************************************************************/
242 242
 	function get_sortable_columns() {
243 243
 		$sortable_columns = array(
244 244
 			//'name'    => array('name',true)    //true means its already sorted
@@ -247,19 +247,19 @@  discard block
 block discarded – undo
247 247
 	}
248 248
 
249 249
 	/** ************************************************************************
250
-	* Optional. If you need to include bulk actions in your list table, this is
251
-	* the place to define them. Bulk actions are an associative array in the format
252
-	* 'slug'=>'Visible Title'
253
-	*
254
-	* If this method returns an empty value, no bulk action will be rendered. If
255
-	* you specify any bulk actions, the bulk actions box will be rendered with
256
-	* the table automatically on display().
257
-	*
258
-	* Also note that list tables are not automatically wrapped in <form> elements,
259
-	* so you will need to create those manually in order for bulk actions to function.
260
-	*
261
-	* @return array An associative array containing all the bulk actions: 'slugs'=>'Visible Titles'
262
-	**************************************************************************/
250
+	 * Optional. If you need to include bulk actions in your list table, this is
251
+	 * the place to define them. Bulk actions are an associative array in the format
252
+	 * 'slug'=>'Visible Title'
253
+	 *
254
+	 * If this method returns an empty value, no bulk action will be rendered. If
255
+	 * you specify any bulk actions, the bulk actions box will be rendered with
256
+	 * the table automatically on display().
257
+	 *
258
+	 * Also note that list tables are not automatically wrapped in <form> elements,
259
+	 * so you will need to create those manually in order for bulk actions to function.
260
+	 *
261
+	 * @return array An associative array containing all the bulk actions: 'slugs'=>'Visible Titles'
262
+	 **************************************************************************/
263 263
 	function get_bulk_actions() {
264 264
 		$actions = array(
265 265
 			// 'delete'    => __('Delete','wpshop')
@@ -268,12 +268,12 @@  discard block
 block discarded – undo
268 268
 	}
269 269
 
270 270
 	/** ************************************************************************
271
-	* Optional. You can handle your bulk actions anywhere or anyhow you prefer.
272
-	* For this example package, we will handle it in the class to keep things
273
-	* clean and organized.
274
-	*
275
-	* @see $this->prepare_items()
276
-	**************************************************************************/
271
+	 * Optional. You can handle your bulk actions anywhere or anyhow you prefer.
272
+	 * For this example package, we will handle it in the class to keep things
273
+	 * clean and organized.
274
+	 *
275
+	 * @see $this->prepare_items()
276
+	 **************************************************************************/
277 277
 	function process_bulk_action() {
278 278
 		//Detect when a bulk action is being triggered...
279 279
 		if( 'delete'===$this->current_action() ) {
@@ -282,90 +282,90 @@  discard block
 block discarded – undo
282 282
 	}
283 283
 
284 284
 	/** ************************************************************************
285
-	* REQUIRED! This is where you prepare your data for display. This method will
286
-	* usually be used to query the database, sort and filter the data, and generally
287
-	* get it ready to be displayed. At a minimum, we should set $this->items and
288
-	* $this->set_pagination_args(), although the following properties and methods
289
-	* are frequently interacted with here...
290
-	*
291
-	* @uses $this->_column_headers
292
-	* @uses $this->items
293
-	* @uses $this->get_columns()
294
-	* @uses $this->get_sortable_columns()
295
-	* @uses $this->get_pagenum()
296
-	* @uses $this->set_pagination_args()
297
-	**************************************************************************/
285
+	 * REQUIRED! This is where you prepare your data for display. This method will
286
+	 * usually be used to query the database, sort and filter the data, and generally
287
+	 * get it ready to be displayed. At a minimum, we should set $this->items and
288
+	 * $this->set_pagination_args(), although the following properties and methods
289
+	 * are frequently interacted with here...
290
+	 *
291
+	 * @uses $this->_column_headers
292
+	 * @uses $this->items
293
+	 * @uses $this->get_columns()
294
+	 * @uses $this->get_sortable_columns()
295
+	 * @uses $this->get_pagenum()
296
+	 * @uses $this->set_pagination_args()
297
+	 **************************************************************************/
298 298
 	function prepare_items() {
299 299
 		/*	First, lets decide how many records per page to show	*/
300 300
 		$per_page = 10;
301 301
 
302 302
 		/**
303
-		* REQUIRED. Now we need to define our column headers. This includes a complete
304
-		* array of columns to be displayed (slugs & titles), a list of columns
305
-		* to keep hidden, and a list of columns that are sortable. Each of these
306
-		* can be defined in another method (as we've done here) before being
307
-		* used to build the value for our _column_headers property.
308
-		*/
303
+		 * REQUIRED. Now we need to define our column headers. This includes a complete
304
+		 * array of columns to be displayed (slugs & titles), a list of columns
305
+		 * to keep hidden, and a list of columns that are sortable. Each of these
306
+		 * can be defined in another method (as we've done here) before being
307
+		 * used to build the value for our _column_headers property.
308
+		 */
309 309
 		$columns = $this->get_columns();
310 310
 		$hidden = array();
311 311
 		$sortable = $this->get_sortable_columns();
312 312
 
313 313
 		/**
314
-		* REQUIRED. Finally, we build an array to be used by the class for column
315
-		* headers. The $this->_column_headers property takes an array which contains
316
-		* 3 other arrays. One for all columns, one for hidden columns, and one
317
-		* for sortable columns.
318
-		*/
314
+		 * REQUIRED. Finally, we build an array to be used by the class for column
315
+		 * headers. The $this->_column_headers property takes an array which contains
316
+		 * 3 other arrays. One for all columns, one for hidden columns, and one
317
+		 * for sortable columns.
318
+		 */
319 319
 		$this->_column_headers = array($columns, $hidden, $sortable);
320 320
 
321 321
 		/**
322
-		* Optional. You can handle your bulk actions however you see fit. In this
323
-		* case, we'll handle them within our package just to keep things clean.
324
-		*/
322
+		 * Optional. You can handle your bulk actions however you see fit. In this
323
+		 * case, we'll handle them within our package just to keep things clean.
324
+		 */
325 325
 		$this->process_bulk_action();
326 326
 
327 327
 		/**
328
-		* Instead of querying a database, we're going to fetch the example data
329
-		* property we created for use in this plugin. This makes this example
330
-		* package slightly different than one you might build on your own. In
331
-		* this example, we'll be using array manipulation to sort and paginate
332
-		* our data. In a real-world implementation, you will probably want to
333
-		* use sort and pagination data to build a custom query instead, as you'll
334
-		* be able to use your precisely-queried data immediately.
335
-		*/
328
+		 * Instead of querying a database, we're going to fetch the example data
329
+		 * property we created for use in this plugin. This makes this example
330
+		 * package slightly different than one you might build on your own. In
331
+		 * this example, we'll be using array manipulation to sort and paginate
332
+		 * our data. In a real-world implementation, you will probably want to
333
+		 * use sort and pagination data to build a custom query instead, as you'll
334
+		 * be able to use your precisely-queried data immediately.
335
+		 */
336 336
 		$data = $this->datas;
337 337
 
338 338
 		/**
339
-		* REQUIRED for pagination. Let's figure out what page the user is currently
340
-		* looking at. We'll need this later, so you should always include it in
341
-		* your own package classes.
342
-		*/
339
+		 * REQUIRED for pagination. Let's figure out what page the user is currently
340
+		 * looking at. We'll need this later, so you should always include it in
341
+		 * your own package classes.
342
+		 */
343 343
 		$current_page = $this->get_pagenum();
344 344
 
345 345
 		/**
346
-		* REQUIRED for pagination. Let's check how many items are in our data array.
347
-		* In real-world use, this would be the total number of items in your database,
348
-		* without filtering. We'll need this later, so you should always include it
349
-		* in your own package classes.
350
-		*/
346
+		 * REQUIRED for pagination. Let's check how many items are in our data array.
347
+		 * In real-world use, this would be the total number of items in your database,
348
+		 * without filtering. We'll need this later, so you should always include it
349
+		 * in your own package classes.
350
+		 */
351 351
 		$total_items = count($data);
352 352
 
353 353
 		/**
354
-		* The WP_List_Table class does not handle pagination for us, so we need
355
-		* to ensure that the data is trimmed to only the current page. We can use
356
-		* array_slice() to
357
-		*/
354
+		 * The WP_List_Table class does not handle pagination for us, so we need
355
+		 * to ensure that the data is trimmed to only the current page. We can use
356
+		 * array_slice() to
357
+		 */
358 358
 		$data = array_slice($data,(($current_page-1)*$per_page),$per_page);
359 359
 
360 360
 		/**
361
-		* REQUIRED. Now we can add our *sorted* data to the items property, where
362
-		* it can be used by the rest of the class.
363
-		*/
361
+		 * REQUIRED. Now we can add our *sorted* data to the items property, where
362
+		 * it can be used by the rest of the class.
363
+		 */
364 364
 		$this->items = $data;
365 365
 
366 366
 		/**
367
-		* REQUIRED. We also have to register our pagination options & calculations.
368
-		*/
367
+		 * REQUIRED. We also have to register our pagination options & calculations.
368
+		 */
369 369
 		$this->set_pagination_args( array(
370 370
 			'total_items' => $total_items,               		//WE have to calculate the total number of items
371 371
 			'per_page'    => $per_page,                 		//WE have to determine how many items to show on a page
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 
3 3
 /*	Check if file is include. No direct access possible with file url	*/
4
-if ( !defined( 'WPSHOP_VERSION' ) ) {
5
-	die( __('Access is not allowed by this way', 'wpshop') );
4
+if (!defined('WPSHOP_VERSION')) {
5
+	die(__('Access is not allowed by this way', 'wpshop'));
6 6
 }
7 7
 
8 8
 
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 * @package wpshop
12 12
 * @subpackage librairies
13 13
 */
14
-class wpshop_attributes_set_custom_List_table extends WP_List_Table{
14
+class wpshop_attributes_set_custom_List_table extends WP_List_Table {
15 15
 
16 16
 	var $datas;
17 17
 
@@ -19,28 +19,28 @@  discard block
 block discarded – undo
19 19
 	* REQUIRED. Set up a constructor that references the parent constructor. We
20 20
 	* use the parent reference to set some default configs.
21 21
 	***************************************************************************/
22
-	function __construct(){
22
+	function __construct() {
23 23
 		global $status, $page;
24 24
 
25 25
 		//Set parent defaults
26
-		parent::__construct( array(
27
-			'singular'  => __('attribute\'s set', 'wpshop'),    //singular name of the listed records
28
-			'plural'    => __('attributes\' set', 'wpshop'),    //plural name of the listed records
26
+		parent::__construct(array(
27
+			'singular'  => __('attribute\'s set', 'wpshop'), //singular name of the listed records
28
+			'plural'    => __('attributes\' set', 'wpshop'), //plural name of the listed records
29 29
 			'ajax'     => true       //does this table support ajax?
30
-		) );
30
+		));
31 31
 	}
32 32
 
33 33
 	/*	Allows to set different listings for attributes	*/
34
-	function get_views(){
34
+	function get_views() {
35 35
 		$wpshop_attribute_links = array();
36 36
 
37 37
 		$active_nb = wpshop_attributes_set::getElement('', "'moderated','valid'");
38 38
 		$deleted_nb = wpshop_attributes_set::getElement('', "'deleted'");
39 39
 
40
-		$attribute_group_status = !empty( $_REQUEST['attribute_groups_status'] ) ? sanitize_text_field( $_REQUEST['attribute_groups_status'] ) : '';
40
+		$attribute_group_status = !empty($_REQUEST['attribute_groups_status']) ? sanitize_text_field($_REQUEST['attribute_groups_status']) : '';
41 41
 
42
-		$wpshop_attribute_links['wpshop_attribute_groups_links wpshop_attribute_groups_links_valid'.(empty($attribute_group_status)?' current':'')] = '<a href="'.admin_url('admin.php?page='.wpshop_attributes_set::getEditionSlug()).'" >'.__('Attribute groups', 'wpshop').' ('.count($active_nb).')</a>';
43
-		$wpshop_attribute_links['wpshop_attribute_groups_links wpshop_attribute_groups_links_deleted'.(!empty($attribute_group_status) && ($attribute_group_status=='deleted')?' current':'')] = '<a href="'.admin_url('admin.php?page='.wpshop_attributes_set::getEditionSlug().'&attribute_groups_status=deleted').'" >'.__('Trashed attribute groups', 'wpshop').' ('.count($deleted_nb).')</a>';
42
+		$wpshop_attribute_links['wpshop_attribute_groups_links wpshop_attribute_groups_links_valid' . (empty($attribute_group_status) ? ' current' : '')] = '<a href="' . admin_url('admin.php?page=' . wpshop_attributes_set::getEditionSlug()) . '" >' . __('Attribute groups', 'wpshop') . ' (' . count($active_nb) . ')</a>';
43
+		$wpshop_attribute_links['wpshop_attribute_groups_links wpshop_attribute_groups_links_deleted' . (!empty($attribute_group_status) && ($attribute_group_status == 'deleted') ? ' current' : '')] = '<a href="' . admin_url('admin.php?page=' . wpshop_attributes_set::getEditionSlug() . '&attribute_groups_status=deleted') . '" >' . __('Trashed attribute groups', 'wpshop') . ' (' . count($deleted_nb) . ')</a>';
44 44
 
45 45
 		return $wpshop_attribute_links;
46 46
 	}
@@ -58,9 +58,9 @@  discard block
 block discarded – undo
58 58
 	* @see WP_List_Table::::single_row_columns()
59 59
 	* @return array An associative array containing column information: 'slugs'=>'Visible Titles'
60 60
 	**************************************************************************/
61
-	function get_columns(){
61
+	function get_columns() {
62 62
 		$columns = array(
63
-			'cb'       => '',//'<input type="checkbox" />', //Render a checkbox instead of text
63
+			'cb'       => '', //'<input type="checkbox" />', //Render a checkbox instead of text
64 64
 			'id'       => 'Id.',
65 65
 			'name'    => 'Nom',
66 66
 			'status'    => 'Statut',
@@ -91,10 +91,10 @@  discard block
 block discarded – undo
91 91
 	* @param array $column_name The name/slug of the column to be processed
92 92
 	* @return string Text or HTML to be placed inside the column <td>
93 93
 	**************************************************************************/
94
-	function column_default($item, $column_name){
95
-		switch($column_name){
94
+	function column_default($item, $column_name) {
95
+		switch ($column_name) {
96 96
 			default:
97
-				return print_r($item,true); //Show the whole array for troubleshooting purposes
97
+				return print_r($item, true); //Show the whole array for troubleshooting purposes
98 98
 		}
99 99
 	}
100 100
 
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	* @param array $item A singular item (one full row's worth of data)
115 115
 	* @return string Text to be placed inside the column <td> (movie title only)
116 116
 	**************************************************************************/
117
-	function column_id($item){
117
+	function column_id($item) {
118 118
 		return $item['id'];
119 119
 	}
120 120
 	/** ************************************************************************
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 	* @param array $item A singular item (one full row's worth of data)
134 134
 	* @return string Text to be placed inside the column <td> (movie title only)
135 135
 	**************************************************************************/
136
-	function column_status($item){
136
+	function column_status($item) {
137 137
 		return __($item['status'], 'wpshop');
138 138
 	}
139 139
 	/** ************************************************************************
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	* @param array $item A singular item (one full row's worth of data)
153 153
 	* @return string Text to be placed inside the column <td> (movie title only)
154 154
 	**************************************************************************/
155
-	function column_content($item){
155
+	function column_content($item) {
156 156
 		return $item['content'];
157 157
 	}
158 158
 	/** ************************************************************************
@@ -171,8 +171,8 @@  discard block
 block discarded – undo
171 171
 	* @param array $item A singular item (one full row's worth of data)
172 172
 	* @return string Text to be placed inside the column <td> (movie title only)
173 173
 	**************************************************************************/
174
-	function column_entity($item){
175
-		return __($item['entity'],'wpshop');
174
+	function column_entity($item) {
175
+		return __($item['entity'], 'wpshop');
176 176
 	}
177 177
 	/** ************************************************************************
178 178
 	* Recommended. This is a custom column method and is responsible for what
@@ -190,23 +190,23 @@  discard block
 block discarded – undo
190 190
 	* @param array $item A singular item (one full row's worth of data)
191 191
 	* @return string Text to be placed inside the column <td> (movie title only)
192 192
 	**************************************************************************/
193
-	function column_name($item){
193
+	function column_name($item) {
194 194
 		//Build row actions
195
-		$default_action='edit';
196
-		$default_action_text=__('Edit', 'wpshop');
197
-		$attribute_groups_status = !empty( $_REQUEST['attribute_groups_status'] ) ? sanitize_text_field( $_REQUEST['attribute_groups_status'] ) : '';
198
-		if( !empty( $attribute_groups_status ) && ( $attribute_groups_status=='deleted' ) ){
199
-			$default_action='activate';
200
-			$default_action_text=__('Restore', 'wpshop');
195
+		$default_action = 'edit';
196
+		$default_action_text = __('Edit', 'wpshop');
197
+		$attribute_groups_status = !empty($_REQUEST['attribute_groups_status']) ? sanitize_text_field($_REQUEST['attribute_groups_status']) : '';
198
+		if (!empty($attribute_groups_status) && ($attribute_groups_status == 'deleted')) {
199
+			$default_action = 'activate';
200
+			$default_action_text = __('Restore', 'wpshop');
201 201
 		}
202
-		$actions['edit']=sprintf('<a href="'.admin_url('admin.php').'?page=%2$s&amp;action=%3$s&amp;id=%4$s">'.$default_action_text.'</a>',WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_SET_LISTING,$default_action,$item['id']);
202
+		$actions['edit'] = sprintf('<a href="' . admin_url('admin.php') . '?page=%2$s&amp;action=%3$s&amp;id=%4$s">' . $default_action_text . '</a>', WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_SET_LISTING, $default_action, $item['id']);
203 203
 
204 204
 		if (empty($attribute_groups_status))
205
-			$actions['delete']=sprintf('<a href="'.admin_url('admin.php').'?page=%2$s&amp;action=%3$s&amp;id=%4$s">'.__('Delete', 'wpshop').'</a>',WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_SET_LISTING,'delete',$item['id']);
205
+			$actions['delete'] = sprintf('<a href="' . admin_url('admin.php') . '?page=%2$s&amp;action=%3$s&amp;id=%4$s">' . __('Delete', 'wpshop') . '</a>', WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_SET_LISTING, 'delete', $item['id']);
206 206
 
207 207
 		//Return the title contents
208 208
 		return sprintf('%1$s%2$s',
209
-			/*$1%s*/ sprintf('<a href="'.admin_url('admin.php').'?page=%2$s&amp;action=%3$s&amp;id=%4$s">'.__($item['name'], 'wpshop').'</a>',WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_SET_LISTING,'edit',$item['id']),
209
+			/*$1%s*/ sprintf('<a href="' . admin_url('admin.php') . '?page=%2$s&amp;action=%3$s&amp;id=%4$s">' . __($item['name'], 'wpshop') . '</a>', WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_SET_LISTING, 'edit', $item['id']),
210 210
 			/*$3%s*/ $this->row_actions($actions)
211 211
 		);
212 212
 	}
@@ -219,11 +219,11 @@  discard block
 block discarded – undo
219 219
 	* @param array $item A singular item (one full row's worth of data)
220 220
 	* @return string Text to be placed inside the column <td> (movie title only)
221 221
 	**************************************************************************/
222
-	function column_cb($item){
222
+	function column_cb($item) {
223 223
 		return '';
224 224
 		return sprintf(
225 225
 			'<input type="checkbox" name="%1$s[]" value="%2$s" />',
226
-			/*$1%s*/ $this->_args['singular'],  //Let's simply repurpose the table's singular label ("movie")
226
+			/*$1%s*/ $this->_args['singular'], //Let's simply repurpose the table's singular label ("movie")
227 227
 			/*$2%s*/ $item['id']             //The value of the checkbox should be the record's id
228 228
 		);
229 229
 	}
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 	**************************************************************************/
280 280
 	function process_bulk_action() {
281 281
 		//Detect when a bulk action is being triggered...
282
-		if( 'delete'===$this->current_action() ) {
282
+		if ('delete' === $this->current_action()) {
283 283
 			wp_die('Items deleted (or they would be if we had items to delete)!');
284 284
 		}
285 285
 	}
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 		* to ensure that the data is trimmed to only the current page. We can use
359 359
 		* array_slice() to
360 360
 		*/
361
-		$data = array_slice($data,(($current_page-1)*$per_page),$per_page);
361
+		$data = array_slice($data, (($current_page - 1) * $per_page), $per_page);
362 362
 
363 363
 		/**
364 364
 		* REQUIRED. Now we can add our *sorted* data to the items property, where
@@ -369,11 +369,11 @@  discard block
 block discarded – undo
369 369
 		/**
370 370
 		* REQUIRED. We also have to register our pagination options & calculations.
371 371
 		*/
372
-		$this->set_pagination_args( array(
373
-			'total_items' => $total_items,               		//WE have to calculate the total number of items
374
-			'per_page'    => $per_page,                 		//WE have to determine how many items to show on a page
375
-			'total_pages' => ceil($total_items/$per_page)   //WE have to calculate the total number of pages
376
-		) );
372
+		$this->set_pagination_args(array(
373
+			'total_items' => $total_items, //WE have to calculate the total number of items
374
+			'per_page'    => $per_page, //WE have to determine how many items to show on a page
375
+			'total_pages' => ceil($total_items / $per_page)   //WE have to calculate the total number of pages
376
+		));
377 377
 	}
378 378
 
379 379
 }
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 
3 5
 /*	Check if file is include. No direct access possible with file url	*/
4 6
 if ( !defined( 'WPSHOP_VERSION' ) ) {
@@ -201,8 +203,9 @@  discard block
 block discarded – undo
201 203
 		}
202 204
 		$actions['edit']=sprintf('<a href="'.admin_url('admin.php').'?page=%2$s&amp;action=%3$s&amp;id=%4$s">'.$default_action_text.'</a>',WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_SET_LISTING,$default_action,$item['id']);
203 205
 
204
-		if (empty($attribute_groups_status))
205
-			$actions['delete']=sprintf('<a href="'.admin_url('admin.php').'?page=%2$s&amp;action=%3$s&amp;id=%4$s">'.__('Delete', 'wpshop').'</a>',WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_SET_LISTING,'delete',$item['id']);
206
+		if (empty($attribute_groups_status)) {
207
+					$actions['delete']=sprintf('<a href="'.admin_url('admin.php').'?page=%2$s&amp;action=%3$s&amp;id=%4$s">'.__('Delete', 'wpshop').'</a>',WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES, WPSHOP_URL_SLUG_ATTRIBUTE_SET_LISTING,'delete',$item['id']);
208
+		}
206 209
 
207 210
 		//Return the title contents
208 211
 		return sprintf('%1$s%2$s',
Please login to merge, or discard this patch.
includes/librairies/eav/attributes.class.php 4 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1423,7 +1423,7 @@
 block discarded – undo
1423 1423
 	 *	@param string $attributeType The extension of the database table to get the attribute value in
1424 1424
 	 *	@param integer $attributeId The attribute identifier we want to get the value for
1425 1425
 	 *	@param integer $entityTypeId The entity type identifier we want to get the attribute value for (example: product = 1)
1426
-	 	*	@param integer $entityId The entity id we want the attribute value for
1426
+	 *	@param integer $entityId The entity id we want the attribute value for
1427 1427
 	 *
1428 1428
 	 *	@return object $attributeValue A wordpress database object containing the value of the attribute for the selected entity
1429 1429
 	 */
Please login to merge, or discard this patch.
Doc Comments   +10 added lines, -8 removed lines patch added patch discarded remove patch
@@ -46,6 +46,7 @@  discard block
 block discarded – undo
46 46
 	/**
47 47
 	 *	Get the url listing slug of the current class
48 48
 	 *
49
+	 *	@param string $message
49 50
 	 *	@return string The table of the class
50 51
 	 */
51 52
 	function setMessage($message){
@@ -1244,7 +1245,7 @@  discard block
 block discarded – undo
1244 1245
 	 *
1245 1246
 	 *	@param integer $element_id optionnal The attribute identifier we want to get. If not specify the entire list will be returned
1246 1247
 	 *	@param string $element_status optionnal The status of element to get into database. Default is set to valid element
1247
-	 *	@param mixed $field_to_search optionnal The field we want to check the row identifier into. Default is to set id
1248
+	 *	@param string $field_to_search optionnal The field we want to check the row identifier into. Default is to set id
1248 1249
 	 *
1249 1250
 	 *	@return object $element_list A wordpress database object containing the attribute list
1250 1251
 	 */
@@ -1484,9 +1485,6 @@  discard block
 block discarded – undo
1484 1485
 	 *	Get the existing element list into database
1485 1486
 	 *
1486 1487
 	 *	@param integer $elementId optionnal The element identifier we want to get. If not specify the entire list will be returned
1487
-	 *	@param string $elementStatus optionnal The status of element to get into database. Default is set to valid element
1488
-	 *
1489
-	 *	@return object $elements A wordpress database object containing the element list
1490 1488
 	 */
1491 1489
 	public static function getElementWithAttributeAndValue($entityId, $elementId, $language, $keyForArray = '', $outputType = '') {
1492 1490
 		global $wpdb;
@@ -1625,7 +1623,7 @@  discard block
 block discarded – undo
1625 1623
 	/**
1626 1624
 	 * Traduit le shortcode et affiche la valeur d'un attribut donn�
1627 1625
 	 * @param array $atts : tableau de param�tre du shortcode
1628
-	 * @return mixed
1626
+	 * @return string|null
1629 1627
 	 **/
1630 1628
 	public static function wpshop_att_val_func($atts) {
1631 1629
 		global $wpdb;
@@ -1914,7 +1912,7 @@  discard block
 block discarded – undo
1914 1912
 
1915 1913
 	/**
1916 1914
 	 *
1917
-	 * @param array $attribute_list
1915
+	 * @param array $attribute_code
1918 1916
 	 * @param string $output_from
1919 1917
 	 * @return string The output for
1920 1918
 	 */
@@ -2455,6 +2453,12 @@  discard block
 block discarded – undo
2455 2453
 		return $affected_value;
2456 2454
 	}
2457 2455
 
2456
+	/**
2457
+	 * @param string $attr_code
2458
+	 * @param string $attr_option
2459
+	 *
2460
+	 * @return string
2461
+	 */
2458 2462
 	public static function get_attribute_option_output($item, $attr_code, $attr_option, $additionnal_params = '') {
2459 2463
 		switch($attr_code){
2460 2464
 			case 'is_downloadable_':
@@ -3187,7 +3191,6 @@  discard block
 block discarded – undo
3187 3191
 	 * Define the different field available for bulk edition for entities. Attributes to display are defined by checking box in attribute option
3188 3192
 	 *
3189 3193
 	 * @param string $column_name The column name for output type definition
3190
-	 * @param string $post_type The current
3191 3194
 	 *
3192 3195
 	 */
3193 3196
 	function quick_edit( $column_name, $entity ) {
@@ -3212,7 +3215,6 @@  discard block
 block discarded – undo
3212 3215
 	 * Define the different field available for bulk edition for entities. Attributes to display are defined by checking box in attribute option
3213 3216
 	 *
3214 3217
 	 * @param string $column_name The column name for output type definition
3215
-	 * @param string $post_type The current
3216 3218
 	 *
3217 3219
 	 */
3218 3220
 	public static function bulk_edit( $column_name, $entity ) {
Please login to merge, or discard this patch.
Spacing   +557 added lines, -557 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if (!defined('ABSPATH')) exit;
2 2
 
3 3
 /*	Check if file is include. No direct access possible with file url	*/
4
-if ( !defined( 'WPSHOP_VERSION' ) ) {
5
-	die( __('Access is not allowed by this way', 'wpshop') );
4
+if (!defined('WPSHOP_VERSION')) {
5
+	die(__('Access is not allowed by this way', 'wpshop'));
6 6
 }
7 7
 
8 8
 /**
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
  * @package wpshop
21 21
  * @subpackage librairies
22 22
  */
23
-class wpshop_attributes{
23
+class wpshop_attributes {
24 24
 	/*	Define the database table used in the current class	*/
25 25
 	const dbTable = WPSHOP_DBT_ATTRIBUTE;
26 26
 	/*	Define the url listing slug used in the current class	*/
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 *
51 51
 	 *	@return string The table of the class
52 52
 	 */
53
-	function setMessage($message){
53
+	function setMessage($message) {
54 54
 		$this->pageMessage = $message;
55 55
 	}
56 56
 	/**
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	 *
59 59
 	 *	@return string The table of the class
60 60
 	 */
61
-	function getListingSlug(){
61
+	function getListingSlug() {
62 62
 		return self::urlSlugListing;
63 63
 	}
64 64
 	/**
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	 *
67 67
 	 *	@return string The table of the class
68 68
 	 */
69
-	function getEditionSlug(){
69
+	function getEditionSlug() {
70 70
 		return self::urlSlugEdition;
71 71
 	}
72 72
 	/**
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	 *
75 75
 	 *	@return string The table of the class
76 76
 	 */
77
-	public static function getDbTable(){
77
+	public static function getDbTable() {
78 78
 		return self::dbTable;
79 79
 	}
80 80
 	/**
@@ -82,21 +82,21 @@  discard block
 block discarded – undo
82 82
 	 *
83 83
 	 *	@return string $title The title of the page looking at the environnement
84 84
 	 */
85
-	function pageTitle(){
85
+	function pageTitle() {
86 86
 		$action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : '';
87 87
 		$objectInEdition = isset($_REQUEST['id']) ? sanitize_key($_REQUEST['id']) : '';
88
-		$page = !empty( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
88
+		$page = !empty($_GET['page']) ? sanitize_text_field($_GET['page']) : '';
89 89
 
90
-		$title = __(self::pageTitle, 'wpshop' );
91
-		if($action != ''){
92
-			if(($action == 'edit') || ($action == 'delete')){
90
+		$title = __(self::pageTitle, 'wpshop');
91
+		if ($action != '') {
92
+			if (($action == 'edit') || ($action == 'delete')) {
93 93
 				$editedItem = self::getElement($objectInEdition);
94 94
 				$title = sprintf(__(self::pageEditingTitle, 'wpshop'), str_replace("\\", "", $editedItem->frontend_label));
95 95
 			}
96
-			elseif($action == 'add')
96
+			elseif ($action == 'add')
97 97
 				$title = __(self::pageAddingTitle, 'wpshop');
98 98
 		}
99
-		elseif((self::getEditionSlug() != self::getListingSlug()) && ($page == self::getEditionSlug()))
99
+		elseif ((self::getEditionSlug() != self::getListingSlug()) && ($page == self::getEditionSlug()))
100 100
 			$title = __(self::pageAddingTitle, 'wpshop');
101 101
 
102 102
 		return $title;
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	/**
106 106
 	 *	Define the different message and action after an action is send through the element interface
107 107
 	 */
108
-	function elementAction(){
108
+	function elementAction() {
109 109
 		global $wpdb, $initialEavData;
110 110
 
111 111
 		$pageMessage = $actionResult = '';
@@ -118,75 +118,75 @@  discard block
 block discarded – undo
118 118
 		$saveditem = isset($_REQUEST['saveditem']) ? sanitize_text_field($_REQUEST['saveditem']) : '';
119 119
 		$set_section = !empty($_REQUEST[self::getDbTable()]['set_section']) ? sanitize_text_field($_REQUEST[self::getDbTable()]['set_section']) : '';
120 120
 		//@TODO $_REQUEST
121
-		$id = !empty($_REQUEST['id']) ? (int) $_REQUEST['id'] : null;
122
-		if(!empty($action) && ($action=='activate') ){
123
-			if( isset($id) ) {
121
+		$id = !empty($_REQUEST['id']) ? (int)$_REQUEST['id'] : null;
122
+		if (!empty($action) && ($action == 'activate')) {
123
+			if (isset($id)) {
124 124
 				$query = $wpdb->update(self::getDbTable(), array('status'=>'moderated'), array('id'=>$id));
125 125
 				wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=edit&id=" . $id));
126 126
 			}
127 127
 		}
128
-		if(($action != '') && ($action == 'saveok') && ($saveditem > 0)){
128
+		if (($action != '') && ($action == 'saveok') && ($saveditem > 0)) {
129 129
 			$editedElement = self::getElement($saveditem);
130 130
 			$pageMessage = '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully saved', 'wpshop'), '<span class="bold" >' . $editedElement->code . '</span>');
131 131
 		}
132
-		elseif(($action != '') && ($action == 'deleteok') && ($saveditem > 0)){
132
+		elseif (($action != '') && ($action == 'deleteok') && ($saveditem > 0)) {
133 133
 			$editedElement = self::getElement($saveditem, "'deleted'");
134 134
 			$pageMessage = '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully deleted', 'wpshop'), '<span class="bold" >' . $editedElement->code . '</span>');
135 135
 		}
136 136
 
137
-		$attribute_parameter = !empty( $_REQUEST[self::getDbTable()] ) ? (array)$_REQUEST[self::getDbTable()] : array();
138
-		 if ( !empty($set_section) ) unset($attribute_parameter['set_section']);
137
+		$attribute_parameter = !empty($_REQUEST[self::getDbTable()]) ? (array)$_REQUEST[self::getDbTable()] : array();
138
+		 if (!empty($set_section)) unset($attribute_parameter['set_section']);
139 139
 
140 140
 		$wpshop_attribute_combo_values_list_order_def = !empty($attribute_parameter['wpshop_attribute_combo_values_list_order_def']) ? $attribute_parameter['wpshop_attribute_combo_values_list_order_def'] : array();
141 141
 		// @TODO $_REQUEST
142 142
 		// unset($_REQUEST[self::getDbTable()]['wpshop_attribute_combo_values_list_order_def']);
143 143
 
144
-		if(!isset($attribute_parameter['status'])){
144
+		if (!isset($attribute_parameter['status'])) {
145 145
 			$attribute_parameter['status'] = 'moderated';
146 146
 		}
147
-		if(!isset($attribute_parameter['is_historisable'])){
147
+		if (!isset($attribute_parameter['is_historisable'])) {
148 148
 			$attribute_parameter['is_historisable'] = 'no';
149 149
 		}
150
-		if(!isset($attribute_parameter['is_required'])){
150
+		if (!isset($attribute_parameter['is_required'])) {
151 151
 			$attribute_parameter['is_required'] = 'no';
152 152
 		}
153
-		if(!isset($attribute_parameter['is_used_in_admin_listing_column'])){
153
+		if (!isset($attribute_parameter['is_used_in_admin_listing_column'])) {
154 154
 			$attribute_parameter['is_used_in_admin_listing_column'] = 'no';
155 155
 		}
156
-		if(!isset($attribute_parameter['is_used_in_quick_add_form'])){
156
+		if (!isset($attribute_parameter['is_used_in_quick_add_form'])) {
157 157
 			$attribute_parameter['is_used_in_quick_add_form'] = 'no';
158 158
 		}
159
-		if(!isset($attribute_parameter['is_intrinsic'])){
159
+		if (!isset($attribute_parameter['is_intrinsic'])) {
160 160
 			$attribute_parameter['is_intrinsic'] = 'no';
161 161
 		}
162
-		if(!isset($attribute_parameter['is_requiring_unit'])){
162
+		if (!isset($attribute_parameter['is_requiring_unit'])) {
163 163
 			$attribute_parameter['is_requiring_unit'] = 'no';
164 164
 		}
165
-		if(!isset($attribute_parameter['is_visible_in_front'])){
165
+		if (!isset($attribute_parameter['is_visible_in_front'])) {
166 166
 			$attribute_parameter['is_visible_in_front'] = 'no';
167 167
 		}
168
-		if(!isset($attribute_parameter['is_visible_in_front_listing'])){
168
+		if (!isset($attribute_parameter['is_visible_in_front_listing'])) {
169 169
 			$attribute_parameter['is_visible_in_front_listing'] = 'no';
170 170
 		}
171
-		if(!isset($attribute_parameter['is_used_for_sort_by'])){
171
+		if (!isset($attribute_parameter['is_used_for_sort_by'])) {
172 172
 			$attribute_parameter['is_used_for_sort_by'] = 'no';
173 173
 		}
174
-		if(!isset($attribute_parameter['is_visible_in_advanced_search'])){
174
+		if (!isset($attribute_parameter['is_visible_in_advanced_search'])) {
175 175
 			$attribute_parameter['is_visible_in_advanced_search'] = 'no';
176 176
 		}
177
-		if(!isset($attribute_parameter['is_searchable'])){
177
+		if (!isset($attribute_parameter['is_searchable'])) {
178 178
 			$attribute_parameter['is_searchable'] = 'no';
179 179
 		}
180
-		if(!isset($attribute_parameter['is_used_for_variation'])){
180
+		if (!isset($attribute_parameter['is_used_for_variation'])) {
181 181
 			$attribute_parameter['is_used_for_variation'] = 'no';
182 182
 		}
183
-		if(!isset($attribute_parameter['is_used_in_variation'])){
183
+		if (!isset($attribute_parameter['is_used_in_variation'])) {
184 184
 			$attribute_parameter['is_used_in_variation'] = 'no';
185 185
 		}
186
-		if(!isset($attribute_parameter['is_user_defined'])){
186
+		if (!isset($attribute_parameter['is_user_defined'])) {
187 187
 			$attribute_parameter['is_user_defined'] = 'no';
188 188
 		}
189
-		if(!isset($attribute_parameter['_display_informations_about_value'])){
189
+		if (!isset($attribute_parameter['_display_informations_about_value'])) {
190 190
 			$attribute_parameter['_display_informations_about_value'] = 'no';
191 191
 		}
192 192
 
@@ -195,58 +195,58 @@  discard block
 block discarded – undo
195 195
 			switch ($attribute_parameter['frontend_input']) {
196 196
 				case 'short_text':
197 197
 						$attribute_parameter['frontend_input'] = 'text';
198
-						if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text';
198
+						if (empty($attribute_parameter['backend_input'])) $attribute_parameter['backend_input'] = 'text';
199 199
 						$attribute_parameter['data_type'] = 'varchar';
200 200
 					break;
201 201
 				case 'date_field':
202 202
 						$attribute_parameter['frontend_input'] = 'text';
203
-						if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text';
203
+						if (empty($attribute_parameter['backend_input'])) $attribute_parameter['backend_input'] = 'text';
204 204
 						$attribute_parameter['data_type'] = 'datetime';
205 205
 					break;
206 206
 				case 'float_field':
207 207
 						$attribute_parameter['frontend_input'] = 'text';
208
-						if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text';
208
+						if (empty($attribute_parameter['backend_input'])) $attribute_parameter['backend_input'] = 'text';
209 209
 						$attribute_parameter['data_type'] = 'decimal';
210 210
 					break;
211 211
 				case 'hidden_field':
212 212
 						$attribute_parameter['frontend_input'] = 'hidden';
213
-						if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text';
213
+						if (empty($attribute_parameter['backend_input'])) $attribute_parameter['backend_input'] = 'text';
214 214
 						$attribute_parameter['data_type'] = 'varchar';
215 215
 					break;
216 216
 				case 'pass_field':
217 217
 						$attribute_parameter['frontend_input'] = 'password';
218
-						if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text';
218
+						if (empty($attribute_parameter['backend_input'])) $attribute_parameter['backend_input'] = 'text';
219 219
 						$attribute_parameter['data_type'] = 'varchar';
220 220
 					break;
221 221
 
222 222
 				case 'select':
223 223
 						$attribute_parameter['frontend_input'] = 'select';
224
-						if ( empty($attribute_parameter['backend_input']) || empty($id) )
224
+						if (empty($attribute_parameter['backend_input']) || empty($id))
225 225
 							$attribute_parameter['backend_input'] = 'multiple-select';
226 226
 						$attribute_parameter['data_type'] = 'integer';
227 227
 					break;
228 228
 				case 'multiple-select':
229 229
 						$attribute_parameter['frontend_input'] = 'multiple-select';
230
-						if ( empty($attribute_parameter['backend_input']) || empty($id) )
230
+						if (empty($attribute_parameter['backend_input']) || empty($id))
231 231
 							$attribute_parameter['backend_input'] = 'multiple-select';
232 232
 						$attribute_parameter['data_type'] = 'integer';
233 233
 					break;
234 234
 				case 'radio':
235 235
 						$attribute_parameter['frontend_input'] = 'radio';
236
-						if ( empty($attribute_parameter['backend_input']) || empty($id) )
236
+						if (empty($attribute_parameter['backend_input']) || empty($id))
237 237
 							$attribute_parameter['backend_input'] = 'multiple-select';
238 238
 						$attribute_parameter['data_type'] = 'integer';
239 239
 					break;
240 240
 				case 'checkbox':
241 241
 						$attribute_parameter['frontend_input'] = 'checkbox';
242
-						if ( empty($attribute_parameter['backend_input']) || empty($id) )
242
+						if (empty($attribute_parameter['backend_input']) || empty($id))
243 243
 							$attribute_parameter['backend_input'] = 'multiple-select';
244 244
 						$attribute_parameter['data_type'] = 'integer';
245 245
 					break;
246 246
 
247 247
 				case 'textarea':
248 248
 						$attribute_parameter['frontend_input'] = 'textarea';
249
-						if ( empty($attribute_parameter['backend_input']) || empty($id) )
249
+						if (empty($attribute_parameter['backend_input']) || empty($id))
250 250
 							$attribute_parameter['backend_input'] = 'textarea';
251 251
 						$attribute_parameter['data_type'] = 'text';
252 252
 					break;
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 		}
255 255
 		else {
256 256
 			$attribute_parameter['frontend_input'] = 'text';
257
-			if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text';
257
+			if (empty($attribute_parameter['backend_input'])) $attribute_parameter['backend_input'] = 'text';
258 258
 			$attribute_parameter['data_type'] = 'varchar';
259 259
 		}
260 260
 
@@ -263,55 +263,55 @@  discard block
 block discarded – undo
263 263
 			// $attribute_parameter['use_ajax_for_filling_field']='no';
264 264
 		// }
265 265
 		$attribute_parameter['use_ajax_for_filling_field'] = 'yes';
266
-		if( $attribute_parameter['backend_input'] == 'multiple-select' ) {
266
+		if ($attribute_parameter['backend_input'] == 'multiple-select') {
267 267
 			$attribute_parameter['is_used_for_variation'] = 'yes';
268 268
 		}
269 269
 
270 270
 		/*	Define the database operation type from action launched by the user	 */
271 271
 		$attribute_parameter['default_value'] = (!empty($attribute_parameter['default_value']) && is_array($attribute_parameter['default_value'])) ? serialize($attribute_parameter['default_value']) : (isset($attribute_parameter['default_value']) ? str_replace('"', "'", $attribute_parameter['default_value']) : '');
272
-		if ( $attribute_parameter['data_type'] == 'datetime' ) {
272
+		if ($attribute_parameter['data_type'] == 'datetime') {
273 273
 			$date_default_value_trasform_into_config = array('default_value' => $attribute_parameter['default_value'], 'field_options' => (!empty($_POST[self::getDbTable() . '_options']) ? sanitize_text_field($_POST[self::getDbTable() . '_options']) : null));
274
-			$attribute_parameter['default_value'] = serialize( $date_default_value_trasform_into_config );
274
+			$attribute_parameter['default_value'] = serialize($date_default_value_trasform_into_config);
275 275
 		}
276 276
 		/*****************************		GENERIC				**************************/
277 277
 		/*************************************************************************/
278
-		$pageAction = (!empty($attribute_parameter['frontend_label']) && isset($_REQUEST[self::getDbTable() . '_action'])) ? sanitize_text_field($_REQUEST[self::getDbTable() . '_action']) : ((!empty($_GET['action']) && ($_GET['action']=='delete')) ? sanitize_text_field($_GET['action']) : '');
278
+		$pageAction = (!empty($attribute_parameter['frontend_label']) && isset($_REQUEST[self::getDbTable() . '_action'])) ? sanitize_text_field($_REQUEST[self::getDbTable() . '_action']) : ((!empty($_GET['action']) && ($_GET['action'] == 'delete')) ? sanitize_text_field($_GET['action']) : '');
279 279
 		$id = isset($attribute_parameter['id']) ? sanitize_key($attribute_parameter['id']) : ((!empty($_GET['id'])) ? $_GET['id'] : '');
280
-		if(($pageAction != '') && (($pageAction == 'edit') || ($pageAction == 'editandcontinue'))){
281
-			if(current_user_can('wpshop_edit_attributes')){
280
+		if (($pageAction != '') && (($pageAction == 'edit') || ($pageAction == 'editandcontinue'))) {
281
+			if (current_user_can('wpshop_edit_attributes')) {
282 282
 				$attribute_parameter['last_update_date'] = date('Y-m-d H:i:s');
283
-				if($pageAction == 'delete'){
283
+				if ($pageAction == 'delete') {
284 284
 					$attribute_code = $attribute_parameter['code'];
285
-					if(!isset($attribute_parameter['code']) || ($attribute_parameter['code'] == '')){
285
+					if (!isset($attribute_parameter['code']) || ($attribute_parameter['code'] == '')) {
286 286
 						$attribute = self::getElement($id, "'valid', 'moderated', 'notused'", 'id');
287 287
 						$attribute_code = $attribute->code;
288 288
 					}
289
-					if(!in_array($attribute_code, $attribute_undeletable)){
290
-						if(current_user_can('wpshop_delete_attributes')){
289
+					if (!in_array($attribute_code, $attribute_undeletable)) {
290
+						if (current_user_can('wpshop_delete_attributes')) {
291 291
 							$attribute_parameter['status'] = 'deleted';
292 292
 						}
293
-						else{
293
+						else {
294 294
 							$actionResult = 'userNotAllowedForActionDelete';
295 295
 						}
296 296
 					}
297
-					else{
297
+					else {
298 298
 						$actionResult = 'unDeletableAtribute';
299 299
 					}
300 300
 				}
301 301
 				$actionResult = wpshop_database::update($attribute_parameter, $id, self::getDbTable());
302 302
 			}
303
-			else{
303
+			else {
304 304
 				$actionResult = 'userNotAllowedForActionEdit';
305 305
 			}
306 306
 		}
307
-		elseif(($pageAction != '') && (($pageAction == 'delete'))){
307
+		elseif (($pageAction != '') && (($pageAction == 'delete'))) {
308 308
 			$attribute_code = '';
309
-			if (empty(	$attribute_parameter['code'])) {
309
+			if (empty($attribute_parameter['code'])) {
310 310
 				$attribute = self::getElement($id, "'valid', 'moderated', 'notused', 'deleted'", 'id');
311 311
 				$attribute_code = $attribute->code;
312 312
 			}
313 313
 			if (!in_array($attribute_code, $attribute_undeletable)) {
314
-				if(current_user_can('wpshop_delete_attributes')){
314
+				if (current_user_can('wpshop_delete_attributes')) {
315 315
 					$attribute_parameter['last_update_date'] = current_time('mysql', 0);
316 316
 					$attribute_parameter['status'] = 'deleted';
317 317
 					$actionResult = wpshop_database::update($attribute_parameter, $id, self::getDbTable());
@@ -322,21 +322,21 @@  discard block
 block discarded – undo
322 322
 			else
323 323
 				$actionResult = 'unDeletableAtribute';
324 324
 		}
325
-		elseif(($pageAction != '') && (($pageAction == 'save') || ($pageAction == 'saveandcontinue') || ($pageAction == 'add'))){
326
-			if(current_user_can('wpshop_add_attributes')){
325
+		elseif (($pageAction != '') && (($pageAction == 'save') || ($pageAction == 'saveandcontinue') || ($pageAction == 'add'))) {
326
+			if (current_user_can('wpshop_add_attributes')) {
327 327
 				$attribute_parameter['creation_date'] = current_time('mysql', 0);
328
-				if(trim($attribute_parameter['code']) == ''){
328
+				if (trim($attribute_parameter['code']) == '') {
329 329
 					$attribute_parameter['code'] = $attribute_parameter['frontend_label'];
330 330
 				}
331 331
 				$attribute_parameter['code'] = wpshop_tools::slugify(str_replace("\'", "_", str_replace('\"', "_", $attribute_parameter['code'])), array('noAccent', 'noSpaces', 'lowerCase', 'noPunctuation'));
332 332
 				$code_exists = self::getElement($attribute_parameter['code'], "'valid', 'moderated', 'deleted'", 'code');
333
-				if((is_object($code_exists) || is_array($code_exists)) && (count($code_exists) > 0)){
333
+				if ((is_object($code_exists) || is_array($code_exists)) && (count($code_exists) > 0)) {
334 334
 					$attribute_parameter['code'] = $attribute_parameter['code'] . '_' . (count($code_exists) + rand());
335 335
 				}
336 336
 				$actionResult = wpshop_database::save($attribute_parameter, self::getDbTable());
337 337
 				$id = $wpdb->insert_id;
338 338
 			}
339
-			else{
339
+			else {
340 340
 				$actionResult = 'userNotAllowedForActionAdd';
341 341
 			}
342 342
 		}
@@ -345,9 +345,9 @@  discard block
 block discarded – undo
345 345
 		/************		CHANGE THE FIELD NAME TO TAKE TO DISPLAY				*************/
346 346
 		/************		CHANGE ERROR MESSAGE FOR SPECIFIC CASE					*************/
347 347
 		/****************************************************************************/
348
-		if($actionResult != ''){
348
+		if ($actionResult != '') {
349 349
 			$elementIdentifierForMessage = __('the attribute', 'wpshop');
350
-			if(!empty($attribute_parameter['name']))$elementIdentifierForMessage = '<span class="bold" >' . $attribute_parameter['frontend_label'] . '</span>';
350
+			if (!empty($attribute_parameter['name']))$elementIdentifierForMessage = '<span class="bold" >' . $attribute_parameter['frontend_label'] . '</span>';
351 351
 			if ($actionResult == 'error') {/*	CHANGE HERE FOR SPECIFIC CASE	*/
352 352
 				$pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . sprintf(__('An error occured while saving %s', 'wpshop'), $elementIdentifierForMessage, ' -> ' . $wpdb->last_error);
353 353
 			}
@@ -359,11 +359,11 @@  discard block
 block discarded – undo
359 359
 				$done_options_value = array();
360 360
 				$default_value = $attribute_parameter['default_value'];
361 361
 				$i = 1;
362
-				$options = !empty($_REQUEST['options']) ? (array) $_REQUEST['options'] : array();
363
-				$optionsValue = !empty($_REQUEST['optionsValue']) ? (array) $_REQUEST['optionsValue'] : array();
364
-				$optionsUpdate = !empty($_REQUEST['optionsUpdate']) ? (array) $_REQUEST['optionsUpdate'] : array();
365
-				$optionsUpdateValue = !empty($_REQUEST['optionsUpdateValue']) ? (array) $_REQUEST['optionsUpdateValue'] : array();
366
-				if ( !empty($optionsUpdate) ) {
362
+				$options = !empty($_REQUEST['options']) ? (array)$_REQUEST['options'] : array();
363
+				$optionsValue = !empty($_REQUEST['optionsValue']) ? (array)$_REQUEST['optionsValue'] : array();
364
+				$optionsUpdate = !empty($_REQUEST['optionsUpdate']) ? (array)$_REQUEST['optionsUpdate'] : array();
365
+				$optionsUpdateValue = !empty($_REQUEST['optionsUpdateValue']) ? (array)$_REQUEST['optionsUpdateValue'] : array();
366
+				if (!empty($optionsUpdate)) {
367 367
 					/**
368 368
 					 *	Check if there is an attribute code into sended request or if we have to get the code from database (Bug fix)
369 369
 					 */
@@ -377,25 +377,25 @@  discard block
 block discarded – undo
377 377
 					foreach ($optionsUpdate as $option_key => $option_label) {
378 378
 						$option_value = !empty($optionsUpdateValue[$option_key]) ? str_replace(",", ".", $optionsUpdateValue[$option_key]) : '';
379 379
 
380
-						if ( empty($option_value) || !in_array($option_value, $done_options_value) ) {
380
+						if (empty($option_value) || !in_array($option_value, $done_options_value)) {
381 381
 							/*	Update an existing value only if the value does not exist into existing list	*/
382 382
 							$label = (($option_label != '') ? $option_label : str_replace(",", ".", $option_value));
383 383
 							$value = str_replace(",", ".", $option_value);
384
-							if( !WPSHOP_DISPLAY_VALUE_FOR_ATTRIBUTE_SELECT ) {
384
+							if (!WPSHOP_DISPLAY_VALUE_FOR_ATTRIBUTE_SELECT) {
385 385
 								$label = $option_label;
386
-								$value =  str_replace(",", ".", $label);
386
+								$value = str_replace(",", ".", $label);
387 387
 							}
388 388
 
389 389
 							$wpdb->update(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('last_update_date' => current_time('mysql', 0), 'position' => $i, 'label' => stripslashes($label), 'value' => stripslashes($value)), array('id' => $option_key));
390 390
 							$done_options_value[] = str_replace(",", ".", $option_value);
391 391
 
392 392
 							/*	Check if this value is used for price calculation and make update on the different product using this value	*/
393
-							if($attribute_code == WPSHOP_PRODUCT_PRICE_TAX){
393
+							if ($attribute_code == WPSHOP_PRODUCT_PRICE_TAX) {
394 394
 								$action = wpshop_prices::mass_update_prices();
395 395
 							}
396 396
 						}
397 397
 
398
-						if($default_value == $option_key) {
398
+						if ($default_value == $option_key) {
399 399
 							/*	Update an existing a only if the value does not exist into existing list	*/
400 400
 							$wpdb->update(WPSHOP_DBT_ATTRIBUTE, array('last_update_date' => current_time('mysql', 0), 'default_value' => $option_key), array('id' => $id));
401 401
 							$done_options_value[] = str_replace(",", ".", $option_value);
@@ -403,13 +403,13 @@  discard block
 block discarded – undo
403 403
 						$i++;
404 404
 					}
405 405
 				}
406
-				if ( !empty($options) ) {
407
-					foreach ( $options as $option_key => $option_label ) {
406
+				if (!empty($options)) {
407
+					foreach ($options as $option_key => $option_label) {
408 408
 						$option_value = !empty($optionsValue[$option_key]) ? str_replace(",", ".", $optionsValue[$option_key]) : sanitize_title($option_label);
409 409
 
410 410
 						/*	Check what value to use for the new values	*/
411 411
 						$label = (!empty($option_label) ? $option_label : str_replace(",", ".", $option_value));
412
-						if( !WPSHOP_DISPLAY_VALUE_FOR_ATTRIBUTE_SELECT && empty($option_value) ) {
412
+						if (!WPSHOP_DISPLAY_VALUE_FOR_ATTRIBUTE_SELECT && empty($option_value)) {
413 413
 							$label = $option_label;
414 414
 							$option_value = sanitize_title($label);
415 415
 						}
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
 						// If the optionsUpdateValue is empty, set it a empty array to avoid error calling the in_array() function
418 418
 						// $_REQUEST['optionsUpdateValue'] = !empty($_REQUEST['optionsUpdateValue']) ? $_REQUEST['optionsUpdateValue'] : array();
419 419
 
420
-						if (!in_array($option_value, $done_options_value) && !in_array($option_value, $optionsUpdateValue) ) {
420
+						if (!in_array($option_value, $done_options_value) && !in_array($option_value, $optionsUpdateValue)) {
421 421
 
422 422
 							$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS, array('creation_date' => current_time('mysql', 0), 'status' => 'valid', 'attribute_id' => $id, 'position' => $i, 'label' => stripslashes($label), 'value' => stripslashes($option_value)));
423 423
 							$done_options_value[] = str_replace(",", ".", $option_value);
@@ -435,19 +435,19 @@  discard block
 block discarded – undo
435 435
 				}
436 436
 
437 437
 				// If the is_used_for_sort_by is mark as yes, we have to get out some attributes and save it separately
438
-				if( (!empty($attribute_parameter['is_used_for_sort_by']) && ($attribute_parameter['is_used_for_sort_by'] == 'yes')) || (!empty($attribute_parameter['is_filterable']) && ($attribute_parameter['is_filterable'] == 'yes')) || (!empty($attribute_parameter['is_searchable']) && ($attribute_parameter['is_searchable'] == 'yes')) ){
438
+				if ((!empty($attribute_parameter['is_used_for_sort_by']) && ($attribute_parameter['is_used_for_sort_by'] == 'yes')) || (!empty($attribute_parameter['is_filterable']) && ($attribute_parameter['is_filterable'] == 'yes')) || (!empty($attribute_parameter['is_searchable']) && ($attribute_parameter['is_searchable'] == 'yes'))) {
439 439
 					$attribute_code = $attribute_parameter['code'];
440
-					if(!isset($attribute_parameter['code']) || ($attribute_parameter['code'] == '')){
440
+					if (!isset($attribute_parameter['code']) || ($attribute_parameter['code'] == '')) {
441 441
 						$attribute = self::getElement($id, "'valid', 'moderated', 'notused'", 'id');
442 442
 						$attribute_code = $attribute->code;
443 443
 					}
444 444
 
445 445
 					$count_products = wp_count_posts(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT);
446
-					for( $i = 0; $i <= $count_products->publish; $i+= 20 ) {
447
-						$query = $wpdb->prepare( 'SELECT * FROM '. $wpdb->posts .' WHERE post_type = %s AND post_status = %s ORDER BY ID DESC LIMIT '.$i.', 20', WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'publish' );
448
-						$products = $wpdb->get_results( $query );
449
-						if ( !empty($products) ) {
450
-							foreach( $products as $product ) {
446
+					for ($i = 0; $i <= $count_products->publish; $i += 20) {
447
+						$query = $wpdb->prepare('SELECT * FROM ' . $wpdb->posts . ' WHERE post_type = %s AND post_status = %s ORDER BY ID DESC LIMIT ' . $i . ', 20', WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'publish');
448
+						$products = $wpdb->get_results($query);
449
+						if (!empty($products)) {
450
+							foreach ($products as $product) {
451 451
 								$query = $wpdb->prepare("SELECT value FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attribute_parameter['data_type'] . " WHERE attribute_id = %d AND entity_type_id = %d AND entity_id = %d AND value != '' ORDER BY creation_date_value DESC", $id, $attribute_parameter['entity_id'], $product->ID);
452 452
 								$value = $wpdb->get_var($query);
453 453
 								update_post_meta($product->ID, '_' . $attribute_code, $value);
@@ -457,13 +457,13 @@  discard block
 block discarded – undo
457 457
 					wp_reset_query();
458 458
 				}
459 459
 
460
-				if ( $pageAction != 'delete' ) {/*	Add the new attribute in the additionnal informations attribute group	*/
461
-					if ( !empty($set_section) ) {
460
+				if ($pageAction != 'delete') {/*	Add the new attribute in the additionnal informations attribute group	*/
461
+					if (!empty($set_section)) {
462 462
 						$choosen_set_section = explode('_', $set_section);
463 463
 						$set_id = $choosen_set_section[0];
464 464
 						$group_id = $choosen_set_section[1];
465 465
 					}
466
-					else{
466
+					else {
467 467
 						$attribute_current_attribute_set = 0;
468 468
 						$query = $wpdb->prepare("
469 469
 								SELECT id
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
 									AND ATTRIBUTE_SET_DETAILS.entity_type_id = %d", $id, $attribute_parameter['entity_id']);
474 474
 						$attribute_current_attribute_set = $wpdb->get_results($query);
475 475
 
476
-						if ( empty($attribute_current_attribute_set) ) {
476
+						if (empty($attribute_current_attribute_set)) {
477 477
 							$query = $wpdb->prepare("
478 478
 								SELECT
479 479
 									(
@@ -494,12 +494,12 @@  discard block
 block discarded – undo
494 494
 							$wpshop_default_group = $wpdb->get_row($query);
495 495
 
496 496
 							$set_id = $wpshop_default_group->attribute_set_id;
497
-							$default_group_id = ( !empty( $wpshop_default_group->default_attribute_group_id) ) ? $wpshop_default_group->default_attribute_group_id : '';
497
+							$default_group_id = (!empty($wpshop_default_group->default_attribute_group_id)) ? $wpshop_default_group->default_attribute_group_id : '';
498 498
 							$group_id = !empty($default_group_id) ? $default_group_id : $wpshop_default_group->attribute_group_id;
499 499
 						}
500 500
 					}
501 501
 
502
-					if ( !empty($set_id) && !empty($group_id) ) {
502
+					if (!empty($set_id) && !empty($group_id)) {
503 503
 						$query = $wpdb->prepare(
504 504
 								"SELECT (MAX(position) + 1) AS position
505 505
 								FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . "
@@ -511,12 +511,12 @@  discard block
 block discarded – undo
511 511
 								$attribute_parameter['entity_id']
512 512
 						);
513 513
 						$wpshopAttributePosition = $wpdb->get_var($query);
514
-						if($wpshopAttributePosition == 0)$wpshopAttributePosition = 1;
514
+						if ($wpshopAttributePosition == 0)$wpshopAttributePosition = 1;
515 515
 						$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'entity_type_id' => $attribute_parameter['entity_id'], 'attribute_set_id' => $set_id, 'attribute_group_id' => $group_id, 'attribute_id' => $id, 'position' => $wpshopAttributePosition));
516 516
 					}
517 517
 				}
518 518
 
519
-				if ( !empty($wpshop_attribute_combo_values_list_order_def) ) {
519
+				if (!empty($wpshop_attribute_combo_values_list_order_def)) {
520 520
 					$post_order = explode(',', $wpshop_attribute_combo_values_list_order_def);
521 521
 					$position = 1;
522 522
 					foreach ($post_order as $post_id) {
@@ -532,19 +532,19 @@  discard block
 block discarded – undo
532 532
 					wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=saveok&saveditem=" . $id));
533 533
 				}
534 534
 				else */
535
-				if ( $pageAction == 'add' )
535
+				if ($pageAction == 'add')
536 536
 					wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=edit&id=" . $id));
537
-				elseif ( $pageAction == 'delete' )
537
+				elseif ($pageAction == 'delete')
538 538
 					wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=deleteok&saveditem=" . $id));
539 539
 			}
540
-			elseif(($actionResult == 'userNotAllowedForActionEdit') || ($actionResult == 'userNotAllowedForActionAdd') || ($actionResult == 'userNotAllowedForActionDelete')){
540
+			elseif (($actionResult == 'userNotAllowedForActionEdit') || ($actionResult == 'userNotAllowedForActionAdd') || ($actionResult == 'userNotAllowedForActionDelete')) {
541 541
 				$pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . __('You are not allowed to do this action', 'wpshop');
542 542
 			}
543
-			elseif(($actionResult == 'unDeletableAtribute')){
543
+			elseif (($actionResult == 'unDeletableAtribute')) {
544 544
 				$pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . __('This attribute could not be deleted due to configuration', 'wpshop');
545 545
 			}
546 546
 
547
-			if(empty($attribute_parameter['frontend_label']) && ($pageAction!='delete')){
547
+			if (empty($attribute_parameter['frontend_label']) && ($pageAction != 'delete')) {
548 548
 				$pageMessage .= __('Please enter an label for the attribut', 'wpshop');
549 549
 			}
550 550
 		}
@@ -562,37 +562,37 @@  discard block
 block discarded – undo
562 562
 		//Create an instance of our package class...
563 563
 		$wpshop_list_table = new wpshop_attributes_custom_List_table();
564 564
 		//Fetch, prepare, sort, and filter our data...
565
-		$status="'valid'";
566
-		$attribute_status = !empty($_REQUEST['attribute_status']) ? sanitize_text_field( $_REQUEST['attribute_status'] ) : null;
567
-		$s = !empty($_REQUEST['s']) ? sanitize_text_field( $_REQUEST['s'] ) : null;
565
+		$status = "'valid'";
566
+		$attribute_status = !empty($_REQUEST['attribute_status']) ? sanitize_text_field($_REQUEST['attribute_status']) : null;
567
+		$s = !empty($_REQUEST['s']) ? sanitize_text_field($_REQUEST['s']) : null;
568 568
 		$order = !empty($_REQUEST['order']) ? sanitize_text_field($_REQUEST['order']) : null;
569 569
 		$orderby = !empty($_REQUEST['orderby']) ? sanitize_text_field($_REQUEST['orderby']) : null;
570
-		if(!empty($attribute_status)){
571
-			switch($attribute_status){
570
+		if (!empty($attribute_status)) {
571
+			switch ($attribute_status) {
572 572
 				case 'unactive':
573
-					$status="'moderated', 'notused'";
574
-					if(empty($order_by) && empty($order)){
573
+					$status = "'moderated', 'notused'";
574
+					if (empty($order_by) && empty($order)) {
575 575
 						// @TODO : REQUEST
576 576
 						// $_REQUEST['orderby']='status';
577 577
 						// $_REQUEST['order']='asc';
578 578
 					}
579 579
 					break;
580 580
 				default:
581
-					$status="'".sanitize_text_field($_REQUEST['attribute_status'])."'";
581
+					$status = "'" . sanitize_text_field($_REQUEST['attribute_status']) . "'";
582 582
 					break;
583 583
 			}
584 584
 		}
585
-		if ( !empty($s) ) {
586
-			$query = $wpdb->prepare("SELECT * FROM " . self::dbTable . ' WHERE frontend_label LIKE "%%%1$s%%" OR frontend_label LIKE "%%%2$s%%" AND backend_label LIKE "%%%1$s%%" OR backend_label LIKE "%%%2$s%%" AND code LIKE "%%%1$s%%" OR code LIKE "%%%2$s%%"', $s, __($s, 'wpshop') );
587
-			$attr_set_list = $wpdb->get_results( $query );
585
+		if (!empty($s)) {
586
+			$query = $wpdb->prepare("SELECT * FROM " . self::dbTable . ' WHERE frontend_label LIKE "%%%1$s%%" OR frontend_label LIKE "%%%2$s%%" AND backend_label LIKE "%%%1$s%%" OR backend_label LIKE "%%%2$s%%" AND code LIKE "%%%1$s%%" OR code LIKE "%%%2$s%%"', $s, __($s, 'wpshop'));
587
+			$attr_set_list = $wpdb->get_results($query);
588 588
 		}
589 589
 		else {
590
-			$attr_set_list = self::getElement( '', $status );
590
+			$attr_set_list = self::getElement('', $status);
591 591
 		}
592
-		$i=0;
593
-		$attribute_set_list=array();
594
-		foreach($attr_set_list as $attr_set){
595
-			if(!empty($attr_set->id) && ($attr_set->code != 'product_attribute_set_id') ){
592
+		$i = 0;
593
+		$attribute_set_list = array();
594
+		foreach ($attr_set_list as $attr_set) {
595
+			if (!empty($attr_set->id) && ($attr_set->code != 'product_attribute_set_id')) {
596 596
 				$attribute_set_list[$i]['id'] = $attr_set->id;
597 597
 				$attribute_set_list[$i]['name'] = $attr_set->frontend_label;
598 598
 				$attribute_set_list[$i]['status'] = $attr_set->status;
@@ -640,31 +640,31 @@  discard block
 block discarded – undo
640 640
 		global $attribute_displayed_field, $attribute_options_group;
641 641
 		$dbFieldList = wpshop_database::fields_to_input(self::getDbTable());
642 642
 		$editedItem = '';
643
-		if($itemToEdit != '')
643
+		if ($itemToEdit != '')
644 644
 			$editedItem = self::getElement($itemToEdit);
645 645
 
646 646
 		$the_form_content_hidden = $the_form_general_content = '';
647 647
 		$the_form_option_content_list = array();
648
-		foreach($dbFieldList as $input_key => $input_def){
648
+		foreach ($dbFieldList as $input_key => $input_def) {
649 649
 
650
-			if(!isset($attribute_displayed_field) || !is_array($attribute_displayed_field) || in_array($input_def['name'], $attribute_displayed_field)){
650
+			if (!isset($attribute_displayed_field) || !is_array($attribute_displayed_field) || in_array($input_def['name'], $attribute_displayed_field)) {
651 651
 				$input_def['label'] = $input_def['name'];
652
-				$input_def_id=$input_def['id']='wpshop_' . self::currentPageCode . '_edition_table_field_id_'.$input_def['label'];
652
+				$input_def_id = $input_def['id'] = 'wpshop_' . self::currentPageCode . '_edition_table_field_id_' . $input_def['label'];
653 653
 
654 654
 				$pageAction = isset($_REQUEST[self::getDbTable() . '_action']) ? sanitize_text_field($_REQUEST[self::getDbTable() . '_action']) : '';
655 655
 				$requestFormValue = isset($_REQUEST[self::currentPageCode][$input_def['label']]) ? sanitize_text_field($_REQUEST[self::currentPageCode][$input_def['label']]) : '';
656 656
 				$currentFieldValue = $input_def['value'];
657
-				if(is_object($editedItem))
657
+				if (is_object($editedItem))
658 658
 					$currentFieldValue = $editedItem->{$input_def['label']};
659
-				elseif(($pageAction != '') && ($requestFormValue != ''))
659
+				elseif (($pageAction != '') && ($requestFormValue != ''))
660 660
 					$currentFieldValue = $requestFormValue;
661 661
 
662
-				if($input_def['label'] == 'status'){
663
-					if(in_array('notused', $input_def['possible_value'])){
662
+				if ($input_def['label'] == 'status') {
663
+					if (in_array('notused', $input_def['possible_value'])) {
664 664
 						$key = array_keys($input_def['possible_value'], 'notused');
665 665
 						unset($input_def['possible_value'][$key[0]]);
666 666
 					}
667
-					if(in_array('dbl', $input_def['possible_value'])){
667
+					if (in_array('dbl', $input_def['possible_value'])) {
668 668
 						$key = array_keys($input_def['possible_value'], 'dbl');
669 669
 						unset($input_def['possible_value'][$key[0]]);
670 670
 					}
@@ -672,94 +672,94 @@  discard block
 block discarded – undo
672 672
 					$input_def['type'] = 'checkbox';
673 673
 					$input_def['label'] = __('Use this attribute', 'wpshop');
674 674
 					$input_def['possible_value'] = array('valid');
675
-					$input_def_id.='_valid';
676
-					$input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box for using this attribute', 'wpshop').'" class="wpshop_infobulle_marker">?</a>';
675
+					$input_def_id .= '_valid';
676
+					$input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for using this attribute', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
677 677
 				}
678 678
 
679
-				if ( (substr($input_def['label'], 0, 3) == 'is_') || ( $input_def['label'] == '_display_informations_about_value') ) {
679
+				if ((substr($input_def['label'], 0, 3) == 'is_') || ($input_def['label'] == '_display_informations_about_value')) {
680 680
 					$input_def['type'] = 'checkbox';
681 681
 					$input_def['possible_value'] = 'yes';
682 682
 				}
683
-				switch($input_def['label']){
683
+				switch ($input_def['label']) {
684 684
 					case 'is_requiring_unit':
685
-						$input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box for using unit with this attribute', 'wpshop').'" class="wpshop_infobulle_marker">?</a>';
685
+						$input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for using unit with this attribute', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
686 686
 					break;
687 687
 					case 'is_visible_in_front':
688
-						$input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box for displaying this attribute in shop', 'wpshop').'" class="wpshop_infobulle_marker">?</a>';
688
+						$input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for displaying this attribute in shop', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
689 689
 					break;
690 690
 					case 'is_visible_in_front_listing':
691
-						$input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box for displaying this attribute in product listing in shop', 'wpshop').'" class="wpshop_infobulle_marker">?</a>';
691
+						$input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for displaying this attribute in product listing in shop', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
692 692
 					break;
693 693
 					case 'is_used_for_sort_by':
694
-						$input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box for displaying this attribute into sortbar', 'wpshop').'" class="wpshop_infobulle_marker">?</a>';
694
+						$input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for displaying this attribute into sortbar', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
695 695
 					break;
696 696
 					case 'is_searchable':
697
-						$input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box for including values of this attribute as search parameter', 'wpshop').'" class="wpshop_infobulle_marker">?</a>';
697
+						$input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for including values of this attribute as search parameter', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
698 698
 					break;
699 699
 					case 'is_visible_in_advanced_search':
700
-						$input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box for using in advanced search form', 'wpshop').'" class="wpshop_infobulle_marker">?</a>';
700
+						$input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box for using in advanced search form', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
701 701
 					break;
702 702
 					case 'frontend_css_class':
703
-						$input_def['options_label']['custom'] = '<a href="#" title="'.__('Separate with a space each CSS Class', 'wpshop').'" class="wpshop_infobulle_marker">?</a>';
703
+						$input_def['options_label']['custom'] = '<a href="#" title="' . __('Separate with a space each CSS Class', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
704 704
 					break;
705 705
 					case 'backend_css_class':
706
-						$input_def['options_label']['custom'] = '<a href="#" title="'.__('Separate with a space each CSS Class', 'wpshop').'" class="wpshop_infobulle_marker">?</a>';
706
+						$input_def['options_label']['custom'] = '<a href="#" title="' . __('Separate with a space each CSS Class', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
707 707
 					break;
708 708
 					case 'is_historisable':
709
-						$input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box if you want to save the different value this attribute, each time it is modified', 'wpshop').'" class="wpshop_infobulle_marker">?</a>';
709
+						$input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box if you want to save the different value this attribute, each time it is modified', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
710 710
 					break;
711 711
 					case 'is_filterable':
712
-						$input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box if you want to use this attribute in the filter search', 'wpshop').'" class="wpshop_infobulle_marker">?</a>';
712
+						$input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box if you want to use this attribute in the filter search', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
713 713
 					break;
714 714
 					case 'is_intrinsic':
715
-						$input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box if this attribute is intrinsic for a product', 'wpshop').'" class="wpshop_infobulle_marker">?</a>';
715
+						$input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box if this attribute is intrinsic for a product', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
716 716
 					break;
717 717
 					case 'is_used_for_variation':
718
-						$input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box if this attribute is used for variation. It means that the user would be able to choose a value in frontend', 'wpshop').'" class="wpshop_infobulle_marker">?</a>';
718
+						$input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box if this attribute is used for variation. It means that the user would be able to choose a value in frontend', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
719 719
 					break;
720 720
 					case 'is_used_in_variation':
721
-						$input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box if you want to use this attribute for variation definition', 'wpshop').'" class="wpshop_infobulle_marker">?</a>';
722
-						if ( !empty($editedItem) && ($editedItem->is_used_for_variation == 'yes') ) {
721
+						$input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box if you want to use this attribute for variation definition', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
722
+						if (!empty($editedItem) && ($editedItem->is_used_for_variation == 'yes')) {
723 723
 							$input_def['option'] = 'disabled="disabled"';
724 724
 						}
725 725
 					break;
726 726
 					case 'is_user_defined':
727
-						$input_def['options_label']['custom'] = '<a href="#" title="'.__('Check this box if you want your customer to choose a value for this attribute into frontend product', 'wpshop').'" class="wpshop_infobulle_marker">?</a>';
727
+						$input_def['options_label']['custom'] = '<a href="#" title="' . __('Check this box if you want your customer to choose a value for this attribute into frontend product', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
728 728
 					break;
729 729
 				}
730 730
 
731 731
 				$input_def['value'] = $currentFieldValue;
732
-				if($input_def['label'] == 'code')
732
+				if ($input_def['label'] == 'code')
733 733
 					$input_def['type'] = 'hidden';
734
-				elseif($input_def['label'] == 'entity_id'){
734
+				elseif ($input_def['label'] == 'entity_id') {
735 735
 					$input_def['possible_value'] = wpshop_entities::get_entities_list();
736 736
 					$input_def['valueToPut'] = 'index';
737 737
 					$input_def['type'] = 'select';
738 738
 
739
-					$i=0;
740
-					foreach($input_def['possible_value'] as $entity_id => $entity_name) {
741
-						if($i <= 0){
739
+					$i = 0;
740
+					foreach ($input_def['possible_value'] as $entity_id => $entity_name) {
741
+						if ($i <= 0) {
742 742
 							$current_entity_id = $entity_id;
743 743
 						}
744 744
 						$i++;
745 745
 					}
746 746
 				}
747
-				elseif($input_def['label'] == '_unit_group_id'){
747
+				elseif ($input_def['label'] == '_unit_group_id') {
748 748
 					$input_def['possible_value'] = wpshop_attributes_unit::get_unit_group();
749 749
 					$input_def['type'] = 'select';
750 750
 				}
751
-				elseif($input_def['label'] == '_default_unit'){
751
+				elseif ($input_def['label'] == '_default_unit') {
752 752
 					$unit_group_list = wpshop_attributes_unit::get_unit_group();
753
-					$input_def['possible_value'] = wpshop_attributes_unit::get_unit_list_for_group(!empty($editedItem->_unit_group_id)?$editedItem->_unit_group_id:(!empty($unit_group_list)?$unit_group_list[0]->id:''));
753
+					$input_def['possible_value'] = wpshop_attributes_unit::get_unit_list_for_group(!empty($editedItem->_unit_group_id) ? $editedItem->_unit_group_id : (!empty($unit_group_list) ? $unit_group_list[0]->id : ''));
754 754
 					$input_def['type'] = 'select';
755 755
 				}
756 756
 				elseif ($input_def['label'] == 'backend_input') {
757
-					if ( !is_object($editedItem) ) {
757
+					if (!is_object($editedItem)) {
758 758
 						$input_def['type'] = 'hidden';
759 759
 					}
760 760
 					else {
761 761
 						$new_possible_value = array();
762
-						switch ( $editedItem->data_type) {
762
+						switch ($editedItem->data_type) {
763 763
 							case 'integer':
764 764
 								$new_possible_value[__('Checkbox', 'wpshop')] = 'checkbox';
765 765
 								$new_possible_value[__('Radio button', 'wpshop')] = 'radio';
@@ -767,7 +767,7 @@  discard block
 block discarded – undo
767 767
 								$new_possible_value[__('multiple-select', 'wpshop')] = 'multiple-select';
768 768
 								break;
769 769
 							case 'varchar':
770
-								switch ( $input_def['value'] ) {
770
+								switch ($input_def['value']) {
771 771
 									case 'hidden':
772 772
 										$new_possible_value[__('Hidden field', 'wpshop')] = 'hidden_field';
773 773
 										break;
@@ -795,8 +795,8 @@  discard block
 block discarded – undo
795 795
 				elseif ($input_def['label'] == 'frontend_input') {
796 796
 					$new_possible_value = array();
797 797
 
798
-					if ( is_object($editedItem) ) {
799
-						switch ( $editedItem->data_type) {
798
+					if (is_object($editedItem)) {
799
+						switch ($editedItem->data_type) {
800 800
 							case 'integer':
801 801
 								$new_possible_value[__('Checkbox', 'wpshop')] = 'checkbox';
802 802
 								$new_possible_value[__('Radio button', 'wpshop')] = 'radio';
@@ -804,7 +804,7 @@  discard block
 block discarded – undo
804 804
 								$new_possible_value[__('multiple-select', 'wpshop')] = 'multiple-select';
805 805
 								break;
806 806
 							case 'varchar':
807
-									switch ( $input_def['value'] ) {
807
+									switch ($input_def['value']) {
808 808
 										case 'hidden':
809 809
 											$new_possible_value[__('Hidden field', 'wpshop')] = 'hidden_field';
810 810
 										break;
@@ -842,10 +842,10 @@  discard block
 block discarded – undo
842 842
 
843 843
 					$input_def['possible_value'] = $new_possible_value;
844 844
 
845
-					if ( !empty($editedItem->frontend_input) ) {
846
-						switch ( $editedItem->frontend_input ) {
845
+					if (!empty($editedItem->frontend_input)) {
846
+						switch ($editedItem->frontend_input) {
847 847
 							case 'text':
848
-								switch ( $editedItem->data_type ) {
848
+								switch ($editedItem->data_type) {
849 849
 									case 'varchar':
850 850
 										$input_def['value'] = 'short_text';
851 851
 									break;
@@ -870,7 +870,7 @@  discard block
 block discarded – undo
870 870
 					}
871 871
 				}
872 872
 
873
-				if(is_object($editedItem) && (($input_def['label'] == 'code') || ($input_def['label'] == 'data_type') || ($input_def['label'] == 'entity_id'))){
873
+				if (is_object($editedItem) && (($input_def['label'] == 'code') || ($input_def['label'] == 'data_type') || ($input_def['label'] == 'entity_id'))) {
874 874
 					// $input_def['type'] = 'hidden';
875 875
 					$input_def['option'] = ' disabled="disabled" ';
876 876
 					$the_form_content_hidden .= '<input type="hidden" name="' . self::getDbTable() . '[' . $input_def['name'] . ']" value="' . $input_def['value'] . '" />';
@@ -881,16 +881,16 @@  discard block
 block discarded – undo
881 881
 				$input_def['value'] = str_replace("\\", "", $input_def['value']);
882 882
 
883 883
 				$the_input = wpshop_form::check_input_type($input_def, self::getDbTable());
884
-				if ( $input_def['label'] == 'default_value' ) {
885
-					if ( !empty($editedItem->frontend_input) ) {
886
-						switch ( $editedItem->frontend_input ) {
884
+				if ($input_def['label'] == 'default_value') {
885
+					if (!empty($editedItem->frontend_input)) {
886
+						switch ($editedItem->frontend_input) {
887 887
 							case 'text':
888 888
 								$input_def['type'] = 'text';
889
-								switch ( $editedItem->data_type ) {
889
+								switch ($editedItem->data_type) {
890 890
 									case 'datetime':
891
-										$the_input = wpshop_attributes::attribute_type_date_config( unserialize($input_def['value']) );
891
+										$the_input = wpshop_attributes::attribute_type_date_config(unserialize($input_def['value']));
892 892
 
893
-										$input_def['label'] = __('Date field configuration','wpshop');
893
+										$input_def['label'] = __('Date field configuration', 'wpshop');
894 894
 									break;
895 895
 									default:
896 896
 										$the_input = wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE);
@@ -907,7 +907,7 @@  discard block
 block discarded – undo
907 907
 							case 'multiple-select':
908 908
 							case 'radio':
909 909
 							case 'checkbox':
910
-								$input_def['label'] = __('Options list for attribute','wpshop') . '
910
+								$input_def['label'] = __('Options list for attribute', 'wpshop') . '
911 911
 <div class="alignright wpshop_change_select_data_type" >
912 912
 	+' . __('Change data type for this attribute', 'wpshop') . '
913 913
 </div>';
@@ -921,50 +921,50 @@  discard block
 block discarded – undo
921 921
 						}
922 922
 					}
923 923
 					else {
924
-						$input_def['type']='text';
924
+						$input_def['type'] = 'text';
925 925
 						$the_input = wpshop_form::check_input_type($input_def, self::getDbTable());
926 926
 					}
927 927
 				}
928
-				if( $input_def['label'] == '_unit_group_id') {
928
+				if ($input_def['label'] == '_unit_group_id') {
929 929
 					$the_input .= '<div id="wpshop_loader_input_group_unit"></div>';
930
-					$the_input .= '<a class="button-primary" href="#wpshop_unit_group_list" id="wpshop_attribute_group_unit_manager_opener" data-nonce="' . wp_create_nonce( 'load_unit_interface' ) . '">'.__('Manage group unit', 'wpshop').'</a>';
930
+					$the_input .= '<a class="button-primary" href="#wpshop_unit_group_list" id="wpshop_attribute_group_unit_manager_opener" data-nonce="' . wp_create_nonce('load_unit_interface') . '">' . __('Manage group unit', 'wpshop') . '</a>';
931 931
 				}
932 932
 
933
-				if( $input_def['label'] == '_default_unit') {
933
+				if ($input_def['label'] == '_default_unit') {
934 934
 					$the_input .= '<div id="wpshop_loader_input_unit"></div>';
935
-					$the_input .= '<a class="button-primary" href="#wpshop_unit_list" id="wpshop_attribute_unit_manager_opener" data-nonce="' . wp_create_nonce( 'load_unit_interface' ) . '">'.__('Manage units', 'wpshop').'</a>';
935
+					$the_input .= '<a class="button-primary" href="#wpshop_unit_list" id="wpshop_attribute_unit_manager_opener" data-nonce="' . wp_create_nonce('load_unit_interface') . '">' . __('Manage units', 'wpshop') . '</a>';
936 936
 					$the_input .= '<input type="hidden" name="input_wpshop_load_attribute_unit_list" id="input_wpshop_load_attribute_unit_list" value="' . wp_create_nonce("wpshop_load_attribute_unit_list") . '" />';
937 937
 					$the_input .= '<div id="wpshop_attribute_unit_manager" title="' . __('Unit management', 'wpshop') . '" class="wpshopHide" ><div class="loading_picture_container" id="product_chooser_picture" ><img src="' . WPSHOP_LOADING_ICON . '" alt="loading..." /></div></div>';
938 938
 				}
939 939
 
940 940
 
941
-				if($input_def['type'] != 'hidden'){
942
-					if ( ($input_def['label'] == 'entity_id') && is_object($editedItem) ) {
941
+				if ($input_def['type'] != 'hidden') {
942
+					if (($input_def['label'] == 'entity_id') && is_object($editedItem)) {
943 943
 						$the_input .= '<br/><span class="wpshop_duplicate_attribute" >' . __('Duplicate this attribute to . another entity', 'wpshop') . '</span>';
944 944
 					}
945 945
 					$input = '
946
-		<tr class="wpshop_' . self::currentPageCode . '_edition_table_line wpshop_' . self::currentPageCode . '_edition_table_line_'.$input_def['name'].'" >
947
-			<td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_label wpshop_' . self::currentPageCode . '_edition_table_field_label_'.$input_def['name'].'" ><label for="'.$input_def_id.'" >' . __($input_def['label'], 'wpshop') . '</label></td>
948
-			<td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_input wpshop_' . self::currentPageCode . '_edition_table_field_input_'.$input_def['name'].'" >' . $the_input . '</td>
946
+		<tr class="wpshop_' . self::currentPageCode . '_edition_table_line wpshop_' . self::currentPageCode . '_edition_table_line_' . $input_def['name'] . '" >
947
+			<td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_label wpshop_' . self::currentPageCode . '_edition_table_field_label_' . $input_def['name'] . '" ><label for="' . $input_def_id . '" >' . __($input_def['label'], 'wpshop') . '</label></td>
948
+			<td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_input wpshop_' . self::currentPageCode . '_edition_table_field_input_' . $input_def['name'] . '" >' . $the_input . '</td>
949 949
 		</tr>';
950
-					if ( (substr($input_def['label'], 0, 3) == 'is_') || (substr($input_def['label'], 0, 1) == '_') || in_array($input_def['label'], unserialize( WPSHOP_ATTRIBUTE_DEF_COLUMN_INTO_OPTIONS )) )
950
+					if ((substr($input_def['label'], 0, 3) == 'is_') || (substr($input_def['label'], 0, 1) == '_') || in_array($input_def['label'], unserialize(WPSHOP_ATTRIBUTE_DEF_COLUMN_INTO_OPTIONS)))
951 951
 						$the_form_option_content_list[$input_def['label']] = $input;
952 952
 					else {
953 953
 						$the_form_general_content .= $input;
954
-						if ( ($input_def['label'] == 'frontend_input') && !is_object($editedItem) ) {
954
+						if (($input_def['label'] == 'frontend_input') && !is_object($editedItem)) {
955 955
 
956
-							$the_input = wpshop_attributes_set::get_attribute_set_complete_list($current_entity_id,  self::getDbTable(), self::currentPageCode);
956
+							$the_input = wpshop_attributes_set::get_attribute_set_complete_list($current_entity_id, self::getDbTable(), self::currentPageCode);
957 957
 
958 958
 							$input = '
959 959
 		<tr class="wpshop_' . self::currentPageCode . '_edition_table_line wpshop_' . self::currentPageCode . '_edition_table_line_set_section" >
960
-			<td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_label wpshop_' . self::currentPageCode . '_edition_table_field_label_set_section" ><label for="'.self::currentPageCode.'_set_section" >' . __('Affect this new attribute to the set section', 'wpshop') . '</label></td>
960
+			<td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_label wpshop_' . self::currentPageCode . '_edition_table_field_label_set_section" ><label for="' . self::currentPageCode . '_set_section" >' . __('Affect this new attribute to the set section', 'wpshop') . '</label></td>
961 961
 			<td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_input wpshop_' . self::currentPageCode . '_edition_table_field_input_set_section" >' . $the_input . '</td>
962 962
 		</tr>';
963 963
 							$the_form_general_content .= $input;
964 964
 						}
965 965
 					}
966 966
 				}
967
-				else{
967
+				else {
968 968
 					$the_form_content_hidden .= '
969 969
 				' . $the_input;
970 970
 				}
@@ -980,17 +980,17 @@  discard block
 block discarded – undo
980 980
 		$section_content = $the_form_general_content;
981 981
 
982 982
 		ob_start();
983
-		include(WPSHOP_TEMPLATES_DIR.'admin/admin_box_section.tpl.php');
983
+		include(WPSHOP_TEMPLATES_DIR . 'admin/admin_box_section.tpl.php');
984 984
 		$the_form_general_content = ob_get_contents();
985 985
 		ob_end_clean();
986 986
 
987 987
 		/** It is attribute TVA, add a button to calcilate price in mass **/
988
-		if ( !empty($editedItem) && !empty($editedItem->code) && $editedItem->code == 'tx_tva' ) {
989
-			$the_form_general_content .= '<input type="button" data-nonce="' . wp_create_nonce( 'wps_update_products_prices' ) . '" id="wps_update_price_infos" value="' .__('Update all products price', 'wpshop').'" /> <img src="' .WPSHOP_LOADING_ICON. '" alt="" id="update_products_loader" /> <br/>';
990
-			$the_form_general_content .= __('If you have updated your VAT rates, save it and update your products price after', 'wpshop' );
988
+		if (!empty($editedItem) && !empty($editedItem->code) && $editedItem->code == 'tx_tva') {
989
+			$the_form_general_content .= '<input type="button" data-nonce="' . wp_create_nonce('wps_update_products_prices') . '" id="wps_update_price_infos" value="' . __('Update all products price', 'wpshop') . '" /> <img src="' . WPSHOP_LOADING_ICON . '" alt="" id="update_products_loader" /> <br/>';
990
+			$the_form_general_content .= __('If you have updated your VAT rates, save it and update your products price after', 'wpshop');
991 991
 		}
992 992
 		if (!empty($the_form_option_content_list)) {
993
-			$the_form_option_content_section='';
993
+			$the_form_option_content_section = '';
994 994
 			foreach ($attribute_options_group as $group_name => $group_content) {
995 995
 				$section_content = '';
996 996
 				foreach ($group_content as $group_code) {
@@ -999,23 +999,23 @@  discard block
 block discarded – undo
999 999
 						unset($the_form_option_content_list[$group_code]);
1000 1000
 					}
1001 1001
 				}
1002
-				$section_legend = __($group_name,'wpshop');
1002
+				$section_legend = __($group_name, 'wpshop');
1003 1003
 				$section_page_code = self::currentPageCode;
1004 1004
 
1005 1005
 				ob_start();
1006
-				include(WPSHOP_TEMPLATES_DIR.'admin/admin_box_section.tpl.php');
1006
+				include(WPSHOP_TEMPLATES_DIR . 'admin/admin_box_section.tpl.php');
1007 1007
 				$the_form_option_content_section .= ob_get_contents();
1008 1008
 				ob_end_clean();
1009 1009
 			}
1010 1010
 
1011 1011
 			/*	Check there are other attributes to display not in defined group	*/
1012 1012
 			if (!empty($the_form_option_content_list)) {
1013
-				$section_legend = __('General options','wpshop');
1013
+				$section_legend = __('General options', 'wpshop');
1014 1014
 				$section_content = implode('', $the_form_option_content_list);
1015 1015
 				$section_page_code = self::currentPageCode;
1016 1016
 
1017 1017
 				ob_start();
1018
-				include(WPSHOP_TEMPLATES_DIR.'admin/admin_box_section.tpl.php');
1018
+				include(WPSHOP_TEMPLATES_DIR . 'admin/admin_box_section.tpl.php');
1019 1019
 				$the_form_option_content = ob_get_contents();
1020 1020
 				ob_end_clean();
1021 1021
 
@@ -1025,17 +1025,17 @@  discard block
 block discarded – undo
1025 1025
 		}
1026 1026
 
1027 1027
 		/*	Default content for the current page	*/
1028
-		$bloc_list[self::currentPageCode]['main_info']['title']=__('Main informations', 'wpshop');
1028
+		$bloc_list[self::currentPageCode]['main_info']['title'] = __('Main informations', 'wpshop');
1029 1029
 		$bloc_list[self::currentPageCode]['main_info']['content'] = $the_form_general_content;
1030 1030
 
1031
-		$bloc_list[self::currentPageCode]['options']['title']=__('Options', 'wpshop');
1032
-		$bloc_list[self::currentPageCode]['options']['content']=$the_form_option_content;
1031
+		$bloc_list[self::currentPageCode]['options']['title'] = __('Options', 'wpshop');
1032
+		$bloc_list[self::currentPageCode]['options']['content'] = $the_form_option_content;
1033 1033
 
1034
-		$action = !empty( $_REQUEST['action'] ) ? sanitize_text_field( $_REQUEST['action' ] ) : '';
1034
+		$action = !empty($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : '';
1035 1035
 		$the_form = '
1036 1036
 <form name="' . self::getDbTable() . '_form" id="' . self::getDbTable() . '_form" method="post" action="#" >
1037
-	' . wpshop_form::form_input(self::getDbTable() . '_action', self::getDbTable() . '_action', (isset($action) && ($action != '') ? sanitize_text_field($action) : 'save') , 'hidden') . '
1038
-	' . wpshop_form::form_input(self::currentPageCode . '_form_has_modification', self::currentPageCode . '_form_has_modification', 'no' , 'hidden') . $the_form_content_hidden . wpshop_display::custom_page_output_builder($bloc_list, WPSHOP_ATTRIBUTE_EDITION_PAGE_LAYOUT) . '
1037
+	' . wpshop_form::form_input(self::getDbTable() . '_action', self::getDbTable() . '_action', (isset($action) && ($action != '') ? sanitize_text_field($action) : 'save'), 'hidden') . '
1038
+	' . wpshop_form::form_input(self::currentPageCode . '_form_has_modification', self::currentPageCode . '_form_has_modification', 'no', 'hidden') . $the_form_content_hidden . wpshop_display::custom_page_output_builder($bloc_list, WPSHOP_ATTRIBUTE_EDITION_PAGE_LAYOUT) . '
1039 1039
 </form>
1040 1040
 <div title="' . __('Change data type for selected attribute', 'wpshop') . '" id="wpshop_dialog_change_select_data_type" ><div id="wpshop_dialog_change_select_data_type_container" ></div></div>';
1041 1041
 		$input_def['possible_value'] = wpshop_entities::get_entities_list();
@@ -1053,7 +1053,7 @@  discard block
 block discarded – undo
1053 1053
 		$the_form .= '
1054 1054
 <script type="text/javascript" >
1055 1055
 	wpshop(document).ready(function(){
1056
-		wpshopMainInterface("'.self::getDbTable().'", "' . __('Are you sure you want to quit this page? You will loose all current modification', 'wpshop') . '", "' . __('Are you sure you want to delete this attributes group?', 'wpshop') . '");
1056
+		wpshopMainInterface("'.self::getDbTable() . '", "' . __('Are you sure you want to quit this page? You will loose all current modification', 'wpshop') . '", "' . __('Are you sure you want to delete this attributes group?', 'wpshop') . '");
1057 1057
 
1058 1058
 		jQuery("#wpshop_dialog_duplicate_attribute").dialog({
1059 1059
 			autoOpen: false,
@@ -1063,7 +1063,7 @@  discard block
 block discarded – undo
1063 1063
 			dialogClass: "wpshop_uidialog_box",
1064 1064
 			resizable: false,
1065 1065
 			buttons:{
1066
-				"'.__('Duplicate', 'wpshop').'": function(){
1066
+				"'.__('Duplicate', 'wpshop') . '": function(){
1067 1067
 					var data = {
1068 1068
 						action: "wpshop_duplicate_attribute",
1069 1069
 						wpshop_ajax_nonce: "' . wp_create_nonce("wpshop_duplicate_attribute") . '",
@@ -1079,7 +1079,7 @@  discard block
 block discarded – undo
1079 1079
 						}
1080 1080
 					}, "json");
1081 1081
 				},
1082
-				"'.__('Cancel', 'wpshop').'": function(){
1082
+				"'.__('Cancel', 'wpshop') . '": function(){
1083 1083
 					jQuery(this).dialog("close");
1084 1084
 					jQuery(".wpshop_duplicate_attribute_result").remove();
1085 1085
 				}
@@ -1097,7 +1097,7 @@  discard block
 block discarded – undo
1097 1097
 			dialogClass: "wpshop_uidialog_box",
1098 1098
 			resizable: false,
1099 1099
 			buttons:{
1100
-				"'.__('Change type', 'wpshop').'": function(){
1100
+				"'.__('Change type', 'wpshop') . '": function(){
1101 1101
 					var delete_entity = false;
1102 1102
 					if(jQuery("#delete_entity").is(":checked")){
1103 1103
 						var delete_entity = true;
@@ -1120,7 +1120,7 @@  discard block
 block discarded – undo
1120 1120
 						jQuery("#wpshop_dialog_change_select_data_type").dialog("close");
1121 1121
 					}, "json");
1122 1122
 				},
1123
-				"'.__('Cancel', 'wpshop').'": function(){
1123
+				"'.__('Cancel', 'wpshop') . '": function(){
1124 1124
 					jQuery(this).dialog("close");
1125 1125
 				}
1126 1126
 			}
@@ -1160,7 +1160,7 @@  discard block
 block discarded – undo
1160 1160
 			change_unit_list();
1161 1161
 		});';
1162 1162
 
1163
-		if ( !is_object($editedItem) )  {
1163
+		if (!is_object($editedItem)) {
1164 1164
 			$the_form .= '
1165 1165
 		jQuery("#wpshop_attributes_edition_table_field_id_frontend_input").change(function(){
1166 1166
 			jQuery(".wpshop_attributes_edition_table_field_input_default_value").html(jQuery("#wpshopLoadingPicture").html());
@@ -1243,23 +1243,23 @@  discard block
 block discarded – undo
1243 1243
 	 *
1244 1244
 	 *	@return string $currentPageButton The html output code with the different button to add to the interface
1245 1245
 	 */
1246
-	function getPageFormButton($element_id = 0){
1246
+	function getPageFormButton($element_id = 0) {
1247 1247
 		$action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : 'add';
1248 1248
 		$currentPageButton = '';
1249 1249
 
1250 1250
 		 //$currentPageButton .= '<h2 class="cancelButton alignleft" ><a href="' . admin_url('edit.php?post_type='.WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES.'&amp;page=' . self::getListingSlug()) . '" class="button add-new-h2" >' . __('Back', 'wpshop') . '</a></h2>';
1251 1251
 
1252
-		if(($action == 'add') && (current_user_can('wpshop_add_attributes')))
1252
+		if (($action == 'add') && (current_user_can('wpshop_add_attributes')))
1253 1253
 			$currentPageButton .= '<input type="button" class="button-primary" id="add" name="add" value="' . __('Add', 'wpshop') . '" />';
1254 1254
 
1255
-		elseif(current_user_can('wpshop_edit_attributes'))
1255
+		elseif (current_user_can('wpshop_edit_attributes'))
1256 1256
 		$currentPageButton .= '<input type="button" class="button-primary" id="save" name="save" value="' . __('Save', 'wpshop') . '" />';
1257 1257
 
1258 1258
 		$attribute_undeletable = unserialize(WPSHOP_ATTRIBUTE_UNDELETABLE);
1259 1259
 		$attribute = self::getElement($element_id, "'valid', 'moderated', 'notused'", 'id');
1260
-		$attribute_code = !empty($attribute->code)?$attribute->code:'';
1261
-		if(current_user_can('wpshop_delete_attributes') && ($action != 'add') && !in_array($attribute_code, $attribute_undeletable))
1262
-			$currentPageButton .= '<input type="button" class="button-secondary wpshop_delete_element_button wpshop_delete_element_button_'.self::currentPageCode.'" id="delete" name="delete" value="' . __('Delete', 'wpshop') . '" />';
1260
+		$attribute_code = !empty($attribute->code) ? $attribute->code : '';
1261
+		if (current_user_can('wpshop_delete_attributes') && ($action != 'add') && !in_array($attribute_code, $attribute_undeletable))
1262
+			$currentPageButton .= '<input type="button" class="button-secondary wpshop_delete_element_button wpshop_delete_element_button_' . self::currentPageCode . '" id="delete" name="delete" value="' . __('Delete', 'wpshop') . '" />';
1263 1263
 
1264 1264
 		return $currentPageButton;
1265 1265
 	}
@@ -1273,22 +1273,22 @@  discard block
 block discarded – undo
1273 1273
 	 *
1274 1274
 	 *	@return object $element_list A wordpress database object containing the attribute list
1275 1275
 	 */
1276
-	public static function getElement($element_id = '', $element_status = "'valid', 'moderated', 'notused'", $field_to_search = 'id', $list = false){
1276
+	public static function getElement($element_id = '', $element_status = "'valid', 'moderated', 'notused'", $field_to_search = 'id', $list = false) {
1277 1277
 
1278 1278
 		global $wpdb;
1279 1279
 		$element_list = array();
1280 1280
 		$moreQuery = "";
1281
-		$moreArgs = array( 1, );
1281
+		$moreArgs = array(1,);
1282 1282
 
1283
-		$orderby = !empty( $_REQUEST['orderby'] ) ? sanitize_text_field( $_REQUEST['orderby'] ) : '';
1284
-		$order = !empty( $_REQUEST['order'] ) ? sanitize_text_field( $_REQUEST['order'] ) : '';
1283
+		$orderby = !empty($_REQUEST['orderby']) ? sanitize_text_field($_REQUEST['orderby']) : '';
1284
+		$order = !empty($_REQUEST['order']) ? sanitize_text_field($_REQUEST['order']) : '';
1285 1285
 
1286
-		if($element_id != ''){
1286
+		if ($element_id != '') {
1287 1287
 			$moreQuery .= "
1288 1288
 					AND CURRENT_ELEMENT." . $field_to_search . " = %s ";
1289 1289
 			$moreArgs[] = $element_id;
1290 1290
 		}
1291
-		if(!empty($orderby) && !empty($order)){
1291
+		if (!empty($orderby) && !empty($order)) {
1292 1292
 			$moreQuery .= "
1293 1293
 					ORDER BY " . $orderby . "  " . $order;
1294 1294
 		}
@@ -1297,15 +1297,15 @@  discard block
 block discarded – undo
1297 1297
 			"SELECT CURRENT_ELEMENT.*, ENTITIES.post_name as entity
1298 1298
 			FROM " . self::getDbTable() . " AS CURRENT_ELEMENT
1299 1299
 			INNER JOIN {$wpdb->posts} AS ENTITIES ON (ENTITIES.ID = CURRENT_ELEMENT.entity_id)
1300
-			WHERE %d AND CURRENT_ELEMENT.status IN (".$element_status.") " . $moreQuery,
1300
+			WHERE %d AND CURRENT_ELEMENT.status IN (" . $element_status . ") " . $moreQuery,
1301 1301
 			$moreArgs
1302 1302
 		);
1303 1303
 
1304 1304
 		/*	Get the query result regarding on the function parameters. If there must be only one result or a collection	*/
1305
-		if(($element_id == '') || $list){
1305
+		if (($element_id == '') || $list) {
1306 1306
 			$element_list = $wpdb->get_results($query);
1307 1307
 		}
1308
-		else{
1308
+		else {
1309 1309
 			$element_list = $wpdb->get_row($query);
1310 1310
 		}
1311 1311
 
@@ -1327,8 +1327,8 @@  discard block
 block discarded – undo
1327 1327
 		$user_id = function_exists('is_user_logged_in') && is_user_logged_in() ? get_current_user_id() : '0';
1328 1328
 		$sent_attribute_list = array();
1329 1329
 
1330
-		if ( !empty($attributeToSet) ) {
1331
-			$attributeToSet = apply_filters( 'save_attribute_for_entity', $attributeToSet, $entityTypeId, $entityId );
1330
+		if (!empty($attributeToSet)) {
1331
+			$attributeToSet = apply_filters('save_attribute_for_entity', $attributeToSet, $entityTypeId, $entityId);
1332 1332
 			$old_attribute_to_set = $attributeToSet;
1333 1333
 			$attribute_setted = array();
1334 1334
 			foreach ($attributeToSet as $attributeType => $attributeTypeDetails) {
@@ -1337,39 +1337,39 @@  discard block
 block discarded – undo
1337 1337
 					'entity_id' => $entityId,
1338 1338
 					'entity_type_id' => $entityTypeId
1339 1339
 				);
1340
-				if ( WPSHOP_ATTRIBUTE_VALUE_PER_USER ) {
1340
+				if (WPSHOP_ATTRIBUTE_VALUE_PER_USER) {
1341 1341
 					$delete_current_attribute_values_params['user_id'] = $user_id;
1342 1342
 				}
1343 1343
 
1344
-				if(!empty($attributeTypeDetails) && is_array($attributeTypeDetails)) {
1345
-					$attributeTypeDetails = apply_filters( "save_attribute_for_entity_{$attributeType}", $attributeTypeDetails, $entityTypeId, $entityId );
1346
-					foreach($attributeTypeDetails as $attribute_code => $attributeValue) {
1347
-						$attributeValue = apply_filters( "save_attribute_for_entity_{$attributeType}_{$attribute_code}", apply_filters( "save_attribute_for_entity__{$attribute_code}", $attributeValue, $entityTypeId, $entityId ), $entityTypeId, $entityId );
1344
+				if (!empty($attributeTypeDetails) && is_array($attributeTypeDetails)) {
1345
+					$attributeTypeDetails = apply_filters("save_attribute_for_entity_{$attributeType}", $attributeTypeDetails, $entityTypeId, $entityId);
1346
+					foreach ($attributeTypeDetails as $attribute_code => $attributeValue) {
1347
+						$attributeValue = apply_filters("save_attribute_for_entity_{$attributeType}_{$attribute_code}", apply_filters("save_attribute_for_entity__{$attribute_code}", $attributeValue, $entityTypeId, $entityId), $entityTypeId, $entityId);
1348 1348
 						$old_attribute_value = $attributeValue;
1349 1349
 
1350
-						if ( $attributeType == 'decimal' ) {
1350
+						if ($attributeType == 'decimal') {
1351 1351
 							$attributeValue = str_replace(',', '.', $attributeValue);
1352 1352
 						}
1353
-						if ( ($attributeType == 'integer') && !is_array($attributeValue) ) {
1353
+						if (($attributeType == 'integer') && !is_array($attributeValue)) {
1354 1354
 							$attributeValue = (int)$attributeValue;
1355 1355
 						}
1356 1356
 						$more_query_params_values = array();
1357
-						if($attribute_code != 'unit') {
1357
+						if ($attribute_code != 'unit') {
1358 1358
 
1359 1359
 							$unit_id = 0;
1360
-							if(isset($attributeTypeDetails['unit'][$attribute_code])){
1360
+							if (isset($attributeTypeDetails['unit'][$attribute_code])) {
1361 1361
 								$unit_id = $attributeTypeDetails['unit'][$attribute_code];
1362 1362
 							}
1363 1363
 
1364 1364
 							$currentAttribute = self::getElement($attribute_code, "'valid'", 'code');
1365
-							if( !empty($currentAttribute) ){
1365
+							if (!empty($currentAttribute)) {
1366 1366
 								$sent_attribute_list[] = $currentAttribute->id;
1367 1367
 
1368 1368
 								/*	Enregistrement de la valeur actuelle de l'attribut dans la table d'historique si l'option historique est activee sur l'attribut courant	*/
1369
-								if (  $currentAttribute->is_historisable == 'yes') {
1369
+								if ($currentAttribute->is_historisable == 'yes') {
1370 1370
 									$query = $wpdb->prepare("SELECT * FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType . " WHERE entity_type_id = %d AND attribute_id = %d AND entity_id = %d", $entityTypeId, $currentAttribute->id, $entityId);
1371 1371
 									$attribute_histo = $wpdb->get_results($query);
1372
-									if(!empty($attribute_histo)){
1372
+									if (!empty($attribute_histo)) {
1373 1373
 										$attribute_histo_content['status'] = 'valid';
1374 1374
 										$attribute_histo_content['creation_date'] = current_time('mysql', 0);
1375 1375
 										$attribute_histo_content['creation_date_value'] = $attribute_histo[0]->creation_date_value;
@@ -1387,8 +1387,8 @@  discard block
 block discarded – undo
1387 1387
 								}
1388 1388
 								$attributeValue = str_replace("\\", "", $attributeValue);
1389 1389
 
1390
-								if ( empty($from) || (!empty($attributeValue)) ) {
1391
-									$wpdb->delete(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX.$attributeType, array_merge($delete_current_attribute_values_params, array('attribute_id' => $currentAttribute->id)));
1390
+								if (empty($from) || (!empty($attributeValue))) {
1391
+									$wpdb->delete(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType, array_merge($delete_current_attribute_values_params, array('attribute_id' => $currentAttribute->id)));
1392 1392
 
1393 1393
 									/**	Insertion de la nouvelle valeur de l'attribut dans la base	*/
1394 1394
 									$query_params = array(
@@ -1402,60 +1402,60 @@  discard block
 block discarded – undo
1402 1402
 										'creation_date_value' => current_time('mysql', 0)
1403 1403
 									);
1404 1404
 									/**	Si l'attribut courant est contenu dans un tableau (exemple: select multiple) on lit tout le tableau et on enregistre chaque valeur separement	*/
1405
-									if(is_array($attributeValue)){
1406
-										foreach($attributeValue as $a){
1407
-											$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX.$attributeType, array_merge($query_params, array('value' => $a)));
1405
+									if (is_array($attributeValue)) {
1406
+										foreach ($attributeValue as $a) {
1407
+											$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType, array_merge($query_params, array('value' => $a)));
1408 1408
 										}
1409 1409
 									}
1410
-									else{
1411
-										$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX.$attributeType, array_merge($query_params, array('value' => $attributeValue)));
1412
-										\eoxia\log_class::exec( 'wpshop_attributes', 'wpshop_attributes', __( 'Add the attribute : ' . $currentAttribute->code . ' with value : ' . $attributeValue , 'wpshop' ), array( 'object_id' 	=> $entityId ), 0 );
1410
+									else {
1411
+										$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType, array_merge($query_params, array('value' => $attributeValue)));
1412
+										\eoxia\log_class::exec('wpshop_attributes', 'wpshop_attributes', __('Add the attribute : ' . $currentAttribute->code . ' with value : ' . $attributeValue, 'wpshop'), array('object_id' 	=> $entityId), 0);
1413 1413
 									}
1414 1414
 
1415 1415
 									/**	Dans le cas ou l'attribut courant est utilise dans l'interface permettant de trier les produits (option de l'attribut) on defini une meta specifique	*/
1416
-									if ( ( ($currentAttribute->is_used_for_sort_by == 'yes') || ($currentAttribute->is_searchable == 'yes'))  || ( $currentAttribute->is_filterable == 'yes') && !empty($attributeValue) ) :
1417
-										update_post_meta($entityId, '_'.$attribute_code, $attributeValue);
1416
+									if ((($currentAttribute->is_used_for_sort_by == 'yes') || ($currentAttribute->is_searchable == 'yes')) || ($currentAttribute->is_filterable == 'yes') && !empty($attributeValue)) :
1417
+										update_post_meta($entityId, '_' . $attribute_code, $attributeValue);
1418 1418
 									endif;
1419 1419
 
1420 1420
 									/**	Enregistrement de toutes les valeurs des attributs dans une meta du produit	*/
1421
-									$attribute_option = (!empty($_POST['attribute_option'][$attribute_code])) ? (array) $_POST['attribute_option'][$attribute_code] : null;
1421
+									$attribute_option = (!empty($_POST['attribute_option'][$attribute_code])) ? (array)$_POST['attribute_option'][$attribute_code] : null;
1422 1422
 									if (isset($attribute_option)) {
1423 1423
 										$value = self::get_attribute_type_select_option_info($attributeTypeDetails[$attribute_code], 'value');
1424 1424
 										if (strtolower($value) == 'yes') :
1425
-											update_post_meta($entityId, 'attribute_option_'.$attribute_code, $attribute_option);
1425
+											update_post_meta($entityId, 'attribute_option_' . $attribute_code, $attribute_option);
1426 1426
 										else :
1427
-											delete_post_meta($entityId, 'attribute_option_'.$attribute_code);
1427
+											delete_post_meta($entityId, 'attribute_option_' . $attribute_code);
1428 1428
 										endif;
1429 1429
 									}
1430 1430
 								}
1431 1431
 							}
1432 1432
 						}
1433
-						do_action( "saved_attribute_for_entity_{$attributeType}_{$attribute_code}", $attributeValue, $old_attribute_value, $entityTypeId, $entityId );
1434
-						do_action( "saved_attribute_for_entity__{$attribute_code}", $attributeValue, $old_attribute_value, $entityTypeId, $entityId );
1435
-						if ( isset( $attribute_setted[$attributeType][$attribute_code] ) ) {
1436
-							if( is_array( $attribute_setted[$attributeType][$attribute_code] )) {
1433
+						do_action("saved_attribute_for_entity_{$attributeType}_{$attribute_code}", $attributeValue, $old_attribute_value, $entityTypeId, $entityId);
1434
+						do_action("saved_attribute_for_entity__{$attribute_code}", $attributeValue, $old_attribute_value, $entityTypeId, $entityId);
1435
+						if (isset($attribute_setted[$attributeType][$attribute_code])) {
1436
+							if (is_array($attribute_setted[$attributeType][$attribute_code])) {
1437 1437
 								$attribute_setted[$attributeType][$attribute_code][] = $attributeValue;
1438 1438
 							} else {
1439
-								$attribute_setted[$attributeType][$attribute_code] = array( $attribute_setted[$attributeType][$attribute_code], $attributeValue );
1439
+								$attribute_setted[$attributeType][$attribute_code] = array($attribute_setted[$attributeType][$attribute_code], $attributeValue);
1440 1440
 							}
1441 1441
 						} else {
1442 1442
 							$attribute_setted[$attributeType][$attribute_code] = $attributeValue;
1443 1443
 						}
1444 1444
 					}
1445 1445
 
1446
-					if ( empty($from) ) {
1447
-						$query = $wpdb->prepare("SELECT value_id FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX.$attributeType . " WHERE attribute_id NOT IN ('" . implode("', '", $sent_attribute_list) . "') AND entity_id = %d AND entity_type_id = %d", $entityId, $entityTypeId);
1446
+					if (empty($from)) {
1447
+						$query = $wpdb->prepare("SELECT value_id FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType . " WHERE attribute_id NOT IN ('" . implode("', '", $sent_attribute_list) . "') AND entity_id = %d AND entity_type_id = %d", $entityId, $entityTypeId);
1448 1448
 						$attr_to_delete = $wpdb->get_results($query);
1449
-						if(!empty($attr_to_delete)){
1449
+						if (!empty($attr_to_delete)) {
1450 1450
 							foreach ($attr_to_delete as $value) {
1451
-								$wpdb->delete(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX.$attributeType, array_merge($delete_current_attribute_values_params, array('value_id' => $value->value_id)));
1452
-								\eoxia\log_class::exec( 'wpshop_attributes', 'wpshop_attributes', __( 'Remove the attribute : ' . $value->value_id, 'wpshop' ), array( 'object_id' 	=> $entityId ), 0 );
1451
+								$wpdb->delete(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attributeType, array_merge($delete_current_attribute_values_params, array('value_id' => $value->value_id)));
1452
+								\eoxia\log_class::exec('wpshop_attributes', 'wpshop_attributes', __('Remove the attribute : ' . $value->value_id, 'wpshop'), array('object_id' 	=> $entityId), 0);
1453 1453
 							}
1454 1454
 						}
1455 1455
 					}
1456 1456
 				}
1457 1457
 			}
1458
-			do_action( "saved_attribute_for_entity", $attribute_setted, $old_attribute_to_set, $entityTypeId, $entityId );
1458
+			do_action("saved_attribute_for_entity", $attribute_setted, $old_attribute_to_set, $entityTypeId, $entityId);
1459 1459
 		}
1460 1460
 	}
1461 1461
 
@@ -1475,7 +1475,7 @@  discard block
 block discarded – undo
1475 1475
 
1476 1476
 		$query_params = "";
1477 1477
 		$query_params_values = array($attributeId, $entityTypeId, $entityId);
1478
-		if(WPSHOP_ATTRIBUTE_VALUE_PER_USER && (isset($atribute_params['intrinsic']) && ($atribute_params['intrinsic'] != 'yes'))){
1478
+		if (WPSHOP_ATTRIBUTE_VALUE_PER_USER && (isset($atribute_params['intrinsic']) && ($atribute_params['intrinsic'] != 'yes'))) {
1479 1479
 			$query_params = "
1480 1480
 				AND ATTR_VAL.user_id = %d";
1481 1481
 			$query_params_values[] = get_current_user_id();
@@ -1491,20 +1491,20 @@  discard block
 block discarded – undo
1491 1491
 		);
1492 1492
 		$attributeValue = $wpdb->get_results($query);
1493 1493
 
1494
-		if ( ( (count($attributeValue) <= 1 ) && !empty($attributeValue[0]) ) && ( empty($atribute_params['frontend_input']) || ($atribute_params['frontend_input'] != 'multiple-select') )) {
1494
+		if (((count($attributeValue) <= 1) && !empty($attributeValue[0])) && (empty($atribute_params['frontend_input']) || ($atribute_params['frontend_input'] != 'multiple-select'))) {
1495 1495
 			$attributeValue = $attributeValue[0];
1496 1496
 		}
1497
-		else{
1497
+		else {
1498 1498
 			$entity_meta = get_post_meta($entityId, WPSHOP_PRODUCT_ATTRIBUTE_META_KEY, true);
1499
-			if ( !empty($entity_meta) ) {
1499
+			if (!empty($entity_meta)) {
1500 1500
 				$query = $wpdb->prepare("SELECT code FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE id = %d AND entity_id = %d ", $attributeId, $entityTypeId);
1501 1501
 				$attribute_code = $wpdb->get_var($query);
1502 1502
 				$attributeValue = !empty($entity_meta[$attribute_code]) ? $entity_meta[$attribute_code] : null;
1503 1503
 			}
1504
-			if ( is_array($attributeValue) ) {
1504
+			if (is_array($attributeValue)) {
1505 1505
 				$tmp_array = array();
1506
-				if ( !empty($attributeValue) ) {
1507
-					foreach ( $attributeValue as $att ) {
1506
+				if (!empty($attributeValue)) {
1507
+					foreach ($attributeValue as $att) {
1508 1508
 						$obj = new stdClass();
1509 1509
 						$obj->value = $att;
1510 1510
 						$obj->unit_id = 0;
@@ -1535,9 +1535,9 @@  discard block
 block discarded – undo
1535 1535
 		$elements = array();
1536 1536
 		$elementsWithAttributeAndValues = self::get_attribute_list_for_item($entityId, $elementId, $language);
1537 1537
 
1538
-		foreach ( $elementsWithAttributeAndValues as $elementDefinition ) {
1538
+		foreach ($elementsWithAttributeAndValues as $elementDefinition) {
1539 1539
 			$arrayKey = $elementDefinition->attribute_id;
1540
-			if ( $keyForArray == 'code' ) {
1540
+			if ($keyForArray == 'code') {
1541 1541
 				$arrayKey = $elementDefinition->attribute_code;
1542 1542
 			}
1543 1543
 			$elements[$elementId][$elementDefinition->attribute_set_section_name]['code'] = $elementDefinition->attribute_set_section_code;
@@ -1547,7 +1547,7 @@  discard block
 block discarded – undo
1547 1547
 			$elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['backend_table'] = $elementDefinition->backend_table;
1548 1548
 			$elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['backend_input'] = $elementDefinition->backend_input;
1549 1549
 			$elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['frontend_input'] = $elementDefinition->frontend_input;
1550
-			$elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['frontend_label'] = __( $elementDefinition->frontend_label, 'wpshop' );
1550
+			$elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['frontend_label'] = __($elementDefinition->frontend_label, 'wpshop');
1551 1551
 			$elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['attribute_code'] = $elementDefinition->attribute_code;
1552 1552
 			$elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['data_type_to_use'] = $elementDefinition->data_type_to_use;
1553 1553
 			$elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['is_visible_in_front'] = $elementDefinition->is_visible_in_front;
@@ -1557,29 +1557,29 @@  discard block
 block discarded – undo
1557 1557
 			$attributeValueField = 'attribute_value_' . $elementDefinition->data_type;
1558 1558
 
1559 1559
 			// Manage the value differently if it is an array or not
1560
-			if ( !empty($elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value']) ) {
1560
+			if (!empty($elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'])) {
1561 1561
 				if (is_array($elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'])) {
1562 1562
 					$elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'][] = $elementDefinition->$attributeValueField;
1563 1563
 				}
1564 1564
 				else {
1565
-					$elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'] = array($elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'],$elementDefinition->$attributeValueField);
1565
+					$elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'] = array($elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'], $elementDefinition->$attributeValueField);
1566 1566
 				}
1567 1567
 			}
1568 1568
 			else {
1569 1569
 				$elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'] = $elementDefinition->$attributeValueField;
1570 1570
 			}
1571 1571
 
1572
-			if ( $elementDefinition->backend_input == 'multiple-select' ) {
1572
+			if ($elementDefinition->backend_input == 'multiple-select') {
1573 1573
 				$elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['select_value'] = self::get_attribute_type_select_option_info($attributeValueField, 'value');
1574 1574
 			}
1575 1575
 
1576 1576
 			$attributeUnitField = 'attribute_unit_' . $elementDefinition->data_type;
1577
-			$elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['unit'] = __( $elementDefinition->$attributeUnitField, 'wpshop' );
1578
-			if( !empty($elementDefinition->is_requiring_unit ) && ( $elementDefinition->is_requiring_unit == 'yes' ) && empty( $elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['unit'] ) ) {
1577
+			$elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['unit'] = __($elementDefinition->$attributeUnitField, 'wpshop');
1578
+			if (!empty($elementDefinition->is_requiring_unit) && ($elementDefinition->is_requiring_unit == 'yes') && empty($elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['unit'])) {
1579 1579
 				$unit = '';
1580
-				$query = $wpdb->prepare( 'SELECT unit FROM '. WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id = %d AND status = %s', $elementDefinition->_default_unit, 'valid');
1581
-				$unit = $wpdb->get_var( $query );
1582
-				$elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['unit'] = __( $unit, 'wpshop' );
1580
+				$query = $wpdb->prepare('SELECT unit FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id = %d AND status = %s', $elementDefinition->_default_unit, 'valid');
1581
+				$unit = $wpdb->get_var($query);
1582
+				$elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['unit'] = __($unit, 'wpshop');
1583 1583
 			}
1584 1584
 
1585 1585
 		}
@@ -1591,7 +1591,7 @@  discard block
 block discarded – undo
1591 1591
 		$elementsWithAttributeAndValues = array();
1592 1592
 		$moreQuery = "";
1593 1593
 
1594
-		$entity_type = empty($defined_entity_type) ? get_post_type( $elementId ) : $defined_entity_type;
1594
+		$entity_type = empty($defined_entity_type) ? get_post_type($elementId) : $defined_entity_type;
1595 1595
 
1596 1596
 		$query = $wpdb->prepare(
1597 1597
 				"SELECT POST_META.*,
@@ -1640,23 +1640,23 @@  discard block
 block discarded – undo
1640 1640
 	 *
1641 1641
 	 * @return boolean The result to know if the element has to be displayed on frontend
1642 1642
 	 */
1643
-	public static function check_attribute_display( $attribute_main_config, $attribute_custom_config, $attribute_or_set, $attribute_code, $output_type) {
1644
-		if ( $attribute_main_config === 'yes' ) {
1643
+	public static function check_attribute_display($attribute_main_config, $attribute_custom_config, $attribute_or_set, $attribute_code, $output_type) {
1644
+		if ($attribute_main_config === 'yes') {
1645 1645
 			$attribute_output = true;
1646
-			if ( ( is_array($attribute_custom_config) && in_array($attribute_or_set, array('attribute', 'attribute_set_section', 'product_action_button')) && !empty($attribute_custom_config[$attribute_or_set]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) && $attribute_custom_config[$attribute_or_set][$attribute_code][$output_type] == 'yes' )
1647
-				 || empty($attribute_custom_config) ) {
1646
+			if ((is_array($attribute_custom_config) && in_array($attribute_or_set, array('attribute', 'attribute_set_section', 'product_action_button')) && !empty($attribute_custom_config[$attribute_or_set]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) && $attribute_custom_config[$attribute_or_set][$attribute_code][$output_type] == 'yes')
1647
+				 || empty($attribute_custom_config)) {
1648 1648
 				$attribute_output = true;
1649 1649
 			}
1650
-			else if ( empty($attribute_custom_config[$attribute_or_set][$attribute_code]) || empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) || (!empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) && ( $attribute_custom_config[$attribute_or_set][$attribute_code][$output_type] == 'no')) )  {
1650
+			else if (empty($attribute_custom_config[$attribute_or_set][$attribute_code]) || empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) || (!empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) && ($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type] == 'no'))) {
1651 1651
 				$attribute_output = false;
1652 1652
 			}
1653 1653
 		}
1654
-		elseif ( $attribute_main_config === 'no' ) {
1654
+		elseif ($attribute_main_config === 'no') {
1655 1655
 			$attribute_output = false;
1656
-			if ( empty($attribute_custom_config[$attribute_or_set]) || empty($attribute_custom_config[$attribute_or_set][$attribute_code]) ) {
1656
+			if (empty($attribute_custom_config[$attribute_or_set]) || empty($attribute_custom_config[$attribute_or_set][$attribute_code])) {
1657 1657
 				$attribute_output = false;
1658 1658
 			}
1659
-			else if ( !empty($attribute_custom_config) && !empty($attribute_custom_config[$attribute_or_set]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) && ( $attribute_custom_config[$attribute_or_set][$attribute_code][$output_type] == 'yes') )  {
1659
+			else if (!empty($attribute_custom_config) && !empty($attribute_custom_config[$attribute_or_set]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) && ($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type] == 'yes')) {
1660 1660
 				$attribute_output = true;
1661 1661
 			}
1662 1662
 		}
@@ -1673,22 +1673,22 @@  discard block
 block discarded – undo
1673 1673
 		global $wpdb;
1674 1674
 		global $wp_query;
1675 1675
 
1676
-		$attribute = self::getElement( $atts['attid'] );
1677
-		if(empty($atts['pid'])) $atts['pid'] = $wp_query->posts[0]->ID;
1678
-		$attribute_main_config = ( empty($atts['output_type']) || ($atts['output_type'] == 'complete_sheet') ) ? $attribute->is_visible_in_front : $attribute->is_visible_in_front_listing;
1679
-		$output_type = ( empty($atts['output_type']) || ($atts['output_type'] == 'complete_sheet') ) ? 'complete_sheet' : 'mini_output';
1676
+		$attribute = self::getElement($atts['attid']);
1677
+		if (empty($atts['pid'])) $atts['pid'] = $wp_query->posts[0]->ID;
1678
+		$attribute_main_config = (empty($atts['output_type']) || ($atts['output_type'] == 'complete_sheet')) ? $attribute->is_visible_in_front : $attribute->is_visible_in_front_listing;
1679
+		$output_type = (empty($atts['output_type']) || ($atts['output_type'] == 'complete_sheet')) ? 'complete_sheet' : 'mini_output';
1680 1680
 		$product_attribute_custom_config = get_post_meta($atts['pid'], WPSHOP_PRODUCT_FRONT_DISPLAY_CONF, true);
1681
-		$display_attribute_value = wpshop_attributes::check_attribute_display( $attribute_main_config, $product_attribute_custom_config, 'attribute', $attribute->code, $output_type);
1681
+		$display_attribute_value = wpshop_attributes::check_attribute_display($attribute_main_config, $product_attribute_custom_config, 'attribute', $attribute->code, $output_type);
1682 1682
 
1683
-		if ( !empty( $attribute->data_type ) ) {
1683
+		if (!empty($attribute->data_type)) {
1684 1684
 			$attributeDefinition['unit'] = '';
1685 1685
 
1686 1686
 			$has_value = false;
1687
-			$query = $wpdb->prepare("SELECT value FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attribute->data_type . " WHERE entity_id=%s AND attribute_id=%d", $atts['pid'], $atts['attid'] );
1688
-			if ( in_array($attribute->backend_input, array('multiple-select', 'checkbox')) ) {
1687
+			$query = $wpdb->prepare("SELECT value FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX . $attribute->data_type . " WHERE entity_id=%s AND attribute_id=%d", $atts['pid'], $atts['attid']);
1688
+			if (in_array($attribute->backend_input, array('multiple-select', 'checkbox'))) {
1689 1689
 				$list_of_value = $wpdb->get_results($query);
1690
-				if ( !empty($list_of_value) ) {
1691
-					foreach ( $list_of_value as $value ) {
1690
+				if (!empty($list_of_value)) {
1691
+					foreach ($list_of_value as $value) {
1692 1692
 						$data[] = $value->value;
1693 1693
 					}
1694 1694
 					$has_value = true;
@@ -1696,10 +1696,10 @@  discard block
 block discarded – undo
1696 1696
 			}
1697 1697
 			else {
1698 1698
 				$data = $wpdb->get_var($query);
1699
-				if ( !empty($data) ) {
1699
+				if (!empty($data)) {
1700 1700
 					$has_value = true;
1701 1701
 				}
1702
-				elseif( !empty($attribute->default_value) ) {
1702
+				elseif (!empty($attribute->default_value)) {
1703 1703
 					$has_value = true;
1704 1704
 					$data = $attribute->default_value;
1705 1705
 				}
@@ -1711,7 +1711,7 @@  discard block
 block discarded – undo
1711 1711
 			$attributeDefinition['is_requiring_unit'] = $attribute->is_requiring_unit;
1712 1712
 			$attributeDefinition['backend_input'] = $attribute->backend_input;
1713 1713
 			$attributeDefinition['data_type_to_use'] = $attribute->data_type_to_use;
1714
-			$attribute_display = wpshop_attributes::wps_attribute_values_display( $attributeDefinition );
1714
+			$attribute_display = wpshop_attributes::wps_attribute_values_display($attributeDefinition);
1715 1715
 			$attribute_value = $attribute_display[0];
1716 1716
 			$attributeDefinition['value'] = $attribute_display[1];
1717 1717
 			$attribute_unit_list = $attribute_display[2];
@@ -1731,13 +1731,13 @@  discard block
 block discarded – undo
1731 1731
 	 * @param array $specific_argument Optionnal The different parameters used for filter output
1732 1732
 	 * @return array The definition for the field used to display an attribute
1733 1733
 	 */
1734
-	public static function get_attribute_field_definition( $attribute, $attribute_value = '', $specific_argument = array() ) {
1734
+	public static function get_attribute_field_definition($attribute, $attribute_value = '', $specific_argument = array()) {
1735 1735
 		global $wpdb;
1736 1736
 		$wpshop_price_attributes = unserialize(WPSHOP_ATTRIBUTE_PRICES);
1737 1737
 		$wpshop_weight_attributes = unserialize(WPSHOP_ATTRIBUTE_WEIGHT);
1738 1738
 		$input_def = array();
1739 1739
 		$input_def['option'] = $input_def['field_container_class'] = '';
1740
-		$attributeInputDomain = (!empty($specific_argument['field_custom_name_prefix']) || (!empty($specific_argument['field_custom_name_prefix']) && ($specific_argument['field_custom_name_prefix'] == 'empty')) ) ? $specific_argument['field_custom_name_prefix'] : ((!empty($specific_argument['page_code']) ? $specific_argument['page_code'] . '_' : '' ) . 'attribute[' . $attribute->data_type . ']');
1740
+		$attributeInputDomain = (!empty($specific_argument['field_custom_name_prefix']) || (!empty($specific_argument['field_custom_name_prefix']) && ($specific_argument['field_custom_name_prefix'] == 'empty'))) ? $specific_argument['field_custom_name_prefix'] : ((!empty($specific_argument['page_code']) ? $specific_argument['page_code'] . '_' : '') . 'attribute[' . $attribute->data_type . ']');
1741 1741
 		$input_def['input_domain'] = $attributeInputDomain;
1742 1742
 		$input_def['id'] = (!empty($specific_argument) && !empty($specific_argument['field_id']) ? $specific_argument['field_id'] . '_' : '') . 'attribute_' . $attribute->id;
1743 1743
 		$input_def['intrinsec'] = $attribute->is_intrinsic;
@@ -1757,26 +1757,26 @@  discard block
 block discarded – undo
1757 1757
 		$input_def['frontend_type'] = $attribute->frontend_input;
1758 1758
 		$input_def['is_used_in_quick_add_form'] = $attribute->is_used_in_quick_add_form;
1759 1759
 
1760
-		if ( !empty($attribute_value) && !is_object($attribute_value) ) {
1760
+		if (!empty($attribute_value) && !is_object($attribute_value)) {
1761 1761
 			$input_def['value'] = $attribute_value;
1762 1762
 		}
1763
-		else if ( !empty($attribute_value->value) ) {
1763
+		else if (!empty($attribute_value->value)) {
1764 1764
 			$input_def['value'] = stripslashes($attribute_value->value);
1765 1765
 		}
1766
-		else if ( !empty($specific_argument['element_identifier']) && empty($attribute_value) && (get_post_status($specific_argument['element_identifier']) != 'auto-draft') ) {
1766
+		else if (!empty($specific_argument['element_identifier']) && empty($attribute_value) && (get_post_status($specific_argument['element_identifier']) != 'auto-draft')) {
1767 1767
 			$input_def['value'] = '';
1768 1768
 		}
1769 1769
 
1770 1770
 		$input_def['options'] = '';
1771 1771
 		$input_more_class = !empty($specific_argument['input_class']) ? $specific_argument['input_class'] : '';
1772 1772
 		if ($attribute->data_type == 'datetime') {
1773
-			$date_config = unserialize( $attribute->default_value );
1773
+			$date_config = unserialize($attribute->default_value);
1774 1774
 			if ((($date_config['default_value'] == '') || ($date_config['default_value'] == 'date_of_current_day')) && ($date_config['default_value'] == 'date_of_current_day')) {
1775 1775
 				$input_def['value'] = date('Y-m-d');
1776 1776
 			}
1777 1777
 			else {
1778 1778
 				/**	Modification due to a message on eoxia forum: http://www.eoxia.com/forums/topic/bug-attribut-de-type-date-dans-fiche-produit-admin/	*/
1779
-				$input_def['value'] = !empty($attribute_value->value) && is_string($attribute_value->value) ? str_replace( " 00:00:00", "", $attribute_value->value ) : ( !empty($attribute_value) && is_string($attribute_value) ? str_replace( " 00:00:00", "", $attribute_value ) : '' );
1779
+				$input_def['value'] = !empty($attribute_value->value) && is_string($attribute_value->value) ? str_replace(" 00:00:00", "", $attribute_value->value) : (!empty($attribute_value) && is_string($attribute_value) ? str_replace(" 00:00:00", "", $attribute_value) : '');
1780 1780
 			}
1781 1781
 			$input_more_class .= ' wpshop_input_datetime ';
1782 1782
 			$field_script = '<script type="text/javascript" >
@@ -1789,31 +1789,31 @@  discard block
 block discarded – undo
1789 1789
 		wpshop("#' . $input_def['id'] . '").datepicker("option", "navigationAsDateFormat", true);
1790 1790
 		wpshop("#' . $input_def['id'] . '").val("' . str_replace(" 00:00:00", "", $input_def['value']) . '");';
1791 1791
 
1792
-			if ( !empty($date_config['field_options']['attribute_type_date_options_available_date_past_futur']) ) {
1793
-				if ( !empty($date_config['field_options']['attribute_type_date_options_available_date_past_futur']['minDate'][0]) ) {
1792
+			if (!empty($date_config['field_options']['attribute_type_date_options_available_date_past_futur'])) {
1793
+				if (!empty($date_config['field_options']['attribute_type_date_options_available_date_past_futur']['minDate'][0])) {
1794 1794
 					$field_script .= '
1795 1795
 		wpshop("#' . $input_def['id'] . '").datepicker("option", "minDate", "' . $date_config['field_options']['attribute_type_date_options_available_date_past_futur']['minDate'][0] . '");';
1796 1796
 				}
1797
-				if ( !empty($date_config['field_options']['attribute_type_date_options_available_date_past_futur']['maxDate'][0]) ) {
1797
+				if (!empty($date_config['field_options']['attribute_type_date_options_available_date_past_futur']['maxDate'][0])) {
1798 1798
 					$field_script .= '
1799 1799
 		wpshop("#' . $input_def['id'] . '").datepicker("option", "maxDate", "' . $date_config['field_options']['attribute_type_date_options_available_date_past_futur']['maxDate'][0] . '");';
1800 1800
 				}
1801 1801
 			}
1802 1802
 
1803 1803
 			$script_options = $script_options_params = array();
1804
-			if ( !empty($date_config['field_options']['attribute_type_date_options_day_to_show']) ) {
1804
+			if (!empty($date_config['field_options']['attribute_type_date_options_day_to_show'])) {
1805 1805
 				$day_to_show_list = '    ';
1806
-				foreach ( $date_config['field_options']['attribute_type_date_options_day_to_show'] as $day_to_show ) {
1806
+				foreach ($date_config['field_options']['attribute_type_date_options_day_to_show'] as $day_to_show) {
1807 1807
 					$day_to_show_list .= '(date.getDay() == ' . $day_to_show . ') || ';
1808 1808
 				}
1809 1809
 				$script_options[] = '( ' . substr($day_to_show_list, 0, -4) . ' )';
1810 1810
 			}
1811 1811
 
1812
-			if ( !empty($date_config['field_options']['attribute_type_date_options_available_date_type'][0]) ) {
1813
-				if ( !empty($date_config['field_options']['attribute_type_date_options_available_date']) ) {
1812
+			if (!empty($date_config['field_options']['attribute_type_date_options_available_date_type'][0])) {
1813
+				if (!empty($date_config['field_options']['attribute_type_date_options_available_date'])) {
1814 1814
 					$available_date = ' ';
1815
-					foreach ( $date_config['field_options']['attribute_type_date_options_available_date'] as $avalaible_date_list ) {
1816
-						if ( !empty($avalaible_date_list) ) {
1815
+					foreach ($date_config['field_options']['attribute_type_date_options_available_date'] as $avalaible_date_list) {
1816
+						if (!empty($avalaible_date_list)) {
1817 1817
 							$available_date .= '"' . $avalaible_date_list . '",';
1818 1818
 						}
1819 1819
 					}
@@ -1822,7 +1822,7 @@  discard block
 block discarded – undo
1822 1822
 				}
1823 1823
 			}
1824 1824
 
1825
-			if ( !empty( $script_options ) ) {
1825
+			if (!empty($script_options)) {
1826 1826
 				$field_script .= '
1827 1827
 		wpshop("#' . $input_def['id'] . '").datepicker("option", "beforeShowDay", function(date){
1828 1828
 			' . implode(' ', $script_options_params) . ';
@@ -1850,37 +1850,37 @@  discard block
 block discarded – undo
1850 1850
 </script>';
1851 1851
 			$input_def['options'] .= $field_script;
1852 1852
 		}
1853
-		if ( in_array($attribute->backend_input, array('multiple-select', 'select', 'radio', 'checkbox'))) {
1854
-			$input_more_class .= (!empty($specific_argument['no_chosen']) ? '' : ' chosen_select ' );
1853
+		if (in_array($attribute->backend_input, array('multiple-select', 'select', 'radio', 'checkbox'))) {
1854
+			$input_more_class .= (!empty($specific_argument['no_chosen']) ? '' : ' chosen_select ');
1855 1855
 			$input_def['type'] = ((!empty($specific_argument['from']) && ($specific_argument['from'] == 'frontend')) || (!is_admin() && empty($specific_argument['from'])) ? $attribute->frontend_input : $attribute->backend_input);
1856 1856
 			$input_def['valueToPut'] = 'index';
1857 1857
 
1858 1858
 			$select_display = self::get_select_output($attribute, $specific_argument);
1859
-			if ( empty( $input_def[ 'options_label' ] ) && !empty( $specific_argument ) && (!empty($specific_argument['from']) && ($specific_argument['from'] == 'frontend') ) ) {
1860
-				$input_def[ 'options_label' ][ 'original' ] = true;
1859
+			if (empty($input_def['options_label']) && !empty($specific_argument) && (!empty($specific_argument['from']) && ($specific_argument['from'] == 'frontend'))) {
1860
+				$input_def['options_label']['original'] = true;
1861 1861
 			}
1862 1862
 			$input_def['options'] .= $select_display['more_input'];
1863 1863
 			$input_def['possible_value'] = (!empty($select_display) && !empty($select_display['possible_value'])) ? $select_display['possible_value'] : '';
1864
-			if ( !is_admin() ) {
1864
+			if (!is_admin()) {
1865 1865
 				$input_def['options'] .= '<input type="hidden" value="' . str_replace("\\", "", $input_def['value']) . '" name="wpshop_product_attribute_' . $attribute->code . '_current_value" id="wpshop_product_attribute_' . $attribute->code . '_current_value" />';
1866 1866
 			}
1867
-			if ( in_array($attribute->backend_input, array('multiple-select', 'checkbox')) && is_admin() && (empty($specific_argument['from']) || ($specific_argument['from'] != 'frontend')) ) {
1868
-				$input_def['options'] .= wpshop_display::display_template_element('select_list_multiple_bulk_action', array( 'CURRENT_ATTRIBUTE_ID' => $input_def['id'], 'CURRENT_ATTRIBUTE_CODE' => $attribute->code), array(), 'admin');
1867
+			if (in_array($attribute->backend_input, array('multiple-select', 'checkbox')) && is_admin() && (empty($specific_argument['from']) || ($specific_argument['from'] != 'frontend'))) {
1868
+				$input_def['options'] .= wpshop_display::display_template_element('select_list_multiple_bulk_action', array('CURRENT_ATTRIBUTE_ID' => $input_def['id'], 'CURRENT_ATTRIBUTE_CODE' => $attribute->code), array(), 'admin');
1869 1869
 			}
1870 1870
 		}
1871 1871
 		$input_def['label_pointer'] = 'for="' . $input_def['id'] . '"';
1872
-		if(($input_def['type'] == 'radio') || ($input_def['type'] == 'checkbox')){
1872
+		if (($input_def['type'] == 'radio') || ($input_def['type'] == 'checkbox')) {
1873 1873
 			$input_def['label_pointer'] = '';
1874 1874
 		}
1875 1875
 
1876 1876
 		/*
1877 1877
 		 * Specifc treatment for price attributes
1878 1878
 		 */
1879
-		if((WPSHOP_PRODUCT_PRICE_PILOT == 'HT') && ($attribute->code == WPSHOP_PRODUCT_PRICE_TTC) ){
1879
+		if ((WPSHOP_PRODUCT_PRICE_PILOT == 'HT') && ($attribute->code == WPSHOP_PRODUCT_PRICE_TTC)) {
1880 1880
 			$input_def['option'] .= ' readonly="readonly" ';
1881 1881
 			$input_more_class .= ' wpshop_prices_readonly';
1882 1882
 		}
1883
-		elseif((WPSHOP_PRODUCT_PRICE_PILOT == 'TTC') && ($attribute->code == WPSHOP_PRODUCT_PRICE_HT) ){
1883
+		elseif ((WPSHOP_PRODUCT_PRICE_PILOT == 'TTC') && ($attribute->code == WPSHOP_PRODUCT_PRICE_HT)) {
1884 1884
 			$input_def['option'] .= ' readonly="readonly" ';
1885 1885
 			$input_more_class .= ' wpshop_prices_readonly';
1886 1886
 		}
@@ -1891,7 +1891,7 @@  discard block
 block discarded – undo
1891 1891
 
1892 1892
 		$input_def['label'] = str_replace("\\", "", $input_def['label']);
1893 1893
 // 		$input_def['value'] = str_replace("\\", "", $input_def['value']);
1894
-		$input_def['option'] .= ' class="wpshop_product_attribute_' . $attribute->code . $input_more_class . ' ' . (( is_admin() ) ? $attribute->backend_css_class : $attribute->frontend_css_class) . ( !empty($attribute->frontend_verification) ? ' wps_attr_verification_' . $attribute->frontend_verification : '' ) . '" ';
1894
+		$input_def['option'] .= ' class="wpshop_product_attribute_' . $attribute->code . $input_more_class . ' ' . ((is_admin()) ? $attribute->backend_css_class : $attribute->frontend_css_class) . (!empty($attribute->frontend_verification) ? ' wps_attr_verification_' . $attribute->frontend_verification : '') . '" ';
1895 1895
 		$input_def['title'] = !empty($attribute->frontend_help_message) ? ' title="' . $attribute->frontend_help_message . '" ' : '';
1896 1896
 
1897 1897
 		if (($attribute->is_intrinsic == 'yes') && ((!empty($input_def['value'])) || ($input_def['value'] > 0))) {
@@ -1902,13 +1902,13 @@  discard block
 block discarded – undo
1902 1902
 		 * Add the unit to the attribute if attribute configuration is set to yes
1903 1903
 		 */
1904 1904
 		if ($attribute->is_requiring_unit == 'yes') {
1905
-			if ( in_array($attribute->code, $wpshop_price_attributes) || ( WPSHOP_COST_OF_POSTAGE == $attribute->code) ) {
1905
+			if (in_array($attribute->code, $wpshop_price_attributes) || (WPSHOP_COST_OF_POSTAGE == $attribute->code)) {
1906 1906
 				$input_def['options'] .= '&nbsp;<span class="attribute_currency" id="attribute_currency_' . $attribute->id . '" >' . wpshop_tools::wpshop_get_currency() . '</span>';
1907 1907
 			}
1908
-			elseif ( in_array($attribute->code, $wpshop_weight_attributes) ) {
1908
+			elseif (in_array($attribute->code, $wpshop_weight_attributes)) {
1909 1909
 				$weight_defaut_unity_option = get_option('wpshop_shop_default_weight_unity');
1910
-				$query = $wpdb->prepare('SELECT name FROM '. WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id=%d', $weight_defaut_unity_option);
1911
-				$unity = $wpdb->get_var( $query );
1910
+				$query = $wpdb->prepare('SELECT name FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id=%d', $weight_defaut_unity_option);
1911
+				$unity = $wpdb->get_var($query);
1912 1912
 				$input_def['options'] .= '&nbsp;<span class="attribute_weight" id="attribute_weight_' . $attribute->id . '" >' . __($unity, 'wpshop') . '</span>';
1913 1913
 			}
1914 1914
 			else {
@@ -1916,11 +1916,11 @@  discard block
 block discarded – undo
1916 1916
 				$unit_input_def['possible_value'] = wpshop_attributes_unit::get_unit_list_for_group($attribute->_unit_group_id);
1917 1917
 				$unit_input_def['type'] = 'select';
1918 1918
 				$unit_input_def['option'] = ' class="wpshop_attribute_unit_input chosen_select" ';
1919
-				$unit_input_def['id'] = ( !empty($specific_argument['page_code']) ? $specific_argument['page_code'] : null ) . '_' . ( !empty($specific_argument['element_identifier']) ? $specific_argument['element_identifier'] : null ) . '_unit_attribute_' . $attribute->id;
1919
+				$unit_input_def['id'] = (!empty($specific_argument['page_code']) ? $specific_argument['page_code'] : null) . '_' . (!empty($specific_argument['element_identifier']) ? $specific_argument['element_identifier'] : null) . '_unit_attribute_' . $attribute->id;
1920 1920
 				$unit_input_def['name'] = $attribute->code;
1921 1921
 				$unit_input_def['value'] = (!empty($attribute_value->unit_id) ? $attribute_value->unit_id : '');
1922
-				if($unit_input_def['value'] == ''){
1923
-					if ( $attribute->_default_unit > 0 ) {
1922
+				if ($unit_input_def['value'] == '') {
1923
+					if ($attribute->_default_unit > 0) {
1924 1924
 						$unit_input_def['value'] = $attribute->_default_unit;
1925 1925
 					}
1926 1926
 					else {
@@ -1934,18 +1934,18 @@  discard block
 block discarded – undo
1934 1934
 		/*
1935 1935
 		 * Add indication on postage cost tax
1936 1936
 		 */
1937
-		if ( $attribute->code == WPSHOP_COST_OF_POSTAGE ) {
1937
+		if ($attribute->code == WPSHOP_COST_OF_POSTAGE) {
1938 1938
 			$input_def['options'] .= ' <span class="attribute_currency" >' . __('ATI', 'wpshop') . '</span>';
1939 1939
 		}
1940 1940
 
1941 1941
 		/*
1942 1942
 		 * Create the field output
1943 1943
 		 */
1944
-		if ( is_admin() && ($attribute->data_type == 'datetime') && ($attribute->is_user_defined == 'yes') && (empty($specific_argument['from']) || ($specific_argument['from'] != 'frontend')) ) {
1945
-			$input_def['output'] = sprintf(__('You select this field to be defined by final customer into frontend part. To change this behaviour you have to change attribute option "%s"', 'wpshop'),__('is_user_defined', 'wpshop'));
1944
+		if (is_admin() && ($attribute->data_type == 'datetime') && ($attribute->is_user_defined == 'yes') && (empty($specific_argument['from']) || ($specific_argument['from'] != 'frontend'))) {
1945
+			$input_def['output'] = sprintf(__('You select this field to be defined by final customer into frontend part. To change this behaviour you have to change attribute option "%s"', 'wpshop'), __('is_user_defined', 'wpshop'));
1946 1946
 			$input_def['options'] = '';
1947 1947
 			$input_def['label_pointer'] = '';
1948
-			$input_def['option'] = substr( $input_def['option'], 0 , -2 ) . ' wpshop_attributes_is_user_defined_admin_field "';
1948
+			$input_def['option'] = substr($input_def['option'], 0, -2) . ' wpshop_attributes_is_user_defined_admin_field "';
1949 1949
 			$input_def['field_container_class'] .= 'wpshop_attributes_is_user_defined_admin_container';
1950 1950
 		}
1951 1951
 		else {
@@ -1960,7 +1960,7 @@  discard block
 block discarded – undo
1960 1960
 	 * @param string $output_from
1961 1961
 	 * @return string The output for
1962 1962
 	 */
1963
-	public static function display_attribute( $attribute_code, $output_from = 'admin', $output_specs = array() ) {
1963
+	public static function display_attribute($attribute_code, $output_from = 'admin', $output_specs = array()) {
1964 1964
 		$output = '';
1965 1965
 		/*	Get the page code	*/
1966 1966
 		$currentPageCode = !empty($output_specs['page_code']) ? $output_specs['page_code'] : '';
@@ -1971,17 +1971,17 @@  discard block
 block discarded – undo
1971 1971
 
1972 1972
 		/*	Get attribute input definition	*/
1973 1973
 		$current_value = (!empty($output_specs['current_value']) ? $output_specs['current_value'] : '');
1974
-		$input = wpshop_attributes::get_attribute_field_definition( $attribute_def, $current_value, array_merge($output_specs, array('input_class' => ' wpshop_attributes_display', 'from' => $output_from)) );
1974
+		$input = wpshop_attributes::get_attribute_field_definition($attribute_def, $current_value, array_merge($output_specs, array('input_class' => ' wpshop_attributes_display', 'from' => $output_from)));
1975 1975
 
1976 1976
 		/*	Create default output	*/
1977 1977
 		$input_to_display = $input['output'] . $input['options'];
1978 1978
 
1979 1979
 		/*	Check if current field is linked to an addon, and if the addon is activated	*/
1980 1980
 		$addons_list = unserialize(WPSHOP_ADDONS_LIST);
1981
-		foreach ( $addons_list as $addon_code => $addon_def ) {
1982
-			if ( in_array($attribute_code, $addon_def) ) {
1983
-				if ( constant($addon_code) === false ) {
1984
-					$input_to_display = '<a href="' . admin_url('options-general.php?page=wpshop_option#wpshop_addons_option') . '" >' . __("This addon isn't activated, click to activate",'wpshop') . '</a>';
1981
+		foreach ($addons_list as $addon_code => $addon_def) {
1982
+			if (in_array($attribute_code, $addon_def)) {
1983
+				if (constant($addon_code) === false) {
1984
+					$input_to_display = '<a href="' . admin_url('options-general.php?page=wpshop_option#wpshop_addons_option') . '" >' . __("This addon isn't activated, click to activate", 'wpshop') . '</a>';
1985 1985
 				}
1986 1986
 			}
1987 1987
 		}
@@ -2006,11 +2006,11 @@  discard block
 block discarded – undo
2006 2006
 		/*
2007 2007
 		 * Display attribute option if applicable
2008 2008
 		 */
2009
-		if ( $output_from == 'admin') {
2010
-			$attribute_option_display = $attribute_def->backend_input=='select' && (strtolower( __(self::get_attribute_type_select_option_info($input['value'], 'value'), 'wpshop') ) == strtolower(__('yes', 'wpshop'))) ? '' : ' wpshopHide';
2009
+		if ($output_from == 'admin') {
2010
+			$attribute_option_display = $attribute_def->backend_input == 'select' && (strtolower(__(self::get_attribute_type_select_option_info($input['value'], 'value'), 'wpshop')) == strtolower(__('yes', 'wpshop'))) ? '' : ' wpshopHide';
2011 2011
 
2012 2012
 			$output['field'] .= '
2013
-	<div class="attribute_option_'.$attribute_def->code.''.$attribute_option_display.'">'.self::get_attribute_option_fields($element_identifier, $attribute_def->code).'</div>';
2013
+	<div class="attribute_option_'.$attribute_def->code . '' . $attribute_option_display . '">' . self::get_attribute_option_fields($element_identifier, $attribute_def->code) . '</div>';
2014 2014
 		}
2015 2015
 
2016 2016
 		$output['field'] .= '</div>';
@@ -2028,36 +2028,36 @@  discard block
 block discarded – undo
2028 2028
 	 *
2029 2029
 	 * @return string The html code to output directly tabs
2030 2030
 	 */
2031
-	public static function attribute_of_entity_to_tab( $element_code, $element_id, $element_definition ) {
2031
+	public static function attribute_of_entity_to_tab($element_code, $element_id, $element_definition) {
2032 2032
 		$attributeContentOutput = '';
2033 2033
 
2034 2034
 		/**	Get the different attribute affected to the entity	*/
2035 2035
 		$element_atribute_list = wpshop_attributes::getElementWithAttributeAndValue($element_code, $element_id, WPSHOP_CURRENT_LOCALE, '', 'frontend');
2036 2036
 
2037 2037
 
2038
-		if ( is_array($element_atribute_list) && (count($element_atribute_list) > 0) ) {
2039
-			foreach ( $element_atribute_list[$element_id] as $attributeSetSectionName => $attributeSetContent ) {
2038
+		if (is_array($element_atribute_list) && (count($element_atribute_list) > 0)) {
2039
+			foreach ($element_atribute_list[$element_id] as $attributeSetSectionName => $attributeSetContent) {
2040 2040
 				$attributeToShowNumber = 0;
2041 2041
 				$attributeOutput = '';
2042 2042
 
2043
-				foreach ( $attributeSetContent['attributes'] as $attributeId => $attributeDefinition ) {
2043
+				foreach ($attributeSetContent['attributes'] as $attributeId => $attributeDefinition) {
2044 2044
 
2045 2045
 					/**	Check the value type to check if empty or not	*/
2046
-					if ( $attributeDefinition['data_type'] == 'int' ) {
2046
+					if ($attributeDefinition['data_type'] == 'int') {
2047 2047
 						$attributeDefinition['value'] = (int)$attributeDefinition['value'];
2048 2048
 					}
2049
-					else if ( $attributeDefinition['data_type'] == 'decimal' ) {
2049
+					else if ($attributeDefinition['data_type'] == 'decimal') {
2050 2050
 						$attributeDefinition['value'] = (float)$attributeDefinition['value'];
2051 2051
 					}
2052 2052
 
2053 2053
 					/** Check if the attribute is set to be displayed in frontend	*/
2054
-					$attribute_display_state = wpshop_attributes::check_attribute_display( $attributeDefinition['is_visible_in_front'], $element_definition['custom_display'], 'attribute', $attributeDefinition['code'], 'complete_sheet');
2054
+					$attribute_display_state = wpshop_attributes::check_attribute_display($attributeDefinition['is_visible_in_front'], $element_definition['custom_display'], 'attribute', $attributeDefinition['code'], 'complete_sheet');
2055 2055
 
2056 2056
 					/**	Output the field if the value is not null	*/
2057 2057
 
2058
-					if ( (is_array($attributeDefinition['value']) || ( !empty($attributeDefinition['value']) ) ) && $attribute_display_state) {
2058
+					if ((is_array($attributeDefinition['value']) || (!empty($attributeDefinition['value']))) && $attribute_display_state) {
2059 2059
 
2060
-						$attribute_display = wpshop_attributes::wps_attribute_values_display( $attributeDefinition );
2060
+						$attribute_display = wpshop_attributes::wps_attribute_values_display($attributeDefinition);
2061 2061
 						$attribute_value = $attribute_display[0];
2062 2062
 						$attributeDefinition['value'] = $attribute_display[1];
2063 2063
 						$attribute_unit_list = $attribute_display[2];
@@ -2068,8 +2068,8 @@  discard block
 block discarded – undo
2068 2068
 						$tpl_component['PDT_ENTITY_CODE'] = self::currentPageCode;
2069 2069
 						$tpl_component['ATTRIBUTE_CODE'] = $attributeDefinition['attribute_code'];
2070 2070
 						$tpl_component['ATTRIBUTE_LABEL'] = __($attributeDefinition['frontend_label'], 'wpshop');
2071
-						$tpl_component['ATTRIBUTE_VALUE'] = (  !is_array($attribute_value) ) ? stripslashes($attribute_value) : $attribute_value;
2072
-						$tpl_component['ATTRIBUTE_VALUE_UNIT'] =  $attribute_unit_list;
2071
+						$tpl_component['ATTRIBUTE_VALUE'] = (!is_array($attribute_value)) ? stripslashes($attribute_value) : $attribute_value;
2072
+						$tpl_component['ATTRIBUTE_VALUE_UNIT'] = $attribute_unit_list;
2073 2073
 
2074 2074
 						/** Build template	*/
2075 2075
 						$attributeOutput .= wpshop_display::display_template_element($template_part, $tpl_component);
@@ -2080,9 +2080,9 @@  discard block
 block discarded – undo
2080 2080
 				}
2081 2081
 
2082 2082
 				/** Check if the attribute set section is set to be displayed in frontend	*/
2083
-				$attribute_set_display_state = wpshop_attributes::check_attribute_display( $attributeSetContent['display_on_frontend'], $element_definition['custom_display'], 'attribute_set_section', $attributeSetContent['code'], 'complete_sheet');
2083
+				$attribute_set_display_state = wpshop_attributes::check_attribute_display($attributeSetContent['display_on_frontend'], $element_definition['custom_display'], 'attribute_set_section', $attributeSetContent['code'], 'complete_sheet');
2084 2084
 
2085
-				if ( !$attribute_set_display_state ) {
2085
+				if (!$attribute_set_display_state) {
2086 2086
 					$attributeToShowNumber = 0;
2087 2087
 					$attributeOutput = '';
2088 2088
 				}
@@ -2092,8 +2092,8 @@  discard block
 block discarded – undo
2092 2092
 
2093 2093
 			/** Gestion de l'affichage	*/
2094 2094
 			$tab_list = $content_list = '';
2095
-			foreach ( $element_atribute_list[$element_id] as $attributeSetSectionName => $attributeSetContent ) {
2096
-				if ( !empty($attributeSetContent['count']) > 0 ) {
2095
+			foreach ($element_atribute_list[$element_id] as $attributeSetSectionName => $attributeSetContent) {
2096
+				if (!empty($attributeSetContent['count']) > 0) {
2097 2097
 					/** Template parameters	*/
2098 2098
 					$template_part = 'product_attribute_tabs';
2099 2099
 					$tpl_component = array();
@@ -2102,7 +2102,7 @@  discard block
 block discarded – undo
2102 2102
 
2103 2103
 					/** Build template	*/
2104 2104
 					$tpl_way_to_take = wpshop_display::check_way_for_template($template_part);
2105
-					if ( $tpl_way_to_take[0] && !empty($tpl_way_to_take[1]) ) {
2105
+					if ($tpl_way_to_take[0] && !empty($tpl_way_to_take[1])) {
2106 2106
 						/*	Include the old way template part	*/
2107 2107
 						ob_start();
2108 2108
 						require(wpshop_display::get_template_file($tpl_way_to_take[1]));
@@ -2122,7 +2122,7 @@  discard block
 block discarded – undo
2122 2122
 
2123 2123
 					/** Build template	*/
2124 2124
 					$tpl_way_to_take = wpshop_display::check_way_for_template($template_part);
2125
-					if ( $tpl_way_to_take[0] && !empty($tpl_way_to_take[1]) ) {
2125
+					if ($tpl_way_to_take[0] && !empty($tpl_way_to_take[1])) {
2126 2126
 						/*	Include the old way template part	*/
2127 2127
 						ob_start();
2128 2128
 						require(wpshop_display::get_template_file($tpl_way_to_take[1]));
@@ -2136,16 +2136,16 @@  discard block
 block discarded – undo
2136 2136
 				}
2137 2137
 			}
2138 2138
 
2139
-			if ( $tab_list != '' ) {
2139
+			if ($tab_list != '') {
2140 2140
 				/** Template parameters	*/
2141 2141
 				$template_part = 'product_attribute_container';
2142 2142
 				$tpl_component = array();
2143
-				$tpl_component['PDT_TABS'] = apply_filters( 'wpshop_extra_tabs_menu_before', '' ).$tab_list.apply_filters( 'wpshop_extra_tabs_menu_after', '' );
2144
-				$tpl_component['PDT_TAB_DETAIL'] = apply_filters( 'wpshop_extra_tabs_content_before', '' ).$content_list.apply_filters( 'wpshop_extra_tabs_content_after', '' );
2143
+				$tpl_component['PDT_TABS'] = apply_filters('wpshop_extra_tabs_menu_before', '') . $tab_list . apply_filters('wpshop_extra_tabs_menu_after', '');
2144
+				$tpl_component['PDT_TAB_DETAIL'] = apply_filters('wpshop_extra_tabs_content_before', '') . $content_list . apply_filters('wpshop_extra_tabs_content_after', '');
2145 2145
 
2146 2146
 				/** Build template	*/
2147 2147
 				$tpl_way_to_take = wpshop_display::check_way_for_template($template_part);
2148
-				if ( $tpl_way_to_take[0] && !empty($tpl_way_to_take[1]) ) {
2148
+				if ($tpl_way_to_take[0] && !empty($tpl_way_to_take[1])) {
2149 2149
 					/*	Include the old way template part	*/
2150 2150
 					ob_start();
2151 2151
 					require(wpshop_display::get_template_file($tpl_way_to_take[1]));
@@ -2168,9 +2168,9 @@  discard block
 block discarded – undo
2168 2168
 	 * @param unknown_type $attributeDefinition
2169 2169
 	 * @return multitype:Ambigous <unknown, string> Ambigous <string, string> Ambigous <>
2170 2170
 	 */
2171
-	public static function wps_attribute_values_display( $attributeDefinition ) {
2171
+	public static function wps_attribute_values_display($attributeDefinition) {
2172 2172
 		$attribute_unit_list = '';
2173
-		if ( !empty($attributeDefinition['unit']) ) {
2173
+		if (!empty($attributeDefinition['unit'])) {
2174 2174
 			/** Template parameters	*/
2175 2175
 			$template_part = 'product_attribute_unit';
2176 2176
 			$tpl_component = array();
@@ -2182,31 +2182,31 @@  discard block
 block discarded – undo
2182 2182
 		}
2183 2183
 
2184 2184
 		$attribute_value = $attributeDefinition['value'];
2185
-		if ( $attributeDefinition['data_type'] == 'decimal' ) {
2186
-			$attribute_value =(is_numeric($attribute_value) ) ? number_format($attribute_value, 2, ',', '') : $attribute_value;
2187
-			if ( in_array($attributeDefinition['code'], unserialize(WPSHOP_ATTRIBUTE_PRICES)) ) {
2188
-				if ( $attributeDefinition['is_requiring_unit'] == 'yes' ) {
2185
+		if ($attributeDefinition['data_type'] == 'decimal') {
2186
+			$attribute_value = (is_numeric($attribute_value)) ? number_format($attribute_value, 2, ',', '') : $attribute_value;
2187
+			if (in_array($attributeDefinition['code'], unserialize(WPSHOP_ATTRIBUTE_PRICES))) {
2188
+				if ($attributeDefinition['is_requiring_unit'] == 'yes') {
2189 2189
 					$attribute_unit_list = ' ' . wpshop_tools::wpshop_get_currency();
2190 2190
 				}
2191 2191
 				$attributeDefinition['value'] = wpshop_display::format_field_output('wpshop_product_price', $attributeDefinition['value']);
2192 2192
 			}
2193 2193
 		}
2194
-		if ( $attributeDefinition['data_type'] == 'datetime' ) {
2194
+		if ($attributeDefinition['data_type'] == 'datetime') {
2195 2195
 			$attribute_value = mysql2date('d/m/Y', $attributeDefinition['value'], true);
2196 2196
 		}
2197
-		if ( $attributeDefinition['backend_input'] == 'select' ) {
2197
+		if ($attributeDefinition['backend_input'] == 'select') {
2198 2198
 			$attribute_value = wpshop_attributes::get_attribute_type_select_option_info($attributeDefinition['value'], 'label', $attributeDefinition['data_type_to_use']);
2199 2199
 		}
2200 2200
 		/** Manage differently if its an array of values or not	*/
2201
-		if ( $attributeDefinition['backend_input'] == 'multiple-select') {
2201
+		if ($attributeDefinition['backend_input'] == 'multiple-select') {
2202 2202
 			$attribute_value = '';
2203
-			if ( is_array($attributeDefinition['value']) ) {
2203
+			if (is_array($attributeDefinition['value'])) {
2204 2204
 				foreach ($attributeDefinition['value'] as $v) {
2205
-					$attribute_value .= ' / '.wpshop_attributes::get_attribute_type_select_option_info($v, 'label', $attributeDefinition['data_type_to_use']);
2205
+					$attribute_value .= ' / ' . wpshop_attributes::get_attribute_type_select_option_info($v, 'label', $attributeDefinition['data_type_to_use']);
2206 2206
 				}
2207 2207
 			}
2208
-			else $attribute_value = ' / '.wpshop_attributes::get_attribute_type_select_option_info($attributeDefinition['value'], 'label', $attributeDefinition['data_type_to_use']);
2209
-			$attribute_value = substr($attribute_value,3);
2208
+			else $attribute_value = ' / ' . wpshop_attributes::get_attribute_type_select_option_info($attributeDefinition['value'], 'label', $attributeDefinition['data_type_to_use']);
2209
+			$attribute_value = substr($attribute_value, 3);
2210 2210
 		}
2211 2211
 
2212 2212
 		return array($attribute_value, $attributeDefinition['value'], $attribute_unit_list);
@@ -2216,13 +2216,13 @@  discard block
 block discarded – undo
2216 2216
 	 * Manage display for the output when user uses a shortcode for attributes display
2217 2217
 	 * @param array $shorcode_args The list of argument passed through the shortcode
2218 2218
 	 */
2219
-	function wpshop_attributes_shortcode( $shorcode_args ) {
2219
+	function wpshop_attributes_shortcode($shorcode_args) {
2220 2220
 		$output = '';
2221 2221
 		/*
2222 2222
 		 * Read the attribute list
2223 2223
 		*/
2224
-		foreach ( explode(', ', $shorcode_args['attributes']) as $attribute_code ) {
2225
-			$attribute_output_def = wpshop_attributes::display_attribute( $attribute_code, $shorcode_args['from'] );
2224
+		foreach (explode(', ', $shorcode_args['attributes']) as $attribute_code) {
2225
+			$attribute_output_def = wpshop_attributes::display_attribute($attribute_code, $shorcode_args['from']);
2226 2226
 			$output .= $attribute_output_def['field'];
2227 2227
 		}
2228 2228
 
@@ -2244,7 +2244,7 @@  discard block
 block discarded – undo
2244 2244
 		$productAttributeSetDetails = wpshop_attributes_set::getAttributeSetDetails($attributeSetId, "'valid','deleted'");
2245 2245
 		$attribute_specification = array('page_code' => $currentPageCode, 'element_identifier' => $itemToEdit, 'field_id' => $currentPageCode . '_' . $itemToEdit . '_');
2246 2246
 
2247
-		if ( count($productAttributeSetDetails) > 0 ) {
2247
+		if (count($productAttributeSetDetails) > 0) {
2248 2248
 			/*	Read the attribute list in order to output	*/
2249 2249
 			$shortcodes_attr = '';
2250 2250
 			$shortcodes_to_display = false;
@@ -2254,80 +2254,80 @@  discard block
 block discarded – undo
2254 2254
 
2255 2255
 				$shortcodes = $currentTabContent = '';
2256 2256
 				$output_nb = 0;
2257
-				if(count($productAttributeSetDetail['attribut']) >= 1){
2258
-					foreach($productAttributeSetDetail['attribut'] as $attribute){
2257
+				if (count($productAttributeSetDetail['attribut']) >= 1) {
2258
+					foreach ($productAttributeSetDetail['attribut'] as $attribute) {
2259 2259
 
2260
-						if ( !empty($attribute->id) ) {
2261
-							if ( $attribute->code == 'product_attribute_set_id' ) {
2260
+						if (!empty($attribute->id)) {
2261
+							if ($attribute->code == 'product_attribute_set_id') {
2262 2262
 								$attribute_set_id_is_present = true;
2263 2263
 							}
2264 2264
 
2265 2265
 							/** Generic part for attribute field output	*/
2266 2266
 							$value = wpshop_attributes::getAttributeValueForEntityInSet($attribute->data_type, $attribute->id, wpshop_entities::get_entity_identifier_from_code($currentPageCode), $itemToEdit, array('intrinsic' => $attribute->is_intrinsic, 'backend_input' => $attribute->backend_input));
2267
-							$product_meta = get_post_meta( $itemToEdit, '_wpshop_product_metadata', true);
2267
+							$product_meta = get_post_meta($itemToEdit, '_wpshop_product_metadata', true);
2268 2268
 
2269 2269
 							/**	Check if value is empty and get value in meta if not empty	*/
2270 2270
 							$value = (empty($value) && !empty($product_meta[$attribute->code])) ? $product_meta[$attribute->code] : (!empty($value) ? $value : null);
2271 2271
 
2272 2272
 							/*	Manage specific field as the attribute_set_id in product form	*/
2273
-							if ( $attribute->code == 'product_attribute_set_id' ) {
2273
+							if ($attribute->code == 'product_attribute_set_id') {
2274 2274
 
2275 2275
 								$value = empty($value) ? $attributeSetId : $value;
2276 2276
 							}
2277 2277
 							$attribute_specification['current_value'] = $value;
2278
-							$attribute_output_def = apply_filters( 'wpshop_attribute_output_def', wpshop_attributes::display_attribute( $attribute->code, 'admin', $attribute_specification), $itemToEdit );
2279
-							if ( ($attribute_output_def['field_definition']['type'] != 'hidden') && ($attribute->code != 'product_attribute_set_id') ) {
2278
+							$attribute_output_def = apply_filters('wpshop_attribute_output_def', wpshop_attributes::display_attribute($attribute->code, 'admin', $attribute_specification), $itemToEdit);
2279
+							if (($attribute_output_def['field_definition']['type'] != 'hidden') && ($attribute->code != 'product_attribute_set_id')) {
2280 2280
 								$currentTabContent .= $attribute_output_def['field'];
2281
-								$shortcode_code_def=array();
2282
-								$shortcode_code_def['attribute_'.str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['main_code'] = 'wpshop_att_val';
2283
-								$shortcode_code_def['attribute_'.str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['attrs_exemple']['type'] = $attribute->data_type;
2284
-								$shortcode_code_def['attribute_'.str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['attrs_exemple']['attid'] = $attribute->id;
2285
-								$shortcode_code_def['attribute_'.str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['attrs_exemple']['pid'] = $itemToEdit;
2281
+								$shortcode_code_def = array();
2282
+								$shortcode_code_def['attribute_' . str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['main_code'] = 'wpshop_att_val';
2283
+								$shortcode_code_def['attribute_' . str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['attrs_exemple']['type'] = $attribute->data_type;
2284
+								$shortcode_code_def['attribute_' . str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['attrs_exemple']['attid'] = $attribute->id;
2285
+								$shortcode_code_def['attribute_' . str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label']))]['attrs_exemple']['pid'] = $itemToEdit;
2286 2286
 								ob_start();
2287
-								wps_shortcodes_ctr::output_shortcode('attribute_'.str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label'])), $shortcode_code_def, 'wpshop_product_shortcode_display wpshop_product_attribute_shortcode_display wpshop_product_attribute_shortcode_display_'.str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label'])).' wpshop_cls');
2288
-								$shortcodes .= '<li class="wpshop_cls" >'.sprintf(__('Insertion code for the attribute %s for this product', 'wpshop'), '<span>'.__($attribute_output_def['field_definition']['label'], 'wpshop').'</span>').ob_get_contents().'</li>';
2287
+								wps_shortcodes_ctr::output_shortcode('attribute_' . str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label'])), $shortcode_code_def, 'wpshop_product_shortcode_display wpshop_product_attribute_shortcode_display wpshop_product_attribute_shortcode_display_' . str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label'])) . ' wpshop_cls');
2288
+								$shortcodes .= '<li class="wpshop_cls" >' . sprintf(__('Insertion code for the attribute %s for this product', 'wpshop'), '<span>' . __($attribute_output_def['field_definition']['label'], 'wpshop') . '</span>') . ob_get_contents() . '</li>';
2289 2289
 								ob_end_clean();
2290 2290
 							}
2291 2291
 							else {
2292
-								if ( $attribute->code == 'product_attribute_set_id' ) {
2292
+								if ($attribute->code == 'product_attribute_set_id') {
2293 2293
 									$attribute_output_def['field_definition']['type'] = 'hidden';
2294 2294
 								}
2295
-								$currentTabContent .=  wpshop_form::check_input_type($attribute_output_def['field_definition'], $attribute_output_def['field_definition']['input_domain']);
2295
+								$currentTabContent .= wpshop_form::check_input_type($attribute_output_def['field_definition'], $attribute_output_def['field_definition']['input_domain']);
2296 2296
 							}
2297 2297
 							$output_nb++;
2298 2298
 						}
2299 2299
 					}
2300 2300
 
2301
-					$currentTabContent = apply_filters( 'wps_entity_attribute_edition', $currentTabContent, $itemToEdit, $productAttributeSetDetail );
2301
+					$currentTabContent = apply_filters('wps_entity_attribute_edition', $currentTabContent, $itemToEdit, $productAttributeSetDetail);
2302 2302
 
2303 2303
 					$shortcode_code['attributes_set']['main_code'] = 'wpshop_att_group';
2304 2304
 					$shortcode_code['attributes_set']['attrs_exemple']['pid'] = $itemToEdit;
2305 2305
 					$shortcode_code['attributes_set']['attrs_exemple']['sid'] = $productAttributeSetDetail['id'];
2306 2306
 					ob_start();
2307
-					wps_shortcodes_ctr::output_shortcode('attributes_set', $shortcode_code, 'wpshop_product_shortcode_display wpshop_product_attribute_group_shortcode_display wpshop_product_attribute_group_shortcode_display_'.str_replace('-', '_', sanitize_title($productAttributeSetDetail['name'])).' cls');
2308
-					$attribute_group_display = sprintf(__('Insertion code for attribute group %s for this product', 'wpshop'), '<span>'.$productAttributeSetDetail['name'].'</span>').ob_get_contents().'<ul class="" >'.$shortcodes.'</ul>';
2307
+					wps_shortcodes_ctr::output_shortcode('attributes_set', $shortcode_code, 'wpshop_product_shortcode_display wpshop_product_attribute_group_shortcode_display wpshop_product_attribute_group_shortcode_display_' . str_replace('-', '_', sanitize_title($productAttributeSetDetail['name'])) . ' cls');
2308
+					$attribute_group_display = sprintf(__('Insertion code for attribute group %s for this product', 'wpshop'), '<span>' . $productAttributeSetDetail['name'] . '</span>') . ob_get_contents() . '<ul class="" >' . $shortcodes . '</ul>';
2309 2309
 					ob_end_clean();
2310 2310
 
2311
-					if( WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE == 'each-box' )
2312
-						$currentTabContent .= '<div class="wpshop_cls" ><strong>'.__('Shortcodes','wpshop').'</strong> - <a href="#" class="show-hide-shortcodes">' . __('Display', 'wpshop') . '</a><div class="wpshop_product_shortcode_display wpshop_product_shortcode_display_container wpshopHide" >' . $attribute_group_display . '</div></div>';
2311
+					if (WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE == 'each-box')
2312
+						$currentTabContent .= '<div class="wpshop_cls" ><strong>' . __('Shortcodes', 'wpshop') . '</strong> - <a href="#" class="show-hide-shortcodes">' . __('Display', 'wpshop') . '</a><div class="wpshop_product_shortcode_display wpshop_product_shortcode_display_container wpshopHide" >' . $attribute_group_display . '</div></div>';
2313 2313
 					else
2314 2314
 						$shortcodes_attr .= $attribute_group_display;
2315 2315
 
2316
-					if ( $output_nb <= 0 ) {
2316
+					if ($output_nb <= 0) {
2317 2317
 						$currentTabContent = __('Nothing avaiblable here. You can go in attribute management interface in order to add content here.', 'wpshop');
2318 2318
 					}
2319 2319
 				}
2320 2320
 
2321 2321
 				if ($output_nb > 0) {
2322 2322
 					$shortcodes_to_display = true;
2323
-					if ( $outputType == 'box' ) {
2323
+					if ($outputType == 'box') {
2324 2324
 						$box['box'][$productAttributeSetDetail['code']] = $productAttributeSetDetail['name'];
2325
-						$box['box'][$productAttributeSetDetail['code'].'_backend_display_type'] = $productAttributeSetDetail['backend_display_type'];
2325
+						$box['box'][$productAttributeSetDetail['code'] . '_backend_display_type'] = $productAttributeSetDetail['backend_display_type'];
2326 2326
 						$box['boxContent'][$productAttributeSetDetail['code']] = '
2327 2327
 			<div id="wpshop_' . $currentPageCode . '_' . wpshop_tools::slugify($productAttributeSetDetail['code'], array('noAccent')) . '_form" >' . $currentTabContent . '
2328 2328
 							</div><div class="wpshop_cls" ></div>';
2329 2329
 					}
2330
-					else if ( $outputType == 'column' ) {
2330
+					else if ($outputType == 'column') {
2331 2331
 						$currentTabContent = str_replace('wpshop_form_input_element', 'wpshop_form_input_column', $currentTabContent);
2332 2332
 						$currentTabContent = str_replace('wpshop_form_label', 'wpshop_form_label_column', $currentTabContent);
2333 2333
 
@@ -2337,11 +2337,11 @@  discard block
 block discarded – undo
2337 2337
 				}
2338 2338
 			}
2339 2339
 
2340
-			if( !$attribute_set_id_is_present ) {
2340
+			if (!$attribute_set_id_is_present) {
2341 2341
 				/*	Get attribute definition	*/
2342 2342
 				$attribute_def = wpshop_attributes::getElement('product_attribute_set_id', "'valid'", 'code');
2343 2343
 				/*	Get attribute input definition	*/
2344
-				$input = wpshop_attributes::get_attribute_field_definition( $attribute_def, $attributeSetId, array_merge($attribute_specification, array('input_class' => ' wpshop_attributes_display', 'from' => 'admin')) );
2344
+				$input = wpshop_attributes::get_attribute_field_definition($attribute_def, $attributeSetId, array_merge($attribute_specification, array('input_class' => ' wpshop_attributes_display', 'from' => 'admin')));
2345 2345
 				$input['type'] = 'hidden';
2346 2346
 
2347 2347
 				$box['boxMore'] = wpshop_form::check_input_type($input, $input['input_domain']);
@@ -2352,13 +2352,13 @@  discard block
 block discarded – undo
2352 2352
 			$dialog_identifier = 'wpshop_new_attribute_option_value_add';
2353 2353
 			$dialog_input_identifier = 'wpshop_new_attribute_option_value';
2354 2354
 			ob_start();
2355
-			include(WPSHOP_TEMPLATES_DIR.'admin/add_new_element_dialog.tpl.php');
2355
+			include(WPSHOP_TEMPLATES_DIR . 'admin/add_new_element_dialog.tpl.php');
2356 2356
 			$box['boxMore'] .= ob_get_contents();
2357 2357
 			ob_end_clean();
2358 2358
 			$box['boxMore'] .= '<input type="hidden" name="wpshop_attribute_type_select_code" value="" id="wpshop_attribute_type_select_code" />';
2359 2359
 
2360
-			if ( $shortcodes_to_display ) {
2361
-				switch ( WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE ) {
2360
+			if ($shortcodes_to_display) {
2361
+				switch (WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE) {
2362 2362
 					case 'fixed-tab':
2363 2363
 					case 'movable-tab':
2364 2364
 						if ($outputType == 'box') {
@@ -2366,7 +2366,7 @@  discard block
 block discarded – undo
2366 2366
 							$box['boxContent']['shortcode'] = $shortcodes_attr;
2367 2367
 							$box['box']['shortcode_backend_display_type'] = WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE;
2368 2368
 						}
2369
-						else{
2369
+						else {
2370 2370
 							$box['columnTitle']['shortcode'] = __('Product Shortcodes', 'wpshop');
2371 2371
 							$box['columnContent']['shortcode'] = $shortcodes_attr;
2372 2372
 						}
@@ -2390,12 +2390,12 @@  discard block
 block discarded – undo
2390 2390
 		$ouput['more_input'] = '';
2391 2391
 
2392 2392
 		$attribute_default_value = $attribute->default_value;
2393
-		if ( !empty($attribute->default_value) && ($attribute->default_value == serialize(false) || wpshop_tools::is_serialized( $attribute->default_value ) ) ) {
2393
+		if (!empty($attribute->default_value) && ($attribute->default_value == serialize(false) || wpshop_tools::is_serialized($attribute->default_value))) {
2394 2394
 			$tmp_default_value = unserialize($attribute->default_value);
2395 2395
 			$attribute_default_value = !empty($tmp_default_value["default_value"]) ? $tmp_default_value["default_value"] : null;
2396 2396
 		}
2397 2397
 
2398
-		if ( $attribute->data_type_to_use == 'custom') {
2398
+		if ($attribute->data_type_to_use == 'custom') {
2399 2399
 			$query = $wpdb->prepare("SELECT id, label, value, '' as name FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . " WHERE attribute_id = %d AND status = 'valid' ORDER BY position", $attribute->id);
2400 2400
 			$attribute_select_options = $wpdb->get_results($query);
2401 2401
 
@@ -2407,11 +2407,11 @@  discard block
 block discarded – undo
2407 2407
 // 				}
2408 2408
 			endforeach;
2409 2409
 		}
2410
-		elseif ( $attribute->data_type_to_use == 'internal')  {
2410
+		elseif ($attribute->data_type_to_use == 'internal') {
2411 2411
 			switch ($attribute_default_value) {
2412 2412
 				case 'users':
2413 2413
 					$users = get_users('orderby=nicename');
2414
-					foreach($users as $user){
2414
+					foreach ($users as $user) {
2415 2415
 						$attribute_select_options_list[$user->ID] = $user->display_name;
2416 2416
 					}
2417 2417
 				break;
@@ -2420,11 +2420,11 @@  discard block
 block discarded – undo
2420 2420
 					$wpshop_attr_custom_post_query = new WP_Query(array(
2421 2421
 						'post_type' => $attribute_default_value,
2422 2422
 						'posts_per_page' => -1,
2423
-						'post_status' => array( 'publish', 'draft', 'future' ) ,
2423
+						'post_status' => array('publish', 'draft', 'future'),
2424 2424
 					));
2425 2425
 
2426
-					if($wpshop_attr_custom_post_query->have_posts()):
2427
-						foreach($wpshop_attr_custom_post_query->posts as $post){
2426
+					if ($wpshop_attr_custom_post_query->have_posts()):
2427
+						foreach ($wpshop_attr_custom_post_query->posts as $post) {
2428 2428
 							$attribute_select_options_list[$post->ID] = $post->post_title;
2429 2429
 						}
2430 2430
 					endif;
@@ -2435,27 +2435,27 @@  discard block
 block discarded – undo
2435 2435
 
2436 2436
 		/*	There is no value existing for this value	*/
2437 2437
 		if (empty($attribute_select_options_list)) :
2438
-			$ouput['more_input'].=__('Nothing found for this field', 'wpshop');
2438
+			$ouput['more_input'] .= __('Nothing found for this field', 'wpshop');
2439 2439
 		else:
2440 2440
 			/*	Add a default value to the combobox list	*/
2441 2441
 			$default_value_is_serial = false;
2442 2442
 			$attribute_list_first_element = $attribute->default_value;
2443
-			if ( !empty($attribute->default_value) && ($attribute->default_value == serialize(false) || wpshop_tools::is_serialized( $attribute->default_value ) ) ) {
2443
+			if (!empty($attribute->default_value) && ($attribute->default_value == serialize(false) || wpshop_tools::is_serialized($attribute->default_value))) {
2444 2444
 				$default_value_is_serial = true;
2445 2445
 				$tmp_default_value = unserialize($attribute->default_value);
2446 2446
 				$attribute_list_first_element = $tmp_default_value["field_options"]["label_for_first_item"];
2447 2447
 			}
2448 2448
 			//if ( !in_array($attribute->frontend_input, array('radio', 'checkbox')) || ($attribute_list_first_element != 'none') ) $ouput['possible_value'][] = ($default_value_is_serial && !empty($attribute_list_first_element)) ? $attribute_list_first_element : __('Choose a value', 'wpshop');
2449
-			foreach ( $attribute_select_options_list as $option_key => $option_value ) {
2449
+			foreach ($attribute_select_options_list as $option_key => $option_value) {
2450 2450
 				$ouput['possible_value'][$option_key] = stripslashes($option_value);
2451 2451
 			}
2452 2452
 		endif;
2453 2453
 
2454 2454
 		/*	Add a extra element to create a new element into list	*/
2455
-		if ( is_admin()  && ( empty($provenance['from']) || ($provenance['from'] != 'frontend')) ) {
2455
+		if (is_admin() && (empty($provenance['from']) || ($provenance['from'] != 'frontend'))) {
2456 2456
 			/**	$ouput['more_input'] .= '<img src="'.WPSHOP_MEDIAS_ICON_URL.'add.png" id="new_value_pict_' . $attribute->code . '" alt="'.__('Add a new value for this attribute', 'wpshop').'" title="'.__('Add a new value for this attribute', 'wpshop').'" class="wpshop_icons wpshop_icons_add_new_value_to_option_list wpshop_icons_add_new_value_to_option_list_'.$attribute->code.'" />';	*/
2457 2457
 		}
2458
-		else if ( 'yes' == $attribute->is_used_in_quick_add_form ) {
2458
+		else if ('yes' == $attribute->is_used_in_quick_add_form) {
2459 2459
 			$tpl_component = array();
2460 2460
 			$tpl_component['NEW_ELEMENT_CREATION_FIELD'] = 'attribute[new_value_creation][' . $attribute->code . ']';
2461 2461
 			$ouput['more_input'] .= wpshop_display::display_template_element('quick_entity_specific_field_new_element', $tpl_component);
@@ -2464,11 +2464,11 @@  discard block
 block discarded – undo
2464 2464
 		return $ouput;
2465 2465
 	}
2466 2466
 
2467
-	public static function get_affected_value_for_list( $attribute_code, $element_id, $attribute_data_type ) {
2467
+	public static function get_affected_value_for_list($attribute_code, $element_id, $attribute_data_type) {
2468 2468
 		global $wpdb;
2469 2469
 		$affected_value = array();
2470 2470
 
2471
-		if ( $attribute_data_type == 'custom' ) {
2471
+		if ($attribute_data_type == 'custom') {
2472 2472
 			$query = $wpdb->prepare("
2473 2473
 SELECT ATT_SELECT_OPTIONS_VALUE.id AS chosen_val, ATT_SELECT_OPTIONS_VALUE.value
2474 2474
 FROM " . WPSHOP_DBT_ATTRIBUTE . " AS ATT
@@ -2490,20 +2490,20 @@  discard block
 block discarded – undo
2490 2490
 		}
2491 2491
 
2492 2492
 		$attribute_values_for_variations = $wpdb->get_results($query);
2493
-		foreach ( $attribute_values_for_variations as $attribute_def ) {
2494
-			$affected_value[] = (int) $attribute_def->chosen_val;
2493
+		foreach ($attribute_values_for_variations as $attribute_def) {
2494
+			$affected_value[] = (int)$attribute_def->chosen_val;
2495 2495
 		}
2496 2496
 
2497 2497
 		return $affected_value;
2498 2498
 	}
2499 2499
 
2500 2500
 	public static function get_attribute_option_output($item, $attr_code, $attr_option, $additionnal_params = '') {
2501
-		switch($attr_code){
2501
+		switch ($attr_code) {
2502 2502
 			case 'is_downloadable_':
2503
-				$option = get_post_meta($item['item_id'], 'attribute_option_'.$attr_code, true);
2504
-				switch($attr_option){
2503
+				$option = get_post_meta($item['item_id'], 'attribute_option_' . $attr_code, true);
2504
+				switch ($attr_option) {
2505 2505
 					case 'file_url':
2506
-						if(in_array($additionnal_params['order_status'], array('completed', 'shipped')) && (!empty($item['item_'.$attr_code]) && (strtolower(__($item['item_'.$attr_code], 'wpshop')) == __('yes','wpshop'))) ){
2506
+						if (in_array($additionnal_params['order_status'], array('completed', 'shipped')) && (!empty($item['item_' . $attr_code]) && (strtolower(__($item['item_' . $attr_code], 'wpshop')) == __('yes', 'wpshop')))) {
2507 2507
 							$file_url = isset($option[$attr_option]) ? $option[$attr_option] : false;
2508 2508
 							return $file_url;
2509 2509
 						}
@@ -2516,17 +2516,17 @@  discard block
 block discarded – undo
2516 2516
 
2517 2517
 	public static function get_attribute_option_fields($postid, $code) {
2518 2518
 
2519
-		switch($code){
2519
+		switch ($code) {
2520 2520
 			case 'is_downloadable_':
2521
-				$data = get_post_meta($postid, 'attribute_option_'.$code, true);
2522
-				$data['file_url'] = !empty($data['file_url'])?$data['file_url']:__('No file selected', 'wpshop');
2523
-				$fields =  wp_nonce_field( 'ajax_wpshop_show_downloadable_interface_in_admin'.$postid, '_show_downloadable_interface_in_admin_wpnonce', true, false );
2521
+				$data = get_post_meta($postid, 'attribute_option_' . $code, true);
2522
+				$data['file_url'] = !empty($data['file_url']) ? $data['file_url'] : __('No file selected', 'wpshop');
2523
+				$fields = wp_nonce_field('ajax_wpshop_show_downloadable_interface_in_admin' . $postid, '_show_downloadable_interface_in_admin_wpnonce', true, false);
2524 2524
 				$fields .= '<div class="wpshop_form_label alignleft">&nbsp;</div>
2525 2525
 						<div class="wpshop_form_input_element alignleft">
2526
-						<div class="send_downloadable_file_dialog wpshop_add_box" data-post="'.$postid.'" title="' .__('Send the downloadable file', 'wpshop'). '"></div>
2527
-						<a data-nonce="' . wp_create_nonce( "ajax_wpshop_fill_the_downloadable_dialog".$postid ) . '"  class="send_downlodable_file wps-bton-first-mini-rounded">' .__('Send a file', 'wpshop').'</a>
2528
-						<input type="hidden" class="product_identifer_field" value="' .( !empty($postid) ? esc_attr( $postid ) : '') . '" /><br/><u>'.__('File url','wpshop').' :</u>
2529
-						<div class="is_downloadable_statut_'.$postid.'"><a href="' .$data['file_url']. '" target="_blank" download>'.basename($data['file_url']).'</a></div>
2526
+						<div class="send_downloadable_file_dialog wpshop_add_box" data-post="'.$postid . '" title="' . __('Send the downloadable file', 'wpshop') . '"></div>
2527
+						<a data-nonce="' . wp_create_nonce("ajax_wpshop_fill_the_downloadable_dialog" . $postid) . '"  class="send_downlodable_file wps-bton-first-mini-rounded">' . __('Send a file', 'wpshop') . '</a>
2528
+						<input type="hidden" class="product_identifer_field" value="' .(!empty($postid) ? esc_attr($postid) : '') . '" /><br/><u>' . __('File url', 'wpshop') . ' :</u>
2529
+						<div class="is_downloadable_statut_'.$postid . '"><a href="' . $data['file_url'] . '" target="_blank" download>' . basename($data['file_url']) . '</a></div>
2530 2530
 						</div>';
2531 2531
 				return $fields;
2532 2532
 				break;
@@ -2551,8 +2551,8 @@  discard block
 block discarded – undo
2551 2551
 		$attribute_value_content = '';
2552 2552
 
2553 2553
 		$atributes = self::getElement($attribute_code, "'valid'", 'code');
2554
-		if ( !empty($atributes) ) {
2555
-			$attribute_value_content = self::getAttributeValueForEntityInSet($atributes->data_type, $atributes->id,  wpshop_entities::get_entity_identifier_from_code($entity_type), $entity_id);
2554
+		if (!empty($atributes)) {
2555
+			$attribute_value_content = self::getAttributeValueForEntityInSet($atributes->data_type, $atributes->id, wpshop_entities::get_entity_identifier_from_code($entity_type), $entity_id);
2556 2556
 		}
2557 2557
 
2558 2558
 		return $attribute_value_content;
@@ -2564,14 +2564,14 @@  discard block
 block discarded – undo
2564 2564
 	 * @param mixed $value
2565 2565
 	 * @return string The complete interface allowing to manage datetime attribute field
2566 2566
 	 */
2567
-	function attribute_type_date_config( $value ) {
2567
+	function attribute_type_date_config($value) {
2568 2568
 		$date_config_output = '';
2569 2569
 
2570 2570
 		$input_def['name'] = 'default_value';
2571 2571
 		$input_def['type'] = 'checkbox';
2572 2572
 		$input_def['possible_value'] = 'date_of_current_day';
2573 2573
 		$input_def['value'] = !empty($value['default_value']) ? $value['default_value'] : '';
2574
-		$input_def['options_label']['custom'] = ' ' . __('Use the date of the day as default value', 'wpshop') . ' <a href="#" title="'.__('Check this box for using date of the day as value when editing a product', 'wpshop').'" class="wpshop_infobulle_marker">?</a>';
2574
+		$input_def['options_label']['custom'] = ' ' . __('Use the date of the day as default value', 'wpshop') . ' <a href="#" title="' . __('Check this box for using date of the day as value when editing a product', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>';
2575 2575
 		$date_config_output .= wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE);
2576 2576
 
2577 2577
 		$input_def = array();
@@ -2580,35 +2580,35 @@  discard block
 block discarded – undo
2580 2580
 		$input_def['type'] = 'checkbox';
2581 2581
 		$input_def['valueToPut'] = 'index';
2582 2582
 		$input_def['value'] = !empty($value['field_options']['attribute_type_date_options_day_to_show']) ? $value['field_options']['attribute_type_date_options_day_to_show'] : '';
2583
-		$input_def['possible_value'] = array('1' => ' ' . __('Monday', 'wpshop'), '2' => ' ' .__('Tuesday', 'wpshop'), '3' => ' ' .__('Wednesday', 'wpshop'), '4' => ' ' .__('Thursday', 'wpshop'), '5' => ' ' .__('Friday', 'wpshop'), '6' => ' ' .__('Saturday', 'wpshop'), '0' => ' ' .__('Sunday', 'wpshop'));
2583
+		$input_def['possible_value'] = array('1' => ' ' . __('Monday', 'wpshop'), '2' => ' ' . __('Tuesday', 'wpshop'), '3' => ' ' . __('Wednesday', 'wpshop'), '4' => ' ' . __('Thursday', 'wpshop'), '5' => ' ' . __('Friday', 'wpshop'), '6' => ' ' . __('Saturday', 'wpshop'), '0' => ' ' . __('Sunday', 'wpshop'));
2584 2584
 		$input_def['options_label']['original'] = true;
2585
-		$date_config_output .= '<div>' . __('Choose available days in date picker', 'wpshop') . '<a href="#" title="'.__('This option allows you to define the available day in final datepicker', 'wpshop').'" class="wpshop_infobulle_marker">?</a>' . '<br/>' . wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE . '_options[attribute_type_date_options_day_to_show]') . '</div>';
2585
+		$date_config_output .= '<div>' . __('Choose available days in date picker', 'wpshop') . '<a href="#" title="' . __('This option allows you to define the available day in final datepicker', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>' . '<br/>' . wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE . '_options[attribute_type_date_options_day_to_show]') . '</div>';
2586 2586
 
2587 2587
 		/**	Past and futur date restriction	*/
2588 2588
 		$input_def = array();
2589 2589
 		$input_def['name'] = '';
2590 2590
 		$input_def['type'] = 'text';
2591
-		$date_config_output .= '<div id="wpshop_avalaible_date_for_past_and_futur" >' . __('Calendar past and futur date available', 'wpshop') . '<a href="#" title="'.__('Define if the end user is allowed to choose past and/or futur date', 'wpshop').'" class="wpshop_infobulle_marker">?</a><br/>';
2591
+		$date_config_output .= '<div id="wpshop_avalaible_date_for_past_and_futur" >' . __('Calendar past and futur date available', 'wpshop') . '<a href="#" title="' . __('Define if the end user is allowed to choose past and/or futur date', 'wpshop') . '" class="wpshop_infobulle_marker">?</a><br/>';
2592 2592
 		$available_type_input_def = array();
2593 2593
 		$available_type_input_def['name'] = '';
2594 2594
 		$available_type_input_def['id'] = 'wpshop_attributes_edition_table_field_attribute_type_date_options_available_date_past_futur_minimum';
2595 2595
 		$available_type_input_def['type'] = 'text';
2596 2596
 		$available_type_input_def['value'] = !empty($value['field_options']['attribute_type_date_options_available_date_past_futur']['minDate'][0]) ? $value['field_options']['attribute_type_date_options_available_date_past_futur']['minDate'][0] : '';
2597
-		$date_config_output .= __('Minimum date to show', 'wpshop') . '<a href="#" title="'.__('If you want the calendar to start today put only 0, if you want to show anterior date, put the number of Day or Month or Year (ex: -1D)', 'wpshop').'" class="wpshop_infobulle_marker">?</a>' . wpshop_form::check_input_type($available_type_input_def, WPSHOP_DBT_ATTRIBUTE . '_options[attribute_type_date_options_available_date_past_futur][minDate]') . '<br/>';
2597
+		$date_config_output .= __('Minimum date to show', 'wpshop') . '<a href="#" title="' . __('If you want the calendar to start today put only 0, if you want to show anterior date, put the number of Day or Month or Year (ex: -1D)', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>' . wpshop_form::check_input_type($available_type_input_def, WPSHOP_DBT_ATTRIBUTE . '_options[attribute_type_date_options_available_date_past_futur][minDate]') . '<br/>';
2598 2598
 		$available_type_input_def = array();
2599 2599
 		$available_type_input_def['name'] = '';
2600 2600
 		$available_type_input_def['id'] = 'wpshop_attributes_edition_table_field_attribute_type_date_options_available_date_past_futur_maximum';
2601 2601
 		$available_type_input_def['type'] = 'text';
2602 2602
 		$available_type_input_def['value'] = !empty($value['field_options']['attribute_type_date_options_available_date_past_futur']['maxDate'][0]) ? $value['field_options']['attribute_type_date_options_available_date_past_futur']['maxDate'][0] : '';
2603
-		$date_config_output .= __('Maximum date to show', 'wpshop') . '<a href="#" title="'.__('If you want the calendar to end today put only 0, if you want to show date in futur, put the number of Day or Month or Year (ex: +1M)', 'wpshop').'" class="wpshop_infobulle_marker">?</a>' . wpshop_form::check_input_type($available_type_input_def, WPSHOP_DBT_ATTRIBUTE . '_options[attribute_type_date_options_available_date_past_futur][maxDate]') . '<br/>';
2603
+		$date_config_output .= __('Maximum date to show', 'wpshop') . '<a href="#" title="' . __('If you want the calendar to end today put only 0, if you want to show date in futur, put the number of Day or Month or Year (ex: +1M)', 'wpshop') . '" class="wpshop_infobulle_marker">?</a>' . wpshop_form::check_input_type($available_type_input_def, WPSHOP_DBT_ATTRIBUTE . '_options[attribute_type_date_options_available_date_past_futur][maxDate]') . '<br/>';
2604 2604
 		$date_config_output .= '</div>';
2605 2605
 
2606 2606
 		$input_def = array();
2607 2607
 		$input_def['name'] = '';
2608 2608
 		$input_def['type'] = 'text';
2609 2609
 		$date_config_output .= '
2610
-<div id="wpshop_attribute_date_empy_field" class="wpshopHide" ><br/>' . wpshop_form::check_input_type(array_merge($input_def, array('value' => '', 'id' => 'wpshop_attributes_edition_table_field_attribute_type_date_options_available_date_new_input')), WPSHOP_DBT_ATTRIBUTE . '_options[attribute_type_date_options_available_date]') .'</div>
2611
-<div id="wpshop_avalaible_date_list_container" >' . __('Choose available date in date picker', 'wpshop') . '<a href="#" title="'.__('This option allows you to define the available date in final datepicker', 'wpshop').'" class="wpshop_infobulle_marker">?</a><br/>';
2610
+<div id="wpshop_attribute_date_empy_field" class="wpshopHide" ><br/>' . wpshop_form::check_input_type(array_merge($input_def, array('value' => '', 'id' => 'wpshop_attributes_edition_table_field_attribute_type_date_options_available_date_new_input')), WPSHOP_DBT_ATTRIBUTE . '_options[attribute_type_date_options_available_date]') . '</div>
2611
+<div id="wpshop_avalaible_date_list_container" >' . __('Choose available date in date picker', 'wpshop') . '<a href="#" title="' . __('This option allows you to define the available date in final datepicker', 'wpshop') . '" class="wpshop_infobulle_marker">?</a><br/>';
2612 2612
 
2613 2613
 		$available_type_input_def = array();
2614 2614
 		$available_type_input_def['name'] = '';
@@ -2621,9 +2621,9 @@  discard block
 block discarded – undo
2621 2621
 		$date_config_output .= wpshop_form::check_input_type($available_type_input_def, WPSHOP_DBT_ATTRIBUTE . '_options[attribute_type_date_options_available_date_type]') . '<br/>';
2622 2622
 
2623 2623
 		$existing = 0;
2624
-		if ( !empty($value['field_options']['attribute_type_date_options_available_date']) ) {
2625
-			foreach ( $value['field_options']['attribute_type_date_options_available_date'] as $index => $value ) {
2626
-				if ( !empty($value) ) {
2624
+		if (!empty($value['field_options']['attribute_type_date_options_available_date'])) {
2625
+			foreach ($value['field_options']['attribute_type_date_options_available_date'] as $index => $value) {
2626
+				if (!empty($value)) {
2627 2627
 					$input_def['value'] = $value;
2628 2628
 					$input_def['id'] = 'wpshop_attributes_edition_table_field_attribute_type_date_options_available_date_' . $index;
2629 2629
 					$date_config_output .= wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE . '_options[attribute_type_date_options_available_date]') . '<br/>';
@@ -2647,20 +2647,20 @@  discard block
 block discarded – undo
2647 2647
 	 * @param array $values Valeurs d'attributs
2648 2648
 	 * @return array
2649 2649
 	 */
2650
-	public static function setAttributesValuesForItem($entityId, $values=array(), $defaultValueForOthers=false, $from = 'webservice') {
2651
-		$message='';
2650
+	public static function setAttributesValuesForItem($entityId, $values = array(), $defaultValueForOthers = false, $from = 'webservice') {
2651
+		$message = '';
2652 2652
 		$attribute_available = array();
2653 2653
 		$attribute_final = array();
2654 2654
 		$entity_type = get_post_type($entityId);
2655
-		$data = self::get_attribute_list_for_item( wpshop_entities::get_entity_identifier_from_code($entity_type), $entityId, WPSHOP_CURRENT_LOCALE);
2656
-		foreach($data as $d) $attribute_available[$d->attribute_code] = array('attribute_id' => $d->attribute_id, 'data_type' => $d->data_type);
2655
+		$data = self::get_attribute_list_for_item(wpshop_entities::get_entity_identifier_from_code($entity_type), $entityId, WPSHOP_CURRENT_LOCALE);
2656
+		foreach ($data as $d) $attribute_available[$d->attribute_code] = array('attribute_id' => $d->attribute_id, 'data_type' => $d->data_type);
2657 2657
 
2658 2658
 		// Creation d'un array "propre" et valide pour la fonction self::saveAttributeForEntity
2659
-		foreach ( $values as $key => $value ) {
2660
-			if ( in_array( $key, array_keys( $attribute_available ) ) ) {
2659
+		foreach ($values as $key => $value) {
2660
+			if (in_array($key, array_keys($attribute_available))) {
2661 2661
 				$attribute_final[$attribute_available[$key]['data_type']][$key] = $value;
2662 2662
 			}
2663
-			else $message .= sprintf(__('Impossible to set "%s" attribute', 'wpshop'), $key)."\n";
2663
+			else $message .= sprintf(__('Impossible to set "%s" attribute', 'wpshop'), $key) . "\n";
2664 2664
 		}
2665 2665
 
2666 2666
 		// Pour les autres attributs non donné on leur affecte leur valeur par défaut
@@ -2681,7 +2681,7 @@  discard block
 block discarded – undo
2681 2681
 			}
2682 2682
 		}
2683 2683
 
2684
-		switch ( $entity_type ) {
2684
+		switch ($entity_type) {
2685 2685
 			case WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT:
2686 2686
 					$meta_key = WPSHOP_PRODUCT_ATTRIBUTE_META_KEY;
2687 2687
 				break;
@@ -2711,22 +2711,22 @@  discard block
 block discarded – undo
2711 2711
 	 */
2712 2712
 	public static function get_attribute_type_select_option_info($option_id, $field = 'label', $attribute_data_type = 'custom', $only_value = false) {
2713 2713
 		global $wpdb;
2714
-		if( ! is_numeric( $option_id ) ) {
2714
+		if (!is_numeric($option_id)) {
2715 2715
 			return '';
2716 2716
 		}
2717
-		$option_id = (int) $option_id;
2718
-		switch ( $attribute_data_type ) {
2717
+		$option_id = (int)$option_id;
2718
+		switch ($attribute_data_type) {
2719 2719
 			case 'internal':
2720 2720
 				$entity_infos = get_post($option_id);
2721
-				if ( !empty($entity_infos) ) {
2722
-					if ( !$only_value ) {
2721
+				if (!empty($entity_infos)) {
2722
+					if (!$only_value) {
2723 2723
 						/** Template parameters */
2724 2724
 						$template_part = 'product_attribute_value_internal';
2725 2725
 						$tpl_component = array();
2726 2726
 						$tpl_component['ATTRIBUTE_VALUE_POST_LINK'] = get_permalink($option_id);
2727 2727
 						$tpl_component['ATTRIBUTE_VALUE_POST_TITLE'] = $entity_infos->post_title;
2728 2728
 
2729
-						foreach ( $entity_infos as $post_definition_key => $post_definition_value ) {
2729
+						foreach ($entity_infos as $post_definition_key => $post_definition_value) {
2730 2730
 							$tpl_component['ATTRIBUTE_VALUE_' . strtoupper($post_definition_key)] = $entity_infos->$post_definition_key;
2731 2731
 						}
2732 2732
 
@@ -2741,8 +2741,8 @@  discard block
 block discarded – undo
2741 2741
 				break;
2742 2742
 
2743 2743
 			default:
2744
-				if ( ! array_key_exists( $option_id, self::$select_option_info_cache ) ) {
2745
-					$query = $wpdb->prepare("SELECT " . $field . " FROM ".WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS." WHERE id=%d LIMIT 1", $option_id);
2744
+				if (!array_key_exists($option_id, self::$select_option_info_cache)) {
2745
+					$query = $wpdb->prepare("SELECT " . $field . " FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . " WHERE id=%d LIMIT 1", $option_id);
2746 2746
 					self::$select_option_info_cache[$option_id] = $wpdb->get_var($query);
2747 2747
 				}
2748 2748
 				$info = self::$select_option_info_cache[$option_id];
@@ -2782,39 +2782,39 @@  discard block
 block discarded – undo
2782 2782
 	 * @param string $data_type optionnal Le type de donnees choisi pour cet attribut (custom | internal)
2783 2783
 	 * @return string Le resultat sous forme de code html pour la liste des options
2784 2784
 	 */
2785
-	function get_select_options_list($attribute_id, $data_type='custom') {
2785
+	function get_select_options_list($attribute_id, $data_type = 'custom') {
2786 2786
 		global $wpdb;
2787 2787
 		$output = '';
2788 2788
 
2789 2789
 		$attribute_select_options = self::get_select_option_list_($attribute_id);
2790 2790
 
2791 2791
 		/*	Add possibily to choose datat type to use with list	*/
2792
-		if(empty($attribute_id) || (!empty($attribute_select_options) && empty($attribute_select_options[0]->data_type_to_use))){
2793
-			unset($input_def);$input_def=array();
2792
+		if (empty($attribute_id) || (!empty($attribute_select_options) && empty($attribute_select_options[0]->data_type_to_use))) {
2793
+			unset($input_def); $input_def = array();
2794 2794
 			$input_def['label'] = __('Type of data for list', 'wpshop');
2795 2795
 			$input_def['type'] = 'radio';
2796 2796
 			$input_def['name'] = 'data_type_to_use';
2797 2797
 			$input_def['valueToPut'] = 'index';
2798 2798
 			$input_def['possible_value'] = unserialize(WPSHOP_ATTR_SELECT_TYPE);
2799 2799
 			$input_def['option'] = 'class="wpshop_cls wpshop_attr_combo_data_type"';
2800
-			$input_def['value'] = $data_type.'_data';
2800
+			$input_def['value'] = $data_type . '_data';
2801 2801
 			$input_def['options_label']['original'] = true;
2802 2802
 			$output = wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE);
2803 2803
 		}
2804 2804
 
2805
-		if(!empty($attribute_id) || !empty($data_type)){
2806
-			$defaut_value = ( !empty($attribute_select_options[0]) && !empty($attribute_select_options[0]->default_value) ) ? $attribute_select_options[0]->default_value : null;
2805
+		if (!empty($attribute_id) || !empty($data_type)) {
2806
+			$defaut_value = (!empty($attribute_select_options[0]) && !empty($attribute_select_options[0]->default_value)) ? $attribute_select_options[0]->default_value : null;
2807 2807
 			$default_is_serial = false;
2808
-			if ( !empty($attribute_select_options[0]->default_value) && ($attribute_select_options[0]->default_value == serialize(false) || wpshop_tools::is_serialized( $attribute_select_options[0]->default_value ) ) ) {
2808
+			if (!empty($attribute_select_options[0]->default_value) && ($attribute_select_options[0]->default_value == serialize(false) || wpshop_tools::is_serialized($attribute_select_options[0]->default_value))) {
2809 2809
 				$defaut_value = unserialize($attribute_select_options[0]->default_value);
2810 2810
 				$default_is_serial = true;
2811 2811
 			}
2812 2812
 			/**	Add a custom text first item of list	*/
2813
-			$output .= '<div class="wpshop_cls" ><label for="text_for_empty_value" >' . __('Text displayed when no value selected', 'wpshop') . '</label> <input type="text" name="' . WPSHOP_DBT_ATTRIBUTE . '[default_value][field_options][label_for_first_item]" value="' . (($default_is_serial && is_array($defaut_value) && !empty($defaut_value["field_options"]["label_for_first_item"])) ? stripslashes( $defaut_value["field_options"]["label_for_first_item"] ) : __('Choose a value', 'wpshop')) . '" id="text_for_empty_value" /></div>';
2813
+			$output .= '<div class="wpshop_cls" ><label for="text_for_empty_value" >' . __('Text displayed when no value selected', 'wpshop') . '</label> <input type="text" name="' . WPSHOP_DBT_ATTRIBUTE . '[default_value][field_options][label_for_first_item]" value="' . (($default_is_serial && is_array($defaut_value) && !empty($defaut_value["field_options"]["label_for_first_item"])) ? stripslashes($defaut_value["field_options"]["label_for_first_item"]) : __('Choose a value', 'wpshop')) . '" id="text_for_empty_value" /></div>';
2814 2814
 
2815
-			if((($data_type == 'custom') && empty($attribute_select_options)) || (!empty($attribute_select_options) && !empty($attribute_select_options[0]->data_type_to_use) && ($attribute_select_options[0]->data_type_to_use == 'custom'))){
2815
+			if ((($data_type == 'custom') && empty($attribute_select_options)) || (!empty($attribute_select_options) && !empty($attribute_select_options[0]->data_type_to_use) && ($attribute_select_options[0]->data_type_to_use == 'custom'))) {
2816 2816
 				$sub_output = '';
2817
-				if ( !empty($attribute_select_options) && !empty($attribute_select_options[0]) && !empty($attribute_select_options[0]->id) ) {
2817
+				if (!empty($attribute_select_options) && !empty($attribute_select_options[0]) && !empty($attribute_select_options[0]->id)) {
2818 2818
 					$sub_output .= '
2819 2819
 					<li class="wpshop_attribute_combo_options_container ui-state-disabled" >
2820 2820
 						<input type="radio" name="' . WPSHOP_DBT_ATTRIBUTE . '[default_value][default_value]" value="" id="default_value_empty" ' . (($default_is_serial && is_array($defaut_value) && empty($defaut_value["default_value"])) || empty($defaut_value) ? 'checked ' : '') . '/> <label for="default_value_empty">' . __('No default value', 'wpshop') . '</label>
@@ -2827,7 +2827,7 @@  discard block
 block discarded – undo
2827 2827
 						$tpl_component['ADMIN_ATTRIBUTE_VALUES_OPTION_VALUE'] = str_replace(".", ",", $options->value);
2828 2828
 						$tpl_component['ADMIN_ATTRIBUTE_VALUES_OPTION_STATE'] = (!empty($options->id) && (($default_is_serial && is_array($defaut_value) && !empty($defaut_value["default_value"]) && ($defaut_value["default_value"] == $options->id))) ? ' checked="checked"' : '');
2829 2829
 						$tpl_component['ADMIN_ATTRIBUTE_VALUE_OPTIN_ACTIONS'] = '';
2830
-						if( current_user_can('wpshop_delete_attributes_select_values') && ($options->value_id >= 0) ):
2830
+						if (current_user_can('wpshop_delete_attributes_select_values') && ($options->value_id >= 0)):
2831 2831
 							$tpl_component['ADMIN_ATTRIBUTE_VALUE_OPTIN_ACTIONS'] .= wpshop_display::display_template_element('wpshop_admin_attr_option_value_item_deletion', $tpl_component, array('type' => WPSHOP_DBT_ATTRIBUTE, 'id' => $attribute_id), 'admin');
2832 2832
 						endif;
2833 2833
 						$sub_output .= wpshop_display::display_template_element('wpshop_admin_attr_option_value_item', $tpl_component, array('type' => WPSHOP_DBT_ATTRIBUTE, 'id' => $attribute_id), 'admin');
@@ -2835,13 +2835,13 @@  discard block
 block discarded – undo
2835 2835
 					}
2836 2836
 				}
2837 2837
 				$add_button = $add_dialog_box = $user_more_script = '';
2838
-				if( current_user_can('wpshop_add_attributes_select_values') ) {
2838
+				if (current_user_can('wpshop_add_attributes_select_values')) {
2839 2839
 
2840 2840
 					$dialog_title = __('New value for attribute', 'wpshop');
2841 2841
 					$dialog_identifier = 'wpshop_new_attribute_option_value_add';
2842 2842
 					$dialog_input_identifier = 'wpshop_new_attribute_option_value';
2843 2843
 					ob_start();
2844
-					include(WPSHOP_TEMPLATES_DIR.'admin/add_new_element_dialog.tpl.php');
2844
+					include(WPSHOP_TEMPLATES_DIR . 'admin/add_new_element_dialog.tpl.php');
2845 2845
 					$add_dialog_box = ob_get_contents();
2846 2846
 					ob_end_clean();
2847 2847
 
@@ -2849,23 +2849,23 @@  discard block
 block discarded – undo
2849 2849
 					$add_button_parent_class = 'wpshop_attribute_option_value_add';
2850 2850
 					$add_button_name = 'wpshop_add_option_to_select';
2851 2851
 					ob_start();
2852
-					include(WPSHOP_TEMPLATES_DIR.'admin/add_new_element_with_dialog.tpl.php');
2852
+					include(WPSHOP_TEMPLATES_DIR . 'admin/add_new_element_with_dialog.tpl.php');
2853 2853
 					$add_button = ob_get_contents();
2854 2854
 					ob_end_clean();
2855 2855
 
2856 2856
 					$user_more_script = '
2857
-			jQuery("#'.$dialog_identifier.'").dialog({
2857
+			jQuery("#'.$dialog_identifier . '").dialog({
2858 2858
 				modal: true,
2859 2859
 				dialogClass: "wpshop_uidialog_box",
2860 2860
 				autoOpen:false,
2861 2861
 				show: "blind",
2862 2862
 				resizable: false,
2863 2863
 				buttons:{
2864
-					"'.__('Add', 'wpshop').'": function(){
2864
+					"'.__('Add', 'wpshop') . '": function(){
2865 2865
 						var data = {
2866 2866
 							action: "new_option_for_select",
2867 2867
 							wpshop_ajax_nonce: "' . wp_create_nonce("wpshop_new_option_for_attribute_creation") . '",
2868
-							attribute_new_label: jQuery("#'.$dialog_input_identifier.'").val(),
2868
+							attribute_new_label: jQuery("#'.$dialog_input_identifier . '").val(),
2869 2869
 							attribute_identifier: "' . $attribute_id . '"
2870 2870
 						};
2871 2871
 						jQuery.post(ajaxurl, data, function(response) {
@@ -2881,21 +2881,21 @@  discard block
 block discarded – undo
2881 2881
 
2882 2882
 						jQuery(this).children("img").show();
2883 2883
 					},
2884
-					"'.__('Cancel', 'wpshop').'": function(){
2884
+					"'.__('Cancel', 'wpshop') . '": function(){
2885 2885
 						jQuery(this).dialog("close");
2886 2886
 					}
2887 2887
 				},
2888 2888
 				close:function(){
2889
-					jQuery("#'.$dialog_input_identifier.'").val("");
2889
+					jQuery("#'.$dialog_input_identifier . '").val("");
2890 2890
 				}
2891 2891
 			});
2892
-			jQuery(".'.$add_button_parent_class.' input").click(function(){
2893
-				jQuery("#'.$dialog_identifier.'").dialog("open");
2892
+			jQuery(".'.$add_button_parent_class . ' input").click(function(){
2893
+				jQuery("#'.$dialog_identifier . '").dialog("open");
2894 2894
 			});';
2895 2895
 
2896 2896
 				}
2897 2897
 				$output .= $add_dialog_box . '
2898
-	<ul id="sortable_attribute" class="wpshop_cls" >'.(count($attribute_select_options)>5 ? $add_button : '').$sub_output.$add_button.'
2898
+	<ul id="sortable_attribute" class="wpshop_cls" >'.(count($attribute_select_options) > 5 ? $add_button : '') . $sub_output . $add_button . '
2899 2899
 	</ul>
2900 2900
 	<input type="hidden" value="' . wp_create_nonce("wpshop_new_option_for_attribute_deletion") . '" name="wpshop_new_option_for_attribute_deletion_nonce" id="wpshop_new_option_for_attribute_deletion_nonce" />
2901 2901
 	<script type="text/javascript" >
@@ -2911,7 +2911,7 @@  discard block
 block discarded – undo
2911 2911
 					var data = {
2912 2912
 						action: "attribute_output_type",
2913 2913
 						current_type: jQuery("#wpshop_attributes_edition_table_field_id_frontend_input").val(),
2914
-						elementIdentifier: "'.$attribute_id.'",
2914
+						elementIdentifier: "'.$attribute_id . '",
2915 2915
 						data_type_to_use: jQuery(this).val(),
2916 2916
 						wpshop_ajax_nonce: "' . wp_create_nonce("wpshop_attribute_output_type_selection") . '"
2917 2917
 					};
@@ -2926,10 +2926,10 @@  discard block
 block discarded – undo
2926 2926
 		});
2927 2927
 	</script>';
2928 2928
 			}
2929
-			elseif((($data_type == 'internal') && empty($attribute_select_options)) || (!empty($attribute_select_options) && !empty($attribute_select_options[0]->data_type_to_use) && ($attribute_select_options[0]->data_type_to_use == 'internal'))){
2930
-				$sub_output='';
2929
+			elseif ((($data_type == 'internal') && empty($attribute_select_options)) || (!empty($attribute_select_options) && !empty($attribute_select_options[0]->data_type_to_use) && ($attribute_select_options[0]->data_type_to_use == 'internal'))) {
2930
+				$sub_output = '';
2931 2931
 				$wp_types = unserialize(WPSHOP_INTERNAL_TYPES);
2932
-				unset($input_def);$input_def=array();
2932
+				unset($input_def); $input_def = array();
2933 2933
 				$input_def['label'] = __('Type of data for list', 'wpshop');
2934 2934
 				$input_def['type'] = 'select';
2935 2935
 				$input_def['name'] = 'default_value][default_value';
@@ -2938,20 +2938,20 @@  discard block
 block discarded – undo
2938 2938
 				$input_def['possible_value'] = $wp_types;
2939 2939
 				$input_def['value'] = (($default_is_serial && is_array($defaut_value) && !empty($defaut_value["default_value"])) ? $defaut_value["default_value"] : (!empty($defaut_value) ? $defaut_value : null));
2940 2940
 				$combo_wp_type = wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE);
2941
-				$output .= '<div class="wpshop_cls">'.$combo_wp_type.'</div>';
2942
-				if ( !empty($attribute_id) ) {
2941
+				$output .= '<div class="wpshop_cls">' . $combo_wp_type . '</div>';
2942
+				if (!empty($attribute_id)) {
2943 2943
 					$option_list = '<div>' . __('You can reorder element for display them in the order you want into frontend part', 'wpshop') . '</div>';
2944
-					$options_for_current_attribute = query_posts( array('post_type' => $input_def['value'], 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => 'ASC' ) );
2945
-					if ( !empty($options_for_current_attribute) ) {
2944
+					$options_for_current_attribute = query_posts(array('post_type' => $input_def['value'], 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => 'ASC'));
2945
+					if (!empty($options_for_current_attribute)) {
2946 2946
 						$option_list .= '<ul class="wpshop_attribute_combo_values_list_container" >';
2947 2947
 						$current_order = ' ';
2948
-						foreach ( $options_for_current_attribute as $options_def ) {
2948
+						foreach ($options_for_current_attribute as $options_def) {
2949 2949
 							$current_order .= 'post_' . $options_def->ID . ',';
2950 2950
 							$option_list .= '<li id="post_' . $options_def->ID . '" class="wpshop_attribute_combo_values_list_item wpshop_attribute_combo_values_list_item_' . $options_def->ID . '" ><span class="wpshop_internal_value_for_option_list_identifier" >#' . $options_def->ID . '</span> ' . $options_def->post_title . '</li>';
2951 2951
 						}
2952 2952
 						$option_list .= '</ul><input type="hidden" value="' . substr($current_order, 0, -1) . '" name="' . WPSHOP_DBT_ATTRIBUTE . '[wpshop_attribute_combo_values_list_order_def]" id="wpshop_attribute_combo_values_list_order_def" />';
2953 2953
 					}
2954
-					$output .= '<div class="wpshop_cls">'.$option_list.'</div>';
2954
+					$output .= '<div class="wpshop_cls">' . $option_list . '</div>';
2955 2955
 				}
2956 2956
 			}
2957 2957
 		}
@@ -2979,8 +2979,8 @@  discard block
 block discarded – undo
2979 2979
 		$attribute_list_for_entity = self::getElement($entity_id, "'valid'", 'entity_id', true);
2980 2980
 
2981 2981
 		/*	Read the list	*/
2982
-		if ( !empty ($attribute_list_for_entity ) ) {
2983
-			foreach ( $attribute_list_for_entity as $attribute) {
2982
+		if (!empty ($attribute_list_for_entity)) {
2983
+			foreach ($attribute_list_for_entity as $attribute) {
2984 2984
 				switch ($list_for) {
2985 2985
 					case 'attribute_value':
2986 2986
 							$checkbox_state = ' ';
@@ -2989,8 +2989,8 @@  discard block
 block discarded – undo
2989 2989
 								<select id="wpshop_shortcode_element_attribute_value_product_list_' . $attribute->id . '" class="wpshop_shortcode_element_attribute_value_product_list" >';
2990 2990
 
2991 2991
 							global $post;
2992
-							$posts = get_posts( array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'numberposts' => -1) );
2993
-							foreach( $posts as $post ) :
2992
+							$posts = get_posts(array('post_type' => WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'numberposts' => -1));
2993
+							foreach ($posts as $post) :
2994 2994
 								setup_postdata($post);
2995 2995
 								$attribute_possible_values .= '<option value="' . get_the_ID() . '" >' . get_the_ID() . ' - ' . get_the_title() . '</option>';
2996 2996
 							endforeach;
@@ -3006,23 +3006,23 @@  discard block
 block discarded – undo
3006 3006
 
3007 3007
 						$checkbox_state = 'disabled ';
3008 3008
 						$attribute_possible_values = '';
3009
-						if ( !empty($attribute_values) ) {
3009
+						if (!empty($attribute_values)) {
3010 3010
 							$checkbox_state = '';
3011 3011
 							$attribute_possible_values = '
3012 3012
 							<div class="wpshop_shortcode_element_product_listing_per_attribute_value wpshop_shortcode_element_prodcut_listing_per_attribute_value_' . $attribute->code . '_container" >
3013 3013
 								<select id="wpshop_attribute_value_for_shortcode_generation_' . $attribute->id . '" class="wpshop_shortcode_element_prodcut_listing_per_attribute_value hidden" >';
3014 3014
 
3015
-								if ( ($attribute->data_type == 'integer') && ( ($attribute->backend_input == 'select') || ($attribute->backend_input == 'multiple-select') ) ) {
3015
+								if (($attribute->data_type == 'integer') && (($attribute->backend_input == 'select') || ($attribute->backend_input == 'multiple-select'))) {
3016 3016
 									$query = $wpdb->prepare("SELECT * FROM " . WPSHOP_DBT_ATTRIBUTE_VALUES_OPTIONS . " WHERE attribute_id=%d ORDER BY position", $attribute->id);
3017 3017
 									$possible_values = $wpdb->get_results($query);
3018 3018
 									$already_selected_values = array();
3019 3019
 									foreach ($attribute_values as $attribute_value) {
3020
-										if ( !empty($attribute_value->value) ) {
3020
+										if (!empty($attribute_value->value)) {
3021 3021
 											$already_selected_values[] = $attribute_value->value;
3022 3022
 										}
3023 3023
 									}
3024 3024
 									foreach ($possible_values as $value) {
3025
-										if ( in_array( $value->id, $already_selected_values ) ) {
3025
+										if (in_array($value->id, $already_selected_values)) {
3026 3026
 											$attribute_possible_values .= '
3027 3027
 									<option value="' . $value->value . '" >' . $value->label . '</option>';
3028 3028
 										}
@@ -3030,7 +3030,7 @@  discard block
 block discarded – undo
3030 3030
 								}
3031 3031
 								else {
3032 3032
 									foreach ($attribute_values as $attribute_value) {
3033
-										if ( !empty($attribute_value->value) ) {
3033
+										if (!empty($attribute_value->value)) {
3034 3034
 											$attribute_possible_values .= '
3035 3035
 									<option value="' . $attribute_value->value . '" >' . $attribute_value->value . '</option>';
3036 3036
 										}
@@ -3059,23 +3059,23 @@  discard block
 block discarded – undo
3059 3059
 	 *
3060 3060
 	 * @return object The attribute list as a wordpress database object
3061 3061
 	 */
3062
-	function get_attribute_list_in_same_set_section( $attribute_code ) {
3062
+	function get_attribute_list_in_same_set_section($attribute_code) {
3063 3063
 		global $wpdb;
3064 3064
 
3065 3065
 		$attribute_def = wpshop_attributes::getElement($attribute_code, "'valid'", 'code');
3066 3066
 
3067 3067
 		/** Get the entire list of attribute in price set section for display	*/
3068
-		$query = $wpdb->prepare( "SELECT entity_type_id, attribute_set_id, attribute_group_id FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " WHERE attribute_id = %d AND status = 'valid'", $attribute_def->id);
3068
+		$query = $wpdb->prepare("SELECT entity_type_id, attribute_set_id, attribute_group_id FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " WHERE attribute_id = %d AND status = 'valid'", $attribute_def->id);
3069 3069
 		$attribute_attribution_def = $wpdb->get_row($query);
3070 3070
 
3071
-		$query = $wpdb->prepare( "
3071
+		$query = $wpdb->prepare("
3072 3072
 							SELECT ATTR.code, is_visible_in_front_listing, is_visible_in_front
3073 3073
 							FROM " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " AS SET_SECTION_DETAIL
3074 3074
 								INNER JOIN " . WPSHOP_DBT_ATTRIBUTE . " AS ATTR ON (ATTR.id = SET_SECTION_DETAIL.attribute_id)
3075 3075
 							WHERE entity_type_id = %d
3076 3076
 								AND attribute_set_id = %d
3077 3077
 								AND attribute_group_id = %d",
3078
-				$attribute_attribution_def->entity_type_id, $attribute_attribution_def->attribute_set_id, $attribute_attribution_def->attribute_group_id );
3078
+				$attribute_attribution_def->entity_type_id, $attribute_attribution_def->attribute_set_id, $attribute_attribution_def->attribute_group_id);
3079 3079
 		$atribute_list = $wpdb->get_results($query);
3080 3080
 
3081 3081
 		return $atribute_list;
@@ -3086,7 +3086,7 @@  discard block
 block discarded – undo
3086 3086
 	 * @param unknown_type $current_entity_id
3087 3087
 	 * @return Ambigous <multitype:, multitype:NULL >
3088 3088
 	 */
3089
-	public static function get_variation_available_attribute( $current_entity_id ) {
3089
+	public static function get_variation_available_attribute($current_entity_id) {
3090 3090
 		global $wpdb;
3091 3091
 		$final_list = array();
3092 3092
 
@@ -3094,7 +3094,7 @@  discard block
 block discarded – undo
3094 3094
 		$query = $wpdb->prepare(
3095 3095
 				"SELECT ATT.*, ENTITY_META.meta_value
3096 3096
 				FROM " . self::getDbTable() . " AS ATT
3097
-					INNER JOIN " . WPSHOP_DBT_ATTRIBUTE_DETAILS. " AS ATT_DETAILS ON ((ATT_DETAILS.attribute_id = ATT.id) AND (ATT_DETAILS.entity_type_id = %d) AND (ATT_DETAILS.status = 'valid'))
3097
+					INNER JOIN " . WPSHOP_DBT_ATTRIBUTE_DETAILS . " AS ATT_DETAILS ON ((ATT_DETAILS.attribute_id = ATT.id) AND (ATT_DETAILS.entity_type_id = %d) AND (ATT_DETAILS.status = 'valid'))
3098 3098
 					INNER JOIN " . $wpdb->postmeta . " AS ENTITY_META ON ((ENTITY_META.meta_key = %s) AND (ENTITY_META.meta_value = ATT_DETAILS.attribute_set_id))
3099 3099
 				WHERE ATT.status IN ('valid')
3100 3100
 					AND ATT.is_used_for_variation = %s
@@ -3104,10 +3104,10 @@  discard block
 block discarded – undo
3104 3104
 		);
3105 3105
 		$attribute_list = $wpdb->get_results($query);
3106 3106
 		foreach ($attribute_list as $attribute) {
3107
-			if ( !in_array($attribute->code, unserialize(WPSHOP_VARIATION_ATTRIBUTE_TO_HIDE)) && in_array($attribute->backend_input, array('select', 'multiple-select')) ) {
3108
-				$attribute_values_for_variations = wpshop_attributes::get_affected_value_for_list( $attribute->code, $current_entity_id, $attribute->data_type_to_use );
3107
+			if (!in_array($attribute->code, unserialize(WPSHOP_VARIATION_ATTRIBUTE_TO_HIDE)) && in_array($attribute->backend_input, array('select', 'multiple-select'))) {
3108
+				$attribute_values_for_variations = wpshop_attributes::get_affected_value_for_list($attribute->code, $current_entity_id, $attribute->data_type_to_use);
3109 3109
 
3110
-				if ( empty($attribute_values_for_variations) ) {
3110
+				if (empty($attribute_values_for_variations)) {
3111 3111
 					$final_list['unavailable'][$attribute->code]['label'] = $attribute->frontend_label;
3112 3112
 					$final_list['unavailable'][$attribute->code]['values'] = array();
3113 3113
 					$final_list['unavailable'][$attribute->code]['attribute_complete_def'] = $attribute;
@@ -3127,16 +3127,16 @@  discard block
 block discarded – undo
3127 3127
 	 * @param integer $current_entity_id The current element edited
3128 3128
 	 * @return Ambigous <string, string, mixed>
3129 3129
 	 */
3130
-	public static function get_variation_available_attribute_display( $current_entity_id, $variation_type = 'multiple' ) {
3130
+	public static function get_variation_available_attribute_display($current_entity_id, $variation_type = 'multiple') {
3131 3131
 		$attribute_list = wpshop_attributes::get_variation_available_attribute($current_entity_id);
3132 3132
 
3133 3133
 		$attribute_defined_as_available_for_variation = '';
3134
-		if ( !empty($attribute_list) ) {
3134
+		if (!empty($attribute_list)) {
3135 3135
 			foreach ($attribute_list as $list_type => $attribute_list_by_type) {
3136 3136
 				$sub_attribute_list = '';
3137 3137
 				foreach ($attribute_list_by_type as $attribute_code => $attribute_def) {
3138 3138
 					$tpl_component = array();
3139
-					if ( $list_type == 'available' ) {
3139
+					if ($list_type == 'available') {
3140 3140
 						$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_LABEL_STATE'] = '';
3141 3141
 						$tpl_component['ADMIN_VARIATIONS_DEF_LIST_ATTRIBUTE_CHECKBOX_STATE'] = '';
3142 3142
 						$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_LABEL_EXPLAINATION'] = '';
@@ -3150,13 +3150,13 @@  discard block
 block discarded – undo
3150 3150
 					$tpl_component['ADMIN_ATTRIBUTE_CODE_FOR_VARIATION'] = $attribute_code;
3151 3151
 					$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_NAME'] = $attribute_code;
3152 3152
 					$tpl_component['ADMIN_VARIATION_ATTRIBUTE_CONTAINER_CLASS'] = ' wpshop_attribute_for_variation_' . $attribute_code;
3153
-					$tpl_component['ADMIN_VARIATION_NEW_SINGLE_LABEL'] = __( $attribute_def['label'], 'wpshop' );
3153
+					$tpl_component['ADMIN_VARIATION_NEW_SINGLE_LABEL'] = __($attribute_def['label'], 'wpshop');
3154 3154
 					$tpl_component['ADMIN_VARIATION_NEW_SINGLE_INPUT'] = '';
3155
-					if ( $variation_type == 'single' ) {
3156
-						$attribute_output_def = wpshop_attributes::get_attribute_field_definition( $attribute_def['attribute_complete_def'], $attribute_def['values'], array('from' => 'frontend', 'field_custom_name_prefix' => 'variation_attr', 'input_class' => ' variation_attribute_usable_input') );
3157
-						if ( !empty($attribute_output_def['possible_value']) ) {
3158
-							foreach( $attribute_output_def['possible_value'] as $value_id => $value ){
3159
-								if ( !in_array($value_id, $attribute_def['values']) ) {
3155
+					if ($variation_type == 'single') {
3156
+						$attribute_output_def = wpshop_attributes::get_attribute_field_definition($attribute_def['attribute_complete_def'], $attribute_def['values'], array('from' => 'frontend', 'field_custom_name_prefix' => 'variation_attr', 'input_class' => ' variation_attribute_usable_input'));
3157
+						if (!empty($attribute_output_def['possible_value'])) {
3158
+							foreach ($attribute_output_def['possible_value'] as $value_id => $value) {
3159
+								if (!in_array($value_id, $attribute_def['values'])) {
3160 3160
 									unset($attribute_output_def['possible_value'][$value_id]);
3161 3161
 								}
3162 3162
 							}
@@ -3171,7 +3171,7 @@  discard block
 block discarded – undo
3171 3171
 			}
3172 3172
 		}
3173 3173
 
3174
-		return array($attribute_defined_as_available_for_variation, ( (!empty($attribute_list['available']) ) ? $attribute_list['available'] : ''), ( ( !empty($attribute_list['unavailable']) ) ? $attribute_list['unavailable'] : ''));
3174
+		return array($attribute_defined_as_available_for_variation, ((!empty($attribute_list['available'])) ? $attribute_list['available'] : ''), ((!empty($attribute_list['unavailable'])) ? $attribute_list['unavailable'] : ''));
3175 3175
 	}
3176 3176
 
3177 3177
 	/**
@@ -3180,18 +3180,18 @@  discard block
 block discarded – undo
3180 3180
 	 * @param array $variations_attribute_parameters Allows to give some parameters for customize list
3181 3181
 	 * @return string The output for all specific attribute in each product with option
3182 3182
 	 */
3183
-	public static function get_variation_attribute( $variations_attribute_parameters ) {
3183
+	public static function get_variation_attribute($variations_attribute_parameters) {
3184 3184
 		$output = '';
3185 3185
 
3186 3186
 		$attribute_list = wpshop_attributes::getElement('yes', "'valid'", "is_used_in_variation", true);
3187
-		if ( !empty( $attribute_list ) ) {
3187
+		if (!empty($attribute_list)) {
3188 3188
 			$tpl_component = array();
3189 3189
 			$tpl_component['ADMIN_VARIATION_DETAIL'] = '';
3190 3190
 			$price_piloting_option = get_option('wpshop_shop_price_piloting');
3191
-			foreach ( $attribute_list as $attribute_def ) {
3191
+			foreach ($attribute_list as $attribute_def) {
3192 3192
 
3193 3193
 				$variations_attribute_parameters['field_custom_name_prefix'] = $variations_attribute_parameters['field_name'] . '[attribute][' . $attribute_def->data_type . ']';
3194
-				$attribute_output_def = wpshop_attributes::get_attribute_field_definition( $attribute_def, (!empty($variations_attribute_parameters['variation_dif_values'][$attribute_def->code]) ? $variations_attribute_parameters['variation_dif_values'][$attribute_def->code] : ''), $variations_attribute_parameters );
3194
+				$attribute_output_def = wpshop_attributes::get_attribute_field_definition($attribute_def, (!empty($variations_attribute_parameters['variation_dif_values'][$attribute_def->code]) ? $variations_attribute_parameters['variation_dif_values'][$attribute_def->code] : ''), $variations_attribute_parameters);
3195 3195
 
3196 3196
 				$field_output = $attribute_output_def['output'];
3197 3197
 
@@ -3203,9 +3203,9 @@  discard block
 block discarded – undo
3203 3203
 				$sub_tpl_component['ADMIN_VARIATION_DETAIL_DEF_ID'] = $attribute_output_def['id'];
3204 3204
 				$sub_tpl_component['ADMIN_VARIATION_DETAIL_DEF_LABEL'] = $attribute_output_def['label'];
3205 3205
 				$sub_tpl_component['ADMIN_VARIATION_DETAIL_DEF_INPUT'] = $field_output;
3206
-				if( isset( $variations_attribute_parameters['post_id'] ) ) {
3207
-					$attribute_option_display = $attribute_def->backend_input=='select' && (strtolower( __(self::get_attribute_type_select_option_info($attribute_output_def['value'], 'value'), 'wpshop') ) == strtolower( __('yes', 'wpshop') )) ? '' : ' wpshopHide';
3208
-					$sub_tpl_component['ADMIN_VARIATION_DETAIL_DEF_INPUT'] .= '<div class="attribute_option_'.$attribute_def->code.''.$attribute_option_display.'">'.self::get_attribute_option_fields($variations_attribute_parameters['post_id'], $attribute_def->code).'</div>';
3206
+				if (isset($variations_attribute_parameters['post_id'])) {
3207
+					$attribute_option_display = $attribute_def->backend_input == 'select' && (strtolower(__(self::get_attribute_type_select_option_info($attribute_output_def['value'], 'value'), 'wpshop')) == strtolower(__('yes', 'wpshop'))) ? '' : ' wpshopHide';
3208
+					$sub_tpl_component['ADMIN_VARIATION_DETAIL_DEF_INPUT'] .= '<div class="attribute_option_' . $attribute_def->code . '' . $attribute_option_display . '">' . self::get_attribute_option_fields($variations_attribute_parameters['post_id'], $attribute_def->code) . '</div>';
3209 3209
 				}
3210 3210
 				$tpl_component['ADMIN_VARIATION_DETAIL'] .= wpshop_display::display_template_element('wpshop_admin_variation_item_details_line', $sub_tpl_component, array(), 'admin');
3211 3211
 				unset($sub_tpl_component);
@@ -3216,7 +3216,7 @@  discard block
 block discarded – undo
3216 3216
 		return $output;
3217 3217
 	}
3218 3218
 
3219
-	public static function get_attribute_user_defined( $use_defined_parameters, $status = "'publish'" ) {
3219
+	public static function get_attribute_user_defined($use_defined_parameters, $status = "'publish'") {
3220 3220
 		global $wpdb;
3221 3221
 		$attribute_user_defined_list = array();
3222 3222
 
@@ -3243,12 +3243,12 @@  discard block
 block discarded – undo
3243 3243
 	 * @param string $post_type The current
3244 3244
 	 *
3245 3245
 	 */
3246
-	function quick_edit( $column_name, $entity ) {
3247
-		switch ( $entity ) {
3246
+	function quick_edit($column_name, $entity) {
3247
+		switch ($entity) {
3248 3248
 			case WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT:
3249 3249
 				$attribute_def = wpshop_attributes::getElement($column_name, "'valid'", 'code');
3250
-				if ( !empty($attribute_def) ) {
3251
-					$input_def = self::get_attribute_field_definition( $attribute_def, '', array('input_class' => ' wpshop_bulk_and_quick_edit_input') );
3250
+				if (!empty($attribute_def)) {
3251
+					$input_def = self::get_attribute_field_definition($attribute_def, '', array('input_class' => ' wpshop_bulk_and_quick_edit_input'));
3252 3252
 					$input = wpshop_form::check_input_type($input_def, $input_def['input_domain']);
3253 3253
 ?>
3254 3254
 	<div class="wpshop_bulk_and_quick_edit_column_container wpshop_bulk_and_quick_edit_column_<?php echo $column_name; ?>_container">
@@ -3268,12 +3268,12 @@  discard block
 block discarded – undo
3268 3268
 	 * @param string $post_type The current
3269 3269
 	 *
3270 3270
 	 */
3271
-	public static function bulk_edit( $column_name, $entity ) {
3272
-		switch ( $entity ) {
3271
+	public static function bulk_edit($column_name, $entity) {
3272
+		switch ($entity) {
3273 3273
 			case WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT:
3274 3274
 				$attribute_def = wpshop_attributes::getElement($column_name, "'valid'", 'code');
3275
-				if ( !empty($attribute_def) ) {
3276
-					$input_def = self::get_attribute_field_definition( $attribute_def, '', array('input_class' => ' wpshop_bulk_and_quick_edit_input') );
3275
+				if (!empty($attribute_def)) {
3276
+					$input_def = self::get_attribute_field_definition($attribute_def, '', array('input_class' => ' wpshop_bulk_and_quick_edit_input'));
3277 3277
 					$input = wpshop_form::check_input_type($input_def, $input_def['input_domain']);
3278 3278
 ?>
3279 3279
 	<div class="wpshop_bulk_and_quick_edit_column_container wpshop_bulk_and_quick_edit_column_<?php echo $column_name; ?>_container">
Please login to merge, or discard this patch.
Braces   +156 added lines, -171 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'ABSPATH' ) ) exit;
1
+<?php if ( !defined( 'ABSPATH' ) ) {
2
+	exit;
3
+}
2 4
 
3 5
 /*	Check if file is include. No direct access possible with file url	*/
4 6
 if ( !defined( 'WPSHOP_VERSION' ) ) {
@@ -92,12 +94,12 @@  discard block
 block discarded – undo
92 94
 			if(($action == 'edit') || ($action == 'delete')){
93 95
 				$editedItem = self::getElement($objectInEdition);
94 96
 				$title = sprintf(__(self::pageEditingTitle, 'wpshop'), str_replace("\\", "", $editedItem->frontend_label));
97
+			} elseif($action == 'add') {
98
+							$title = __(self::pageAddingTitle, 'wpshop');
95 99
 			}
96
-			elseif($action == 'add')
97
-				$title = __(self::pageAddingTitle, 'wpshop');
100
+		} elseif((self::getEditionSlug() != self::getListingSlug()) && ($page == self::getEditionSlug())) {
101
+					$title = __(self::pageAddingTitle, 'wpshop');
98 102
 		}
99
-		elseif((self::getEditionSlug() != self::getListingSlug()) && ($page == self::getEditionSlug()))
100
-			$title = __(self::pageAddingTitle, 'wpshop');
101 103
 
102 104
 		return $title;
103 105
 	}
@@ -128,14 +130,15 @@  discard block
 block discarded – undo
128 130
 		if(($action != '') && ($action == 'saveok') && ($saveditem > 0)){
129 131
 			$editedElement = self::getElement($saveditem);
130 132
 			$pageMessage = '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully saved', 'wpshop'), '<span class="bold" >' . $editedElement->code . '</span>');
131
-		}
132
-		elseif(($action != '') && ($action == 'deleteok') && ($saveditem > 0)){
133
+		} elseif(($action != '') && ($action == 'deleteok') && ($saveditem > 0)){
133 134
 			$editedElement = self::getElement($saveditem, "'deleted'");
134 135
 			$pageMessage = '<img src="' . WPSHOP_SUCCES_ICON . '" alt="action success" class="wpshopPageMessage_Icon" />' . sprintf(__('%s succesfully deleted', 'wpshop'), '<span class="bold" >' . $editedElement->code . '</span>');
135 136
 		}
136 137
 
137 138
 		$attribute_parameter = !empty( $_REQUEST[self::getDbTable()] ) ? (array)$_REQUEST[self::getDbTable()] : array();
138
-		 if ( !empty($set_section) ) unset($attribute_parameter['set_section']);
139
+		 if ( !empty($set_section) ) {
140
+		 	unset($attribute_parameter['set_section']);
141
+		 }
139 142
 
140 143
 		$wpshop_attribute_combo_values_list_order_def = !empty($attribute_parameter['wpshop_attribute_combo_values_list_order_def']) ? $attribute_parameter['wpshop_attribute_combo_values_list_order_def'] : array();
141 144
 		// @TODO $_REQUEST
@@ -195,66 +198,82 @@  discard block
 block discarded – undo
195 198
 			switch ($attribute_parameter['frontend_input']) {
196 199
 				case 'short_text':
197 200
 						$attribute_parameter['frontend_input'] = 'text';
198
-						if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text';
201
+						if ( empty($attribute_parameter['backend_input']) ) {
202
+							$attribute_parameter['backend_input'] = 'text';
203
+						}
199 204
 						$attribute_parameter['data_type'] = 'varchar';
200 205
 					break;
201 206
 				case 'date_field':
202 207
 						$attribute_parameter['frontend_input'] = 'text';
203
-						if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text';
208
+						if ( empty($attribute_parameter['backend_input']) ) {
209
+							$attribute_parameter['backend_input'] = 'text';
210
+						}
204 211
 						$attribute_parameter['data_type'] = 'datetime';
205 212
 					break;
206 213
 				case 'float_field':
207 214
 						$attribute_parameter['frontend_input'] = 'text';
208
-						if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text';
215
+						if ( empty($attribute_parameter['backend_input']) ) {
216
+							$attribute_parameter['backend_input'] = 'text';
217
+						}
209 218
 						$attribute_parameter['data_type'] = 'decimal';
210 219
 					break;
211 220
 				case 'hidden_field':
212 221
 						$attribute_parameter['frontend_input'] = 'hidden';
213
-						if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text';
222
+						if ( empty($attribute_parameter['backend_input']) ) {
223
+							$attribute_parameter['backend_input'] = 'text';
224
+						}
214 225
 						$attribute_parameter['data_type'] = 'varchar';
215 226
 					break;
216 227
 				case 'pass_field':
217 228
 						$attribute_parameter['frontend_input'] = 'password';
218
-						if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text';
229
+						if ( empty($attribute_parameter['backend_input']) ) {
230
+							$attribute_parameter['backend_input'] = 'text';
231
+						}
219 232
 						$attribute_parameter['data_type'] = 'varchar';
220 233
 					break;
221 234
 
222 235
 				case 'select':
223 236
 						$attribute_parameter['frontend_input'] = 'select';
224
-						if ( empty($attribute_parameter['backend_input']) || empty($id) )
225
-							$attribute_parameter['backend_input'] = 'multiple-select';
237
+						if ( empty($attribute_parameter['backend_input']) || empty($id) ) {
238
+													$attribute_parameter['backend_input'] = 'multiple-select';
239
+						}
226 240
 						$attribute_parameter['data_type'] = 'integer';
227 241
 					break;
228 242
 				case 'multiple-select':
229 243
 						$attribute_parameter['frontend_input'] = 'multiple-select';
230
-						if ( empty($attribute_parameter['backend_input']) || empty($id) )
231
-							$attribute_parameter['backend_input'] = 'multiple-select';
244
+						if ( empty($attribute_parameter['backend_input']) || empty($id) ) {
245
+													$attribute_parameter['backend_input'] = 'multiple-select';
246
+						}
232 247
 						$attribute_parameter['data_type'] = 'integer';
233 248
 					break;
234 249
 				case 'radio':
235 250
 						$attribute_parameter['frontend_input'] = 'radio';
236
-						if ( empty($attribute_parameter['backend_input']) || empty($id) )
237
-							$attribute_parameter['backend_input'] = 'multiple-select';
251
+						if ( empty($attribute_parameter['backend_input']) || empty($id) ) {
252
+													$attribute_parameter['backend_input'] = 'multiple-select';
253
+						}
238 254
 						$attribute_parameter['data_type'] = 'integer';
239 255
 					break;
240 256
 				case 'checkbox':
241 257
 						$attribute_parameter['frontend_input'] = 'checkbox';
242
-						if ( empty($attribute_parameter['backend_input']) || empty($id) )
243
-							$attribute_parameter['backend_input'] = 'multiple-select';
258
+						if ( empty($attribute_parameter['backend_input']) || empty($id) ) {
259
+													$attribute_parameter['backend_input'] = 'multiple-select';
260
+						}
244 261
 						$attribute_parameter['data_type'] = 'integer';
245 262
 					break;
246 263
 
247 264
 				case 'textarea':
248 265
 						$attribute_parameter['frontend_input'] = 'textarea';
249
-						if ( empty($attribute_parameter['backend_input']) || empty($id) )
250
-							$attribute_parameter['backend_input'] = 'textarea';
266
+						if ( empty($attribute_parameter['backend_input']) || empty($id) ) {
267
+													$attribute_parameter['backend_input'] = 'textarea';
268
+						}
251 269
 						$attribute_parameter['data_type'] = 'text';
252 270
 					break;
253 271
 			}
254
-		}
255
-		else {
272
+		} else {
256 273
 			$attribute_parameter['frontend_input'] = 'text';
257
-			if ( empty($attribute_parameter['backend_input']) ) $attribute_parameter['backend_input'] = 'text';
274
+			if ( empty($attribute_parameter['backend_input']) ) {
275
+				$attribute_parameter['backend_input'] = 'text';
276
+			}
258 277
 			$attribute_parameter['data_type'] = 'varchar';
259 278
 		}
260 279
 
@@ -289,22 +308,18 @@  discard block
 block discarded – undo
289 308
 					if(!in_array($attribute_code, $attribute_undeletable)){
290 309
 						if(current_user_can('wpshop_delete_attributes')){
291 310
 							$attribute_parameter['status'] = 'deleted';
292
-						}
293
-						else{
311
+						} else{
294 312
 							$actionResult = 'userNotAllowedForActionDelete';
295 313
 						}
296
-					}
297
-					else{
314
+					} else{
298 315
 						$actionResult = 'unDeletableAtribute';
299 316
 					}
300 317
 				}
301 318
 				$actionResult = wpshop_database::update($attribute_parameter, $id, self::getDbTable());
302
-			}
303
-			else{
319
+			} else{
304 320
 				$actionResult = 'userNotAllowedForActionEdit';
305 321
 			}
306
-		}
307
-		elseif(($pageAction != '') && (($pageAction == 'delete'))){
322
+		} elseif(($pageAction != '') && (($pageAction == 'delete'))){
308 323
 			$attribute_code = '';
309 324
 			if (empty(	$attribute_parameter['code'])) {
310 325
 				$attribute = self::getElement($id, "'valid', 'moderated', 'notused', 'deleted'", 'id');
@@ -315,14 +330,13 @@  discard block
 block discarded – undo
315 330
 					$attribute_parameter['last_update_date'] = current_time('mysql', 0);
316 331
 					$attribute_parameter['status'] = 'deleted';
317 332
 					$actionResult = wpshop_database::update($attribute_parameter, $id, self::getDbTable());
333
+				} else {
334
+									$actionResult = 'userNotAllowedForActionDelete';
318 335
 				}
319
-				else
320
-					$actionResult = 'userNotAllowedForActionDelete';
336
+			} else {
337
+							$actionResult = 'unDeletableAtribute';
321 338
 			}
322
-			else
323
-				$actionResult = 'unDeletableAtribute';
324
-		}
325
-		elseif(($pageAction != '') && (($pageAction == 'save') || ($pageAction == 'saveandcontinue') || ($pageAction == 'add'))){
339
+		} elseif(($pageAction != '') && (($pageAction == 'save') || ($pageAction == 'saveandcontinue') || ($pageAction == 'add'))){
326 340
 			if(current_user_can('wpshop_add_attributes')){
327 341
 				$attribute_parameter['creation_date'] = current_time('mysql', 0);
328 342
 				if(trim($attribute_parameter['code']) == ''){
@@ -335,8 +349,7 @@  discard block
 block discarded – undo
335 349
 				}
336 350
 				$actionResult = wpshop_database::save($attribute_parameter, self::getDbTable());
337 351
 				$id = $wpdb->insert_id;
338
-			}
339
-			else{
352
+			} else{
340 353
 				$actionResult = 'userNotAllowedForActionAdd';
341 354
 			}
342 355
 		}
@@ -347,11 +360,12 @@  discard block
 block discarded – undo
347 360
 		/****************************************************************************/
348 361
 		if($actionResult != ''){
349 362
 			$elementIdentifierForMessage = __('the attribute', 'wpshop');
350
-			if(!empty($attribute_parameter['name']))$elementIdentifierForMessage = '<span class="bold" >' . $attribute_parameter['frontend_label'] . '</span>';
363
+			if(!empty($attribute_parameter['name'])) {
364
+				$elementIdentifierForMessage = '<span class="bold" >' . $attribute_parameter['frontend_label'] . '</span>';
365
+			}
351 366
 			if ($actionResult == 'error') {/*	CHANGE HERE FOR SPECIFIC CASE	*/
352 367
 				$pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . sprintf(__('An error occured while saving %s', 'wpshop'), $elementIdentifierForMessage, ' -> ' . $wpdb->last_error);
353
-			}
354
-			else if (($actionResult == 'done') || ($actionResult == 'nothingToUpdate')) {/*	CHANGE HERE FOR SPECIFIC CASE	*/
368
+			} else if (($actionResult == 'done') || ($actionResult == 'nothingToUpdate')) {/*	CHANGE HERE FOR SPECIFIC CASE	*/
355 369
 				/*****************************************************************************************************************/
356 370
 				/*************************			CHANGE FOR SPECIFIC ACTION FOR CURRENT ELEMENT				****************************/
357 371
 				/*****************************************************************************************************************/
@@ -370,8 +384,7 @@  discard block
 block discarded – undo
370 384
 					if (empty($attribute_parameter['code'])) {
371 385
 						$attribute = self::getElement($id, "'valid', 'moderated', 'notused'", 'id');
372 386
 						$attribute_code = $attribute->code;
373
-					}
374
-					else {
387
+					} else {
375 388
 						$attribute_code = $attribute_parameter['code'];
376 389
 					}
377 390
 					foreach ($optionsUpdate as $option_key => $option_label) {
@@ -462,8 +475,7 @@  discard block
 block discarded – undo
462 475
 						$choosen_set_section = explode('_', $set_section);
463 476
 						$set_id = $choosen_set_section[0];
464 477
 						$group_id = $choosen_set_section[1];
465
-					}
466
-					else{
478
+					} else{
467 479
 						$attribute_current_attribute_set = 0;
468 480
 						$query = $wpdb->prepare("
469 481
 								SELECT id
@@ -511,7 +523,9 @@  discard block
 block discarded – undo
511 523
 								$attribute_parameter['entity_id']
512 524
 						);
513 525
 						$wpshopAttributePosition = $wpdb->get_var($query);
514
-						if($wpshopAttributePosition == 0)$wpshopAttributePosition = 1;
526
+						if($wpshopAttributePosition == 0) {
527
+							$wpshopAttributePosition = 1;
528
+						}
515 529
 						$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_DETAILS, array('status' => 'valid', 'creation_date' => current_time('mysql', 0), 'entity_type_id' => $attribute_parameter['entity_id'], 'attribute_set_id' => $set_id, 'attribute_group_id' => $group_id, 'attribute_id' => $id, 'position' => $wpshopAttributePosition));
516 530
 					}
517 531
 				}
@@ -532,15 +546,14 @@  discard block
 block discarded – undo
532 546
 					wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=saveok&saveditem=" . $id));
533 547
 				}
534 548
 				else */
535
-				if ( $pageAction == 'add' )
536
-					wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=edit&id=" . $id));
537
-				elseif ( $pageAction == 'delete' )
538
-					wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=deleteok&saveditem=" . $id));
539
-			}
540
-			elseif(($actionResult == 'userNotAllowedForActionEdit') || ($actionResult == 'userNotAllowedForActionAdd') || ($actionResult == 'userNotAllowedForActionDelete')){
549
+				if ( $pageAction == 'add' ) {
550
+									wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=edit&id=" . $id));
551
+				} elseif ( $pageAction == 'delete' ) {
552
+									wpshop_tools::wpshop_safe_redirect(admin_url('admin.php?page=' . self::getListingSlug() . "&action=deleteok&saveditem=" . $id));
553
+				}
554
+			} elseif(($actionResult == 'userNotAllowedForActionEdit') || ($actionResult == 'userNotAllowedForActionAdd') || ($actionResult == 'userNotAllowedForActionDelete')){
541 555
 				$pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . __('You are not allowed to do this action', 'wpshop');
542
-			}
543
-			elseif(($actionResult == 'unDeletableAtribute')){
556
+			} elseif(($actionResult == 'unDeletableAtribute')){
544 557
 				$pageMessage .= '<img src="' . WPSHOP_ERROR_ICON . '" alt="action error" class="wpshopPageMessage_Icon" />' . __('This attribute could not be deleted due to configuration', 'wpshop');
545 558
 			}
546 559
 
@@ -585,8 +598,7 @@  discard block
 block discarded – undo
585 598
 		if ( !empty($s) ) {
586 599
 			$query = $wpdb->prepare("SELECT * FROM " . self::dbTable . ' WHERE frontend_label LIKE "%%%1$s%%" OR frontend_label LIKE "%%%2$s%%" AND backend_label LIKE "%%%1$s%%" OR backend_label LIKE "%%%2$s%%" AND code LIKE "%%%1$s%%" OR code LIKE "%%%2$s%%"', $s, __($s, 'wpshop') );
587 600
 			$attr_set_list = $wpdb->get_results( $query );
588
-		}
589
-		else {
601
+		} else {
590 602
 			$attr_set_list = self::getElement( '', $status );
591 603
 		}
592 604
 		$i=0;
@@ -640,8 +652,9 @@  discard block
 block discarded – undo
640 652
 		global $attribute_displayed_field, $attribute_options_group;
641 653
 		$dbFieldList = wpshop_database::fields_to_input(self::getDbTable());
642 654
 		$editedItem = '';
643
-		if($itemToEdit != '')
644
-			$editedItem = self::getElement($itemToEdit);
655
+		if($itemToEdit != '') {
656
+					$editedItem = self::getElement($itemToEdit);
657
+		}
645 658
 
646 659
 		$the_form_content_hidden = $the_form_general_content = '';
647 660
 		$the_form_option_content_list = array();
@@ -654,10 +667,11 @@  discard block
 block discarded – undo
654 667
 				$pageAction = isset($_REQUEST[self::getDbTable() . '_action']) ? sanitize_text_field($_REQUEST[self::getDbTable() . '_action']) : '';
655 668
 				$requestFormValue = isset($_REQUEST[self::currentPageCode][$input_def['label']]) ? sanitize_text_field($_REQUEST[self::currentPageCode][$input_def['label']]) : '';
656 669
 				$currentFieldValue = $input_def['value'];
657
-				if(is_object($editedItem))
658
-					$currentFieldValue = $editedItem->{$input_def['label']};
659
-				elseif(($pageAction != '') && ($requestFormValue != ''))
660
-					$currentFieldValue = $requestFormValue;
670
+				if(is_object($editedItem)) {
671
+									$currentFieldValue = $editedItem->{$input_def['label']};
672
+				} elseif(($pageAction != '') && ($requestFormValue != '')) {
673
+									$currentFieldValue = $requestFormValue;
674
+				}
661 675
 
662 676
 				if($input_def['label'] == 'status'){
663 677
 					if(in_array('notused', $input_def['possible_value'])){
@@ -729,9 +743,9 @@  discard block
 block discarded – undo
729 743
 				}
730 744
 
731 745
 				$input_def['value'] = $currentFieldValue;
732
-				if($input_def['label'] == 'code')
733
-					$input_def['type'] = 'hidden';
734
-				elseif($input_def['label'] == 'entity_id'){
746
+				if($input_def['label'] == 'code') {
747
+									$input_def['type'] = 'hidden';
748
+				} elseif($input_def['label'] == 'entity_id'){
735 749
 					$input_def['possible_value'] = wpshop_entities::get_entities_list();
736 750
 					$input_def['valueToPut'] = 'index';
737 751
 					$input_def['type'] = 'select';
@@ -743,21 +757,17 @@  discard block
 block discarded – undo
743 757
 						}
744 758
 						$i++;
745 759
 					}
746
-				}
747
-				elseif($input_def['label'] == '_unit_group_id'){
760
+				} elseif($input_def['label'] == '_unit_group_id'){
748 761
 					$input_def['possible_value'] = wpshop_attributes_unit::get_unit_group();
749 762
 					$input_def['type'] = 'select';
750
-				}
751
-				elseif($input_def['label'] == '_default_unit'){
763
+				} elseif($input_def['label'] == '_default_unit'){
752 764
 					$unit_group_list = wpshop_attributes_unit::get_unit_group();
753 765
 					$input_def['possible_value'] = wpshop_attributes_unit::get_unit_list_for_group(!empty($editedItem->_unit_group_id)?$editedItem->_unit_group_id:(!empty($unit_group_list)?$unit_group_list[0]->id:''));
754 766
 					$input_def['type'] = 'select';
755
-				}
756
-				elseif ($input_def['label'] == 'backend_input') {
767
+				} elseif ($input_def['label'] == 'backend_input') {
757 768
 					if ( !is_object($editedItem) ) {
758 769
 						$input_def['type'] = 'hidden';
759
-					}
760
-					else {
770
+					} else {
761 771
 						$new_possible_value = array();
762 772
 						switch ( $editedItem->data_type) {
763 773
 							case 'integer':
@@ -791,8 +801,7 @@  discard block
 block discarded – undo
791 801
 						}
792 802
 						$input_def['possible_value'] = $new_possible_value;
793 803
 					}
794
-				}
795
-				elseif ($input_def['label'] == 'frontend_input') {
804
+				} elseif ($input_def['label'] == 'frontend_input') {
796 805
 					$new_possible_value = array();
797 806
 
798 807
 					if ( is_object($editedItem) ) {
@@ -826,8 +835,7 @@  discard block
 block discarded – undo
826 835
 									$new_possible_value[__('Date field', 'wpshop')] = 'date_field';
827 836
 								break;
828 837
 						}
829
-					}
830
-					else {
838
+					} else {
831 839
 						$new_possible_value[__('Text field', 'wpshop')] = 'short_text';
832 840
 						$new_possible_value[__('Number field', 'wpshop')] = 'float_field';
833 841
 						$new_possible_value[__('Date field', 'wpshop')] = 'date_field';
@@ -919,8 +927,7 @@  discard block
 block discarded – undo
919 927
 								$the_input = wpshop_form::check_input_type($input_def, WPSHOP_DBT_ATTRIBUTE);
920 928
 							break;
921 929
 						}
922
-					}
923
-					else {
930
+					} else {
924 931
 						$input_def['type']='text';
925 932
 						$the_input = wpshop_form::check_input_type($input_def, self::getDbTable());
926 933
 					}
@@ -947,9 +954,9 @@  discard block
 block discarded – undo
947 954
 			<td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_label wpshop_' . self::currentPageCode . '_edition_table_field_label_'.$input_def['name'].'" ><label for="'.$input_def_id.'" >' . __($input_def['label'], 'wpshop') . '</label></td>
948 955
 			<td class="wpshop_' . self::currentPageCode . '_edition_table_cell wpshop_' . self::currentPageCode . '_edition_table_field_input wpshop_' . self::currentPageCode . '_edition_table_field_input_'.$input_def['name'].'" >' . $the_input . '</td>
949 956
 		</tr>';
950
-					if ( (substr($input_def['label'], 0, 3) == 'is_') || (substr($input_def['label'], 0, 1) == '_') || in_array($input_def['label'], unserialize( WPSHOP_ATTRIBUTE_DEF_COLUMN_INTO_OPTIONS )) )
951
-						$the_form_option_content_list[$input_def['label']] = $input;
952
-					else {
957
+					if ( (substr($input_def['label'], 0, 3) == 'is_') || (substr($input_def['label'], 0, 1) == '_') || in_array($input_def['label'], unserialize( WPSHOP_ATTRIBUTE_DEF_COLUMN_INTO_OPTIONS )) ) {
958
+											$the_form_option_content_list[$input_def['label']] = $input;
959
+					} else {
953 960
 						$the_form_general_content .= $input;
954 961
 						if ( ($input_def['label'] == 'frontend_input') && !is_object($editedItem) ) {
955 962
 
@@ -963,8 +970,7 @@  discard block
 block discarded – undo
963 970
 							$the_form_general_content .= $input;
964 971
 						}
965 972
 					}
966
-				}
967
-				else{
973
+				} else{
968 974
 					$the_form_content_hidden .= '
969 975
 				' . $the_input;
970 976
 				}
@@ -1249,17 +1255,18 @@  discard block
 block discarded – undo
1249 1255
 
1250 1256
 		 //$currentPageButton .= '<h2 class="cancelButton alignleft" ><a href="' . admin_url('edit.php?post_type='.WPSHOP_NEWTYPE_IDENTIFIER_ENTITIES.'&amp;page=' . self::getListingSlug()) . '" class="button add-new-h2" >' . __('Back', 'wpshop') . '</a></h2>';
1251 1257
 
1252
-		if(($action == 'add') && (current_user_can('wpshop_add_attributes')))
1253
-			$currentPageButton .= '<input type="button" class="button-primary" id="add" name="add" value="' . __('Add', 'wpshop') . '" />';
1254
-
1255
-		elseif(current_user_can('wpshop_edit_attributes'))
1256
-		$currentPageButton .= '<input type="button" class="button-primary" id="save" name="save" value="' . __('Save', 'wpshop') . '" />';
1258
+		if(($action == 'add') && (current_user_can('wpshop_add_attributes'))) {
1259
+					$currentPageButton .= '<input type="button" class="button-primary" id="add" name="add" value="' . __('Add', 'wpshop') . '" />';
1260
+		} elseif(current_user_can('wpshop_edit_attributes')) {
1261
+				$currentPageButton .= '<input type="button" class="button-primary" id="save" name="save" value="' . __('Save', 'wpshop') . '" />';
1262
+		}
1257 1263
 
1258 1264
 		$attribute_undeletable = unserialize(WPSHOP_ATTRIBUTE_UNDELETABLE);
1259 1265
 		$attribute = self::getElement($element_id, "'valid', 'moderated', 'notused'", 'id');
1260 1266
 		$attribute_code = !empty($attribute->code)?$attribute->code:'';
1261
-		if(current_user_can('wpshop_delete_attributes') && ($action != 'add') && !in_array($attribute_code, $attribute_undeletable))
1262
-			$currentPageButton .= '<input type="button" class="button-secondary wpshop_delete_element_button wpshop_delete_element_button_'.self::currentPageCode.'" id="delete" name="delete" value="' . __('Delete', 'wpshop') . '" />';
1267
+		if(current_user_can('wpshop_delete_attributes') && ($action != 'add') && !in_array($attribute_code, $attribute_undeletable)) {
1268
+					$currentPageButton .= '<input type="button" class="button-secondary wpshop_delete_element_button wpshop_delete_element_button_'.self::currentPageCode.'" id="delete" name="delete" value="' . __('Delete', 'wpshop') . '" />';
1269
+		}
1263 1270
 
1264 1271
 		return $currentPageButton;
1265 1272
 	}
@@ -1304,8 +1311,7 @@  discard block
 block discarded – undo
1304 1311
 		/*	Get the query result regarding on the function parameters. If there must be only one result or a collection	*/
1305 1312
 		if(($element_id == '') || $list){
1306 1313
 			$element_list = $wpdb->get_results($query);
1307
-		}
1308
-		else{
1314
+		} else{
1309 1315
 			$element_list = $wpdb->get_row($query);
1310 1316
 		}
1311 1317
 
@@ -1406,8 +1412,7 @@  discard block
 block discarded – undo
1406 1412
 										foreach($attributeValue as $a){
1407 1413
 											$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX.$attributeType, array_merge($query_params, array('value' => $a)));
1408 1414
 										}
1409
-									}
1410
-									else{
1415
+									} else{
1411 1416
 										$wpdb->insert(WPSHOP_DBT_ATTRIBUTE_VALUES_PREFIX.$attributeType, array_merge($query_params, array('value' => $attributeValue)));
1412 1417
 										\eoxia\log_class::exec( 'wpshop_attributes', 'wpshop_attributes', __( 'Add the attribute : ' . $currentAttribute->code . ' with value : ' . $attributeValue , 'wpshop' ), array( 'object_id' 	=> $entityId ), 0 );
1413 1418
 									}
@@ -1423,8 +1428,10 @@  discard block
 block discarded – undo
1423 1428
 										$value = self::get_attribute_type_select_option_info($attributeTypeDetails[$attribute_code], 'value');
1424 1429
 										if (strtolower($value) == 'yes') :
1425 1430
 											update_post_meta($entityId, 'attribute_option_'.$attribute_code, $attribute_option);
1426
-										else :
1431
+										else {
1432
+											:
1427 1433
 											delete_post_meta($entityId, 'attribute_option_'.$attribute_code);
1434
+										}
1428 1435
 										endif;
1429 1436
 									}
1430 1437
 								}
@@ -1493,8 +1500,7 @@  discard block
 block discarded – undo
1493 1500
 
1494 1501
 		if ( ( (count($attributeValue) <= 1 ) && !empty($attributeValue[0]) ) && ( empty($atribute_params['frontend_input']) || ($atribute_params['frontend_input'] != 'multiple-select') )) {
1495 1502
 			$attributeValue = $attributeValue[0];
1496
-		}
1497
-		else{
1503
+		} else{
1498 1504
 			$entity_meta = get_post_meta($entityId, WPSHOP_PRODUCT_ATTRIBUTE_META_KEY, true);
1499 1505
 			if ( !empty($entity_meta) ) {
1500 1506
 				$query = $wpdb->prepare("SELECT code FROM " . WPSHOP_DBT_ATTRIBUTE . " WHERE id = %d AND entity_id = %d ", $attributeId, $entityTypeId);
@@ -1560,12 +1566,10 @@  discard block
 block discarded – undo
1560 1566
 			if ( !empty($elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value']) ) {
1561 1567
 				if (is_array($elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'])) {
1562 1568
 					$elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'][] = $elementDefinition->$attributeValueField;
1563
-				}
1564
-				else {
1569
+				} else {
1565 1570
 					$elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'] = array($elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'],$elementDefinition->$attributeValueField);
1566 1571
 				}
1567
-			}
1568
-			else {
1572
+			} else {
1569 1573
 				$elements[$elementId][$elementDefinition->attribute_set_section_name]['attributes'][$arrayKey]['value'] = $elementDefinition->$attributeValueField;
1570 1574
 			}
1571 1575
 
@@ -1646,17 +1650,14 @@  discard block
 block discarded – undo
1646 1650
 			if ( ( is_array($attribute_custom_config) && in_array($attribute_or_set, array('attribute', 'attribute_set_section', 'product_action_button')) && !empty($attribute_custom_config[$attribute_or_set]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) && $attribute_custom_config[$attribute_or_set][$attribute_code][$output_type] == 'yes' )
1647 1651
 				 || empty($attribute_custom_config) ) {
1648 1652
 				$attribute_output = true;
1649
-			}
1650
-			else if ( empty($attribute_custom_config[$attribute_or_set][$attribute_code]) || empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) || (!empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) && ( $attribute_custom_config[$attribute_or_set][$attribute_code][$output_type] == 'no')) )  {
1653
+			} else if ( empty($attribute_custom_config[$attribute_or_set][$attribute_code]) || empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) || (!empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) && ( $attribute_custom_config[$attribute_or_set][$attribute_code][$output_type] == 'no')) )  {
1651 1654
 				$attribute_output = false;
1652 1655
 			}
1653
-		}
1654
-		elseif ( $attribute_main_config === 'no' ) {
1656
+		} elseif ( $attribute_main_config === 'no' ) {
1655 1657
 			$attribute_output = false;
1656 1658
 			if ( empty($attribute_custom_config[$attribute_or_set]) || empty($attribute_custom_config[$attribute_or_set][$attribute_code]) ) {
1657 1659
 				$attribute_output = false;
1658
-			}
1659
-			else if ( !empty($attribute_custom_config) && !empty($attribute_custom_config[$attribute_or_set]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) && ( $attribute_custom_config[$attribute_or_set][$attribute_code][$output_type] == 'yes') )  {
1660
+			} else if ( !empty($attribute_custom_config) && !empty($attribute_custom_config[$attribute_or_set]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code]) && !empty($attribute_custom_config[$attribute_or_set][$attribute_code][$output_type]) && ( $attribute_custom_config[$attribute_or_set][$attribute_code][$output_type] == 'yes') )  {
1660 1661
 				$attribute_output = true;
1661 1662
 			}
1662 1663
 		}
@@ -1674,7 +1675,9 @@  discard block
 block discarded – undo
1674 1675
 		global $wp_query;
1675 1676
 
1676 1677
 		$attribute = self::getElement( $atts['attid'] );
1677
-		if(empty($atts['pid'])) $atts['pid'] = $wp_query->posts[0]->ID;
1678
+		if(empty($atts['pid'])) {
1679
+			$atts['pid'] = $wp_query->posts[0]->ID;
1680
+		}
1678 1681
 		$attribute_main_config = ( empty($atts['output_type']) || ($atts['output_type'] == 'complete_sheet') ) ? $attribute->is_visible_in_front : $attribute->is_visible_in_front_listing;
1679 1682
 		$output_type = ( empty($atts['output_type']) || ($atts['output_type'] == 'complete_sheet') ) ? 'complete_sheet' : 'mini_output';
1680 1683
 		$product_attribute_custom_config = get_post_meta($atts['pid'], WPSHOP_PRODUCT_FRONT_DISPLAY_CONF, true);
@@ -1693,13 +1696,11 @@  discard block
 block discarded – undo
1693 1696
 					}
1694 1697
 					$has_value = true;
1695 1698
 				}
1696
-			}
1697
-			else {
1699
+			} else {
1698 1700
 				$data = $wpdb->get_var($query);
1699 1701
 				if ( !empty($data) ) {
1700 1702
 					$has_value = true;
1701
-				}
1702
-				elseif( !empty($attribute->default_value) ) {
1703
+				} elseif( !empty($attribute->default_value) ) {
1703 1704
 					$has_value = true;
1704 1705
 					$data = $attribute->default_value;
1705 1706
 				}
@@ -1759,11 +1760,9 @@  discard block
 block discarded – undo
1759 1760
 
1760 1761
 		if ( !empty($attribute_value) && !is_object($attribute_value) ) {
1761 1762
 			$input_def['value'] = $attribute_value;
1762
-		}
1763
-		else if ( !empty($attribute_value->value) ) {
1763
+		} else if ( !empty($attribute_value->value) ) {
1764 1764
 			$input_def['value'] = stripslashes($attribute_value->value);
1765
-		}
1766
-		else if ( !empty($specific_argument['element_identifier']) && empty($attribute_value) && (get_post_status($specific_argument['element_identifier']) != 'auto-draft') ) {
1765
+		} else if ( !empty($specific_argument['element_identifier']) && empty($attribute_value) && (get_post_status($specific_argument['element_identifier']) != 'auto-draft') ) {
1767 1766
 			$input_def['value'] = '';
1768 1767
 		}
1769 1768
 
@@ -1773,8 +1772,7 @@  discard block
 block discarded – undo
1773 1772
 			$date_config = unserialize( $attribute->default_value );
1774 1773
 			if ((($date_config['default_value'] == '') || ($date_config['default_value'] == 'date_of_current_day')) && ($date_config['default_value'] == 'date_of_current_day')) {
1775 1774
 				$input_def['value'] = date('Y-m-d');
1776
-			}
1777
-			else {
1775
+			} else {
1778 1776
 				/**	Modification due to a message on eoxia forum: http://www.eoxia.com/forums/topic/bug-attribut-de-type-date-dans-fiche-produit-admin/	*/
1779 1777
 				$input_def['value'] = !empty($attribute_value->value) && is_string($attribute_value->value) ? str_replace( " 00:00:00", "", $attribute_value->value ) : ( !empty($attribute_value) && is_string($attribute_value) ? str_replace( " 00:00:00", "", $attribute_value ) : '' );
1780 1778
 			}
@@ -1879,8 +1877,7 @@  discard block
 block discarded – undo
1879 1877
 		if((WPSHOP_PRODUCT_PRICE_PILOT == 'HT') && ($attribute->code == WPSHOP_PRODUCT_PRICE_TTC) ){
1880 1878
 			$input_def['option'] .= ' readonly="readonly" ';
1881 1879
 			$input_more_class .= ' wpshop_prices_readonly';
1882
-		}
1883
-		elseif((WPSHOP_PRODUCT_PRICE_PILOT == 'TTC') && ($attribute->code == WPSHOP_PRODUCT_PRICE_HT) ){
1880
+		} elseif((WPSHOP_PRODUCT_PRICE_PILOT == 'TTC') && ($attribute->code == WPSHOP_PRODUCT_PRICE_HT) ){
1884 1881
 			$input_def['option'] .= ' readonly="readonly" ';
1885 1882
 			$input_more_class .= ' wpshop_prices_readonly';
1886 1883
 		}
@@ -1904,14 +1901,12 @@  discard block
 block discarded – undo
1904 1901
 		if ($attribute->is_requiring_unit == 'yes') {
1905 1902
 			if ( in_array($attribute->code, $wpshop_price_attributes) || ( WPSHOP_COST_OF_POSTAGE == $attribute->code) ) {
1906 1903
 				$input_def['options'] .= '&nbsp;<span class="attribute_currency" id="attribute_currency_' . $attribute->id . '" >' . wpshop_tools::wpshop_get_currency() . '</span>';
1907
-			}
1908
-			elseif ( in_array($attribute->code, $wpshop_weight_attributes) ) {
1904
+			} elseif ( in_array($attribute->code, $wpshop_weight_attributes) ) {
1909 1905
 				$weight_defaut_unity_option = get_option('wpshop_shop_default_weight_unity');
1910 1906
 				$query = $wpdb->prepare('SELECT name FROM '. WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id=%d', $weight_defaut_unity_option);
1911 1907
 				$unity = $wpdb->get_var( $query );
1912 1908
 				$input_def['options'] .= '&nbsp;<span class="attribute_weight" id="attribute_weight_' . $attribute->id . '" >' . __($unity, 'wpshop') . '</span>';
1913
-			}
1914
-			else {
1909
+			} else {
1915 1910
 				unset($unit_input_def);
1916 1911
 				$unit_input_def['possible_value'] = wpshop_attributes_unit::get_unit_list_for_group($attribute->_unit_group_id);
1917 1912
 				$unit_input_def['type'] = 'select';
@@ -1922,8 +1917,7 @@  discard block
 block discarded – undo
1922 1917
 				if($unit_input_def['value'] == ''){
1923 1918
 					if ( $attribute->_default_unit > 0 ) {
1924 1919
 						$unit_input_def['value'] = $attribute->_default_unit;
1925
-					}
1926
-					else {
1920
+					} else {
1927 1921
 						$unit_input_def['value'] = wpshop_attributes_unit::get_default_unit_for_group($attribute->_unit_group_id);
1928 1922
 					}
1929 1923
 				}
@@ -1947,8 +1941,7 @@  discard block
 block discarded – undo
1947 1941
 			$input_def['label_pointer'] = '';
1948 1942
 			$input_def['option'] = substr( $input_def['option'], 0 , -2 ) . ' wpshop_attributes_is_user_defined_admin_field "';
1949 1943
 			$input_def['field_container_class'] .= 'wpshop_attributes_is_user_defined_admin_container';
1950
-		}
1951
-		else {
1944
+		} else {
1952 1945
 			$input_def['output'] = wpshop_form::check_input_type($input_def, $attributeInputDomain);
1953 1946
 		}
1954 1947
 		return $input_def;
@@ -2045,8 +2038,7 @@  discard block
 block discarded – undo
2045 2038
 					/**	Check the value type to check if empty or not	*/
2046 2039
 					if ( $attributeDefinition['data_type'] == 'int' ) {
2047 2040
 						$attributeDefinition['value'] = (int)$attributeDefinition['value'];
2048
-					}
2049
-					else if ( $attributeDefinition['data_type'] == 'decimal' ) {
2041
+					} else if ( $attributeDefinition['data_type'] == 'decimal' ) {
2050 2042
 						$attributeDefinition['value'] = (float)$attributeDefinition['value'];
2051 2043
 					}
2052 2044
 
@@ -2108,8 +2100,7 @@  discard block
 block discarded – undo
2108 2100
 						require(wpshop_display::get_template_file($tpl_way_to_take[1]));
2109 2101
 						$tab_list .= ob_get_contents();
2110 2102
 						ob_end_clean();
2111
-					}
2112
-					else {
2103
+					} else {
2113 2104
 						$tab_list .= wpshop_display::display_template_element($template_part, $tpl_component);
2114 2105
 					}
2115 2106
 					unset($tpl_component);
@@ -2128,8 +2119,7 @@  discard block
 block discarded – undo
2128 2119
 						require(wpshop_display::get_template_file($tpl_way_to_take[1]));
2129 2120
 						$content_list .= ob_get_contents();
2130 2121
 						ob_end_clean();
2131
-					}
2132
-					else {
2122
+					} else {
2133 2123
 						$content_list .= wpshop_display::display_template_element($template_part, $tpl_component);
2134 2124
 					}
2135 2125
 					unset($tpl_component);
@@ -2151,8 +2141,7 @@  discard block
 block discarded – undo
2151 2141
 					require(wpshop_display::get_template_file($tpl_way_to_take[1]));
2152 2142
 					$attributeContentOutput = ob_get_contents();
2153 2143
 					ob_end_clean();
2154
-				}
2155
-				else {
2144
+				} else {
2156 2145
 					$attributeContentOutput = wpshop_display::display_template_element($template_part, $tpl_component);
2157 2146
 				}
2158 2147
 				unset($tpl_component);
@@ -2204,8 +2193,9 @@  discard block
 block discarded – undo
2204 2193
 				foreach ($attributeDefinition['value'] as $v) {
2205 2194
 					$attribute_value .= ' / '.wpshop_attributes::get_attribute_type_select_option_info($v, 'label', $attributeDefinition['data_type_to_use']);
2206 2195
 				}
2196
+			} else {
2197
+				$attribute_value = ' / '.wpshop_attributes::get_attribute_type_select_option_info($attributeDefinition['value'], 'label', $attributeDefinition['data_type_to_use']);
2207 2198
 			}
2208
-			else $attribute_value = ' / '.wpshop_attributes::get_attribute_type_select_option_info($attributeDefinition['value'], 'label', $attributeDefinition['data_type_to_use']);
2209 2199
 			$attribute_value = substr($attribute_value,3);
2210 2200
 		}
2211 2201
 
@@ -2287,8 +2277,7 @@  discard block
 block discarded – undo
2287 2277
 								wps_shortcodes_ctr::output_shortcode('attribute_'.str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label'])), $shortcode_code_def, 'wpshop_product_shortcode_display wpshop_product_attribute_shortcode_display wpshop_product_attribute_shortcode_display_'.str_replace('-', '_', sanitize_title($attribute_output_def['field_definition']['label'])).' wpshop_cls');
2288 2278
 								$shortcodes .= '<li class="wpshop_cls" >'.sprintf(__('Insertion code for the attribute %s for this product', 'wpshop'), '<span>'.__($attribute_output_def['field_definition']['label'], 'wpshop').'</span>').ob_get_contents().'</li>';
2289 2279
 								ob_end_clean();
2290
-							}
2291
-							else {
2280
+							} else {
2292 2281
 								if ( $attribute->code == 'product_attribute_set_id' ) {
2293 2282
 									$attribute_output_def['field_definition']['type'] = 'hidden';
2294 2283
 								}
@@ -2308,10 +2297,11 @@  discard block
 block discarded – undo
2308 2297
 					$attribute_group_display = sprintf(__('Insertion code for attribute group %s for this product', 'wpshop'), '<span>'.$productAttributeSetDetail['name'].'</span>').ob_get_contents().'<ul class="" >'.$shortcodes.'</ul>';
2309 2298
 					ob_end_clean();
2310 2299
 
2311
-					if( WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE == 'each-box' )
2312
-						$currentTabContent .= '<div class="wpshop_cls" ><strong>'.__('Shortcodes','wpshop').'</strong> - <a href="#" class="show-hide-shortcodes">' . __('Display', 'wpshop') . '</a><div class="wpshop_product_shortcode_display wpshop_product_shortcode_display_container wpshopHide" >' . $attribute_group_display . '</div></div>';
2313
-					else
2314
-						$shortcodes_attr .= $attribute_group_display;
2300
+					if( WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE == 'each-box' ) {
2301
+											$currentTabContent .= '<div class="wpshop_cls" ><strong>'.__('Shortcodes','wpshop').'</strong> - <a href="#" class="show-hide-shortcodes">' . __('Display', 'wpshop') . '</a><div class="wpshop_product_shortcode_display wpshop_product_shortcode_display_container wpshopHide" >' . $attribute_group_display . '</div></div>';
2302
+					} else {
2303
+											$shortcodes_attr .= $attribute_group_display;
2304
+					}
2315 2305
 
2316 2306
 					if ( $output_nb <= 0 ) {
2317 2307
 						$currentTabContent = __('Nothing avaiblable here. You can go in attribute management interface in order to add content here.', 'wpshop');
@@ -2326,8 +2316,7 @@  discard block
 block discarded – undo
2326 2316
 						$box['boxContent'][$productAttributeSetDetail['code']] = '
2327 2317
 			<div id="wpshop_' . $currentPageCode . '_' . wpshop_tools::slugify($productAttributeSetDetail['code'], array('noAccent')) . '_form" >' . $currentTabContent . '
2328 2318
 							</div><div class="wpshop_cls" ></div>';
2329
-					}
2330
-					else if ( $outputType == 'column' ) {
2319
+					} else if ( $outputType == 'column' ) {
2331 2320
 						$currentTabContent = str_replace('wpshop_form_input_element', 'wpshop_form_input_column', $currentTabContent);
2332 2321
 						$currentTabContent = str_replace('wpshop_form_label', 'wpshop_form_label_column', $currentTabContent);
2333 2322
 
@@ -2365,8 +2354,7 @@  discard block
 block discarded – undo
2365 2354
 							$box['box']['shortcode'] = __('Product Shortcodes', 'wpshop');
2366 2355
 							$box['boxContent']['shortcode'] = $shortcodes_attr;
2367 2356
 							$box['box']['shortcode_backend_display_type'] = WPSHOP_PRODUCT_SHORTCODE_DISPLAY_TYPE;
2368
-						}
2369
-						else{
2357
+						} else{
2370 2358
 							$box['columnTitle']['shortcode'] = __('Product Shortcodes', 'wpshop');
2371 2359
 							$box['columnContent']['shortcode'] = $shortcodes_attr;
2372 2360
 						}
@@ -2406,8 +2394,7 @@  discard block
 block discarded – undo
2406 2394
 //					$ouput['more_input'] .= '<input type="hidden" value="' . (WPSHOP_DISPLAY_VALUE_FOR_ATTRIBUTE_SELECT ? str_replace("\\", "", $option->value) : str_replace("\\", "", $option->label)) . '" name="wpshop_product_attribute_' . $attribute->code . '_value_' . $option->id . '" id="wpshop_product_attribute_' . $attribute->code . '_value_' . $option->id . '" />';
2407 2395
 // 				}
2408 2396
 			endforeach;
2409
-		}
2410
-		elseif ( $attribute->data_type_to_use == 'internal')  {
2397
+		} elseif ( $attribute->data_type_to_use == 'internal')  {
2411 2398
 			switch ($attribute_default_value) {
2412 2399
 				case 'users':
2413 2400
 					$users = get_users('orderby=nicename');
@@ -2436,9 +2423,11 @@  discard block
 block discarded – undo
2436 2423
 		/*	There is no value existing for this value	*/
2437 2424
 		if (empty($attribute_select_options_list)) :
2438 2425
 			$ouput['more_input'].=__('Nothing found for this field', 'wpshop');
2439
-		else:
2426
+		else {
2427
+			:
2440 2428
 			/*	Add a default value to the combobox list	*/
2441 2429
 			$default_value_is_serial = false;
2430
+		}
2442 2431
 			$attribute_list_first_element = $attribute->default_value;
2443 2432
 			if ( !empty($attribute->default_value) && ($attribute->default_value == serialize(false) || wpshop_tools::is_serialized( $attribute->default_value ) ) ) {
2444 2433
 				$default_value_is_serial = true;
@@ -2454,8 +2443,7 @@  discard block
 block discarded – undo
2454 2443
 		/*	Add a extra element to create a new element into list	*/
2455 2444
 		if ( is_admin()  && ( empty($provenance['from']) || ($provenance['from'] != 'frontend')) ) {
2456 2445
 			/**	$ouput['more_input'] .= '<img src="'.WPSHOP_MEDIAS_ICON_URL.'add.png" id="new_value_pict_' . $attribute->code . '" alt="'.__('Add a new value for this attribute', 'wpshop').'" title="'.__('Add a new value for this attribute', 'wpshop').'" class="wpshop_icons wpshop_icons_add_new_value_to_option_list wpshop_icons_add_new_value_to_option_list_'.$attribute->code.'" />';	*/
2457
-		}
2458
-		else if ( 'yes' == $attribute->is_used_in_quick_add_form ) {
2446
+		} else if ( 'yes' == $attribute->is_used_in_quick_add_form ) {
2459 2447
 			$tpl_component = array();
2460 2448
 			$tpl_component['NEW_ELEMENT_CREATION_FIELD'] = 'attribute[new_value_creation][' . $attribute->code . ']';
2461 2449
 			$ouput['more_input'] .= wpshop_display::display_template_element('quick_entity_specific_field_new_element', $tpl_component);
@@ -2477,8 +2465,7 @@  discard block
 block discarded – undo
2477 2465
 WHERE ATT.code = %s
2478 2466
 	AND ATT_SELECT_OPTIONS_VALUE.status = 'valid'
2479 2467
 GROUP BY ATT.id, chosen_val", $element_id, $attribute_code);
2480
-		}
2481
-		else {
2468
+		} else {
2482 2469
 			$query = $wpdb->prepare("
2483 2470
 SELECT P.ID AS chosen_val, P.post_title
2484 2471
 FROM " . WPSHOP_DBT_ATTRIBUTE . " AS ATT
@@ -2653,14 +2640,17 @@  discard block
 block discarded – undo
2653 2640
 		$attribute_final = array();
2654 2641
 		$entity_type = get_post_type($entityId);
2655 2642
 		$data = self::get_attribute_list_for_item( wpshop_entities::get_entity_identifier_from_code($entity_type), $entityId, WPSHOP_CURRENT_LOCALE);
2656
-		foreach($data as $d) $attribute_available[$d->attribute_code] = array('attribute_id' => $d->attribute_id, 'data_type' => $d->data_type);
2643
+		foreach($data as $d) {
2644
+			$attribute_available[$d->attribute_code] = array('attribute_id' => $d->attribute_id, 'data_type' => $d->data_type);
2645
+		}
2657 2646
 
2658 2647
 		// Creation d'un array "propre" et valide pour la fonction self::saveAttributeForEntity
2659 2648
 		foreach ( $values as $key => $value ) {
2660 2649
 			if ( in_array( $key, array_keys( $attribute_available ) ) ) {
2661 2650
 				$attribute_final[$attribute_available[$key]['data_type']][$key] = $value;
2651
+			} else {
2652
+				$message .= sprintf(__('Impossible to set "%s" attribute', 'wpshop'), $key)."\n";
2662 2653
 			}
2663
-			else $message .= sprintf(__('Impossible to set "%s" attribute', 'wpshop'), $key)."\n";
2664 2654
 		}
2665 2655
 
2666 2656
 		// Pour les autres attributs non donné on leur affecte leur valeur par défaut
@@ -2733,8 +2723,7 @@  discard block
 block discarded – undo
2733 2723
 						/** Build template	*/
2734 2724
 						$info = wpshop_display::display_template_element($template_part, $tpl_component);
2735 2725
 						unset($tpl_component);
2736
-					}
2737
-					else {
2726
+					} else {
2738 2727
 						$info = $entity_infos->post_title;
2739 2728
 					}
2740 2729
 				}
@@ -2925,8 +2914,7 @@  discard block
 block discarded – undo
2925 2914
 
2926 2915
 		});
2927 2916
 	</script>';
2928
-			}
2929
-			elseif((($data_type == 'internal') && empty($attribute_select_options)) || (!empty($attribute_select_options) && !empty($attribute_select_options[0]->data_type_to_use) && ($attribute_select_options[0]->data_type_to_use == 'internal'))){
2917
+			} elseif((($data_type == 'internal') && empty($attribute_select_options)) || (!empty($attribute_select_options) && !empty($attribute_select_options[0]->data_type_to_use) && ($attribute_select_options[0]->data_type_to_use == 'internal'))){
2930 2918
 				$sub_output='';
2931 2919
 				$wp_types = unserialize(WPSHOP_INTERNAL_TYPES);
2932 2920
 				unset($input_def);$input_def=array();
@@ -3027,8 +3015,7 @@  discard block
 block discarded – undo
3027 3015
 									<option value="' . $value->value . '" >' . $value->label . '</option>';
3028 3016
 										}
3029 3017
 									}
3030
-								}
3031
-								else {
3018
+								} else {
3032 3019
 									foreach ($attribute_values as $attribute_value) {
3033 3020
 										if ( !empty($attribute_value->value) ) {
3034 3021
 											$attribute_possible_values .= '
@@ -3111,8 +3098,7 @@  discard block
 block discarded – undo
3111 3098
 					$final_list['unavailable'][$attribute->code]['label'] = $attribute->frontend_label;
3112 3099
 					$final_list['unavailable'][$attribute->code]['values'] = array();
3113 3100
 					$final_list['unavailable'][$attribute->code]['attribute_complete_def'] = $attribute;
3114
-				}
3115
-				else {
3101
+				} else {
3116 3102
 					$final_list['available'][$attribute->code]['label'] = $attribute->frontend_label;
3117 3103
 					$final_list['available'][$attribute->code]['values'] = $attribute_values_for_variations;
3118 3104
 					$final_list['available'][$attribute->code]['attribute_complete_def'] = $attribute;
@@ -3140,8 +3126,7 @@  discard block
 block discarded – undo
3140 3126
 						$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_LABEL_STATE'] = '';
3141 3127
 						$tpl_component['ADMIN_VARIATIONS_DEF_LIST_ATTRIBUTE_CHECKBOX_STATE'] = '';
3142 3128
 						$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_LABEL_EXPLAINATION'] = '';
3143
-					}
3144
-					else {
3129
+					} else {
3145 3130
 						$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_LABEL_STATE'] = ' class="wpshop_unavailable_label_variation_definition" ';
3146 3131
 						$tpl_component['ADMIN_VARIATIONS_DEF_LIST_ATTRIBUTE_CHECKBOX_STATE'] = ' disabled="disabled"';
3147 3132
 						$tpl_component['ADMIN_VARIATIONS_DEF_ATTRIBUTE_TO_USE_LABEL_EXPLAINATION'] = '';
Please login to merge, or discard this patch.