commit 0545637d85b252c730742aa4886145e0527fcbae
Author: Filip Jani <jsem@filek.cz>
Date:   Wed Jun 12 21:53:57 2019 +0200

    Re #7618 oprava kódování

diff --git a/app/FrontModule/component/Transliteration/TransliterationSearchResultList.php b/app/FrontModule/component/Transliteration/TransliterationSearchResultList.php
index 95c4e51..81eaf34 100644
--- a/app/FrontModule/component/Transliteration/TransliterationSearchResultList.php
+++ b/app/FrontModule/component/Transliteration/TransliterationSearchResultList.php
@@ -34,6 +34,8 @@ class TransliterationSearchResultList extends Control
     private $searchTerms;
 
     private $resultRows;
+
+    /** @var int */
     private $totalCount;
 
     /**
@@ -108,6 +110,7 @@ class TransliterationSearchResultList extends Control
 
         $this->template->resultRows = $this->resultRows;
         $this->template->paginator = $this->paginator;
+
         $this->template->render();
     }
 
@@ -119,10 +122,13 @@ class TransliterationSearchResultList extends Control
             //jelikož následně přidáváme html tagy pro vyznačení a výstup v latte nemůže být escapovaný
             $resultRow->transliteration = htmlspecialchars($resultRow->transliteration);
 
-            $resultRow->transliteration = preg_replace(
-                "/" . $this->transliterationRepository->prepareSearchRegExp($this->searchTerms['word1']) . "/",
-                "<span class='found'>$0</span>",
-                $resultRow->transliteration);
+            if(!empty($this->searchTerms['word1']))
+            {
+                $resultRow->transliteration = preg_replace(
+                    "/" . $this->transliterationRepository->prepareSearchRegExp($this->searchTerms['word1']) . "/",
+                    "<span class='found'>$0</span>",
+                    $resultRow->transliteration);
+            }
 
             /**
              * TODO: dořešit označování slov, když se zadají slova co se překrývají tak se tagy mezi sebou ruší,
diff --git a/app/model/repository/TransliterationRepository.php b/app/model/repository/TransliterationRepository.php
index 835e3fb..e2c11a4 100644
--- a/app/model/repository/TransliterationRepository.php
+++ b/app/model/repository/TransliterationRepository.php
@@ -44,15 +44,17 @@ class TransliterationRepository extends Repository
         $where = '';
         $whereArgs = [];
 
-        if($queryParams['exact_match'])
+        if(!empty($queryParams['word1']))
         {
-            $where .= "l.transliteration LIKE ? ";
-            $whereArgs[] = "%" . $queryParams['word1'] . "%";
-        }
-        else
-        {
-            $where .= "l.transliteration REGEXP ? ";
-            $whereArgs[] = $this->prepareSearchRegExp($queryParams['word1']);
+            if ($queryParams['exact_match'])
+            {
+                $where .= "l.transliteration LIKE ? ";
+                $whereArgs[] = "%" . $queryParams['word1'] . "%";
+            } else
+            {
+                $where .= "l.transliteration REGEXP ? ";
+                $whereArgs[] = $this->prepareSearchRegExp($queryParams['word1']);
+            }
         }
 
         if($queryParams['word2_condition'])
@@ -136,8 +138,12 @@ class TransliterationRepository extends Repository
         $query .= "FROM transliteration t
                   LEFT JOIN surface s ON s.id_transliteration = t.id_transliteration
                   LEFT JOIN line l ON l.id_surface = s.id_surface
-                  LEFT JOIN book b ON t.id_book = b.id_book
-                  WHERE " . $where;
+                  LEFT JOIN book b ON t.id_book = b.id_book ";
+
+        if (!empty($where))
+        {
+            $query .= 'WHERE ' . $where;
+        }
 
         if (!$countOnly)
         {
@@ -154,7 +160,7 @@ class TransliterationRepository extends Repository
         return $this->context->queryArgs($query, $whereArgs);
     }
 
-    public function getTransliterationsFulltextSearchTotalCount($queryParams)
+    public function getTransliterationsFulltextSearchTotalCount($queryParams): int
     {
         return $this->transliterationsFulltextSearch($queryParams, null, null, true)->fetch()->count;
     }
