Core  3.2
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  * @package FDL
5 */
6 /**
7  * Generated Header (not documented yet)
8  *
9  * @author Anakeen
10  * @version $Id: generic_search_kind.php,v 1.15 2008/08/14 09:59:14 eric Exp $
11  * @package FDL
12  * @subpackage
13  */
14 /**
15  */
16 // ---------------------------------------------------------------
17 // $Id: generic_search_kind.php,v 1.15 2008/08/14 09:59:14 eric Exp $
18 // $Source: /home/cvsroot/anakeen/freedom/freedom/Action/Generic/generic_search_kind.php,v $
19 // ---------------------------------------------------------------
20 include_once ("FDL/Class.DocSearch.php");
21 include_once ("FDL/freedom_util.php");
22 include_once ("GENERIC/generic_util.php");
23 // -----------------------------------
25 {
26  // -----------------------------------
27  // Get all the params
28  $kid = $action->getArgument("kid"); // kind id to search
29  $aid = $action->getArgument("aid"); // attribute to search
30  $dirid = $action->getArgument("catg"); // folder or research to search
31  $onefamOrigin = $action->getArgument("onefam"); // onefam origin
32  $dbaccess = $action->dbaccess;
33 
34  $famid = getDefFam($action);
35  $fdoc = new_Doc($dbaccess, $famid);
36  /*
37  * @var NormalAttribute $attr
38  */
39  $attr = $fdoc->getAttribute($aid);
40  $enum = $attr->getEnum();
41  $kindname = $enum[$kid];
42 
44  /*
45  * @var DocSearch $sdoc
46  */
47  $sdoc = createTmpDoc($dbaccess, 5); //new DocSearch($dbaccess);
48  $sdoc->title = sprintf(_("search %s") , $kid);
49  if (($dirid == 0) || ($dir->id == getDefFld($action))) $sdoc->title = sprintf(_("search %s is %s") , $attr->getLabel() , $kindname);
50  else $sdoc->title = sprintf(_("search %s is %s in %s") , $attr->getLabel() , $kindname, $dir->gettitle());
51 
52  $sdoc->Add();
53 
54  $searchquery = "";
55  $sdirid = 0;
56  if ($dir->defDoctype == 'S') { // case of search in search doc
57  $sdirid = $dir->id;
58  $pds = $dir->urlWhatEncodeSpec("");
59  //print "<hr>pds=$pds";
60 
61  } else { // case of search in folder
62  if ($dir->id != getDefFld($action)) $sdirid = $dirid;
63  }
64 
65  $kid = str_replace('\.', '-dot-', $kid);
66  if (strrpos($kid, '.') !== false) $kid = substr($kid, strrpos($kid, '.') + 1); // last reference
67  // clear key
68  $action->parent->param->Set("GENE_LATESTTXTSEARCH", setUkey($action, $famid, '') , Param::PARAM_USER . $action->user->id, $action->parent->id);
69 
70  $sqlfilter[] = "locked != -1";
71  // $sqlfilter[]= "doctype='F'";
72  // $sqlfilter[]= "usefor != 'D'";
73  // searches for all fathers kind
74  $a = $fdoc->getAttribute($aid);
75  /*
76  * @var NormalAttribute $a
77  */
78  $enum = $a->getEnum();
79  $tkids = array();;
80  foreach ($enum as $k => $v) {
81  $k = str_replace('\.', '-dot-', $k);
82  if (in_array($kid, explode(".", $k))) {
83  $tkids[] = pg_escape_string(str_replace('-dot-', '.', substr($k, strrpos("." . $k, '.'))));
84  }
85  }
86  if ($a->type == "enum") {
87  if ($a->repeat) {
88  $sqlfilter[] = "in_textlist($aid,'" . implode("') or in_textlist($aid,'", $tkids) . "')";
89  } else {
90  $sqlfilter[] = "$aid='" . implode("' or $aid='", $tkids) . "'";
91  }
92  }
93 
94  $query = getSqlSearchDoc($dbaccess, $sdirid, $famid, $sqlfilter);
95 
96  $sdoc->AddQuery($query);
97 
98  redirect($action, $action->getArgument("app") , "GENERIC_LIST&onefam=$onefamOrigin&famid=$famid&dirid=" . $sdoc->id . "&catg=" . $dirid);
99 }
global $action
getSqlSearchDoc($dbaccess, $dirid, $fromid, $sqlfilters=array(), $distinct=false, $latest=true, $trash="", $simplesearch=false, $folderRecursiveLevel=2, $join= '', $only="")
Definition: Lib.Dir.php:108
print< H1 > Check Database< i > $dbaccess</i ></H1 > $a
Definition: checklist.php:45
getDefFld(Action &$action)
generic_search_kind(Action &$action)
getDefFam(Action &$action)
Set($name, &$parent)
const PARAM_USER
Definition: Class.Param.php:34
new_Doc($dbaccess, $id= '', $latest=false)
setUkey(Action &$action, $famid, $key)
$dir
Definition: resizeimg.php:144
static getArgument($k, $def= '')
$dbaccess
Definition: checkVault.php:17
if(($docid!==0)&&(!is_numeric($docid))) $query
createTmpDoc($dbaccess, $fromid, $defaultvalue=true)
← centre documentaire © anakeen