Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
colorconverter.php
1<?php
2
4
6{
7 private const OFFICE_DEFAULT_COLOR = 'auto';
8 private const BITRIX_DEFAULT_COLOR = '#838fa0';
9
10 private const MAP_EXPORT_INT = [
11 '#86b100' => '1',
12 '#0092cc' => '0',
13 '#00afc7' => '5',
14 '#e89b06' => '7',
15 '#00b38c' => '-1', //
16 '#de2b24' => '2',
17 '#838fa0' => '6',
18 '#c3612c' => '4',
19 '#e97090' => '-1',
20 ];
21
22 private const MAP_EXPORT = [
23 '#86b100' => 'lightGreen',
24 '#0092cc' => 'lightBlue',
25 '#00afc7' => 'lightTeal',
26 '#c3612c' => 'lightBrown',
27 '#e89b06' => 'lightOrange',
28// '#838fa0' => 'lightYellow',
29 '#bd7ac9' => 'lightPink',
30 '#838fa0' => 'lightGray',
31 '#de2b24' => 'lightRed',
32 ];
33
34 private const MAP_IMPORT = [
35 'lightGreen' => '#86b100',
36 'lightBlue' => '#0092cc',
37 'lightTeal' => '#00afc7',
38 'lightBrown' => '#c3612c',
39 'lightOrange' => '#e89b06',
40// 'lightYellow' => '#838fa0',
41 'lightPink' => '#bd7ac9',
42 'lightGray' => '#838fa0',
43 'lightRed' => '#de2b24',
44 ];
45
46 private const OFFICE_COLORS = [
47 'auto' => -1,
48 'lightBlue' => 0,
49 'lightGreen' => 1,
50 'lightOrange' => 2,
51 'lightGray' => 3,
52 'lightYellow' => 4,
53 'lightTeal' => 5,
54 'lightPink' => 6,
55 'lightBrown' => 7,
56 'lightRed' => 8,
57 'maxColor' => 9,
58 ];
59
60 private const OUR_COLORS = [
61 '#86b100', // 1
62 '#0092cc', // 2
63 '#00afc7', // 3
64 '#e89b06', // 4
65 '#00b38c', // 5
66 '#de2b24', // 6
67 '#bd7ac9', // 7
68 '#838fa0', // 8
69 '#c3612c', // 9
70 '#e97090', // 10
71 ];
72
78 public static function toOfficCode(?string $color = null): string
79 {
80 return self::MAP_EXPORT_INT[$color] ?? '-1';
81 }
82
88 public static function toOffice(?string $color = null): string
89 {
90 return self::MAP_EXPORT[$color] ?? self::OFFICE_DEFAULT_COLOR;
91 }
92
99 public static function fromOffice(string $color, ?string $hexColor = null): ?string
100 {
101 return $hexColor ?:
102 self::MAP_IMPORT[$color]
103 ?? null
104 ;
105 }
106}
static fromOffice(string $color, ?string $hexColor=null)