Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 0545637d

Přidáno uživatelem Filip Jani před téměř 6 roky(ů)

Re #7618 oprava kódování

Zobrazit rozdíly:

app/FrontModule/component/Transliteration/TransliterationSearchResultList.php
34 34
    private $searchTerms;
35 35

  
36 36
    private $resultRows;
37

  
38
    /** @var int */
37 39
    private $totalCount;
38 40

  
39 41
    /**
......
108 110

  
109 111
        $this->template->resultRows = $this->resultRows;
110 112
        $this->template->paginator = $this->paginator;
113

  
111 114
        $this->template->render();
112 115
    }
113 116

  
......
119 122
            //jelikož následně přidáváme html tagy pro vyznačení a výstup v latte nemůže být escapovaný
120 123
            $resultRow->transliteration = htmlspecialchars($resultRow->transliteration);
121 124

  
122
            $resultRow->transliteration = preg_replace(
123
                "/" . $this->transliterationRepository->prepareSearchRegExp($this->searchTerms['word1']) . "/",
124
                "<span class='found'>$0</span>",
125
                $resultRow->transliteration);
125
            if(!empty($this->searchTerms['word1']))
126
            {
127
                $resultRow->transliteration = preg_replace(
128
                    "/" . $this->transliterationRepository->prepareSearchRegExp($this->searchTerms['word1']) . "/",
129
                    "<span class='found'>$0</span>",
130
                    $resultRow->transliteration);
131
            }
126 132

  
127 133
            /**
128 134
             * TODO: dořešit označování slov, když se zadají slova co se překrývají tak se tagy mezi sebou ruší,
app/model/repository/TransliterationRepository.php
44 44
        $where = '';
45 45
        $whereArgs = [];
46 46

  
47
        if($queryParams['exact_match'])
47
        if(!empty($queryParams['word1']))
48 48
        {
49
            $where .= "l.transliteration LIKE ? ";
50
            $whereArgs[] = "%" . $queryParams['word1'] . "%";
51
        }
52
        else
53
        {
54
            $where .= "l.transliteration REGEXP ? ";
55
            $whereArgs[] = $this->prepareSearchRegExp($queryParams['word1']);
49
            if ($queryParams['exact_match'])
50
            {
51
                $where .= "l.transliteration LIKE ? ";
52
                $whereArgs[] = "%" . $queryParams['word1'] . "%";
53
            } else
54
            {
55
                $where .= "l.transliteration REGEXP ? ";
56
                $whereArgs[] = $this->prepareSearchRegExp($queryParams['word1']);
57
            }
56 58
        }
57 59

  
58 60
        if($queryParams['word2_condition'])
......
136 138
        $query .= "FROM transliteration t
137 139
                  LEFT JOIN surface s ON s.id_transliteration = t.id_transliteration
138 140
                  LEFT JOIN line l ON l.id_surface = s.id_surface
139
                  LEFT JOIN book b ON t.id_book = b.id_book
140
                  WHERE " . $where;
141
                  LEFT JOIN book b ON t.id_book = b.id_book ";
142

  
143
        if (!empty($where))
144
        {
145
            $query .= 'WHERE ' . $where;
146
        }
141 147

  
142 148
        if (!$countOnly)
143 149
        {
......
154 160
        return $this->context->queryArgs($query, $whereArgs);
155 161
    }
156 162

  
157
    public function getTransliterationsFulltextSearchTotalCount($queryParams)
163
    public function getTransliterationsFulltextSearchTotalCount($queryParams): int
158 164
    {
159 165
        return $this->transliterationsFulltextSearch($queryParams, null, null, true)->fetch()->count;
160 166
    }

Také k dispozici: Unified diff