17 include_once (
"FDL/Class.SearchDoc.php");
18 include_once (
"FDL/Class.DocSearch.php");
20 include_once (
"FDL/freedom_util.php");
38 $action->lay->rSet(
"isdetail",
false);
39 $action->lay->rSet(
"page", (
int)($page + 1));
40 $action->lay->rSet(
"dirid", json_encode(
$dirid));
41 $action->lay->rSet(
"SUBSEARCH", (
$start > 0));
43 $action->parent->AddJsRef($action->GetParam(
"CORE_JSURL") .
"/resizeimg.js");
57 $action->lay->rSet(
"INITSEARCH", $nosearch);
66 $tf = explode(
",", $faml);
67 foreach ($tf as $k => $v) {
68 if ($v ==
"")
continue;
85 $searchMode = $action->
getParam(
"FGSEARCH_SEARCHMODE",
"words");
90 $sqlfilters = array();
91 $famfilter = $or = $and =
"";
92 if (count($kfams) > 0) {
95 foreach ($kfams as $k => $v) {
96 foreach ($tclassdoc as $kdoc => $cdoc) {
97 if (strstr(strtolower($cdoc[
"title"]) , $v[
"kfam"]) !=
false) {
98 if ($v[
"include"]) $or.= ($or !=
"" ?
" OR " :
"") .
"(fromid" . ($v[
"include"] ?
"=" :
"!=") . $cdoc[
"initid"] .
")";
99 else $and.= ($and !=
"" ?
" AND " :
"") .
"(fromid" . ($v[
"include"] ?
"=" :
"!=") . $cdoc[
"initid"] .
")";
103 if ($or !=
"") $famfilter =
"($or)";
104 if ($and !=
"") $famfilter.= ($famfilter !=
"" ?
" AND " :
"") .
" ($and)";
106 $keys = $vardids = $displayedIds =
'';
111 $s->addFilter(
"usefor !~ '^S'");
112 $s->setObjectReturn();
115 $s->addGeneralFilter(
$keyword,
true, $searchMode ===
"characters");
116 $s->setPertinenceOrder();
119 $tkeys = $sdoc->getMultipleRawValues(
"se_keys");
120 foreach ($tkeys as $k => $v)
if (!$v) unset($tkeys[$k]);
121 $keys = implode(
'|', $tkeys);
123 if ($famfilter !=
"") $sqlfilters[] = $famfilter;
127 $vardids =
"did_$dirid";
129 $vardids =
"did_$famid$keys";
130 foreach ($sqlfilters as
$filter) {
131 $s->addFilter($filter);
134 $displayedIds = array();
136 $displayedIds = $action->read($vardids);
137 if ($displayedIds && count($displayedIds) > 0) {
138 $sqlExclude = sprintf(
"initid not in (%s)", implode(
",", $displayedIds));
139 $s->addFilter($sqlExclude);
144 $s->setSlice($slice + 1);
145 $s->excludeConfidential();
147 if (
$s->getError()) {
148 addLogMsg(
$s->getSearchInfo());
152 catch(Exception $e) {
157 if (
$s->count() < ($slice + 1)) $globalCount =
$s->count();
160 if (
$keyword) $sc->addGeneralFilter(
$keyword,
true, $searchMode ===
"characters");
162 $sc->useCollection(
$dirid);
164 foreach ($sqlfilters as
$filter) $sc->addFilter($filter);
166 $sc->addFilter(
"usefor !~ '^S'");
167 $sc->excludeConfidential();
168 $globalCount = $sc->onlyCount();
175 if (
$s->count() == ($slice + 1)) {
176 $action->lay->rSet(
"notthenend",
true);
180 $action->lay->rSet(
"notthenend",
false);
184 $action->lay->rSet(
"notfirst", (
$start != 0));
185 $action->lay->eSet(
"theFollowingText", _(
"View next results"));
190 while (
$doc =
$s->getNextDoc()) {
192 if (
$doc->confidential) {
193 if ((
$doc->profid > 0) && ($workdoc->controlId(
$doc->profid,
"confidential") !=
"")) {
197 $displayedIds[] =
$doc->initid;
199 $tdocs[$k][
"number"] = htmlspecialchars(
$c +
$start, ENT_QUOTES);
200 $tdocs[$k][
"title"] =
$doc->getHTMLTitle();
201 $tdocs[$k][
"id"] =
$doc->id;
203 $highlight =
$s->getHighLightText(
$doc,
'<strong>',
'</strong>', $action->GetParam(
"FULLTEXT_HIGHTLIGHTSIZE", 200) , $searchMode ===
"words");
204 $tokens = preg_split(
'!(</?strong>)!', $highlight, -1, PREG_SPLIT_DELIM_CAPTURE);
205 foreach ($tokens as & $token) {
206 if ($token ==
'<strong>' || $token ==
'</strong>') {
209 $token = htmlspecialchars($token, ENT_QUOTES);
211 $tdocs[$k][
"htext"] = str_replace(
'[',
'B;', nl2br(join(
'', $tokens)));
212 $tdocs[$k][
"iconsrc"] =
$doc->getIcon(
'', 20);
213 $tdocs[$k][
"mdate"] = strftime(
"%a %d %b %Y",
$doc->revdate);
219 array_pop($displayedIds);
221 $action->register($vardids, $displayedIds);
226 "xpage" => $i / $slice + 1,
231 $action->lay->eSetBlockData(
"PAGES", $tpages);
234 $action->lay->setBlockData(
"DOCS", $tdocs);
236 $action->lay->eset(
"dirid",
$dirid);
239 if ($sdoc->isAffected()) {
240 $action->lay->rSet(
"isdetail",
false);
241 $action->lay->eSet(
"searchtitle", $sdoc->title);
242 $action->lay->rSet(
"dirid", $sdoc->id);
246 $action->lay->rSet(
"cpage",
"0");
247 $action->lay->rSet(
"notfirst",
false);
248 $action->lay->rSet(
"notthenend",
false);
251 $famsuffix = (
$famid == 0 ?
"" : sprintf(
"<span class=\"families\">(%s %s)</span>", _(
"family search result") ,
$famtitle));
252 if ($globalCount == 0) {
253 $action->lay->rSet(
"resulttext", sprintf(_(
"No document found for <strong>%s</strong>%s") , htmlspecialchars(
$keyword) , $famsuffix));
254 }
else if ($globalCount == 1) {
255 $action->lay->rSet(
"resulttext", sprintf(_(
"One document for <strong>%s</strong>%s") , htmlspecialchars(
$keyword) , $famsuffix));
257 $action->lay->rSet(
"resulttext", sprintf(_(
"Found <strong>%d</strong> Result for <strong>%s</strong>%s") , $globalCount, htmlspecialchars(
$keyword) , $famsuffix));
259 $action->lay->rSet(
"displayBottomBar", ($globalCount == 0 ?
false :
true));
260 $action->lay->rSet(
"displayTopBar", ($page == 0));
262 $action->lay->eSet(
"searchdate",
Doc::getDate(0, 0, 0,
true));
267 $s9 = utf8_decode(
$s);
268 $s9 = strtr($s9, utf8_decode($c1) , utf8_decode($c2));
269 return utf8_encode($s9);
Layout is a template generator.
if($dbaccess=="") if($statusFile=== '') $famtitle
static getDate($daydelta=0, $dayhour="", $daymin="", $getlocale=false)
getNonSystemFamilies($dbaccess, $userid, $qtype="TABLE")
fullsearchresult(Action &$action)
exitError($texterr, $exit=true, $code="")
getLayoutFile($app, $layfile)
getFamIdFromName($dbaccess, $name)
static getArgument($k, $def= '')