-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsize.php
107 lines (90 loc) · 2.21 KB
/
size.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
require 'data.php';
/**
* sizing conversion
*/
class SizeConversion extends SizeConversion_data
{
public function women($from, $to, $size, $atyp = FALSE)
{
$from = strtolower($from);
$to = strtolower($to);
if ($atyp == 'shoes')
$this->shoes('woman', $from, $to, $size);
else
$this->woman_general($from, $to, $size);
}
public function man($from, $to, $size, $atyp = FALSE)
{
$from = strtolower($from);
$to = strtolower($to);
if ($atyp)
return $this->man_special( $from, $to, $size, $atyp );
else
return $this->man_general( $from, $to, $size);
}
private function man_special($from, $to, $size, $atyp)
{
$atyp = strtolower($atyp);
if ($atyp == 't-shirts' || $atyp == 'tshirts')
$type = 'tshirts';
// for shirts us & uk is the same
if ($atyp == 'shirts') {
if ($from == 'uk') $from = 'us';
if ($to == 'uk') $to = 'us';
$type = 'shirts';
}
// extra fuction for shoes
if ($atyp == 'shoes') {
return $this->shoes('man', $from, $to, $size);
}
$type .= '_man';
$source = $this->$type;
$index = array_search($size, $source[$from]);
if ( $index != FALSE )
return $source[$to][$index];
else
return 'Invalid size';
}
private function man_general($from, $to, $size)
{
if ($size > 62 || $size < 32 || $size%2 > 0 )
return 'Invalid size';
if ($from == 'eu' && ( $to == 'us' || $to == 'uk' ) )
return $size - 10;
else if (( $from == 'us' || $from == 'uk' ) && $to == 'eu' )
return $size + 10;
else
return $size;
}
private function woman_general($from, $to, $size)
{
$source = $this->woman_general;
$index = array_search($size, $source[$from]);
if ( $index != FALSE )
return $source[$to][$index];
else
return 'Invalid size';
}
private function shoes($sex, $from, $to ,$size)
{
$from = strtolower($from);
$to = strtolower($to);
$source = 'shoes'.'_'.$sex;
$source = $this->$shoes;
$diff = 0.5;
if ( $sex == 'woman' ) { $diff = 2; }
if ( $from == 'uk' ) { $size += 0.5; $from = 'us'; }
$index = array_search($size, $source[$from]);
if ( $index != FALSE )
{
if ( $to == 'uk' )
return $source['us'][$index] - 0.5;
else
return $source[$to][$index];
}
else
return 'Invalid size';
}
}
?>