Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
editfamilyparameter.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 
7 include_once ("FDL/Class.Dir.php");
8 include_once ("FDL/editcard.php");
9 /**
10  * Compose family parameter edit field
11  * @param Action $action
12  * @return bool
13  */
15 {
16  $usage = new ActionUsage($action);
17  $famid = $usage->addRequiredParameter("famid", _("family id"));
18  $attrid = $usage->addRequiredParameter("attrid", _("attribute id"));
19  $default = $usage->addOptionalParameter("emptyValue", _("value for empty field"));
20  $value = $usage->addOptionalParameter("value", _("value in field"));
21  $onChange = $usage->addOptionalParameter("submitOnChange", _("Sending input on change?"));
22  $localSubmit = $usage->addOptionalParameter("localSubmit", _("Adding button to submit")) == "yes" ? true : false;
23  $submitLabel = $usage->addOptionalParameter("submitLabel", _("Label of submit button") , array() , _("Submit"));
24  $usage->setStrictMode();
25  $usage->verify();
26 
27  editmode($action);
28 
29  $action->lay->eset("famid", $famid);
30  $action->lay->eset("attrid", strtolower($attrid));
31  /*
32  * @var DocFam $doc
33  */
34  $doc = new_Doc($action->dbaccess, $famid, true);
35  if ($doc->isAlive()) {
36  /*
37  * @var NormalAttribute $attr
38  */
39  $attr = $doc->getAttribute($attrid);
40  if (!$attr) {
41  $action->AddWarningMsg(sprintf(_("Attribute [%s] is not found") , $attrid));
42  $action->lay->template = htmlspecialchars(sprintf(_("Attribute [%s] is not found") , $attrid) , ENT_QUOTES);
43  $action->lay->noparse = true;
44  return false;
45  }
46  $action->lay->eset("label", $attr->getLabel());
47 
48  if ($onChange == "no") {
49  $onChange = "";
50  } elseif ($onChange == "yes" || (!$onChange && !$localSubmit)) {
51  $onChange = "yes";
52  }
53  $action->lay->eset("local_submit", $localSubmit);
54  $action->lay->eset("submit_label", $submitLabel);
55 
56  if (!$value) {
57  if ($default !== null) {
58  $value = $default;
59  } else {
60  $value = $doc->getParameterRawValue($attrid, $doc->GetValueMethod($attrid));
61  }
62  }
63  $d = createTmpDoc($action->dbaccess, $doc->id);
64  $fdoc = $d->getFamilyDocument();
65  $d->setDefaultValues($fdoc->getParams() , false);
67  $input_field = getHtmlInput($d, $attr, $value, "", "", true);
68  $action->lay->set("input_field", $input_field);
69  $action->lay->set("change", ($onChange != ""));
70  } else {
71  $action->AddWarningMsg(sprintf(_("Family [%s] not found") , $famid));
72  $action->lay->template = htmlspecialchars(sprintf(_("Family [%s] not found") , $famid) , ENT_QUOTES);
73  $action->lay->noparse = true;
74  return false;
75  }
76 
77  $action->parent->addJsRef("FDL/Layout/editparameter.js");
78  return true;
79 }
global $action
editfamilyparameter(Action &$action)
$d
Definition: dav.php:77
getHtmlInput(&$doc, &$oattr, $value, $index="", $jsevent="", $notd=false)
Definition: editutil.php:30
Verify arguments for action function.
new_Doc($dbaccess, $id= '', $latest=false)
useOwnParamters(Doc &$doc)
Definition: editcard.php:207
editmode(Action &$action)
Definition: editutil.php:41
createTmpDoc($dbaccess, $fromid, $defaultvalue=true)
$usage
$value
← centre documentaire © anakeen