Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
get_enum_label.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 
7 include_once "FDL/freedom_util.php";
8 
10 {
11  $keys = str_replace("\r\n", "\n", $action->getArgument("keys"));
12  $famid = $action->getArgument("famid");
13  $attrid = $action->getArgument("attrid");
14 
15  $alabels = array();
16  $return = array(
17  "success" => true,
18  "error" => "",
19  "data" => ""
20  );
21 
22  $famdoc = new_Doc($action->dbaccess, $famid);
23  if ($famdoc->isAlive()) {
24  /*
25  * @var NormalAttribute $attr
26  */
27  $attr = $famdoc->getAttribute($attrid);
28  $alabels = $attr->getEnumLabel($keys);
29  } else {
30  $return = array(
31  "success" => false,
32  "error" => sprintf(_("Document %s is not alive") , $famid) ,
33  "data" => ""
34  );
35  }
36  if (!empty($alabels)) {
37  $return["data"] = $alabels;
38  }
39  $action->lay->template = json_encode($return);
40  $action->lay->noparse = true;
41  header('Content-type: application/json');
42 }
global $action
get_enum_label(Action &$action)
new_Doc($dbaccess, $id= '', $latest=false)
static getArgument($k, $def= '')
← centre documentaire © anakeen