Skip to content

Commit

Permalink
Коркция на търсенето
Browse files Browse the repository at this point in the history
  • Loading branch information
atrifonoff committed Nov 19, 2018
1 parent a7b3ccb commit ef4c35a
Showing 1 changed file with 11 additions and 56 deletions.
67 changes: 11 additions & 56 deletions vislog/reports/HistoryResourcesCounter.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,72 +116,29 @@ protected function prepareRecs($rec, &$data = null)
}
$counter = array();

$text = mb_strtolower(trim("{$rec->text}", ' '));
$text = mb_strtolower(trim("{$rec->text}"));

$textArr = explode(' ', $text);

$countTextArr = count($textArr);

while ($query = $hQuery->fetch()) {
$flag = false;

$queryToLower = mb_strtolower(trim("{$query->query}", ' '));

$queryArr = explode(' ', $queryToLower);
while ($hRec = $hQuery->fetch()) {
$queryToLower = mb_strtolower(trim("{$hRec->query}", ' '));

if ($countTextArr > count($queryArr)) {
continue;
}

if ($countTextArr == count($queryArr)) {
if ($text == $queryToLower) {
$id = $query->HistoryResourceId;
$flag = true;
}
}

if ($countTextArr < count($queryArr)) {
$marker = 0;
while (($countTextArr + $marker) <= (count($queryArr))) {
$wordIndex = $marker;

for ($i = 0; $i < $countTextArr; $i++) {

$tempQuery .= $queryArr[$wordIndex].' ';

$wordIndex++;
}

if (mb_strtolower(trim("${tempQuery}", ' ')) == $text) {
$id = $query->HistoryResourceId;
$flag = true;
unset($tempQuery);
}

unset($tempQuery);
$marker++;
}
}


// добавяме в масива
if ($flag) {
if (strpos($queryToLower, $text) !== false) {
$id = $hRec->HistoryResourceId;

// добавяме в масива
if (!array_key_exists($id, $recs)) {
$recs[$id] = (object) array(

'HistoryResourceId' => $id,
'query' => $query->query,
'resource' => $queryArr[1],
'place' => $queryArr[0],
'createdOn' => $query->createdOn,
'query' => $hRec->query,
'createdOn' => $hRec->createdOn,
'counter' => 1
);
} else {
$obj = &$recs[$id];
++$obj->counter;
}
}
unset($id,$queryToLower);
unset($id, $queryToLower);
}

if (is_array($recs)) {
Expand Down Expand Up @@ -242,8 +199,6 @@ protected function detailRecToVerbal($rec, &$dRec)

$row->resource = $dRec->query;

// $row->place = $dRec->place;

$row->counter = $dRec->counter;

return $row;
Expand Down Expand Up @@ -276,7 +231,7 @@ protected static function on_AfterRenderSingle(frame2_driver_Proto $Driver, embe
}

if (isset($data->rec->text)) {
$fieldTpl->append('<b>' ." ". $data->rec->text." " . '</b>', 'text');
$fieldTpl->append('<b>' . ' ' . $data->rec->text . ' ' . '</b>', 'text');
}

$tpl->append($fieldTpl, 'DRIVER_FIELDS');
Expand Down

0 comments on commit ef4c35a

Please sign in to comment.