Completed
Branch develop (aa6d31)
by
unknown
24:05
created
htdocs/includes/sabre/sabre/vobject/lib/timezonedata/exchangezones.php 1 patch
Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -12,83 +12,83 @@
 block discarded – undo
12 12
  * @license http://sabre.io/license/ Modified BSD License
13 13
  */
14 14
 return [
15
-    'Universal Coordinated Time' => 'UTC',
16
-    'Casablanca, Monrovia' => 'Africa/Casablanca',
17
-    'Greenwich Mean Time: Dublin, Edinburgh, Lisbon, London' => 'Europe/Lisbon',
18
-    'Greenwich Mean Time; Dublin, Edinburgh, London' => 'Europe/London',
19
-    'Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna' => 'Europe/Berlin',
20
-    'Belgrade, Pozsony, Budapest, Ljubljana, Prague' => 'Europe/Prague',
21
-    'Brussels, Copenhagen, Madrid, Paris' => 'Europe/Paris',
22
-    'Paris, Madrid, Brussels, Copenhagen' => 'Europe/Paris',
23
-    'Prague, Central Europe' => 'Europe/Prague',
24
-    'Sarajevo, Skopje, Sofija, Vilnius, Warsaw, Zagreb' => 'Europe/Sarajevo',
25
-    'West Central Africa' => 'Africa/Luanda', // This was a best guess
26
-    'Athens, Istanbul, Minsk' => 'Europe/Athens',
27
-    'Bucharest' => 'Europe/Bucharest',
28
-    'Cairo' => 'Africa/Cairo',
29
-    'Harare, Pretoria' => 'Africa/Harare',
30
-    'Helsinki, Riga, Tallinn' => 'Europe/Helsinki',
31
-    'Israel, Jerusalem Standard Time' => 'Asia/Jerusalem',
32
-    'Baghdad' => 'Asia/Baghdad',
33
-    'Arab, Kuwait, Riyadh' => 'Asia/Kuwait',
34
-    'Moscow, St. Petersburg, Volgograd' => 'Europe/Moscow',
35
-    'East Africa, Nairobi' => 'Africa/Nairobi',
36
-    'Tehran' => 'Asia/Tehran',
37
-    'Abu Dhabi, Muscat' => 'Asia/Muscat', // Best guess
38
-    'Baku, Tbilisi, Yerevan' => 'Asia/Baku',
39
-    'Kabul' => 'Asia/Kabul',
40
-    'Ekaterinburg' => 'Asia/Yekaterinburg',
41
-    'Islamabad, Karachi, Tashkent' => 'Asia/Karachi',
42
-    'Kolkata, Chennai, Mumbai, New Delhi, India Standard Time' => 'Asia/Calcutta',
43
-    'Kathmandu, Nepal' => 'Asia/Kathmandu',
44
-    'Almaty, Novosibirsk, North Central Asia' => 'Asia/Almaty',
45
-    'Astana, Dhaka' => 'Asia/Dhaka',
46
-    'Sri Jayawardenepura, Sri Lanka' => 'Asia/Colombo',
47
-    'Rangoon' => 'Asia/Rangoon',
48
-    'Bangkok, Hanoi, Jakarta' => 'Asia/Bangkok',
49
-    'Krasnoyarsk' => 'Asia/Krasnoyarsk',
50
-    'Beijing, Chongqing, Hong Kong SAR, Urumqi' => 'Asia/Shanghai',
51
-    'Irkutsk, Ulaan Bataar' => 'Asia/Irkutsk',
52
-    'Kuala Lumpur, Singapore' => 'Asia/Singapore',
53
-    'Perth, Western Australia' => 'Australia/Perth',
54
-    'Taipei' => 'Asia/Taipei',
55
-    'Osaka, Sapporo, Tokyo' => 'Asia/Tokyo',
56
-    'Seoul, Korea Standard time' => 'Asia/Seoul',
57
-    'Yakutsk' => 'Asia/Yakutsk',
58
-    'Adelaide, Central Australia' => 'Australia/Adelaide',
59
-    'Darwin' => 'Australia/Darwin',
60
-    'Brisbane, East Australia' => 'Australia/Brisbane',
61
-    'Canberra, Melbourne, Sydney, Hobart (year 2000 only)' => 'Australia/Sydney',
62
-    'Guam, Port Moresby' => 'Pacific/Guam',
63
-    'Hobart, Tasmania' => 'Australia/Hobart',
64
-    'Vladivostok' => 'Asia/Vladivostok',
65
-    'Magadan, Solomon Is., New Caledonia' => 'Asia/Magadan',
66
-    'Auckland, Wellington' => 'Pacific/Auckland',
67
-    'Fiji Islands, Kamchatka, Marshall Is.' => 'Pacific/Fiji',
68
-    'Nuku\'alofa, Tonga' => 'Pacific/Tongatapu',
69
-    'Azores' => 'Atlantic/Azores',
70
-    'Cape Verde Is.' => 'Atlantic/Cape_Verde',
71
-    'Mid-Atlantic' => 'America/Noronha',
72
-    'Brasilia' => 'America/Sao_Paulo', // Best guess
73
-    'Buenos Aires' => 'America/Argentina/Buenos_Aires',
74
-    'Greenland' => 'America/Godthab',
75
-    'Newfoundland' => 'America/St_Johns',
76
-    'Atlantic Time (Canada)' => 'America/Halifax',
77
-    'Caracas, La Paz' => 'America/Caracas',
78
-    'Santiago' => 'America/Santiago',
79
-    'Bogota, Lima, Quito' => 'America/Bogota',
80
-    'Eastern Time (US & Canada)' => 'America/New_York',
81
-    'Indiana (East)' => 'America/Indiana/Indianapolis',
82
-    'Central America' => 'America/Guatemala',
83
-    'Central Time (US & Canada)' => 'America/Chicago',
84
-    'Mexico City, Tegucigalpa' => 'America/Mexico_City',
85
-    'Saskatchewan' => 'America/Edmonton',
86
-    'Arizona' => 'America/Phoenix',
87
-    'Mountain Time (US & Canada)' => 'America/Denver', // Best guess
88
-    'Pacific Time (US & Canada)' => 'America/Los_Angeles', // Best guess
89
-    'Pacific Time (US & Canada); Tijuana' => 'America/Los_Angeles', // Best guess
90
-    'Alaska' => 'America/Anchorage',
91
-    'Hawaii' => 'Pacific/Honolulu',
92
-    'Midway Island, Samoa' => 'Pacific/Midway',
93
-    'Eniwetok, Kwajalein, Dateline Time' => 'Pacific/Kwajalein',
15
+	'Universal Coordinated Time' => 'UTC',
16
+	'Casablanca, Monrovia' => 'Africa/Casablanca',
17
+	'Greenwich Mean Time: Dublin, Edinburgh, Lisbon, London' => 'Europe/Lisbon',
18
+	'Greenwich Mean Time; Dublin, Edinburgh, London' => 'Europe/London',
19
+	'Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna' => 'Europe/Berlin',
20
+	'Belgrade, Pozsony, Budapest, Ljubljana, Prague' => 'Europe/Prague',
21
+	'Brussels, Copenhagen, Madrid, Paris' => 'Europe/Paris',
22
+	'Paris, Madrid, Brussels, Copenhagen' => 'Europe/Paris',
23
+	'Prague, Central Europe' => 'Europe/Prague',
24
+	'Sarajevo, Skopje, Sofija, Vilnius, Warsaw, Zagreb' => 'Europe/Sarajevo',
25
+	'West Central Africa' => 'Africa/Luanda', // This was a best guess
26
+	'Athens, Istanbul, Minsk' => 'Europe/Athens',
27
+	'Bucharest' => 'Europe/Bucharest',
28
+	'Cairo' => 'Africa/Cairo',
29
+	'Harare, Pretoria' => 'Africa/Harare',
30
+	'Helsinki, Riga, Tallinn' => 'Europe/Helsinki',
31
+	'Israel, Jerusalem Standard Time' => 'Asia/Jerusalem',
32
+	'Baghdad' => 'Asia/Baghdad',
33
+	'Arab, Kuwait, Riyadh' => 'Asia/Kuwait',
34
+	'Moscow, St. Petersburg, Volgograd' => 'Europe/Moscow',
35
+	'East Africa, Nairobi' => 'Africa/Nairobi',
36
+	'Tehran' => 'Asia/Tehran',
37
+	'Abu Dhabi, Muscat' => 'Asia/Muscat', // Best guess
38
+	'Baku, Tbilisi, Yerevan' => 'Asia/Baku',
39
+	'Kabul' => 'Asia/Kabul',
40
+	'Ekaterinburg' => 'Asia/Yekaterinburg',
41
+	'Islamabad, Karachi, Tashkent' => 'Asia/Karachi',
42
+	'Kolkata, Chennai, Mumbai, New Delhi, India Standard Time' => 'Asia/Calcutta',
43
+	'Kathmandu, Nepal' => 'Asia/Kathmandu',
44
+	'Almaty, Novosibirsk, North Central Asia' => 'Asia/Almaty',
45
+	'Astana, Dhaka' => 'Asia/Dhaka',
46
+	'Sri Jayawardenepura, Sri Lanka' => 'Asia/Colombo',
47
+	'Rangoon' => 'Asia/Rangoon',
48
+	'Bangkok, Hanoi, Jakarta' => 'Asia/Bangkok',
49
+	'Krasnoyarsk' => 'Asia/Krasnoyarsk',
50
+	'Beijing, Chongqing, Hong Kong SAR, Urumqi' => 'Asia/Shanghai',
51
+	'Irkutsk, Ulaan Bataar' => 'Asia/Irkutsk',
52
+	'Kuala Lumpur, Singapore' => 'Asia/Singapore',
53
+	'Perth, Western Australia' => 'Australia/Perth',
54
+	'Taipei' => 'Asia/Taipei',
55
+	'Osaka, Sapporo, Tokyo' => 'Asia/Tokyo',
56
+	'Seoul, Korea Standard time' => 'Asia/Seoul',
57
+	'Yakutsk' => 'Asia/Yakutsk',
58
+	'Adelaide, Central Australia' => 'Australia/Adelaide',
59
+	'Darwin' => 'Australia/Darwin',
60
+	'Brisbane, East Australia' => 'Australia/Brisbane',
61
+	'Canberra, Melbourne, Sydney, Hobart (year 2000 only)' => 'Australia/Sydney',
62
+	'Guam, Port Moresby' => 'Pacific/Guam',
63
+	'Hobart, Tasmania' => 'Australia/Hobart',
64
+	'Vladivostok' => 'Asia/Vladivostok',
65
+	'Magadan, Solomon Is., New Caledonia' => 'Asia/Magadan',
66
+	'Auckland, Wellington' => 'Pacific/Auckland',
67
+	'Fiji Islands, Kamchatka, Marshall Is.' => 'Pacific/Fiji',
68
+	'Nuku\'alofa, Tonga' => 'Pacific/Tongatapu',
69
+	'Azores' => 'Atlantic/Azores',
70
+	'Cape Verde Is.' => 'Atlantic/Cape_Verde',
71
+	'Mid-Atlantic' => 'America/Noronha',
72
+	'Brasilia' => 'America/Sao_Paulo', // Best guess
73
+	'Buenos Aires' => 'America/Argentina/Buenos_Aires',
74
+	'Greenland' => 'America/Godthab',
75
+	'Newfoundland' => 'America/St_Johns',
76
+	'Atlantic Time (Canada)' => 'America/Halifax',
77
+	'Caracas, La Paz' => 'America/Caracas',
78
+	'Santiago' => 'America/Santiago',
79
+	'Bogota, Lima, Quito' => 'America/Bogota',
80
+	'Eastern Time (US & Canada)' => 'America/New_York',
81
+	'Indiana (East)' => 'America/Indiana/Indianapolis',
82
+	'Central America' => 'America/Guatemala',
83
+	'Central Time (US & Canada)' => 'America/Chicago',
84
+	'Mexico City, Tegucigalpa' => 'America/Mexico_City',
85
+	'Saskatchewan' => 'America/Edmonton',
86
+	'Arizona' => 'America/Phoenix',
87
+	'Mountain Time (US & Canada)' => 'America/Denver', // Best guess
88
+	'Pacific Time (US & Canada)' => 'America/Los_Angeles', // Best guess
89
+	'Pacific Time (US & Canada); Tijuana' => 'America/Los_Angeles', // Best guess
90
+	'Alaska' => 'America/Anchorage',
91
+	'Hawaii' => 'Pacific/Honolulu',
92
+	'Midway Island, Samoa' => 'Pacific/Midway',
93
+	'Eniwetok, Kwajalein, Dateline Time' => 'Pacific/Kwajalein',
94 94
 ];
Please login to merge, or discard this patch.
htdocs/includes/sabre/sabre/vobject/lib/timezonedata/php-workaround.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -15,32 +15,32 @@
 block discarded – undo
15 15
  * @license http://sabre.io/license/ Modified BSD License
16 16
  */
17 17
 return [
18
-    'CST6CDT' => 'America/Chicago',
19
-    'Cuba' => 'America/Havana',
20
-    'Egypt' => 'Africa/Cairo',
21
-    'Eire' => 'Europe/Dublin',
22
-    'EST5EDT' => 'America/New_York',
23
-    'Factory' => 'UTC',
24
-    'GB-Eire' => 'Europe/London',
25
-    'GMT0' => 'UTC',
26
-    'Greenwich' => 'UTC',
27
-    'Hongkong' => 'Asia/Hong_Kong',
28
-    'Iceland' => 'Atlantic/Reykjavik',
29
-    'Iran' => 'Asia/Tehran',
30
-    'Israel' => 'Asia/Jerusalem',
31
-    'Jamaica' => 'America/Jamaica',
32
-    'Japan' => 'Asia/Tokyo',
33
-    'Kwajalein' => 'Pacific/Kwajalein',
34
-    'Libya' => 'Africa/Tripoli',
35
-    'MST7MDT' => 'America/Denver',
36
-    'Navajo' => 'America/Denver',
37
-    'NZ-CHAT' => 'Pacific/Chatham',
38
-    'Poland' => 'Europe/Warsaw',
39
-    'Portugal' => 'Europe/Lisbon',
40
-    'PST8PDT' => 'America/Los_Angeles',
41
-    'Singapore' => 'Asia/Singapore',
42
-    'Turkey' => 'Europe/Istanbul',
43
-    'Universal' => 'UTC',
44
-    'W-SU' => 'Europe/Moscow',
45
-    'Zulu' => 'UTC',
18
+	'CST6CDT' => 'America/Chicago',
19
+	'Cuba' => 'America/Havana',
20
+	'Egypt' => 'Africa/Cairo',
21
+	'Eire' => 'Europe/Dublin',
22
+	'EST5EDT' => 'America/New_York',
23
+	'Factory' => 'UTC',
24
+	'GB-Eire' => 'Europe/London',
25
+	'GMT0' => 'UTC',
26
+	'Greenwich' => 'UTC',
27
+	'Hongkong' => 'Asia/Hong_Kong',
28
+	'Iceland' => 'Atlantic/Reykjavik',
29
+	'Iran' => 'Asia/Tehran',
30
+	'Israel' => 'Asia/Jerusalem',
31
+	'Jamaica' => 'America/Jamaica',
32
+	'Japan' => 'Asia/Tokyo',
33
+	'Kwajalein' => 'Pacific/Kwajalein',
34
+	'Libya' => 'Africa/Tripoli',
35
+	'MST7MDT' => 'America/Denver',
36
+	'Navajo' => 'America/Denver',
37
+	'NZ-CHAT' => 'Pacific/Chatham',
38
+	'Poland' => 'Europe/Warsaw',
39
+	'Portugal' => 'Europe/Lisbon',
40
+	'PST8PDT' => 'America/Los_Angeles',
41
+	'Singapore' => 'Asia/Singapore',
42
+	'Turkey' => 'Europe/Istanbul',
43
+	'Universal' => 'UTC',
44
+	'W-SU' => 'Europe/Moscow',
45
+	'Zulu' => 'UTC',
46 46
 ];
Please login to merge, or discard this patch.
htdocs/includes/sabre/sabre/vobject/lib/timezonedata/php-bc.php 1 patch
Indentation   +133 added lines, -133 removed lines patch added patch discarded remove patch
@@ -16,137 +16,137 @@
 block discarded – undo
16 16
  * @license http://sabre.io/license/ Modified BSD License
17 17
  */
18 18
 return [
19
-    'Africa/Asmera',
20
-    'Africa/Timbuktu',
21
-    'America/Argentina/ComodRivadavia',
22
-    'America/Atka',
23
-    'America/Buenos_Aires',
24
-    'America/Catamarca',
25
-    'America/Coral_Harbour',
26
-    'America/Cordoba',
27
-    'America/Ensenada',
28
-    'America/Fort_Wayne',
29
-    'America/Indianapolis',
30
-    'America/Jujuy',
31
-    'America/Knox_IN',
32
-    'America/Louisville',
33
-    'America/Mendoza',
34
-    'America/Montreal',
35
-    'America/Porto_Acre',
36
-    'America/Rosario',
37
-    'America/Shiprock',
38
-    'America/Virgin',
39
-    'Antarctica/South_Pole',
40
-    'Asia/Ashkhabad',
41
-    'Asia/Calcutta',
42
-    'Asia/Chungking',
43
-    'Asia/Dacca',
44
-    'Asia/Istanbul',
45
-    'Asia/Katmandu',
46
-    'Asia/Macao',
47
-    'Asia/Saigon',
48
-    'Asia/Tel_Aviv',
49
-    'Asia/Thimbu',
50
-    'Asia/Ujung_Pandang',
51
-    'Asia/Ulan_Bator',
52
-    'Atlantic/Faeroe',
53
-    'Atlantic/Jan_Mayen',
54
-    'Australia/ACT',
55
-    'Australia/Canberra',
56
-    'Australia/LHI',
57
-    'Australia/North',
58
-    'Australia/NSW',
59
-    'Australia/Queensland',
60
-    'Australia/South',
61
-    'Australia/Tasmania',
62
-    'Australia/Victoria',
63
-    'Australia/West',
64
-    'Australia/Yancowinna',
65
-    'Brazil/Acre',
66
-    'Brazil/DeNoronha',
67
-    'Brazil/East',
68
-    'Brazil/West',
69
-    'Canada/Atlantic',
70
-    'Canada/Central',
71
-    'Canada/Eastern',
72
-    'Canada/Mountain',
73
-    'Canada/Newfoundland',
74
-    'Canada/Pacific',
75
-    'Canada/Saskatchewan',
76
-    'Canada/Yukon',
77
-    'CET',
78
-    'Chile/Continental',
79
-    'Chile/EasterIsland',
80
-    'EET',
81
-    'EST',
82
-    'Etc/GMT',
83
-    'Etc/GMT+0',
84
-    'Etc/GMT+1',
85
-    'Etc/GMT+10',
86
-    'Etc/GMT+11',
87
-    'Etc/GMT+12',
88
-    'Etc/GMT+2',
89
-    'Etc/GMT+3',
90
-    'Etc/GMT+4',
91
-    'Etc/GMT+5',
92
-    'Etc/GMT+6',
93
-    'Etc/GMT+7',
94
-    'Etc/GMT+8',
95
-    'Etc/GMT+9',
96
-    'Etc/GMT-0',
97
-    'Etc/GMT-1',
98
-    'Etc/GMT-10',
99
-    'Etc/GMT-11',
100
-    'Etc/GMT-12',
101
-    'Etc/GMT-13',
102
-    'Etc/GMT-14',
103
-    'Etc/GMT-2',
104
-    'Etc/GMT-3',
105
-    'Etc/GMT-4',
106
-    'Etc/GMT-5',
107
-    'Etc/GMT-6',
108
-    'Etc/GMT-7',
109
-    'Etc/GMT-8',
110
-    'Etc/GMT-9',
111
-    'Etc/GMT0',
112
-    'Etc/Greenwich',
113
-    'Etc/UCT',
114
-    'Etc/Universal',
115
-    'Etc/UTC',
116
-    'Etc/Zulu',
117
-    'Europe/Belfast',
118
-    'Europe/Nicosia',
119
-    'Europe/Tiraspol',
120
-    'GB',
121
-    'GMT',
122
-    'GMT+0',
123
-    'GMT-0',
124
-    'HST',
125
-    'MET',
126
-    'Mexico/BajaNorte',
127
-    'Mexico/BajaSur',
128
-    'Mexico/General',
129
-    'MST',
130
-    'NZ',
131
-    'Pacific/Ponape',
132
-    'Pacific/Samoa',
133
-    'Pacific/Truk',
134
-    'Pacific/Yap',
135
-    'PRC',
136
-    'ROC',
137
-    'ROK',
138
-    'UCT',
139
-    'US/Alaska',
140
-    'US/Aleutian',
141
-    'US/Arizona',
142
-    'US/Central',
143
-    'US/East-Indiana',
144
-    'US/Eastern',
145
-    'US/Hawaii',
146
-    'US/Indiana-Starke',
147
-    'US/Michigan',
148
-    'US/Mountain',
149
-    'US/Pacific',
150
-    'US/Samoa',
151
-    'WET',
19
+	'Africa/Asmera',
20
+	'Africa/Timbuktu',
21
+	'America/Argentina/ComodRivadavia',
22
+	'America/Atka',
23
+	'America/Buenos_Aires',
24
+	'America/Catamarca',
25
+	'America/Coral_Harbour',
26
+	'America/Cordoba',
27
+	'America/Ensenada',
28
+	'America/Fort_Wayne',
29
+	'America/Indianapolis',
30
+	'America/Jujuy',
31
+	'America/Knox_IN',
32
+	'America/Louisville',
33
+	'America/Mendoza',
34
+	'America/Montreal',
35
+	'America/Porto_Acre',
36
+	'America/Rosario',
37
+	'America/Shiprock',
38
+	'America/Virgin',
39
+	'Antarctica/South_Pole',
40
+	'Asia/Ashkhabad',
41
+	'Asia/Calcutta',
42
+	'Asia/Chungking',
43
+	'Asia/Dacca',
44
+	'Asia/Istanbul',
45
+	'Asia/Katmandu',
46
+	'Asia/Macao',
47
+	'Asia/Saigon',
48
+	'Asia/Tel_Aviv',
49
+	'Asia/Thimbu',
50
+	'Asia/Ujung_Pandang',
51
+	'Asia/Ulan_Bator',
52
+	'Atlantic/Faeroe',
53
+	'Atlantic/Jan_Mayen',
54
+	'Australia/ACT',
55
+	'Australia/Canberra',
56
+	'Australia/LHI',
57
+	'Australia/North',
58
+	'Australia/NSW',
59
+	'Australia/Queensland',
60
+	'Australia/South',
61
+	'Australia/Tasmania',
62
+	'Australia/Victoria',
63
+	'Australia/West',
64
+	'Australia/Yancowinna',
65
+	'Brazil/Acre',
66
+	'Brazil/DeNoronha',
67
+	'Brazil/East',
68
+	'Brazil/West',
69
+	'Canada/Atlantic',
70
+	'Canada/Central',
71
+	'Canada/Eastern',
72
+	'Canada/Mountain',
73
+	'Canada/Newfoundland',
74
+	'Canada/Pacific',
75
+	'Canada/Saskatchewan',
76
+	'Canada/Yukon',
77
+	'CET',
78
+	'Chile/Continental',
79
+	'Chile/EasterIsland',
80
+	'EET',
81
+	'EST',
82
+	'Etc/GMT',
83
+	'Etc/GMT+0',
84
+	'Etc/GMT+1',
85
+	'Etc/GMT+10',
86
+	'Etc/GMT+11',
87
+	'Etc/GMT+12',
88
+	'Etc/GMT+2',
89
+	'Etc/GMT+3',
90
+	'Etc/GMT+4',
91
+	'Etc/GMT+5',
92
+	'Etc/GMT+6',
93
+	'Etc/GMT+7',
94
+	'Etc/GMT+8',
95
+	'Etc/GMT+9',
96
+	'Etc/GMT-0',
97
+	'Etc/GMT-1',
98
+	'Etc/GMT-10',
99
+	'Etc/GMT-11',
100
+	'Etc/GMT-12',
101
+	'Etc/GMT-13',
102
+	'Etc/GMT-14',
103
+	'Etc/GMT-2',
104
+	'Etc/GMT-3',
105
+	'Etc/GMT-4',
106
+	'Etc/GMT-5',
107
+	'Etc/GMT-6',
108
+	'Etc/GMT-7',
109
+	'Etc/GMT-8',
110
+	'Etc/GMT-9',
111
+	'Etc/GMT0',
112
+	'Etc/Greenwich',
113
+	'Etc/UCT',
114
+	'Etc/Universal',
115
+	'Etc/UTC',
116
+	'Etc/Zulu',
117
+	'Europe/Belfast',
118
+	'Europe/Nicosia',
119
+	'Europe/Tiraspol',
120
+	'GB',
121
+	'GMT',
122
+	'GMT+0',
123
+	'GMT-0',
124
+	'HST',
125
+	'MET',
126
+	'Mexico/BajaNorte',
127
+	'Mexico/BajaSur',
128
+	'Mexico/General',
129
+	'MST',
130
+	'NZ',
131
+	'Pacific/Ponape',
132
+	'Pacific/Samoa',
133
+	'Pacific/Truk',
134
+	'Pacific/Yap',
135
+	'PRC',
136
+	'ROC',
137
+	'ROK',
138
+	'UCT',
139
+	'US/Alaska',
140
+	'US/Aleutian',
141
+	'US/Arizona',
142
+	'US/Central',
143
+	'US/East-Indiana',
144
+	'US/Eastern',
145
+	'US/Hawaii',
146
+	'US/Indiana-Starke',
147
+	'US/Michigan',
148
+	'US/Mountain',
149
+	'US/Pacific',
150
+	'US/Samoa',
151
+	'WET',
152 152
 ];
Please login to merge, or discard this patch.
htdocs/includes/sabre/sabre/vobject/lib/PHPUnitAssertions.php 1 patch
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -14,62 +14,62 @@
 block discarded – undo
14 14
  */
15 15
 trait PHPUnitAssertions
16 16
 {
17
-    /**
18
-     * This method tests whether two vcards or icalendar objects are
19
-     * semantically identical.
20
-     *
21
-     * It supports objects being supplied as strings, streams or
22
-     * Sabre\VObject\Component instances.
23
-     *
24
-     * PRODID is removed from both objects as this is often changes and would
25
-     * just get in the way.
26
-     *
27
-     * CALSCALE will automatically get removed if it's set to GREGORIAN.
28
-     *
29
-     * Any property that has the value **ANY** will be treated as a wildcard.
30
-     *
31
-     * @param resource|string|Component $expected
32
-     * @param resource|string|Component $actual
33
-     * @param string                    $message
34
-     */
35
-    public function assertVObjectEqualsVObject($expected, $actual, $message = '')
36
-    {
37
-        $getObj = function ($input) {
38
-            if (is_resource($input)) {
39
-                $input = stream_get_contents($input);
40
-            }
41
-            if (is_string($input)) {
42
-                $input = Reader::read($input);
43
-            }
44
-            if (!$input instanceof Component) {
45
-                $this->fail('Input must be a string, stream or VObject component');
46
-            }
47
-            unset($input->PRODID);
48
-            if ($input instanceof Component\VCalendar && 'GREGORIAN' === (string) $input->CALSCALE) {
49
-                unset($input->CALSCALE);
50
-            }
17
+	/**
18
+	 * This method tests whether two vcards or icalendar objects are
19
+	 * semantically identical.
20
+	 *
21
+	 * It supports objects being supplied as strings, streams or
22
+	 * Sabre\VObject\Component instances.
23
+	 *
24
+	 * PRODID is removed from both objects as this is often changes and would
25
+	 * just get in the way.
26
+	 *
27
+	 * CALSCALE will automatically get removed if it's set to GREGORIAN.
28
+	 *
29
+	 * Any property that has the value **ANY** will be treated as a wildcard.
30
+	 *
31
+	 * @param resource|string|Component $expected
32
+	 * @param resource|string|Component $actual
33
+	 * @param string                    $message
34
+	 */
35
+	public function assertVObjectEqualsVObject($expected, $actual, $message = '')
36
+	{
37
+		$getObj = function ($input) {
38
+			if (is_resource($input)) {
39
+				$input = stream_get_contents($input);
40
+			}
41
+			if (is_string($input)) {
42
+				$input = Reader::read($input);
43
+			}
44
+			if (!$input instanceof Component) {
45
+				$this->fail('Input must be a string, stream or VObject component');
46
+			}
47
+			unset($input->PRODID);
48
+			if ($input instanceof Component\VCalendar && 'GREGORIAN' === (string) $input->CALSCALE) {
49
+				unset($input->CALSCALE);
50
+			}
51 51
 
52
-            return $input;
53
-        };
52
+			return $input;
53
+		};
54 54
 
55
-        $expected = $getObj($expected)->serialize();
56
-        $actual = $getObj($actual)->serialize();
55
+		$expected = $getObj($expected)->serialize();
56
+		$actual = $getObj($actual)->serialize();
57 57
 
58
-        // Finding wildcards in expected.
59
-        preg_match_all('|^([A-Z]+):\\*\\*ANY\\*\\*\r$|m', $expected, $matches, PREG_SET_ORDER);
58
+		// Finding wildcards in expected.
59
+		preg_match_all('|^([A-Z]+):\\*\\*ANY\\*\\*\r$|m', $expected, $matches, PREG_SET_ORDER);
60 60
 
61
-        foreach ($matches as $match) {
62
-            $actual = preg_replace(
63
-                '|^'.preg_quote($match[1], '|').':(.*)\r$|m',
64
-                $match[1].':**ANY**'."\r",
65
-                $actual
66
-            );
67
-        }
61
+		foreach ($matches as $match) {
62
+			$actual = preg_replace(
63
+				'|^'.preg_quote($match[1], '|').':(.*)\r$|m',
64
+				$match[1].':**ANY**'."\r",
65
+				$actual
66
+			);
67
+		}
68 68
 
69
-        $this->assertEquals(
70
-            $expected,
71
-            $actual,
72
-            $message
73
-        );
74
-    }
69
+		$this->assertEquals(
70
+			$expected,
71
+			$actual,
72
+			$message
73
+		);
74
+	}
75 75
 }
Please login to merge, or discard this patch.
htdocs/includes/sabre/sabre/vobject/lib/Splitter/VCard.php 1 patch
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -21,54 +21,54 @@
 block discarded – undo
21 21
  */
22 22
 class VCard implements SplitterInterface
23 23
 {
24
-    /**
25
-     * File handle.
26
-     *
27
-     * @var resource
28
-     */
29
-    protected $input;
24
+	/**
25
+	 * File handle.
26
+	 *
27
+	 * @var resource
28
+	 */
29
+	protected $input;
30 30
 
31
-    /**
32
-     * Persistent parser.
33
-     *
34
-     * @var MimeDir
35
-     */
36
-    protected $parser;
31
+	/**
32
+	 * Persistent parser.
33
+	 *
34
+	 * @var MimeDir
35
+	 */
36
+	protected $parser;
37 37
 
38
-    /**
39
-     * Constructor.
40
-     *
41
-     * The splitter should receive an readable file stream as its input.
42
-     *
43
-     * @param resource $input
44
-     * @param int      $options parser options, see the OPTIONS constants
45
-     */
46
-    public function __construct($input, $options = 0)
47
-    {
48
-        $this->input = $input;
49
-        $this->parser = new MimeDir($input, $options);
50
-    }
38
+	/**
39
+	 * Constructor.
40
+	 *
41
+	 * The splitter should receive an readable file stream as its input.
42
+	 *
43
+	 * @param resource $input
44
+	 * @param int      $options parser options, see the OPTIONS constants
45
+	 */
46
+	public function __construct($input, $options = 0)
47
+	{
48
+		$this->input = $input;
49
+		$this->parser = new MimeDir($input, $options);
50
+	}
51 51
 
52
-    /**
53
-     * Every time getNext() is called, a new object will be parsed, until we
54
-     * hit the end of the stream.
55
-     *
56
-     * When the end is reached, null will be returned.
57
-     *
58
-     * @return \Sabre\VObject\Component|null
59
-     */
60
-    public function getNext()
61
-    {
62
-        try {
63
-            $object = $this->parser->parse();
52
+	/**
53
+	 * Every time getNext() is called, a new object will be parsed, until we
54
+	 * hit the end of the stream.
55
+	 *
56
+	 * When the end is reached, null will be returned.
57
+	 *
58
+	 * @return \Sabre\VObject\Component|null
59
+	 */
60
+	public function getNext()
61
+	{
62
+		try {
63
+			$object = $this->parser->parse();
64 64
 
65
-            if (!$object instanceof VObject\Component\VCard) {
66
-                throw new VObject\ParseException('The supplied input contained non-VCARD data.');
67
-            }
68
-        } catch (VObject\EofException $e) {
69
-            return;
70
-        }
65
+			if (!$object instanceof VObject\Component\VCard) {
66
+				throw new VObject\ParseException('The supplied input contained non-VCARD data.');
67
+			}
68
+		} catch (VObject\EofException $e) {
69
+			return;
70
+		}
71 71
 
72
-        return $object;
73
-    }
72
+		return $object;
73
+	}
74 74
 }
Please login to merge, or discard this patch.
htdocs/includes/sabre/sabre/vobject/lib/Splitter/ICalendar.php 1 patch
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -21,86 +21,86 @@
 block discarded – undo
21 21
  */
22 22
 class ICalendar implements SplitterInterface
23 23
 {
24
-    /**
25
-     * Timezones.
26
-     *
27
-     * @var array
28
-     */
29
-    protected $vtimezones = [];
24
+	/**
25
+	 * Timezones.
26
+	 *
27
+	 * @var array
28
+	 */
29
+	protected $vtimezones = [];
30 30
 
31
-    /**
32
-     * iCalendar objects.
33
-     *
34
-     * @var array
35
-     */
36
-    protected $objects = [];
31
+	/**
32
+	 * iCalendar objects.
33
+	 *
34
+	 * @var array
35
+	 */
36
+	protected $objects = [];
37 37
 
38
-    /**
39
-     * Constructor.
40
-     *
41
-     * The splitter should receive an readable file stream as its input.
42
-     *
43
-     * @param resource $input
44
-     * @param int      $options parser options, see the OPTIONS constants
45
-     */
46
-    public function __construct($input, $options = 0)
47
-    {
48
-        $data = VObject\Reader::read($input, $options);
38
+	/**
39
+	 * Constructor.
40
+	 *
41
+	 * The splitter should receive an readable file stream as its input.
42
+	 *
43
+	 * @param resource $input
44
+	 * @param int      $options parser options, see the OPTIONS constants
45
+	 */
46
+	public function __construct($input, $options = 0)
47
+	{
48
+		$data = VObject\Reader::read($input, $options);
49 49
 
50
-        if (!$data instanceof VObject\Component\VCalendar) {
51
-            throw new VObject\ParseException('Supplied input could not be parsed as VCALENDAR.');
52
-        }
50
+		if (!$data instanceof VObject\Component\VCalendar) {
51
+			throw new VObject\ParseException('Supplied input could not be parsed as VCALENDAR.');
52
+		}
53 53
 
54
-        foreach ($data->children() as $component) {
55
-            if (!$component instanceof VObject\Component) {
56
-                continue;
57
-            }
54
+		foreach ($data->children() as $component) {
55
+			if (!$component instanceof VObject\Component) {
56
+				continue;
57
+			}
58 58
 
59
-            // Get all timezones
60
-            if ('VTIMEZONE' === $component->name) {
61
-                $this->vtimezones[(string) $component->TZID] = $component;
62
-                continue;
63
-            }
59
+			// Get all timezones
60
+			if ('VTIMEZONE' === $component->name) {
61
+				$this->vtimezones[(string) $component->TZID] = $component;
62
+				continue;
63
+			}
64 64
 
65
-            // Get component UID for recurring Events search
66
-            if (!$component->UID) {
67
-                $component->UID = sha1(microtime()).'-vobjectimport';
68
-            }
69
-            $uid = (string) $component->UID;
65
+			// Get component UID for recurring Events search
66
+			if (!$component->UID) {
67
+				$component->UID = sha1(microtime()).'-vobjectimport';
68
+			}
69
+			$uid = (string) $component->UID;
70 70
 
71
-            // Take care of recurring events
72
-            if (!array_key_exists($uid, $this->objects)) {
73
-                $this->objects[$uid] = new VCalendar();
74
-            }
71
+			// Take care of recurring events
72
+			if (!array_key_exists($uid, $this->objects)) {
73
+				$this->objects[$uid] = new VCalendar();
74
+			}
75 75
 
76
-            $this->objects[$uid]->add(clone $component);
77
-        }
78
-    }
76
+			$this->objects[$uid]->add(clone $component);
77
+		}
78
+	}
79 79
 
80
-    /**
81
-     * Every time getNext() is called, a new object will be parsed, until we
82
-     * hit the end of the stream.
83
-     *
84
-     * When the end is reached, null will be returned.
85
-     *
86
-     * @return \Sabre\VObject\Component|null
87
-     */
88
-    public function getNext()
89
-    {
90
-        if ($object = array_shift($this->objects)) {
91
-            // create our baseobject
92
-            $object->version = '2.0';
93
-            $object->prodid = '-//Sabre//Sabre VObject '.VObject\Version::VERSION.'//EN';
94
-            $object->calscale = 'GREGORIAN';
80
+	/**
81
+	 * Every time getNext() is called, a new object will be parsed, until we
82
+	 * hit the end of the stream.
83
+	 *
84
+	 * When the end is reached, null will be returned.
85
+	 *
86
+	 * @return \Sabre\VObject\Component|null
87
+	 */
88
+	public function getNext()
89
+	{
90
+		if ($object = array_shift($this->objects)) {
91
+			// create our baseobject
92
+			$object->version = '2.0';
93
+			$object->prodid = '-//Sabre//Sabre VObject '.VObject\Version::VERSION.'//EN';
94
+			$object->calscale = 'GREGORIAN';
95 95
 
96
-            // add vtimezone information to obj (if we have it)
97
-            foreach ($this->vtimezones as $vtimezone) {
98
-                $object->add($vtimezone);
99
-            }
96
+			// add vtimezone information to obj (if we have it)
97
+			foreach ($this->vtimezones as $vtimezone) {
98
+				$object->add($vtimezone);
99
+			}
100 100
 
101
-            return $object;
102
-        } else {
103
-            return;
104
-        }
105
-    }
101
+			return $object;
102
+		} else {
103
+			return;
104
+		}
105
+	}
106 106
 }
Please login to merge, or discard this patch.
htdocs/includes/sabre/sabre/vobject/lib/Splitter/SplitterInterface.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -17,22 +17,22 @@
 block discarded – undo
17 17
  */
18 18
 interface SplitterInterface
19 19
 {
20
-    /**
21
-     * Constructor.
22
-     *
23
-     * The splitter should receive an readable file stream as its input.
24
-     *
25
-     * @param resource $input
26
-     */
27
-    public function __construct($input);
20
+	/**
21
+	 * Constructor.
22
+	 *
23
+	 * The splitter should receive an readable file stream as its input.
24
+	 *
25
+	 * @param resource $input
26
+	 */
27
+	public function __construct($input);
28 28
 
29
-    /**
30
-     * Every time getNext() is called, a new object will be parsed, until we
31
-     * hit the end of the stream.
32
-     *
33
-     * When the end is reached, null will be returned.
34
-     *
35
-     * @return \Sabre\VObject\Component|null
36
-     */
37
-    public function getNext();
29
+	/**
30
+	 * Every time getNext() is called, a new object will be parsed, until we
31
+	 * hit the end of the stream.
32
+	 *
33
+	 * When the end is reached, null will be returned.
34
+	 *
35
+	 * @return \Sabre\VObject\Component|null
36
+	 */
37
+	public function getNext();
38 38
 }
Please login to merge, or discard this patch.
htdocs/includes/sabre/sabre/vobject/lib/FreeBusyData.php 1 patch
Indentation   +171 added lines, -171 removed lines patch added patch discarded remove patch
@@ -11,175 +11,175 @@
 block discarded – undo
11 11
  */
12 12
 class FreeBusyData
13 13
 {
14
-    /**
15
-     * Start timestamp.
16
-     *
17
-     * @var int
18
-     */
19
-    protected $start;
20
-
21
-    /**
22
-     * End timestamp.
23
-     *
24
-     * @var int
25
-     */
26
-    protected $end;
27
-
28
-    /**
29
-     * A list of free-busy times.
30
-     *
31
-     * @var array
32
-     */
33
-    protected $data;
34
-
35
-    public function __construct($start, $end)
36
-    {
37
-        $this->start = $start;
38
-        $this->end = $end;
39
-        $this->data = [];
40
-
41
-        $this->data[] = [
42
-            'start' => $this->start,
43
-            'end' => $this->end,
44
-            'type' => 'FREE',
45
-        ];
46
-    }
47
-
48
-    /**
49
-     * Adds free or busytime to the data.
50
-     *
51
-     * @param int    $start
52
-     * @param int    $end
53
-     * @param string $type  FREE, BUSY, BUSY-UNAVAILABLE or BUSY-TENTATIVE
54
-     */
55
-    public function add($start, $end, $type)
56
-    {
57
-        if ($start > $this->end || $end < $this->start) {
58
-            // This new data is outside our timerange.
59
-            return;
60
-        }
61
-
62
-        if ($start < $this->start) {
63
-            // The item starts before our requested time range
64
-            $start = $this->start;
65
-        }
66
-        if ($end > $this->end) {
67
-            // The item ends after our requested time range
68
-            $end = $this->end;
69
-        }
70
-
71
-        // Finding out where we need to insert the new item.
72
-        $currentIndex = 0;
73
-        while ($start > $this->data[$currentIndex]['end']) {
74
-            ++$currentIndex;
75
-        }
76
-
77
-        // The standard insertion point will be one _after_ the first
78
-        // overlapping item.
79
-        $insertStartIndex = $currentIndex + 1;
80
-
81
-        $newItem = [
82
-            'start' => $start,
83
-            'end' => $end,
84
-            'type' => $type,
85
-        ];
86
-
87
-        $precedingItem = $this->data[$insertStartIndex - 1];
88
-        if ($this->data[$insertStartIndex - 1]['start'] === $start) {
89
-            // The old item starts at the exact same point as the new item.
90
-            --$insertStartIndex;
91
-        }
92
-
93
-        // Now we know where to insert the item, we need to know where it
94
-        // starts overlapping with items on the tail end. We need to start
95
-        // looking one item before the insertStartIndex, because it's possible
96
-        // that the new item 'sits inside' the previous old item.
97
-        if ($insertStartIndex > 0) {
98
-            $currentIndex = $insertStartIndex - 1;
99
-        } else {
100
-            $currentIndex = 0;
101
-        }
102
-
103
-        while ($end > $this->data[$currentIndex]['end']) {
104
-            ++$currentIndex;
105
-        }
106
-
107
-        // What we are about to insert into the array
108
-        $newItems = [
109
-            $newItem,
110
-        ];
111
-
112
-        // This is the amount of items that are completely overwritten by the
113
-        // new item.
114
-        $itemsToDelete = $currentIndex - $insertStartIndex;
115
-        if ($this->data[$currentIndex]['end'] <= $end) {
116
-            ++$itemsToDelete;
117
-        }
118
-
119
-        // If itemsToDelete was -1, it means that the newly inserted item is
120
-        // actually sitting inside an existing one. This means we need to split
121
-        // the item at the current position in two and insert the new item in
122
-        // between.
123
-        if (-1 === $itemsToDelete) {
124
-            $itemsToDelete = 0;
125
-            if ($newItem['end'] < $precedingItem['end']) {
126
-                $newItems[] = [
127
-                    'start' => $newItem['end'] + 1,
128
-                    'end' => $precedingItem['end'],
129
-                    'type' => $precedingItem['type'],
130
-                ];
131
-            }
132
-        }
133
-
134
-        array_splice(
135
-            $this->data,
136
-            $insertStartIndex,
137
-            $itemsToDelete,
138
-            $newItems
139
-        );
140
-
141
-        $doMerge = false;
142
-        $mergeOffset = $insertStartIndex;
143
-        $mergeItem = $newItem;
144
-        $mergeDelete = 1;
145
-
146
-        if (isset($this->data[$insertStartIndex - 1])) {
147
-            // Updating the start time of the previous item.
148
-            $this->data[$insertStartIndex - 1]['end'] = $start;
149
-
150
-            // If the previous and the current are of the same type, we can
151
-            // merge them into one item.
152
-            if ($this->data[$insertStartIndex - 1]['type'] === $this->data[$insertStartIndex]['type']) {
153
-                $doMerge = true;
154
-                --$mergeOffset;
155
-                ++$mergeDelete;
156
-                $mergeItem['start'] = $this->data[$insertStartIndex - 1]['start'];
157
-            }
158
-        }
159
-        if (isset($this->data[$insertStartIndex + 1])) {
160
-            // Updating the start time of the next item.
161
-            $this->data[$insertStartIndex + 1]['start'] = $end;
162
-
163
-            // If the next and the current are of the same type, we can
164
-            // merge them into one item.
165
-            if ($this->data[$insertStartIndex + 1]['type'] === $this->data[$insertStartIndex]['type']) {
166
-                $doMerge = true;
167
-                ++$mergeDelete;
168
-                $mergeItem['end'] = $this->data[$insertStartIndex + 1]['end'];
169
-            }
170
-        }
171
-        if ($doMerge) {
172
-            array_splice(
173
-                $this->data,
174
-                $mergeOffset,
175
-                $mergeDelete,
176
-                [$mergeItem]
177
-            );
178
-        }
179
-    }
180
-
181
-    public function getData()
182
-    {
183
-        return $this->data;
184
-    }
14
+	/**
15
+	 * Start timestamp.
16
+	 *
17
+	 * @var int
18
+	 */
19
+	protected $start;
20
+
21
+	/**
22
+	 * End timestamp.
23
+	 *
24
+	 * @var int
25
+	 */
26
+	protected $end;
27
+
28
+	/**
29
+	 * A list of free-busy times.
30
+	 *
31
+	 * @var array
32
+	 */
33
+	protected $data;
34
+
35
+	public function __construct($start, $end)
36
+	{
37
+		$this->start = $start;
38
+		$this->end = $end;
39
+		$this->data = [];
40
+
41
+		$this->data[] = [
42
+			'start' => $this->start,
43
+			'end' => $this->end,
44
+			'type' => 'FREE',
45
+		];
46
+	}
47
+
48
+	/**
49
+	 * Adds free or busytime to the data.
50
+	 *
51
+	 * @param int    $start
52
+	 * @param int    $end
53
+	 * @param string $type  FREE, BUSY, BUSY-UNAVAILABLE or BUSY-TENTATIVE
54
+	 */
55
+	public function add($start, $end, $type)
56
+	{
57
+		if ($start > $this->end || $end < $this->start) {
58
+			// This new data is outside our timerange.
59
+			return;
60
+		}
61
+
62
+		if ($start < $this->start) {
63
+			// The item starts before our requested time range
64
+			$start = $this->start;
65
+		}
66
+		if ($end > $this->end) {
67
+			// The item ends after our requested time range
68
+			$end = $this->end;
69
+		}
70
+
71
+		// Finding out where we need to insert the new item.
72
+		$currentIndex = 0;
73
+		while ($start > $this->data[$currentIndex]['end']) {
74
+			++$currentIndex;
75
+		}
76
+
77
+		// The standard insertion point will be one _after_ the first
78
+		// overlapping item.
79
+		$insertStartIndex = $currentIndex + 1;
80
+
81
+		$newItem = [
82
+			'start' => $start,
83
+			'end' => $end,
84
+			'type' => $type,
85
+		];
86
+
87
+		$precedingItem = $this->data[$insertStartIndex - 1];
88
+		if ($this->data[$insertStartIndex - 1]['start'] === $start) {
89
+			// The old item starts at the exact same point as the new item.
90
+			--$insertStartIndex;
91
+		}
92
+
93
+		// Now we know where to insert the item, we need to know where it
94
+		// starts overlapping with items on the tail end. We need to start
95
+		// looking one item before the insertStartIndex, because it's possible
96
+		// that the new item 'sits inside' the previous old item.
97
+		if ($insertStartIndex > 0) {
98
+			$currentIndex = $insertStartIndex - 1;
99
+		} else {
100
+			$currentIndex = 0;
101
+		}
102
+
103
+		while ($end > $this->data[$currentIndex]['end']) {
104
+			++$currentIndex;
105
+		}
106
+
107
+		// What we are about to insert into the array
108
+		$newItems = [
109
+			$newItem,
110
+		];
111
+
112
+		// This is the amount of items that are completely overwritten by the
113
+		// new item.
114
+		$itemsToDelete = $currentIndex - $insertStartIndex;
115
+		if ($this->data[$currentIndex]['end'] <= $end) {
116
+			++$itemsToDelete;
117
+		}
118
+
119
+		// If itemsToDelete was -1, it means that the newly inserted item is
120
+		// actually sitting inside an existing one. This means we need to split
121
+		// the item at the current position in two and insert the new item in
122
+		// between.
123
+		if (-1 === $itemsToDelete) {
124
+			$itemsToDelete = 0;
125
+			if ($newItem['end'] < $precedingItem['end']) {
126
+				$newItems[] = [
127
+					'start' => $newItem['end'] + 1,
128
+					'end' => $precedingItem['end'],
129
+					'type' => $precedingItem['type'],
130
+				];
131
+			}
132
+		}
133
+
134
+		array_splice(
135
+			$this->data,
136
+			$insertStartIndex,
137
+			$itemsToDelete,
138
+			$newItems
139
+		);
140
+
141
+		$doMerge = false;
142
+		$mergeOffset = $insertStartIndex;
143
+		$mergeItem = $newItem;
144
+		$mergeDelete = 1;
145
+
146
+		if (isset($this->data[$insertStartIndex - 1])) {
147
+			// Updating the start time of the previous item.
148
+			$this->data[$insertStartIndex - 1]['end'] = $start;
149
+
150
+			// If the previous and the current are of the same type, we can
151
+			// merge them into one item.
152
+			if ($this->data[$insertStartIndex - 1]['type'] === $this->data[$insertStartIndex]['type']) {
153
+				$doMerge = true;
154
+				--$mergeOffset;
155
+				++$mergeDelete;
156
+				$mergeItem['start'] = $this->data[$insertStartIndex - 1]['start'];
157
+			}
158
+		}
159
+		if (isset($this->data[$insertStartIndex + 1])) {
160
+			// Updating the start time of the next item.
161
+			$this->data[$insertStartIndex + 1]['start'] = $end;
162
+
163
+			// If the next and the current are of the same type, we can
164
+			// merge them into one item.
165
+			if ($this->data[$insertStartIndex + 1]['type'] === $this->data[$insertStartIndex]['type']) {
166
+				$doMerge = true;
167
+				++$mergeDelete;
168
+				$mergeItem['end'] = $this->data[$insertStartIndex + 1]['end'];
169
+			}
170
+		}
171
+		if ($doMerge) {
172
+			array_splice(
173
+				$this->data,
174
+				$mergeOffset,
175
+				$mergeDelete,
176
+				[$mergeItem]
177
+			);
178
+		}
179
+	}
180
+
181
+	public function getData()
182
+	{
183
+		return $this->data;
184
+	}
185 185
 }
Please login to merge, or discard this patch.
htdocs/includes/sabre/sabre/vobject/lib/Cli.php 1 patch
Indentation   +683 added lines, -683 removed lines patch added patch discarded remove patch
@@ -13,693 +13,693 @@
 block discarded – undo
13 13
  */
14 14
 class Cli
15 15
 {
16
-    /**
17
-     * No output.
18
-     *
19
-     * @var bool
20
-     */
21
-    protected $quiet = false;
22
-
23
-    /**
24
-     * Help display.
25
-     *
26
-     * @var bool
27
-     */
28
-    protected $showHelp = false;
29
-
30
-    /**
31
-     * Whether to spit out 'mimedir' or 'json' format.
32
-     *
33
-     * @var string
34
-     */
35
-    protected $format;
36
-
37
-    /**
38
-     * JSON pretty print.
39
-     *
40
-     * @var bool
41
-     */
42
-    protected $pretty;
43
-
44
-    /**
45
-     * Source file.
46
-     *
47
-     * @var string
48
-     */
49
-    protected $inputPath;
50
-
51
-    /**
52
-     * Destination file.
53
-     *
54
-     * @var string
55
-     */
56
-    protected $outputPath;
57
-
58
-    /**
59
-     * output stream.
60
-     *
61
-     * @var resource
62
-     */
63
-    protected $stdout;
64
-
65
-    /**
66
-     * stdin.
67
-     *
68
-     * @var resource
69
-     */
70
-    protected $stdin;
71
-
72
-    /**
73
-     * stderr.
74
-     *
75
-     * @var resource
76
-     */
77
-    protected $stderr;
78
-
79
-    /**
80
-     * Input format (one of json or mimedir).
81
-     *
82
-     * @var string
83
-     */
84
-    protected $inputFormat;
85
-
86
-    /**
87
-     * Makes the parser less strict.
88
-     *
89
-     * @var bool
90
-     */
91
-    protected $forgiving = false;
92
-
93
-    /**
94
-     * Main function.
95
-     *
96
-     * @return int
97
-     */
98
-    public function main(array $argv)
99
-    {
100
-        // @codeCoverageIgnoreStart
101
-        // We cannot easily test this, so we'll skip it. Pretty basic anyway.
102
-
103
-        if (!$this->stderr) {
104
-            $this->stderr = fopen('php://stderr', 'w');
105
-        }
106
-        if (!$this->stdout) {
107
-            $this->stdout = fopen('php://stdout', 'w');
108
-        }
109
-        if (!$this->stdin) {
110
-            $this->stdin = fopen('php://stdin', 'r');
111
-        }
112
-
113
-        // @codeCoverageIgnoreEnd
114
-
115
-        try {
116
-            list($options, $positional) = $this->parseArguments($argv);
117
-
118
-            if (isset($options['q'])) {
119
-                $this->quiet = true;
120
-            }
121
-            $this->log($this->colorize('green', 'sabre/vobject ').$this->colorize('yellow', Version::VERSION));
122
-
123
-            foreach ($options as $name => $value) {
124
-                switch ($name) {
125
-                    case 'q':
126
-                        // Already handled earlier.
127
-                        break;
128
-                    case 'h':
129
-                    case 'help':
130
-                        $this->showHelp();
131
-
132
-                        return 0;
133
-                        break;
134
-                    case 'format':
135
-                        switch ($value) {
136
-                            // jcard/jcal documents
137
-                            case 'jcard':
138
-                            case 'jcal':
139
-                            // specific document versions
140
-                            case 'vcard21':
141
-                            case 'vcard30':
142
-                            case 'vcard40':
143
-                            case 'icalendar20':
144
-                            // specific formats
145
-                            case 'json':
146
-                            case 'mimedir':
147
-                            // icalendar/vcad
148
-                            case 'icalendar':
149
-                            case 'vcard':
150
-                                $this->format = $value;
151
-                                break;
152
-
153
-                            default:
154
-                                throw new InvalidArgumentException('Unknown format: '.$value);
155
-                        }
156
-                        break;
157
-                    case 'pretty':
158
-                        if (version_compare(PHP_VERSION, '5.4.0') >= 0) {
159
-                            $this->pretty = true;
160
-                        }
161
-                        break;
162
-                    case 'forgiving':
163
-                        $this->forgiving = true;
164
-                        break;
165
-                    case 'inputformat':
166
-                        switch ($value) {
167
-                            // json formats
168
-                            case 'jcard':
169
-                            case 'jcal':
170
-                            case 'json':
171
-                                $this->inputFormat = 'json';
172
-                                break;
173
-
174
-                            // mimedir formats
175
-                            case 'mimedir':
176
-                            case 'icalendar':
177
-                            case 'vcard':
178
-                            case 'vcard21':
179
-                            case 'vcard30':
180
-                            case 'vcard40':
181
-                            case 'icalendar20':
182
-                                $this->inputFormat = 'mimedir';
183
-                                break;
184
-
185
-                            default:
186
-                                throw new InvalidArgumentException('Unknown format: '.$value);
187
-                        }
188
-                        break;
189
-                    default:
190
-                        throw new InvalidArgumentException('Unknown option: '.$name);
191
-                }
192
-            }
193
-
194
-            if (0 === count($positional)) {
195
-                $this->showHelp();
196
-
197
-                return 1;
198
-            }
199
-
200
-            if (1 === count($positional)) {
201
-                throw new InvalidArgumentException('Inputfile is a required argument');
202
-            }
203
-
204
-            if (count($positional) > 3) {
205
-                throw new InvalidArgumentException('Too many arguments');
206
-            }
207
-
208
-            if (!in_array($positional[0], ['validate', 'repair', 'convert', 'color'])) {
209
-                throw new InvalidArgumentException('Unknown command: '.$positional[0]);
210
-            }
211
-        } catch (InvalidArgumentException $e) {
212
-            $this->showHelp();
213
-            $this->log('Error: '.$e->getMessage(), 'red');
214
-
215
-            return 1;
216
-        }
217
-
218
-        $command = $positional[0];
219
-
220
-        $this->inputPath = $positional[1];
221
-        $this->outputPath = isset($positional[2]) ? $positional[2] : '-';
222
-
223
-        if ('-' !== $this->outputPath) {
224
-            $this->stdout = fopen($this->outputPath, 'w');
225
-        }
226
-
227
-        if (!$this->inputFormat) {
228
-            if ('.json' === substr($this->inputPath, -5)) {
229
-                $this->inputFormat = 'json';
230
-            } else {
231
-                $this->inputFormat = 'mimedir';
232
-            }
233
-        }
234
-        if (!$this->format) {
235
-            if ('.json' === substr($this->outputPath, -5)) {
236
-                $this->format = 'json';
237
-            } else {
238
-                $this->format = 'mimedir';
239
-            }
240
-        }
241
-
242
-        $realCode = 0;
243
-
244
-        try {
245
-            while ($input = $this->readInput()) {
246
-                $returnCode = $this->$command($input);
247
-                if (0 !== $returnCode) {
248
-                    $realCode = $returnCode;
249
-                }
250
-            }
251
-        } catch (EofException $e) {
252
-            // end of file
253
-        } catch (\Exception $e) {
254
-            $this->log('Error: '.$e->getMessage(), 'red');
255
-
256
-            return 2;
257
-        }
258
-
259
-        return $realCode;
260
-    }
261
-
262
-    /**
263
-     * Shows the help message.
264
-     */
265
-    protected function showHelp()
266
-    {
267
-        $this->log('Usage:', 'yellow');
268
-        $this->log('  vobject [options] command [arguments]');
269
-        $this->log('');
270
-        $this->log('Options:', 'yellow');
271
-        $this->log($this->colorize('green', '  -q            ')."Don't output anything.");
272
-        $this->log($this->colorize('green', '  -help -h      ').'Display this help message.');
273
-        $this->log($this->colorize('green', '  --format      ').'Convert to a specific format. Must be one of: vcard, vcard21,');
274
-        $this->log($this->colorize('green', '  --forgiving   ').'Makes the parser less strict.');
275
-        $this->log('                vcard30, vcard40, icalendar20, jcal, jcard, json, mimedir.');
276
-        $this->log($this->colorize('green', '  --inputformat ').'If the input format cannot be guessed from the extension, it');
277
-        $this->log('                must be specified here.');
278
-        // Only PHP 5.4 and up
279
-        if (version_compare(PHP_VERSION, '5.4.0') >= 0) {
280
-            $this->log($this->colorize('green', '  --pretty      ').'json pretty-print.');
281
-        }
282
-        $this->log('');
283
-        $this->log('Commands:', 'yellow');
284
-        $this->log($this->colorize('green', '  validate').' source_file              Validates a file for correctness.');
285
-        $this->log($this->colorize('green', '  repair').' source_file [output_file]  Repairs a file.');
286
-        $this->log($this->colorize('green', '  convert').' source_file [output_file] Converts a file.');
287
-        $this->log($this->colorize('green', '  color').' source_file                 Colorize a file, useful for debugging.');
288
-        $this->log(
289
-        <<<HELP
16
+	/**
17
+	 * No output.
18
+	 *
19
+	 * @var bool
20
+	 */
21
+	protected $quiet = false;
22
+
23
+	/**
24
+	 * Help display.
25
+	 *
26
+	 * @var bool
27
+	 */
28
+	protected $showHelp = false;
29
+
30
+	/**
31
+	 * Whether to spit out 'mimedir' or 'json' format.
32
+	 *
33
+	 * @var string
34
+	 */
35
+	protected $format;
36
+
37
+	/**
38
+	 * JSON pretty print.
39
+	 *
40
+	 * @var bool
41
+	 */
42
+	protected $pretty;
43
+
44
+	/**
45
+	 * Source file.
46
+	 *
47
+	 * @var string
48
+	 */
49
+	protected $inputPath;
50
+
51
+	/**
52
+	 * Destination file.
53
+	 *
54
+	 * @var string
55
+	 */
56
+	protected $outputPath;
57
+
58
+	/**
59
+	 * output stream.
60
+	 *
61
+	 * @var resource
62
+	 */
63
+	protected $stdout;
64
+
65
+	/**
66
+	 * stdin.
67
+	 *
68
+	 * @var resource
69
+	 */
70
+	protected $stdin;
71
+
72
+	/**
73
+	 * stderr.
74
+	 *
75
+	 * @var resource
76
+	 */
77
+	protected $stderr;
78
+
79
+	/**
80
+	 * Input format (one of json or mimedir).
81
+	 *
82
+	 * @var string
83
+	 */
84
+	protected $inputFormat;
85
+
86
+	/**
87
+	 * Makes the parser less strict.
88
+	 *
89
+	 * @var bool
90
+	 */
91
+	protected $forgiving = false;
92
+
93
+	/**
94
+	 * Main function.
95
+	 *
96
+	 * @return int
97
+	 */
98
+	public function main(array $argv)
99
+	{
100
+		// @codeCoverageIgnoreStart
101
+		// We cannot easily test this, so we'll skip it. Pretty basic anyway.
102
+
103
+		if (!$this->stderr) {
104
+			$this->stderr = fopen('php://stderr', 'w');
105
+		}
106
+		if (!$this->stdout) {
107
+			$this->stdout = fopen('php://stdout', 'w');
108
+		}
109
+		if (!$this->stdin) {
110
+			$this->stdin = fopen('php://stdin', 'r');
111
+		}
112
+
113
+		// @codeCoverageIgnoreEnd
114
+
115
+		try {
116
+			list($options, $positional) = $this->parseArguments($argv);
117
+
118
+			if (isset($options['q'])) {
119
+				$this->quiet = true;
120
+			}
121
+			$this->log($this->colorize('green', 'sabre/vobject ').$this->colorize('yellow', Version::VERSION));
122
+
123
+			foreach ($options as $name => $value) {
124
+				switch ($name) {
125
+					case 'q':
126
+						// Already handled earlier.
127
+						break;
128
+					case 'h':
129
+					case 'help':
130
+						$this->showHelp();
131
+
132
+						return 0;
133
+						break;
134
+					case 'format':
135
+						switch ($value) {
136
+							// jcard/jcal documents
137
+							case 'jcard':
138
+							case 'jcal':
139
+							// specific document versions
140
+							case 'vcard21':
141
+							case 'vcard30':
142
+							case 'vcard40':
143
+							case 'icalendar20':
144
+							// specific formats
145
+							case 'json':
146
+							case 'mimedir':
147
+							// icalendar/vcad
148
+							case 'icalendar':
149
+							case 'vcard':
150
+								$this->format = $value;
151
+								break;
152
+
153
+							default:
154
+								throw new InvalidArgumentException('Unknown format: '.$value);
155
+						}
156
+						break;
157
+					case 'pretty':
158
+						if (version_compare(PHP_VERSION, '5.4.0') >= 0) {
159
+							$this->pretty = true;
160
+						}
161
+						break;
162
+					case 'forgiving':
163
+						$this->forgiving = true;
164
+						break;
165
+					case 'inputformat':
166
+						switch ($value) {
167
+							// json formats
168
+							case 'jcard':
169
+							case 'jcal':
170
+							case 'json':
171
+								$this->inputFormat = 'json';
172
+								break;
173
+
174
+							// mimedir formats
175
+							case 'mimedir':
176
+							case 'icalendar':
177
+							case 'vcard':
178
+							case 'vcard21':
179
+							case 'vcard30':
180
+							case 'vcard40':
181
+							case 'icalendar20':
182
+								$this->inputFormat = 'mimedir';
183
+								break;
184
+
185
+							default:
186
+								throw new InvalidArgumentException('Unknown format: '.$value);
187
+						}
188
+						break;
189
+					default:
190
+						throw new InvalidArgumentException('Unknown option: '.$name);
191
+				}
192
+			}
193
+
194
+			if (0 === count($positional)) {
195
+				$this->showHelp();
196
+
197
+				return 1;
198
+			}
199
+
200
+			if (1 === count($positional)) {
201
+				throw new InvalidArgumentException('Inputfile is a required argument');
202
+			}
203
+
204
+			if (count($positional) > 3) {
205
+				throw new InvalidArgumentException('Too many arguments');
206
+			}
207
+
208
+			if (!in_array($positional[0], ['validate', 'repair', 'convert', 'color'])) {
209
+				throw new InvalidArgumentException('Unknown command: '.$positional[0]);
210
+			}
211
+		} catch (InvalidArgumentException $e) {
212
+			$this->showHelp();
213
+			$this->log('Error: '.$e->getMessage(), 'red');
214
+
215
+			return 1;
216
+		}
217
+
218
+		$command = $positional[0];
219
+
220
+		$this->inputPath = $positional[1];
221
+		$this->outputPath = isset($positional[2]) ? $positional[2] : '-';
222
+
223
+		if ('-' !== $this->outputPath) {
224
+			$this->stdout = fopen($this->outputPath, 'w');
225
+		}
226
+
227
+		if (!$this->inputFormat) {
228
+			if ('.json' === substr($this->inputPath, -5)) {
229
+				$this->inputFormat = 'json';
230
+			} else {
231
+				$this->inputFormat = 'mimedir';
232
+			}
233
+		}
234
+		if (!$this->format) {
235
+			if ('.json' === substr($this->outputPath, -5)) {
236
+				$this->format = 'json';
237
+			} else {
238
+				$this->format = 'mimedir';
239
+			}
240
+		}
241
+
242
+		$realCode = 0;
243
+
244
+		try {
245
+			while ($input = $this->readInput()) {
246
+				$returnCode = $this->$command($input);
247
+				if (0 !== $returnCode) {
248
+					$realCode = $returnCode;
249
+				}
250
+			}
251
+		} catch (EofException $e) {
252
+			// end of file
253
+		} catch (\Exception $e) {
254
+			$this->log('Error: '.$e->getMessage(), 'red');
255
+
256
+			return 2;
257
+		}
258
+
259
+		return $realCode;
260
+	}
261
+
262
+	/**
263
+	 * Shows the help message.
264
+	 */
265
+	protected function showHelp()
266
+	{
267
+		$this->log('Usage:', 'yellow');
268
+		$this->log('  vobject [options] command [arguments]');
269
+		$this->log('');
270
+		$this->log('Options:', 'yellow');
271
+		$this->log($this->colorize('green', '  -q            ')."Don't output anything.");
272
+		$this->log($this->colorize('green', '  -help -h      ').'Display this help message.');
273
+		$this->log($this->colorize('green', '  --format      ').'Convert to a specific format. Must be one of: vcard, vcard21,');
274
+		$this->log($this->colorize('green', '  --forgiving   ').'Makes the parser less strict.');
275
+		$this->log('                vcard30, vcard40, icalendar20, jcal, jcard, json, mimedir.');
276
+		$this->log($this->colorize('green', '  --inputformat ').'If the input format cannot be guessed from the extension, it');
277
+		$this->log('                must be specified here.');
278
+		// Only PHP 5.4 and up
279
+		if (version_compare(PHP_VERSION, '5.4.0') >= 0) {
280
+			$this->log($this->colorize('green', '  --pretty      ').'json pretty-print.');
281
+		}
282
+		$this->log('');
283
+		$this->log('Commands:', 'yellow');
284
+		$this->log($this->colorize('green', '  validate').' source_file              Validates a file for correctness.');
285
+		$this->log($this->colorize('green', '  repair').' source_file [output_file]  Repairs a file.');
286
+		$this->log($this->colorize('green', '  convert').' source_file [output_file] Converts a file.');
287
+		$this->log($this->colorize('green', '  color').' source_file                 Colorize a file, useful for debugging.');
288
+		$this->log(
289
+		<<<HELP
290 290
 
291 291
 If source_file is set as '-', STDIN will be used.
292 292
 If output_file is omitted, STDOUT will be used.
293 293
 All other output is sent to STDERR.
294 294
 
295 295
 HELP
296
-        );
297
-
298
-        $this->log('Examples:', 'yellow');
299
-        $this->log('   vobject convert contact.vcf contact.json');
300
-        $this->log('   vobject convert --format=vcard40 old.vcf new.vcf');
301
-        $this->log('   vobject convert --inputformat=json --format=mimedir - -');
302
-        $this->log('   vobject color calendar.ics');
303
-        $this->log('');
304
-        $this->log('https://github.com/fruux/sabre-vobject', 'purple');
305
-    }
306
-
307
-    /**
308
-     * Validates a VObject file.
309
-     *
310
-     * @return int
311
-     */
312
-    protected function validate(Component $vObj)
313
-    {
314
-        $returnCode = 0;
315
-
316
-        switch ($vObj->name) {
317
-            case 'VCALENDAR':
318
-                $this->log('iCalendar: '.(string) $vObj->VERSION);
319
-                break;
320
-            case 'VCARD':
321
-                $this->log('vCard: '.(string) $vObj->VERSION);
322
-                break;
323
-        }
324
-
325
-        $warnings = $vObj->validate();
326
-        if (!count($warnings)) {
327
-            $this->log('  No warnings!');
328
-        } else {
329
-            $levels = [
330
-                1 => 'REPAIRED',
331
-                2 => 'WARNING',
332
-                3 => 'ERROR',
333
-            ];
334
-            $returnCode = 2;
335
-            foreach ($warnings as $warn) {
336
-                $extra = '';
337
-                if ($warn['node'] instanceof Property) {
338
-                    $extra = ' (property: "'.$warn['node']->name.'")';
339
-                }
340
-                $this->log('  ['.$levels[$warn['level']].'] '.$warn['message'].$extra);
341
-            }
342
-        }
343
-
344
-        return $returnCode;
345
-    }
346
-
347
-    /**
348
-     * Repairs a VObject file.
349
-     *
350
-     * @return int
351
-     */
352
-    protected function repair(Component $vObj)
353
-    {
354
-        $returnCode = 0;
355
-
356
-        switch ($vObj->name) {
357
-            case 'VCALENDAR':
358
-                $this->log('iCalendar: '.(string) $vObj->VERSION);
359
-                break;
360
-            case 'VCARD':
361
-                $this->log('vCard: '.(string) $vObj->VERSION);
362
-                break;
363
-        }
364
-
365
-        $warnings = $vObj->validate(Node::REPAIR);
366
-        if (!count($warnings)) {
367
-            $this->log('  No warnings!');
368
-        } else {
369
-            $levels = [
370
-                1 => 'REPAIRED',
371
-                2 => 'WARNING',
372
-                3 => 'ERROR',
373
-            ];
374
-            $returnCode = 2;
375
-            foreach ($warnings as $warn) {
376
-                $extra = '';
377
-                if ($warn['node'] instanceof Property) {
378
-                    $extra = ' (property: "'.$warn['node']->name.'")';
379
-                }
380
-                $this->log('  ['.$levels[$warn['level']].'] '.$warn['message'].$extra);
381
-            }
382
-        }
383
-        fwrite($this->stdout, $vObj->serialize());
384
-
385
-        return $returnCode;
386
-    }
387
-
388
-    /**
389
-     * Converts a vObject file to a new format.
390
-     *
391
-     * @param Component $vObj
392
-     *
393
-     * @return int
394
-     */
395
-    protected function convert($vObj)
396
-    {
397
-        $json = false;
398
-        $convertVersion = null;
399
-        $forceInput = null;
400
-
401
-        switch ($this->format) {
402
-            case 'json':
403
-                $json = true;
404
-                if ('VCARD' === $vObj->name) {
405
-                    $convertVersion = Document::VCARD40;
406
-                }
407
-                break;
408
-            case 'jcard':
409
-                $json = true;
410
-                $forceInput = 'VCARD';
411
-                $convertVersion = Document::VCARD40;
412
-                break;
413
-            case 'jcal':
414
-                $json = true;
415
-                $forceInput = 'VCALENDAR';
416
-                break;
417
-            case 'mimedir':
418
-            case 'icalendar':
419
-            case 'icalendar20':
420
-            case 'vcard':
421
-                break;
422
-            case 'vcard21':
423
-                $convertVersion = Document::VCARD21;
424
-                break;
425
-            case 'vcard30':
426
-                $convertVersion = Document::VCARD30;
427
-                break;
428
-            case 'vcard40':
429
-                $convertVersion = Document::VCARD40;
430
-                break;
431
-        }
432
-
433
-        if ($forceInput && $vObj->name !== $forceInput) {
434
-            throw new \Exception('You cannot convert a '.strtolower($vObj->name).' to '.$this->format);
435
-        }
436
-        if ($convertVersion) {
437
-            $vObj = $vObj->convert($convertVersion);
438
-        }
439
-        if ($json) {
440
-            $jsonOptions = 0;
441
-            if ($this->pretty) {
442
-                $jsonOptions = JSON_PRETTY_PRINT;
443
-            }
444
-            fwrite($this->stdout, json_encode($vObj->jsonSerialize(), $jsonOptions));
445
-        } else {
446
-            fwrite($this->stdout, $vObj->serialize());
447
-        }
448
-
449
-        return 0;
450
-    }
451
-
452
-    /**
453
-     * Colorizes a file.
454
-     *
455
-     * @param Component $vObj
456
-     */
457
-    protected function color($vObj)
458
-    {
459
-        $this->serializeComponent($vObj);
460
-    }
461
-
462
-    /**
463
-     * Returns an ansi color string for a color name.
464
-     *
465
-     * @param string $color
466
-     *
467
-     * @return string
468
-     */
469
-    protected function colorize($color, $str, $resetTo = 'default')
470
-    {
471
-        $colors = [
472
-            'cyan' => '1;36',
473
-            'red' => '1;31',
474
-            'yellow' => '1;33',
475
-            'blue' => '0;34',
476
-            'green' => '0;32',
477
-            'default' => '0',
478
-            'purple' => '0;35',
479
-        ];
480
-
481
-        return "\033[".$colors[$color].'m'.$str."\033[".$colors[$resetTo].'m';
482
-    }
483
-
484
-    /**
485
-     * Writes out a string in specific color.
486
-     *
487
-     * @param string $color
488
-     * @param string $str
489
-     */
490
-    protected function cWrite($color, $str)
491
-    {
492
-        fwrite($this->stdout, $this->colorize($color, $str));
493
-    }
494
-
495
-    protected function serializeComponent(Component $vObj)
496
-    {
497
-        $this->cWrite('cyan', 'BEGIN');
498
-        $this->cWrite('red', ':');
499
-        $this->cWrite('yellow', $vObj->name."\n");
500
-
501
-        /**
502
-         * Gives a component a 'score' for sorting purposes.
503
-         *
504
-         * This is solely used by the childrenSort method.
505
-         *
506
-         * A higher score means the item will be lower in the list.
507
-         * To avoid score collisions, each "score category" has a reasonable
508
-         * space to accommodate elements. The $key is added to the $score to
509
-         * preserve the original relative order of elements.
510
-         *
511
-         * @param int   $key
512
-         * @param array $array
513
-         *
514
-         * @return int
515
-         */
516
-        $sortScore = function ($key, $array) {
517
-            if ($array[$key] instanceof Component) {
518
-                // We want to encode VTIMEZONE first, this is a personal
519
-                // preference.
520
-                if ('VTIMEZONE' === $array[$key]->name) {
521
-                    $score = 300000000;
522
-
523
-                    return $score + $key;
524
-                } else {
525
-                    $score = 400000000;
526
-
527
-                    return $score + $key;
528
-                }
529
-            } else {
530
-                // Properties get encoded first
531
-                // VCARD version 4.0 wants the VERSION property to appear first
532
-                if ($array[$key] instanceof Property) {
533
-                    if ('VERSION' === $array[$key]->name) {
534
-                        $score = 100000000;
535
-
536
-                        return $score + $key;
537
-                    } else {
538
-                        // All other properties
539
-                        $score = 200000000;
540
-
541
-                        return $score + $key;
542
-                    }
543
-                }
544
-            }
545
-        };
546
-
547
-        $children = $vObj->children();
548
-        $tmp = $children;
549
-        uksort(
550
-            $children,
551
-            function ($a, $b) use ($sortScore, $tmp) {
552
-                $sA = $sortScore($a, $tmp);
553
-                $sB = $sortScore($b, $tmp);
554
-
555
-                return $sA - $sB;
556
-            }
557
-        );
558
-
559
-        foreach ($children as $child) {
560
-            if ($child instanceof Component) {
561
-                $this->serializeComponent($child);
562
-            } else {
563
-                $this->serializeProperty($child);
564
-            }
565
-        }
566
-
567
-        $this->cWrite('cyan', 'END');
568
-        $this->cWrite('red', ':');
569
-        $this->cWrite('yellow', $vObj->name."\n");
570
-    }
571
-
572
-    /**
573
-     * Colorizes a property.
574
-     */
575
-    protected function serializeProperty(Property $property)
576
-    {
577
-        if ($property->group) {
578
-            $this->cWrite('default', $property->group);
579
-            $this->cWrite('red', '.');
580
-        }
581
-
582
-        $this->cWrite('yellow', $property->name);
583
-
584
-        foreach ($property->parameters as $param) {
585
-            $this->cWrite('red', ';');
586
-            $this->cWrite('blue', $param->serialize());
587
-        }
588
-        $this->cWrite('red', ':');
589
-
590
-        if ($property instanceof Property\Binary) {
591
-            $this->cWrite('default', 'embedded binary stripped. ('.strlen($property->getValue()).' bytes)');
592
-        } else {
593
-            $parts = $property->getParts();
594
-            $first1 = true;
595
-            // Looping through property values
596
-            foreach ($parts as $part) {
597
-                if ($first1) {
598
-                    $first1 = false;
599
-                } else {
600
-                    $this->cWrite('red', $property->delimiter);
601
-                }
602
-                $first2 = true;
603
-                // Looping through property sub-values
604
-                foreach ((array) $part as $subPart) {
605
-                    if ($first2) {
606
-                        $first2 = false;
607
-                    } else {
608
-                        // The sub-value delimiter is always comma
609
-                        $this->cWrite('red', ',');
610
-                    }
611
-
612
-                    $subPart = strtr(
613
-                        $subPart,
614
-                        [
615
-                            '\\' => $this->colorize('purple', '\\\\', 'green'),
616
-                            ';' => $this->colorize('purple', '\;', 'green'),
617
-                            ',' => $this->colorize('purple', '\,', 'green'),
618
-                            "\n" => $this->colorize('purple', "\\n\n\t", 'green'),
619
-                            "\r" => '',
620
-                        ]
621
-                    );
622
-
623
-                    $this->cWrite('green', $subPart);
624
-                }
625
-            }
626
-        }
627
-        $this->cWrite('default', "\n");
628
-    }
629
-
630
-    /**
631
-     * Parses the list of arguments.
632
-     */
633
-    protected function parseArguments(array $argv)
634
-    {
635
-        $positional = [];
636
-        $options = [];
637
-
638
-        for ($ii = 0; $ii < count($argv); ++$ii) {
639
-            // Skipping the first argument.
640
-            if (0 === $ii) {
641
-                continue;
642
-            }
643
-
644
-            $v = $argv[$ii];
645
-
646
-            if ('--' === substr($v, 0, 2)) {
647
-                // This is a long-form option.
648
-                $optionName = substr($v, 2);
649
-                $optionValue = true;
650
-                if (strpos($optionName, '=')) {
651
-                    list($optionName, $optionValue) = explode('=', $optionName);
652
-                }
653
-                $options[$optionName] = $optionValue;
654
-            } elseif ('-' === substr($v, 0, 1) && strlen($v) > 1) {
655
-                // This is a short-form option.
656
-                foreach (str_split(substr($v, 1)) as $option) {
657
-                    $options[$option] = true;
658
-                }
659
-            } else {
660
-                $positional[] = $v;
661
-            }
662
-        }
663
-
664
-        return [$options, $positional];
665
-    }
666
-
667
-    protected $parser;
668
-
669
-    /**
670
-     * Reads the input file.
671
-     *
672
-     * @return Component
673
-     */
674
-    protected function readInput()
675
-    {
676
-        if (!$this->parser) {
677
-            if ('-' !== $this->inputPath) {
678
-                $this->stdin = fopen($this->inputPath, 'r');
679
-            }
680
-
681
-            if ('mimedir' === $this->inputFormat) {
682
-                $this->parser = new Parser\MimeDir($this->stdin, ($this->forgiving ? Reader::OPTION_FORGIVING : 0));
683
-            } else {
684
-                $this->parser = new Parser\Json($this->stdin, ($this->forgiving ? Reader::OPTION_FORGIVING : 0));
685
-            }
686
-        }
687
-
688
-        return $this->parser->parse();
689
-    }
690
-
691
-    /**
692
-     * Sends a message to STDERR.
693
-     *
694
-     * @param string $msg
695
-     */
696
-    protected function log($msg, $color = 'default')
697
-    {
698
-        if (!$this->quiet) {
699
-            if ('default' !== $color) {
700
-                $msg = $this->colorize($color, $msg);
701
-            }
702
-            fwrite($this->stderr, $msg."\n");
703
-        }
704
-    }
296
+		);
297
+
298
+		$this->log('Examples:', 'yellow');
299
+		$this->log('   vobject convert contact.vcf contact.json');
300
+		$this->log('   vobject convert --format=vcard40 old.vcf new.vcf');
301
+		$this->log('   vobject convert --inputformat=json --format=mimedir - -');
302
+		$this->log('   vobject color calendar.ics');
303
+		$this->log('');
304
+		$this->log('https://github.com/fruux/sabre-vobject', 'purple');
305
+	}
306
+
307
+	/**
308
+	 * Validates a VObject file.
309
+	 *
310
+	 * @return int
311
+	 */
312
+	protected function validate(Component $vObj)
313
+	{
314
+		$returnCode = 0;
315
+
316
+		switch ($vObj->name) {
317
+			case 'VCALENDAR':
318
+				$this->log('iCalendar: '.(string) $vObj->VERSION);
319
+				break;
320
+			case 'VCARD':
321
+				$this->log('vCard: '.(string) $vObj->VERSION);
322
+				break;
323
+		}
324
+
325
+		$warnings = $vObj->validate();
326
+		if (!count($warnings)) {
327
+			$this->log('  No warnings!');
328
+		} else {
329
+			$levels = [
330
+				1 => 'REPAIRED',
331
+				2 => 'WARNING',
332
+				3 => 'ERROR',
333
+			];
334
+			$returnCode = 2;
335
+			foreach ($warnings as $warn) {
336
+				$extra = '';
337
+				if ($warn['node'] instanceof Property) {
338
+					$extra = ' (property: "'.$warn['node']->name.'")';
339
+				}
340
+				$this->log('  ['.$levels[$warn['level']].'] '.$warn['message'].$extra);
341
+			}
342
+		}
343
+
344
+		return $returnCode;
345
+	}
346
+
347
+	/**
348
+	 * Repairs a VObject file.
349
+	 *
350
+	 * @return int
351
+	 */
352
+	protected function repair(Component $vObj)
353
+	{
354
+		$returnCode = 0;
355
+
356
+		switch ($vObj->name) {
357
+			case 'VCALENDAR':
358
+				$this->log('iCalendar: '.(string) $vObj->VERSION);
359
+				break;
360
+			case 'VCARD':
361
+				$this->log('vCard: '.(string) $vObj->VERSION);
362
+				break;
363
+		}
364
+
365
+		$warnings = $vObj->validate(Node::REPAIR);
366
+		if (!count($warnings)) {
367
+			$this->log('  No warnings!');
368
+		} else {
369
+			$levels = [
370
+				1 => 'REPAIRED',
371
+				2 => 'WARNING',
372
+				3 => 'ERROR',
373
+			];
374
+			$returnCode = 2;
375
+			foreach ($warnings as $warn) {
376
+				$extra = '';
377
+				if ($warn['node'] instanceof Property) {
378
+					$extra = ' (property: "'.$warn['node']->name.'")';
379
+				}
380
+				$this->log('  ['.$levels[$warn['level']].'] '.$warn['message'].$extra);
381
+			}
382
+		}
383
+		fwrite($this->stdout, $vObj->serialize());
384
+
385
+		return $returnCode;
386
+	}
387
+
388
+	/**
389
+	 * Converts a vObject file to a new format.
390
+	 *
391
+	 * @param Component $vObj
392
+	 *
393
+	 * @return int
394
+	 */
395
+	protected function convert($vObj)
396
+	{
397
+		$json = false;
398
+		$convertVersion = null;
399
+		$forceInput = null;
400
+
401
+		switch ($this->format) {
402
+			case 'json':
403
+				$json = true;
404
+				if ('VCARD' === $vObj->name) {
405
+					$convertVersion = Document::VCARD40;
406
+				}
407
+				break;
408
+			case 'jcard':
409
+				$json = true;
410
+				$forceInput = 'VCARD';
411
+				$convertVersion = Document::VCARD40;
412
+				break;
413
+			case 'jcal':
414
+				$json = true;
415
+				$forceInput = 'VCALENDAR';
416
+				break;
417
+			case 'mimedir':
418
+			case 'icalendar':
419
+			case 'icalendar20':
420
+			case 'vcard':
421
+				break;
422
+			case 'vcard21':
423
+				$convertVersion = Document::VCARD21;
424
+				break;
425
+			case 'vcard30':
426
+				$convertVersion = Document::VCARD30;
427
+				break;
428
+			case 'vcard40':
429
+				$convertVersion = Document::VCARD40;
430
+				break;
431
+		}
432
+
433
+		if ($forceInput && $vObj->name !== $forceInput) {
434
+			throw new \Exception('You cannot convert a '.strtolower($vObj->name).' to '.$this->format);
435
+		}
436
+		if ($convertVersion) {
437
+			$vObj = $vObj->convert($convertVersion);
438
+		}
439
+		if ($json) {
440
+			$jsonOptions = 0;
441
+			if ($this->pretty) {
442
+				$jsonOptions = JSON_PRETTY_PRINT;
443
+			}
444
+			fwrite($this->stdout, json_encode($vObj->jsonSerialize(), $jsonOptions));
445
+		} else {
446
+			fwrite($this->stdout, $vObj->serialize());
447
+		}
448
+
449
+		return 0;
450
+	}
451
+
452
+	/**
453
+	 * Colorizes a file.
454
+	 *
455
+	 * @param Component $vObj
456
+	 */
457
+	protected function color($vObj)
458
+	{
459
+		$this->serializeComponent($vObj);
460
+	}
461
+
462
+	/**
463
+	 * Returns an ansi color string for a color name.
464
+	 *
465
+	 * @param string $color
466
+	 *
467
+	 * @return string
468
+	 */
469
+	protected function colorize($color, $str, $resetTo = 'default')
470
+	{
471
+		$colors = [
472
+			'cyan' => '1;36',
473
+			'red' => '1;31',
474
+			'yellow' => '1;33',
475
+			'blue' => '0;34',
476
+			'green' => '0;32',
477
+			'default' => '0',
478
+			'purple' => '0;35',
479
+		];
480
+
481
+		return "\033[".$colors[$color].'m'.$str."\033[".$colors[$resetTo].'m';
482
+	}
483
+
484
+	/**
485
+	 * Writes out a string in specific color.
486
+	 *
487
+	 * @param string $color
488
+	 * @param string $str
489
+	 */
490
+	protected function cWrite($color, $str)
491
+	{
492
+		fwrite($this->stdout, $this->colorize($color, $str));
493
+	}
494
+
495
+	protected function serializeComponent(Component $vObj)
496
+	{
497
+		$this->cWrite('cyan', 'BEGIN');
498
+		$this->cWrite('red', ':');
499
+		$this->cWrite('yellow', $vObj->name."\n");
500
+
501
+		/**
502
+		 * Gives a component a 'score' for sorting purposes.
503
+		 *
504
+		 * This is solely used by the childrenSort method.
505
+		 *
506
+		 * A higher score means the item will be lower in the list.
507
+		 * To avoid score collisions, each "score category" has a reasonable
508
+		 * space to accommodate elements. The $key is added to the $score to
509
+		 * preserve the original relative order of elements.
510
+		 *
511
+		 * @param int   $key
512
+		 * @param array $array
513
+		 *
514
+		 * @return int
515
+		 */
516
+		$sortScore = function ($key, $array) {
517
+			if ($array[$key] instanceof Component) {
518
+				// We want to encode VTIMEZONE first, this is a personal
519
+				// preference.
520
+				if ('VTIMEZONE' === $array[$key]->name) {
521
+					$score = 300000000;
522
+
523
+					return $score + $key;
524
+				} else {
525
+					$score = 400000000;
526
+
527
+					return $score + $key;
528
+				}
529
+			} else {
530
+				// Properties get encoded first
531
+				// VCARD version 4.0 wants the VERSION property to appear first
532
+				if ($array[$key] instanceof Property) {
533
+					if ('VERSION' === $array[$key]->name) {
534
+						$score = 100000000;
535
+
536
+						return $score + $key;
537
+					} else {
538
+						// All other properties
539
+						$score = 200000000;
540
+
541
+						return $score + $key;
542
+					}
543
+				}
544
+			}
545
+		};
546
+
547
+		$children = $vObj->children();
548
+		$tmp = $children;
549
+		uksort(
550
+			$children,
551
+			function ($a, $b) use ($sortScore, $tmp) {
552
+				$sA = $sortScore($a, $tmp);
553
+				$sB = $sortScore($b, $tmp);
554
+
555
+				return $sA - $sB;
556
+			}
557
+		);
558
+
559
+		foreach ($children as $child) {
560
+			if ($child instanceof Component) {
561
+				$this->serializeComponent($child);
562
+			} else {
563
+				$this->serializeProperty($child);
564
+			}
565
+		}
566
+
567
+		$this->cWrite('cyan', 'END');
568
+		$this->cWrite('red', ':');
569
+		$this->cWrite('yellow', $vObj->name."\n");
570
+	}
571
+
572
+	/**
573
+	 * Colorizes a property.
574
+	 */
575
+	protected function serializeProperty(Property $property)
576
+	{
577
+		if ($property->group) {
578
+			$this->cWrite('default', $property->group);
579
+			$this->cWrite('red', '.');
580
+		}
581
+
582
+		$this->cWrite('yellow', $property->name);
583
+
584
+		foreach ($property->parameters as $param) {
585
+			$this->cWrite('red', ';');
586
+			$this->cWrite('blue', $param->serialize());
587
+		}
588
+		$this->cWrite('red', ':');
589
+
590
+		if ($property instanceof Property\Binary) {
591
+			$this->cWrite('default', 'embedded binary stripped. ('.strlen($property->getValue()).' bytes)');
592
+		} else {
593
+			$parts = $property->getParts();
594
+			$first1 = true;
595
+			// Looping through property values
596
+			foreach ($parts as $part) {
597
+				if ($first1) {
598
+					$first1 = false;
599
+				} else {
600
+					$this->cWrite('red', $property->delimiter);
601
+				}
602
+				$first2 = true;
603
+				// Looping through property sub-values
604
+				foreach ((array) $part as $subPart) {
605
+					if ($first2) {
606
+						$first2 = false;
607
+					} else {
608
+						// The sub-value delimiter is always comma
609
+						$this->cWrite('red', ',');
610
+					}
611
+
612
+					$subPart = strtr(
613
+						$subPart,
614
+						[
615
+							'\\' => $this->colorize('purple', '\\\\', 'green'),
616
+							';' => $this->colorize('purple', '\;', 'green'),
617
+							',' => $this->colorize('purple', '\,', 'green'),
618
+							"\n" => $this->colorize('purple', "\\n\n\t", 'green'),
619
+							"\r" => '',
620
+						]
621
+					);
622
+
623
+					$this->cWrite('green', $subPart);
624
+				}
625
+			}
626
+		}
627
+		$this->cWrite('default', "\n");
628
+	}
629
+
630
+	/**
631
+	 * Parses the list of arguments.
632
+	 */
633
+	protected function parseArguments(array $argv)
634
+	{
635
+		$positional = [];
636
+		$options = [];
637
+
638
+		for ($ii = 0; $ii < count($argv); ++$ii) {
639
+			// Skipping the first argument.
640
+			if (0 === $ii) {
641
+				continue;
642
+			}
643
+
644
+			$v = $argv[$ii];
645
+
646
+			if ('--' === substr($v, 0, 2)) {
647
+				// This is a long-form option.
648
+				$optionName = substr($v, 2);
649
+				$optionValue = true;
650
+				if (strpos($optionName, '=')) {
651
+					list($optionName, $optionValue) = explode('=', $optionName);
652
+				}
653
+				$options[$optionName] = $optionValue;
654
+			} elseif ('-' === substr($v, 0, 1) && strlen($v) > 1) {
655
+				// This is a short-form option.
656
+				foreach (str_split(substr($v, 1)) as $option) {
657
+					$options[$option] = true;
658
+				}
659
+			} else {
660
+				$positional[] = $v;
661
+			}
662
+		}
663
+
664
+		return [$options, $positional];
665
+	}
666
+
667
+	protected $parser;
668
+
669
+	/**
670
+	 * Reads the input file.
671
+	 *
672
+	 * @return Component
673
+	 */
674
+	protected function readInput()
675
+	{
676
+		if (!$this->parser) {
677
+			if ('-' !== $this->inputPath) {
678
+				$this->stdin = fopen($this->inputPath, 'r');
679
+			}
680
+
681
+			if ('mimedir' === $this->inputFormat) {
682
+				$this->parser = new Parser\MimeDir($this->stdin, ($this->forgiving ? Reader::OPTION_FORGIVING : 0));
683
+			} else {
684
+				$this->parser = new Parser\Json($this->stdin, ($this->forgiving ? Reader::OPTION_FORGIVING : 0));
685
+			}
686
+		}
687
+
688
+		return $this->parser->parse();
689
+	}
690
+
691
+	/**
692
+	 * Sends a message to STDERR.
693
+	 *
694
+	 * @param string $msg
695
+	 */
696
+	protected function log($msg, $color = 'default')
697
+	{
698
+		if (!$this->quiet) {
699
+			if ('default' !== $color) {
700
+				$msg = $this->colorize($color, $msg);
701
+			}
702
+			fwrite($this->stderr, $msg."\n");
703
+		}
704
+	}
705 705
 }
Please login to merge, or discard this patch.