Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
generic_search_kind.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
5  * @package FDL
6 */
7 /**
8  * Generated Header (not documented yet)
9  *
10  * @author Anakeen 2000
11  * @version $Id: generic_search_kind.php,v 1.15 2008/08/14 09:59:14 eric Exp $
12  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
13  * @package FDL
14  * @subpackage
15  */
16 /**
17  */
18 // ---------------------------------------------------------------
19 // $Id: generic_search_kind.php,v 1.15 2008/08/14 09:59:14 eric Exp $
20 // $Source: /home/cvsroot/anakeen/freedom/freedom/Action/Generic/generic_search_kind.php,v $
21 // ---------------------------------------------------------------
22 include_once ("FDL/Class.DocSearch.php");
23 include_once ("FDL/freedom_util.php");
24 include_once ("GENERIC/generic_util.php");
25 // -----------------------------------
27 {
28  // -----------------------------------
29  // Get all the params
30  $kid = GetHttpVars("kid"); // kind id to search
31  $aid = GetHttpVars("aid"); // attribute to search
32  $dirid = GetHttpVars("catg"); // folder or research to search
33  $dbaccess = $action->GetParam("FREEDOM_DB");
34 
37 
38  $attr = $fdoc->getAttribute($aid);
39  $enum = $attr->getEnum();
40  $kindname = $enum[$kid];
41 
42  $dir = new_Doc($dbaccess, $dirid);
43 
44  $sdoc = createTmpDoc($dbaccess, 5); //new DocSearch($dbaccess);
45  $sdoc->title = sprintf(_("search %s") , $keyword);
46  if (($dirid == 0) || ($dir->id == getDefFld($action))) $sdoc->title = sprintf(_("search %s is %s") , $attr->getLabel() , $kindname);
47  else $sdoc->title = sprintf(_("search %s is %s in %s") , $attr->getLabel() , $kindname, $dir->gettitle());
48 
49  $sdoc->Add();
50 
51  $searchquery = "";
52  $sdirid = 0;
53  if ($dir->defDoctype == 'S') { // case of search in search doc
54  $sdirid = $dir->id;
55  $pds = $dir->urlWhatEncodeSpec("");
56  //print "<hr>pds=$pds";
57 
58  } else { // case of search in folder
59  if ($dir->id != getDefFld($action)) $sdirid = $dirid;
60  }
61 
62  $kid = str_replace('\.', '-dot-', $kid);
63  if (strrpos($kid, '.') !== false) $kid = substr($kid, strrpos($kid, '.') + 1); // last reference
64  // clear key
65  $action->parent->param->Set("GENE_LATESTTXTSEARCH", setUkey($action, $famid, $keyword) , PARAM_USER . $action->user->id, $action->parent->id);
66 
67  $sqlfilter[] = "locked != -1";
68  // $sqlfilter[]= "doctype='F'";
69  // $sqlfilter[]= "usefor != 'D'";
70  // searches for all fathers kind
71  $a = $fdoc->getAttribute($aid);
72  $enum = $a->getEnum();
73  $tkids = array();;
74  foreach ($enum as $k => $v) {
75  $k = str_replace('\.', '-dot-', $k);
76  if (in_array($kid, explode(".", $k))) {
77  $tkids[] = pg_escape_string(str_replace('-dot-', '.', substr($k, strrpos("." . $k, '.'))));
78  }
79  }
80  if ($a->type == "enum") {
81  if ($a->repeat) {
82  $sqlfilter[] = "in_textlist($aid,'" . implode("') or in_textlist($aid,'", $tkids) . "')";
83  } else {
84  $sqlfilter[] = "$aid='" . implode("' or $aid='", $tkids) . "'";
85  }
86  }
87 
88  $query = getSqlSearchDoc($dbaccess, $sdirid, $famid, $sqlfilter);
89 
90  $sdoc->AddQuery($query);
91 
92  redirect($action, GetHttpVars("app") , "GENERIC_LIST$pds&famid=$famid&dirid=" . $sdoc->id . "&catg=" . $dirid);
93 }
94 ?>
← centre documentaire © anakeen - published under CC License - Dynacase