Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
search.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 /**
7  * Search document
8  *
9  * @author Anakeen
10  * @version $Id: search.php,v 1.29 2008/12/30 17:14:40 eric Exp $
11  * @package FDL
12  * @subpackage GED
13  */
14 /**
15  */
16 
17 include_once ("FDL/Lib.Dir.php");
18 
19 include_once ("FDL/freedom_util.php");
20 
21 include_once ("FDL/modcard.php");
22 /**
23  * Search document
24  * @param Action &$action current action
25  * @global keyword string Http var : word to search in any values
26  * @global famid int Http var : restrict to this family identioficator
27  * @global viewone string Http var : (Y|N) if Y direct view document detail if only one returned
28  * @global view string Http var : display mode : icon|column|list
29  */
30 function search(Action & $action)
31 {
32  // -----------------------------------
33  $docid = GetHttpVars("id", 0);
34  $classid = GetHttpVars("classid", 0);
35  $keyword = GetHttpVars("_se_key", GetHttpVars("keyword")); // keyword to search
36  $viewone = GetHttpVars("viewone"); // direct view if only one Y|N
37  $target = GetHttpVars("target"); // target window when click on document
38  $view = GetHttpVars("view"); // display mode : icon|column|list
39  $famid = GetHttpVars("famid");
40  $generic = (GetHttpVars("ingeneric") == "yes");
41  $dbaccess = $action->dbaccess;
42 
43  if ($classid == 0) {
44  if ($docid > 0) {
46  $classid = $doc->fromid;
47  } else {
48  $classid = 5;
49  // $action->exitError(_("kind of search is not defined"));
50 
51  }
52  }
53  // new doc
54  $ndoc = createTmpDoc($dbaccess, $classid);
55  if (!$ndoc) $action->exitError(sprintf(_("no privilege to create this kind (%d) of document") , $classid));
56 
57  if ($keyword != "") $ndoc->title = _("new search ") . $keyword;
58  else {
59  if (!$famid) $famid = GetHttpVars("_se_famid");
60  if ($famid > 0) {
61  $fam = $ndoc->getTitle($famid);
62  $ndoc->title = sprintf(_("search %s") , $fam);
63  } else {
64  $ndoc->title = sprintf(_("search result"));
65  }
66  }
67  $ndoc->setValue("se_key", $keyword);
68  $ndoc->setValue("se_latest", "yes");
69  $ndoc->setValue("se_famid", $famid);
70  $err = $ndoc->Add();
71 
72  if ($err != "") $action->ExitError($err);
73  $ndoc->preRefresh();
74 
75  SetHttpVar("id", $ndoc->id);
76  $err = modcard($action, $ndocid); // ndocid change if new doc
77  $orderby = urlencode($ndoc->getRawValue("se_orderby"));
78 
79  if ($generic) {
80  redirect($action, "GENERIC", "GENERIC_LIST&famid=$famid&catg=0&dirid=" . $ndoc->id, $action->GetParam("CORE_STANDURL"));
81  } else {
82  redirect($action, GetHttpVars("app") , "FREEDOM_VIEW&view=$view&target=$target&viewone=$viewone&dirid=" . $ndoc->id . "&sqlorder=$orderby", $action->GetParam("CORE_STANDURL"));
83  }
84 }
global $action
SetHttpVar($name, $def)
Definition: Lib.Http.php:150
search(Action &$action)
Definition: search.php:30
$viewone
exitError($texterr, $exit=true, $code="")
$docid
Definition: cleanFamily.php:13
new_Doc($dbaccess, $id= '', $latest=false)
$keyword
$dbaccess
Definition: checkVault.php:17
modcard(Action &$action, &$ndocid, &$info=array())
Definition: modcard.php:30
createTmpDoc($dbaccess, $fromid, $defaultvalue=true)
if($file) if($subject==""&&$file) if($subject=="") $err
← centre documentaire © anakeen