Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
editonedefaultvalue.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 
7 include_once ("FDL/Class.Doc.php");
8 include_once ("FDL/editutil.php");
10 {
11  $usage = new ActionUsage($action);
12 
13  $famid = $usage->addRequiredParameter("famid", "Family identifier", function ($value)
14  {
15  $family = new_doc("", $value);
16  if ($family->doctype !== "C") {
17  return "Must be a family identifier";
18  }
19  return '';
20  });
21  /*
22  * @var DocFam $family
23  */
24  $family = new_doc("", $famid);
25  $attrid = $usage->addRequiredParameter("attrid", "Attribute identifier", function ($value) use ($family)
26  {
27  $oa = $family->getAttribute($value);
28  if (!$oa) {
29  return sprintf("Attribute \"%s\" not found in family \"%s\"", $value, $family->name);
30  }
31  return '';
32  });
33 
34  $usage->verify();
35 
36  $err = $family->control("edit");
37  if ($err) {
38  $action->exitError($err);
39  }
40 
41  editmode($action);
42  $action->parent->addJsRef("FREEDOM/Layout/editonedefaultvalue.js");
43 
44  $oa = $family->getAttribute($attrid);
45 
46  $defval = $family->getDefValue($oa->id);
47 
48  if ($oa->fieldSet->type === "array") {
49  $oa->fieldSet->type = "frame";
50  }
51 
52  $oa->repeat = ($oa->getOption('multiple') === "yes");
53  $oa->setVisibility("W");
54  switch ($oa->type) {
55  case "longtext":
56  case "htmltext":
57  $multiline = true;
58  break;
59 
60  default:
61  $multiline = $oa->repeat;
62  }
63  switch ($oa->type) {
64  case "file":
65  case "image";
66  $inputName = "_UPL_" . $oa->id;
67  break;
68 
69  default:
70  $inputName = "_" . $oa->id;
71  if ($oa->repeat && $oa->type === "enum") {
72  $inputName.= '[]';
73  }
74 }
75 
76 $action->lay->set("inputname", $inputName);
77 $action->lay->set("multiline", $multiline);
78 $action->lay->set("family", $family->getHTMLTitle());
79 $action->lay->eset("value", $defval);
80 $action->lay->set("aid", $oa->id);
81 $action->lay->set("alabel", $oa->getLabel());
82 $action->lay->set("famid", $family->id);
83 
84 $action->lay->set("icon", $family->getIcon("", 32));
85 $action->lay->set("formatInput", getHtmlInput($family, $oa, $defval, "", "", true));
86 }
global $action
editonedefaultvalue(Action $action)
exitError($texterr, $exit=true, $code="")
getHtmlInput(&$doc, &$oattr, $value, $index="", $jsevent="", $notd=false)
Definition: editutil.php:30
Verify arguments for action function.
editmode(Action &$action)
Definition: editutil.php:41
if($file) if($subject==""&&$file) if($subject=="") $err
$usage
$value
← centre documentaire © anakeen