Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
editfamilyenums.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 /**
9  * Modify enum items
10  * @param Action &$action current action
11  * @global string $famid Http var : document id
12  */
14 {
15  $usage = new ActionUsage($action);
16  $usage->setDefinitionText("Modify enum items");
17  $famId = $usage->addRequiredParameter("famid", "Family identifier", function ($id)
18  {
19  $fam = new_doc("", $id);
20  if (!$fam->doctype == "C") {
21  return sprintf("identifier %s is not a family", $id);
22  }
23  return '';
24  });
25  $viewOldInterface = $usage->addOptionalParameter("viewoldinterface", "link to old enum interface", array(
26  "yes",
27  "no"
28  ) , "no");
29  $usage->verify();
30  $fam = new_doc("", $famId);
31  $err = $fam->control("edit");
32  if ($err) {
33  $action->exitError($err);
34  }
35 
36  $action->lay->set("title", sprintf(_("Enum attributes for %s") , $fam->getHTMLTitle()));
37  $action->lay->set("famicon", $fam->getIcon('', 30));
38  $action->parent->addJsRef('lib/jquery/jquery.js');
39 
40  $action->parent->addJsRef("lib/jquery-ui/js/jquery-ui.js");
41  $action->parent->addJsRef("FDL:editfamilyenums.js");
42  $action->parent->addCssRef("css/dcp/jquery-ui.css");
43 
44  $lattr = $fam->getAttributes();
45  $tcf = array();
46  $lastFieldId = '';
47  /*
48  * @var NormalAttribute $oa
49  */
50  foreach ($lattr as $k => $oa) {
51  if ((($oa->type == "enum") || ($oa->type == "enumlist")) && (($oa->phpfile == "") || ($oa->phpfile == "-")) && ($oa->getOption("system") != "yes")) {
52  $parentLabel = '';
53  $parentId = '';
54  $label = $oa->getLabel();
55  if (!empty($oa->fieldSet)) {
56  $parentLabel = $oa->fieldSet->getLabel();
57  $parentId = $oa->fieldSet->id;
58  if ($parentLabel == $label) {
59  if (!empty($oa->fieldSet->fieldSet)) {
60  $parentLabel = $oa->fieldSet->fieldSet->getLabel();
61  $parentId = $oa->fieldSet->fieldSet->id;
62  } else {
63  $parentId = "";
64  $parentLabel = '';
65  }
66  }
67  }
68  $tcf[] = array(
69  "label" => $label,
70  "parentLabel" => $parentLabel,
71  "sameParent" => ($parentId == $lastFieldId) ,
72  "famid" => $oa->docid,
73  "enumid" => $oa->id
74  );
75  $lastFieldId = $parentId;
76  }
77  }
78 
79  $action->lay->set("linkOld", $viewOldInterface == "yes");
80  $action->lay->set("familyid", $fam->id);
81 
82  $action->lay->set("NOENUMS", empty($tcf));
83  $action->lay->setBlockData("ENUMS", $tcf);
84 }
85 ?>
global $action
editfamilyenums(Action &$action)
exitError($texterr, $exit=true, $code="")
Verify arguments for action function.
if($file) if($subject==""&&$file) if($subject=="") $err
$usage
← centre documentaire © anakeen