// (1) Keyword Search, or Archive By Date if (!empty($_GET['c']) || !empty($_GET['k']) || !empty($_GET['d'])) { $previousItemNumber = empty($_GET['p']) ? '0' : $_GET['p']; $date = empty($_GET['d']) ? '' : $_GET['d']; $expand = empty($_GET['ex']) ? '0' : $_GET['ex']; $pageNumberToShow = empty($_GET['pn']) ? '1' : $_GET['pn']; // Keyword Search if (isset($_GET['k'])) { $key = $_GET['k']; $params = array('fields' => '*', 'table' => COMMENT_TABLE . ' AS l', 'title' => 'l.title', 'comment' => 'l.comment', 'date' => 'l.date', 'draft' => 'l.trash', 'group_by' => 'l.refer_id'); $resultTemplateFile = 'search-result.html'; $sql = $app->getSearchSQL($params); $countSql = $app->getSearchHitsSQL($params); } // Count the number of hit results $totalItemsCount = $app->getTotalItemsCount($countSql); if ($totalItemsCount !== 0) { // Archive By Date if (preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}/', $date)) { $contents = $app->getArchives($sql); $pager = $app->getPager($totalItemsCount, $pageNumberToShow, $date, $expand); $result = ''; } else { $contents = $app->getArchives($sql); $pager = $app->getPager($totalItemsCount, $pageNumberToShow, $date, $expand); $templateFile = $pathToIndex . '/theme/' . $resultTemplateFile; $resultView = new Loggix_View($templateFile); $item = $app->setSearchItems($res, $totalItemsCount, $previousItemNumber, $date); $resultView->assign('item', $item); $resultView->assign('lang', $lang); $result = $resultView->render();