Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
editdefaultvalues.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  $famid = $usage->addRequiredParameter("famid", "Family identifier", function ($value)
13  {
14  $family = new_doc("", $value);
15  if ($family->doctype !== "C") {
16  return "Must be a family identifier";
17  }
18  return "";
19  });
20  $family = new_doc("", $famid);
21 
22  $usage->verify();
23 
24  $err = $family->control("edit");
25  if ($err) {
26  $action->exitError($err);
27  }
28  editmode($action);
29  $action->parent->addJsRef("lib/jquery-ui/js/jquery-ui.js");
30  $action->parent->addJsRef("lib/jquery-dataTables/js/jquery.dataTables.min.js");
31  $action->parent->addCssRef("css/dcp/jquery-ui.css");
32  $action->parent->addCssRef("lib/jquery-dataTables/css/jquery.dataTables.css");
33  $action->parent->addJsRef("FREEDOM/Layout/editdefaultvalues.js");
34  /*
35  * @var DocFam $family
36  */
37  $oas = $family->getAttributes();
38  $d = createDoc($action->dbaccess, $family->id, false, true, false);
39  $taDefval = $tpDefval = array();
40  foreach ($oas as $oa) {
41  if ($oa->isNormal && $oa->type !== "array") {
42  /*
43  * @var NormalAttribute $oa
44  */
45  $defval = $family->getDefValue($oa->id);
46  if ($defval) {
47  if ($oa->type === "file" || $oa->type === "image") {
48  $htmlvalue = $family->getHtmlValue($oa, $defval, "_blank");
49  } else {
50  $htmlvalue = $d->getHtmlAttrValue($oa->id, "_blank");
51  }
52  if ($oa->type === "image") {
53  $htmlvalue = sprintf('<img class="image" src="%s">', $htmlvalue);
54  }
55  } else {
56  $htmlvalue = '';
57  }
58  $row = array(
59  "aid" => $oa->id,
60  "alabel" => htmlspecialchars(sprintf("%s / %s", $oa->fieldSet->getLabel() , $oa->getLabel())) ,
61  "multiline" => ($oa->isMultiple() || $oa->type === "longtext" || $oa->type === "htmltext") ,
62  "defval" => htmlspecialchars($defval, ENT_QUOTES) ,
63  "htmlval" => $htmlvalue
64  );
65 
66  if ($oa->usefor === "Q") {
67  $tpDefval[] = $row;
68  } else {
69  $taDefval[] = $row;
70  }
71  }
72  }
73 
74  $action->lay->setBlockData("ADEFAULTS", $taDefval);
75  $action->lay->setBlockData("PDEFAULTS", $tpDefval);
76  $action->lay->set("hasParam", count($tpDefval) > 0);
77 
78  $action->lay->set("famid", $family->id);
79  $action->lay->set("family", $family->getHTMLTitle());
80  $action->lay->set("icon", $family->getIcon("", 32));
81 }
global $action
$d
Definition: dav.php:77
exitError($texterr, $exit=true, $code="")
createDoc($dbaccess, $fromid, $control=true, $defaultvalues=true, $temporary=false)
Verify arguments for action function.
editdefaultvalues(Action $action)
editmode(Action &$action)
Definition: editutil.php:41
if($file) if($subject==""&&$file) if($subject=="") $err
$usage
$value
← centre documentaire © anakeen