17 include_once
"FDL/Class.Doc.php";
27 $usage->setDefinitionText(
"Return list of items for an enumerate attribute");
28 $famid =
$usage->addRequiredParameter(
"famid",
"Family identifier",
function ($fid)
30 $fam = new_doc(
"", $fid);
31 if (!$fam->isAlive()) {
32 return sprintf(
"document \"%s\" not found", $fid);
33 } elseif ($fam->doctype !=
'C') {
34 return sprintf(
"document \"%s\" is not a family", $fid);
38 $enumId =
$usage->addRequiredParameter(
"enumid",
"Enum identifier",
function ($eid) use (
$famid)
40 $fam = new_doc(
"",
$famid);
41 $oa = $fam->getAttribute($eid);
43 return sprintf(
"enumerate attribute \"%s\" not found", $eid);
44 } elseif ($oa->type !=
"enum") {
45 return sprintf(
"attribute \"%s\" is not an enum. Is is a \"%s\" ", $eid, $oa->type);
55 $err = $e->getDcpMessage();
62 $fam = new_doc(
"",
$famid);
63 $oa = $fam->getAttribute($enumId);
70 foreach ($enums as $enum) {
74 "label" => $enum[
"label"],
75 "parentKey" => $enum[
"parentkey"],
76 "disabled" => ($enum[
"disabled"] ==
"t") ,
77 "active" => ($enum[
"disabled"] !=
"t") ,
78 "order" => $enum[
"eorder"]
81 $localeConfig = array();
83 if (empty(
$locale[
"localeLabel"])) {
86 $localeConfig[] = array_merge(
$locale, array(
88 "flag" => sprintf(
"Images/flags/%s.png", strtolower(substr($klang, -2)))
91 foreach ($enums as $enum) {
93 $lkey = sprintf(
"%s#%s#%s", $fam->name, $oa->id, $key);
98 $items[$enum[
"key"]][
"locale"][] = array(
106 $label = $oa->getLabel();
107 if (!empty($oa->fieldSet)) {
108 $parentLabel = $oa->fieldSet->getLabel();
109 if ($parentLabel == $label) {
110 if (!empty($oa->fieldSet->fieldSet)) {
111 $parentLabel = $oa->fieldSet->fieldSet->getLabel();
119 "familyName" => $fam->name,
120 "familyTitle" => $fam->getHtmlTitle() ,
122 "enumLabel" => $oa->getLabel() ,
123 "parentLabel" => $parentLabel,
125 "localeConfig" => $localeConfig
128 $action->lay->template = json_encode(
$out);
129 $action->lay->noparse =
true;
130 header(
'Content-type: application/json');
getenumitems(Action &$action)
Verify arguments for action function.
static getFamilyEnums($famId, $attrid)
if($file) if($subject==""&&$file) if($subject=="") $err
Verify arguments for wsh programs.