Passed
Push — 1.11.x ( 31fff3...86e7ae )
by Yannick
15:37 queued 10s
created

TemplateManager   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 29
dl 0
loc 44
rs 10
c 1
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A getEmptyTemplate() 0 10 2
1
<?php
2
/**
3
 *
4
 * (c) Copyright Ascensio System SIA 2021
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 *     http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 *
18
 */
19
20
require_once __DIR__ . "/../../../main/inc/global.inc.php";
21
22
class TemplateManager {
23
24
    /**
25
     * Mapping local path to templates
26
     *
27
     * @var Array
28
     */
29
    private static $localPath = [
30
        "bg" => "bg-BG",
31
        "cs" => "cs-CS",
32
        "de" => "de-DE",
33
        "el" => "el-GR",
34
        "en" => "en-US",
35
        "es" => "es-ES",
36
        "fr" => "fr-FR",
37
        "it" => "it-IT",
38
        "ja" => "ja-JP",
39
        "ko" => "ko-KR",
40
        "lv" => "lv-LV",
41
        "nl" => "nl-NL",
42
        "pl" => "pl-PL",
43
        "pt" => "pt-PT",
44
        "pt-BR" => "pt-BR",
45
        "ru" => "ru-RU",
46
        "sk" => "sk-SK",
47
        "sv" => "sv-SE",
48
        "uk" => "uk-UA",
49
        "vi" => "vi-VN",
50
        "zh" => "zh-CN"
51
    ];
52
53
    /**
54
     * Return path to template new file
55
     */
56
    public static function getEmptyTemplate($fileExtension): string
57
    {
58
        $langInfo = LangManager::getLangUser();
59
        $lang = $langInfo["isocode"];
60
        if (!array_key_exists($lang, self::$localPath)) {
61
            $lang = "en";
62
        }
63
        $templateFolder = api_get_path(SYS_PLUGIN_PATH) . "onlyoffice/assets/" . self::$localPath[$lang];
64
65
        return $templateFolder . "/" . ltrim($fileExtension, ".") . ".zip";
66
    }
67
}
68