Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
generic_modkind.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
5  * @package FDL
6 */
7 /**
8  * Modify item os enumerate attributes
9  *
10  * @author Anakeen 2000
11  * @version $Id: generic_modkind.php,v 1.8 2008/08/14 09:59:14 eric Exp $
12  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
13  * @package FDL
14  * @subpackage
15  */
16 /**
17  */
18 
19 include_once ("FDL/Class.Doc.php");
20 include_once ("FDL/Class.DocAttr.php");
21 include_once ("FDL/Lib.Attr.php");
22 include_once ("GENERIC/generic_util.php");
23 // -----------------------------------
25 {
26  // -----------------------------------
27  $dbaccess = $action->GetParam("FREEDOM_DB");
28 
29  $aid = GetHttpVars("aid"); // attribute id
30  $famid = GetHttpVars("fid"); // family id
31  $tlevel = GetHttpVars("alevel"); // levels
32  $tref = GetHttpVars("aref"); // references
33  $tlabel = GetHttpVars("alabel"); // label
34  $tsref = array();
35  $tsenum = array();
36  $ref = "";
37  $ple = 1;
38  if (is_array($tref)) {
39  while (list($k, $v) = each($tref)) {
40  $le = intval($tlevel[$k]);
41  if ($le == 1) {
42  $ref = '';
43  } else if ($ple < $le) {
44  // add level ref index
45  $ref = $ref . str_replace(".", "-dot-", $tref[$k - 1]) . '.';
46  } else if ($ple > $le) {
47  // suppress one or more level ref index
48  for ($l = 0; $l < $ple - $le; $l++) {
49  $ref = substr($ref, 0, strrpos($ref, '.') - 1);
50  }
51  }
52  $ple = $le;
53  $tsenum[$k] = stripslashes($ref . str_replace(".", "-dot-", $v) . "|" . $tlabel[$k]);
54  }
55  }
56 
57  $attr = new DocAttr($dbaccess, array(
58  $famid,
59  $aid
60  ));
61  if ($attr->isAffected()) {
62 
63  if (preg_match("/\[([a-z]+)\](.*)/", $attr->phpfunc, $reg)) {
64  $funcformat = $reg[1];
65  } else {
66  $funcformat = "";
67  }
68  $attr->phpfunc = str_replace("-dot-", "\\.", implode(",", str_replace(',', '\,', ($tsenum))));
69  if ($funcformat != "") $attr->phpfunc = "[$funcformat]" . $attr->phpfunc;
70  $attr->modify();
71 
73  }
74 
75  $fdoc = new_doc($dbaccess, $famid);
76  $a = $fdoc->getAttribute($aid);
77  if ($a) {
78  $enum = $a->getenum();
79  foreach ($enum as $kk => $ki) {
80  $klabel = $a->getEnumLabel($ki);
81  //array_pop(explode('/',$ki,substr_count($kk, '.')+1));
82  $tvkind[] = array(
83  "ktitle" => $klabel,
84  "level" => substr_count($kk, '.') * 20,
85  "kid" => $kk
86  );
87  }
88 
89  $action->lay->SetBlockData("vkind", $tvkind);
90  }
91 
92  $action->lay->Set("desc", sprintf(_("Modification for attribute %s for family %s") , $a->getLabel() , $fdoc->title));
93 }
94 ?>
← centre documentaire © anakeen - published under CC License - Dynacase