Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 67ebe0dc

Přidáno uživatelem Petr Lukašík před téměř 6 roky(ů)

Re #7510 oprava na domluvený formát txt souboru

Zobrazit rozdíly:

app/utils/TextParser.php
28 28

  
29 29
        //TODO kontrola a parsovani object types (tablet, envelope)
30 30
        foreach ($array as $value) {
31
            Debugger::barDump($value);
32
            if (strlen($value)==0){
31
            if (strlen($value) == 0) {
33 32
                $nextBook = true;
34
            }
35
            elseif ($value[0] == '|' && $nextBook) {
33
            } elseif ($value[0] == '|' && $nextBook) {
36 34
                $currentBook = substr($value, 1);
37 35
                $currentChapter = "";
38 36
                $currentSurface = $this->transformAbbrev("obverse");
39 37
                $nextBook = false;
40
            }
41
            elseif ($value[0] == '|'){
42
                // TYPÍIIIIIČO ono to může být i tady... k posrání. Odděleno '-', jakože pro jistotu demence (OBTR => "15 (T.R.4020) - le.e.")
43
                $withRef = explode(" - ", substr($value, 1));
44
                if(isset($withRef[1])){
45
                    $currentChapter = trim(substr($value, 1, strripos($value, "-")-1));
46
                    $currentSurface = $this->transformAbbrev(trim($withRef[1]));
47
                }else{
48
                    $currentChapter = substr($value, 1);
49
                    $currentSurface = $this->transformAbbrev("obverse");
50
                }
51
            }
52
            else{
38
            } elseif ($value[0] == '|') {
39
                $currentChapter = substr($value, 1);
40
                $currentSurface = $this->transformAbbrev("obverse");
41
            } else {
53 42
                if (strchr($value, '$')) {
54
                    $output[$currentBook][$currentChapter][$currentSurface][] = trim(substr($value,0,stripos($value,"&")));
55
                    $currentSurface = $this->transformAbbrev(substr(strchr($value, "&"),1, -1));
56
                }else{
43
                    $currentSurface = $this->transformAbbrev(substr(strchr($value, "&"), 1, -1));
44
                    $output[$currentBook][$currentChapter][$currentSurface][] = trim(substr($value, 0, stripos($value, "&")));
45
                } else {
57 46
                    $output[$currentBook][$currentChapter][$currentSurface][] = $value;
58 47
                }
59 48
            }
......
84 73
    }
85 74

  
86 75
    /** Funkce pro transformaci zkratek surfaceType na jejich příslušná idčka v db */
87
    private function transformAbbrev($abbrev){
88
        switch ($abbrev){
76
    private function transformAbbrev($abbrev)
77
    {
78
        switch ($abbrev) {
89 79
            case "rev.":
90 80
                return array_search("reverse", $this->surfaceTypes);
91 81
            case "u.e.":
......
118 108
        }
119 109
    }
120 110

  
121
    public function getTextFile(){
111
    public function getTextFile()
112
    {
122 113
        return $this->textFile;
123 114
    }
124 115
}

Také k dispozici: Unified diff