Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 75df6b2e

Přidáno uživatelem Jan Šedivý před asi 6 roky(ů)

Re #7327 Regexp pro doplňující hledaná slova. Seřazení řádků v detailu

Zobrazit rozdíly:

app/model/repository/LineRepository.php
35 35
                         LEFT JOIN transliteration t on s.id_transliteration = t.id_transliteration
36 36
                         LEFT JOIN object_type o on s.id_object_type = o.id_object_type
37 37
                  WHERE t.id_transliteration = ?
38
                  ORDER BY st.sorter ASC, line_number ASC",
38
                  ORDER BY st.sorter ASC, id_line ASC",
39 39
            $transliterationId
40 40
        );
41 41
    }
app/model/repository/TransliterationRepository.php
46 46
        }
47 47
        else
48 48
        {
49
            $splitWord = preg_split('//u', $queryParams['word1'], -1, PREG_SPLIT_NO_EMPTY);
50
            $regex = implode("[\[\]⌈⌉?!><\.₁₂₃₄₅₆₇₈₉₀\-\s]*?", $splitWord);
51 49
            $where .= "l.transliteration REGEXP ? ";
52
            $whereArgs[] = $regex;
50
            $whereArgs[] = $this->prepareSearchRegExp($queryParams['word1']);
53 51
        }
54 52

  
55 53
        if($queryParams['word2_condition'])
56 54
        {
57
            $where .= ELogicalConditions::$whereCondition[$queryParams['word2_condition']] . " l.transliteration LIKE ? ";
58
            $whereArgs[] = "%" . $queryParams['word2'] . "%";
55
            if($queryParams['exact_match'])
56
            {
57
                $where .= ELogicalConditions::$whereCondition[$queryParams['word2_condition']] . " l.transliteration LIKE ? ";
58
                $whereArgs[] = "%" . $queryParams['word2'] . "%";
59
            }
60
            else
61
            {
62
                $where .= ELogicalConditions::$whereCondition[$queryParams['word2_condition']] . " l.transliteration REGEXP ? ";
63
                $whereArgs[] = $this->prepareSearchRegExp($queryParams['word2']);
64
            }
59 65
        }
60 66

  
61 67
        if($queryParams['word3_condition'])
62 68
        {
63
            $where .= ELogicalConditions::$whereCondition[$queryParams['word3_condition']] . " l.transliteration LIKE ? ";
64
            $whereArgs[] = "%" . $queryParams['word3'] . "%";
69
            if($queryParams['exact_match'])
70
            {
71
                $where .= ELogicalConditions::$whereCondition[$queryParams['word3_condition']] . " l.transliteration LIKE ? ";
72
                $whereArgs[] = "%" . $queryParams['word3'] . "%";
73
            }
74
            else
75
            {
76
                $where .= ELogicalConditions::$whereCondition[$queryParams['word3_condition']] . " l.transliteration REGEXP ? ";
77
                $whereArgs[] = $this->prepareSearchRegExp($queryParams['word3']);
78
            }
65 79
        }
66 80

  
67 81
        $query = "SELECT 
......
79 93
        return $this->context->queryArgs($query, $whereArgs);
80 94
    }
81 95

  
96
    private function prepareSearchRegExp($word)
97
    {
98
        $splitWord = preg_split('//u',$word, -1, PREG_SPLIT_NO_EMPTY);
99
        $regex = implode("[\[\]⌈⌉?!><\.₁₂₃₄₅₆₇₈₉₀\-\s]*?", $splitWord);
100
        return $regex;
101
    }
102

  
82 103
    public function getTransliterationDetail($id)
83 104
    {
84 105
        return $this->context->query(

Také k dispozici: Unified diff