1 | <?php |
||
5 | class TranslationsSheetCoordinates |
||
|
|||
6 | { |
||
7 | protected $headerRowsCount = 1; |
||
8 | |||
9 | protected $dataRowsCount = 0; |
||
10 | |||
11 | protected $columnsCount = 0; |
||
12 | |||
13 | protected $localesCount = 1; |
||
14 | |||
15 | protected $sheetId; |
||
16 | |||
17 | protected $sheetTitle; |
||
18 | |||
19 | 3 | private function __construct() |
|
22 | |||
23 | 3 | public function setSheetId($sheetId) |
|
29 | |||
30 | 3 | public function setSheetTitle($sheetTitle) |
|
36 | |||
37 | 1 | public static function emptySheet($columnsCount, $localesCount, $headerRowsCount) |
|
48 | |||
49 | 2 | public static function sheetWithData($dataRowsCount, $columnsCount, $localesCount, $headerRowsCount) |
|
60 | |||
61 | public function headerShortRange() |
||
67 | |||
68 | public function headerRange() |
||
69 | { |
||
70 | return [ |
||
71 | 'sheetId' => $this->sheetId, |
||
72 | 'startRowIndex' => 0, |
||
73 | 'endRowIndex' => 1, |
||
74 | 'startColumnIndex' => 0, |
||
75 | 'endColumnIndex' => $this->getColumnsCount(), |
||
76 | ]; |
||
77 | } |
||
78 | |||
79 | public function fullKeyColumnRange() |
||
80 | { |
||
81 | return [ |
||
82 | 'sheetId' => $this->sheetId, |
||
83 | 'startRowIndex' => 1, |
||
84 | 'endRowIndex' => $this->getRowsCount(), |
||
85 | 'startColumnIndex' => 0, |
||
86 | 'endColumnIndex' => 1, |
||
87 | ]; |
||
88 | } |
||
89 | |||
90 | public function metaColumnsRange() |
||
91 | { |
||
92 | return [ |
||
93 | 'sheetId' => $this->sheetId, |
||
94 | 'startRowIndex' => 1, |
||
95 | 'endRowIndex' => $this->getRowsCount(), |
||
96 | 'startColumnIndex' => $this->getLocalesCount() + 1, |
||
97 | 'endColumnIndex' => $this->getColumnsCount(), |
||
98 | ]; |
||
99 | } |
||
100 | |||
101 | public function dataShortRange($firstRow = 2, $noLastRow = false) |
||
102 | { |
||
103 | $alphabet = range('A', 'Z'); |
||
104 | $firstColumn = 'A'; |
||
105 | $lastColumn = $alphabet[$this->getColumnsCount() - 1]; |
||
106 | $lastRow = $this->getRowsCount(); |
||
107 | |||
108 | return $this->sheetTitle.'!'.$firstColumn.$firstRow.':'.$lastColumn.($noLastRow ? '' : $lastRow); |
||
109 | } |
||
110 | |||
111 | public function dataRange($endRow, $firstRow = 2) |
||
121 | |||
122 | public function translationsRange($firstColumn = 1, $rowCount = null) |
||
123 | { |
||
124 | return [ |
||
125 | 'sheetId' => $this->sheetId, |
||
132 | |||
133 | public function getColumnsCount() |
||
137 | |||
138 | public function getRowsCount() |
||
142 | |||
143 | public function getLocalesCount() |
||
147 | |||
148 | public function namespaceColumnIndex() |
||
152 | |||
153 | public function groupColumnIndex() |
||
157 | |||
158 | public function keyColumnIndex() |
||
162 | |||
163 | public function sourceFileColumnIndex() |
||
167 | } |
||
168 |