16 include_once (
"FDL/Class.PDocSearch.php");
17 include_once (
"FDL/Lib.Dir.php");
26 "and" =>
"and", #
N_(
"and")
41 if (((!isset($this->fromid))) || ($this->fromid ==
"")) $this->fromid =
FAM_SEARCH;
49 if (!is_object(
$doc) || !
$doc->isAlive() ||
$doc->defDoctype !=
'C') {
50 $err = sprintf(_(
'Family [%s] not found') , abs(
$famId));
82 $err = $this->addQuery($tquery);
89 if (is_array($tquery))
$query = implode(
";\n", $tquery);
92 if (
$query ==
"")
return "";
93 if ($this->
id ==
"")
return "";
95 $oqd =
new QueryDir($this->dbaccess);
100 if ($this->
id > 0) $this->
exec_query(
"delete from fld where dirid=" . intval($this->
id) .
" and qtype='M'");
116 return _(
"containt of searches cannot be modified");
129 $query->AddQuery(
"dirid=" . $this->
id);
130 $query->AddQuery(
"qtype != 'S'");
131 $tq =
$query->Query(0, 0,
"TABLE");
134 return $tq[0][
"query"];
165 if ((count(
$acls) > 0 && ($this->userid != 1))) {
167 foreach (
$acls as $acl) {
168 $dacl = $this->dacls[$acl];
170 $posacl = $dacl[
"pos"];
177 $filters[] =
"locked = -1";
178 $filters[] =
"lmodify = 'L'";
179 }
else if (
$latest ==
"allfixed") {
180 $filters[] =
"locked = -1";
183 $filters[] =
"locked = -1";
187 $filters[] = sprintf(
"archiveid = %d", $this->
getRawValue(
"se_archive"));
200 $filters = array_merge($filters, $sqlfilters);
201 $this->
setValue(
"se_orderby", $order);
207 if (strtolower(substr(
$keyword, 0, 5)) ==
"::get") {
210 $filters[] = sprintf(
"svalues %s '%s'", $op, pg_escape_string(
$keyword));
216 foreach ($tkey as $k => $v) {
218 if ($v[strlen($v) - 1] ==
'"') {
220 $ckey.=
" " . substr($v, 0, -1);
221 $filters[] = sprintf(
"svalues %s '%s'", $op, pg_escape_string($ckey));
225 }
else if ($v && $v[0] ==
'"') {
226 if ($v[strlen($v) - 1] ==
'"') {
227 $ckey = substr($v, 1, -1);
228 $filters[] = sprintf(
"svalues %s '%s'", $op, pg_escape_string($ckey));
231 $ckey = substr($v, 1);
234 $filters[] = sprintf(
"svalues %s '%s'", $op, pg_escape_string($v));
241 $filters[] = sprintf(
"usefor !~ '^S'");
242 $filters[] = sprintf(
"doctype != 'C'");
262 $pspell_link =
false;
263 if (function_exists(
'pspell_new')) {
264 $pspell_link = pspell_new(
"fr",
"",
"",
"utf-8", PSPELL_FAST);
267 $sqlfilters = array();
272 $sqlfiltersbrut = array();
273 $tsearchkeys = array();
274 foreach ($tkeys as $k => $key) {
277 $tsearchkeys[$k] = $key;
278 if ($pspell_link !==
false) {
279 if ((!is_numeric($key)) && (strstr($key,
'|') ===
false) && (strstr($key,
'&') ===
false) && (ord($key[0]) > 47) && (!pspell_check($pspell_link, $key))) {
280 $suggestions = pspell_suggest($pspell_link, $key);
281 $sug = $suggestions[0];
283 if ($sug && (
unaccent($sug) != $key) && (!strstr($sug,
' '))) $tsearchkeys[$k] =
"$key|$sug";
286 if (strstr($key,
'"') !==
false) {
288 if (strstr($key,
'|') ===
false) {
289 $sqlfiltersbrut[] =
"svalues ~* E'\\\\y" . pg_escape_string(str_replace(array(
299 ) , $key)) .
"\\\\y' ";
301 list($left, $right) = explode(
"|", $key);
302 if (strstr($left,
'"') !==
false) $q1 =
"svalues ~* E'\\\\y" . pg_escape_string(str_replace(array(
312 ) , $left)) .
"\\\\y' ";
314 if (strstr($right,
'"') !==
false) $q2 =
"svalues ~* E'\\\\y" . pg_escape_string(str_replace(array(
324 ) , $right)) .
"\\\\y' ";
326 $q3 =
"fulltext @@ to_tsquery('french','" . pg_escape_string(
unaccent($left)) .
"') ";
327 $q4 =
"fulltext @@ to_tsquery('french','" . pg_escape_string(
unaccent($right)) .
"') ";
329 if ((!$q1) && $q2) $sqlfiltersbrut[] =
"($q4 and $q2) or $q3";
330 elseif ((!$q2) && $q1) $sqlfiltersbrut[] =
"($q3 and $q1) or $q4";
331 elseif ($q2 && $q1) $sqlfiltersbrut[] =
"($q3 and $q1) or ($q4 and $q2)";
337 if (count($tsearchkeys) > 0) {
338 $fullkeys =
'(' . implode(
")&(", $tsearchkeys) .
')';
340 $fullkeys = pg_escape_string($fullkeys);
341 $sqlfilters[] = sprintf(
"fulltext @@ to_tsquery('french','%s') ", pg_escape_string($fullkeys));
343 if (count($sqlfiltersbrut) > 0) $sqlfilters = array_merge($sqlfilters, $sqlfiltersbrut);
344 $sqlorder = sprintf(
"ts_rank(fulltext,to_tsquery('french','%s')) desc", pg_escape_string($fullkeys));
350 if ($subfolder) $cdirid =
getRChildDirId($this->dbaccess,
$dirid, array() , 0, $this->folderRecursiveLevel);
370 $query =
getSqlSearchDoc($this->dbaccess, $cdirid,
$famid, $filters,
false,
$latest ==
"yes", $this->
getRawValue(
"se_trash") ,
false, $level = 2, $join =
'', $only);
397 else $query =
'select id from only doc where false';
412 $this->lay->eset(
"rtarget", $rtarget);
413 $this->lay->set(
"restrict",
false);
414 $this->lay->set(
"archive",
false);
416 $farch = new_doc($this->dbaccess,
"ARCHIVING");
417 if ($farch) $this->lay->set(
"archive", ($farch->control(
"view") ==
""));
418 $this->lay->eset(
"thekey", $this->
getRawValue(
"se_key"));
419 $dirid = GetHttpVars(
"dirid");
420 $action->parent->AddJsRef($action->GetParam(
"CORE_PUBURL") .
"/lib/jquery/jquery.js");
421 $action->parent->AddJsRef($action->GetParam(
"CORE_PUBURL") .
"/FDL/Layout/edittable.js");
422 $action->parent->AddJsRef($action->GetParam(
"CORE_PUBURL") .
"/FREEDOM/Layout/editdsearch.js");
430 if (method_exists(
$dir,
"isAuthorized")) {
431 if (
$dir->isAuthorized($classid)) {
433 if (
$dir->hasNoRestriction()) {
434 $tclassdoc =
GetClassesDoc($this->dbaccess, $action->user->id, $classid,
"TABLE");
436 $tclassdoc =
$dir->getAuthorizedFamilies();
437 $this->lay->set(
"restrict",
true);
440 $tclassdoc =
$dir->getAuthorizedFamilies();
441 $first = current($tclassdoc);
442 $famid = abs($first[
"id"]);
443 $this->lay->set(
"restrict",
true);
446 $tclassdoc =
GetClassesDoc($this->dbaccess, $action->user->id, $classid,
"TABLE");
449 $tclassdoc =
GetClassesDoc($this->dbaccess, $action->user->id, $classid,
"TABLE");
452 $this->lay->eset(
"selfam", _(
"no family"));
453 $selectclass = array();
454 foreach ($tclassdoc as $k => $cdoc) {
455 $selectclass[$k][
"idcdoc"] = $cdoc[
"id"];
456 $selectclass[$k][
"classname"] = $cdoc[
"title"];
457 $selectclass[$k][
"system_fam"] = (substr($cdoc[
"usefor"], 0, 1) ==
'S') ?
true :
false;
458 if (abs($cdoc[
"initid"]) == abs(
$famid)) {
459 $selectclass[$k][
"selected"] =
"selected";
460 if (
$famid < 0) $this->lay->eset(
"selfam", $cdoc[
"title"] .
" " . !!_(
"(only)"));
461 else $this->lay->eset(
"selfam", $cdoc[
"title"]);
462 }
else $selectclass[$k][
"selected"] =
"";
465 $this->lay->SetBlockData(
"SELECTCLASS", $selectclass);
466 $this->lay->set(
"has_permission_fdl_system", $action->parent->hasPermission(
'FDL',
'SYSTEM'));
467 $this->lay->set(
"se_sysfam", ($this->
getRawValue(
'se_sysfam') ==
'yes') ?
true :
false);
490 $orderby = $this->
getRawValue(
"se_orderby",
"title");
491 $tdoc =
internalGetDocCollection($this->dbaccess, $this->initid, 0,
"ALL",
$filter, $uid,
"TABLE",
$famid,
false, $orderby,
true, $this->
getRawValue(
"se_trash"));
static getMemberOfVector($uid=0, $strict=false)
__construct($dbaccess= '', $id= '', $res= '', $dbid=0)
getSqlSearchDoc($dbaccess, $dirid, $fromid, $sqlfilters=array(), $distinct=false, $latest=true, $trash="", $simplesearch=false, $folderRecursiveLevel=2, $join= '', $only="")
static getFullSqlFilters($keyword, &$sqlfilters, &$sqlorder, &$fullkeys)
exec_query($sql, $lvl=0, $prepare=false)
getContent($controlview=true, array $filter=array(), $famid="", $qtype="TABLE", $trash="")
getSqlGeneralFilters($keyword, $latest, $sensitive, $full=false)
modify($nopost=false, $sfields="", $nopre=false)
GetClassesDoc($dbaccess, $userid, $classid=0, $qtype="LIST", $extraFilters=array())
setValue($attrid, $value, $index=-1, &$kvalue=null)
getMultipleRawValues($idAttr, $def="", $index=-1)
getHttpVars($name, $def="", $scope="all")
internalGetDocCollection($dbaccess, $dirid, $start="0", $slice="ALL", $sqlfilters=array(), $userid=1, $qtype="LIST", $fromid="", $distinct=false, $orderby="title", $latest=true, $trash="", &$debug=null, $folderRecursiveLevel=2, $join= '',\SearchDoc &$searchDoc=null)
getFamIdFromName($dbaccess, $name)
ComputeQuery($keyword="", $famid=-1, $latest="yes", $sensitive=false, $dirid=-1, $subfolder=true, $full=false)
getRChildDirId($dbaccess, $dirid, $rchilds=array(), $level=0, $levelmax=2)
new_Doc($dbaccess, $id= '', $latest=false)
__construct($dbaccess= '', $id= '', $res= '', $dbid=0)
if(($docid!==0)&&(!is_numeric($docid))) $query
if($file) if($subject==""&&$file) if($subject=="") $err
getRawValue($idAttr, $def="")