Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
vconstraint.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  * Verify constraint on special attribute
9  *
10  * @author Anakeen 2003
11  * @version $Id: vconstraint.php,v 1.6 2008/02/27 08:55:53 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 include_once ("FDL/Class.DocFam.php");
20 include_once ("FDL/modcard.php");
21 
22 function vconstraint(&$action)
23 {
24 
25  $docid = GetHttpVars("id", 0);
26  $famid = GetHttpVars("famid", GetHttpVars("classid"));
27  $attrid = GetHttpVars("attrid");
28  $index = GetHttpVars("index", -1); // index of the attributes for arrays
29  $domindex = GetHttpVars("domindex", ""); // index in dom of the attributes for arrays
30  if ($index === "") $index = - 1;
31 
32  $action->parent->AddJsRef($action->GetParam("CORE_JSURL") . "/geometry.js");
33  $dbaccess = $action->GetParam("FREEDOM_DB");
34 
35  if ($docid > 0) {
37  } else {
38 
39  $doc = createDoc($dbaccess, $famid, false);
40  }
42 
43  $res = $doc->verifyConstraint($attrid, $index);
44 
45  if (is_array($res)) { // error with suggestion
46  $action->lay->Set("error", $res["err"]);
47  $action->lay->Set("iserror", ($res["err"] == "") ? "" : "ko");
48  $rargids = array(
49  $attrid
50  );
51  while (list($k, $v) = each($rargids)) {
52  $rargids[$k].= $domindex;
53  }
54  $sattrid = "[";
55  $sattrid.= strtolower("'" . implode("','", $rargids) . "'");
56  $sattrid.= "]";
57  $action->lay->Set("attrid", $sattrid);
58  // list suggestion
59  $tres = array();
60  if (is_array($res["sug"])) {
61  foreach ($res["sug"] as $sug) {
62  $tres[] = array(
63  $sug,
64  $sug
65  );
66  }
67  }
68 
69  $action->lay->set("suggest", (count($tres) > 0));
70  // view possible correction
71  while (list($k, $v) = each($tres)) {
72  $tselect[$k]["choice"] = htmlentities($v[0]);
73  $tselect[$k]["cindex"] = $k;
74  $tval[$k]["index"] = $k;
75  array_shift($v);
76 
77  foreach ($v as $kv => $vv) {
78  $v[$kv] = addslashes($vv);
79  }
80  $tval[$k]["attrv"] = "['" . implode("','", $v) . "']";
81  }
82  $action->lay->SetBlockData("SELECT", $tselect);
83  $action->lay->SetBlockData("ATTRVAL", $tval);
84  }
85 }
← centre documentaire © anakeen - published under CC License - Dynacase