Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
Class.ADoc.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 /**
7  * Attribute Document Object Definition
8  *
9  * @author Anakeen
10  * @version $Id: Class.ADoc.php,v 1.13 2006/04/03 14:56:26 eric Exp $
11  * @package FDL
12  */
13 /**
14  */
15 
16 include_once ("FDL/Class.DocAttribute.php");
17 /**
18  * Attribute Document Class
19  *
20  */
21 class ADoc
22 {
23  /**
24  * @var BasicAttribute[]
25  */
26  public $attr = array();
27  public $fromname = '';
28  public $isOrdered = false;
29  protected $absoluteOrders = [];
30  const HIDDENFIELD = "FIELD_HIDDENS";
31  /**
32  * @var array
33  */
34  public $fields = array();
35  /**
36  * @var array family ancestors ids
37  */
38  public $fromids = array();
39 
40  public function __construct()
41  {
42  $this->attr[self::HIDDENFIELD] = new FieldSetAttribute(self::HIDDENFIELD, 0, "hiddens");
43  }
44  /**
45  * @param string $id attribute identifier
46  * @return BasicAttribute|false
47  */
48  public function getAttr($id)
49  {
50  if (isset($this->attr[$id])) return $this->attr[$id];
51  if (isset($this->attr[strtolower($id) ])) return $this->attr[strtolower($id)];
52 
53  return false;
54  }
55  /**
56  * get attributes ids
57  */
58  public function getAttrIds()
59  {
60  return array_keys($this->attr);
61  }
62  /**
63  * return all the attributes except frame & menu & action
64  * @param bool $onlyopt
65  * @return NormalAttribute[]
66  */
67  public function GetNormalAttributes($onlyopt = false)
68  {
69  $tsa = array();
70  if (isset($this->attr)) {
71  foreach ($this->attr as & $v) {
72  if ((isset($v->isNormal)) && ((($v->usefor != "Q") && (!$onlyopt)) || (($v->usefor == "O") && ($onlyopt)))) $tsa[$v->id] = & $v;
73  }
74  }
75  return $tsa;
76  }
77  /**
78  * return action attributes
79  *
80  * @return ActionAttribute[]
81  */
82  public function GetActionAttributes()
83  {
84  $tsa = array();
85 
86  foreach ($this->attr as $k => $v) {
87  if (get_class($v) == "ActionAttribute") $tsa[$v->id] = $v;
88  }
89  return $tsa;
90  }
91  /**
92  * return all the family parameters except frame & menu & action
93  * @return NormalAttribute[]
94  */
95  public function getParamAttributes()
96  {
97  $tsa = array();
98  if (isset($this->attr)) {
99  reset($this->attr);
100  foreach ($this->attr as $k => $v) {
101  if (is_object($v) && (get_class($v) == "NormalAttribute") && ($v->usefor == "Q")) $tsa[$v->id] = $v;
102  }
103  }
104  return $tsa;
105  }
106  /**
107  * get attributes included in an arrary
108  * @return NormalAttribute[]|false
109  */
110  public function getArrayElements($id)
111  {
112  $a = $this->getAttr($id);
113 
114  if ($a && ($a->type == "array")) {
115  if ($a->usefor != "Q") {
116  $tsa = $this->GetNormalAttributes();
117  } else {
118  $tsa = $this->getParamAttributes();
119  }
120  $ta = array();
121  foreach ($tsa as $k => $v) {
122  if ($v->fieldSet->id == $id) $ta[$v->id] = $v;
123  }
124  return $ta;
125  }
126  return false;
127  }
128 
129  public function orderAttributes($force = true)
130  {
131  if (!$this->isOrdered || $force) {
132  $this->absoluteOrders[self::HIDDENFIELD] = 0;
133  $tmpSort = $this->attr;
134  $this->attr = [];
135  asort($this->absoluteOrders);
136  foreach ($this->absoluteOrders as $aid => $absorder) {
137  $this->attr[$aid] = & $tmpSort[$aid];
138  }
139  $this->isOrdered = true;
140  }
141  }
142  /**
143  * Add volatile attribute to document structure
144  *
145  * @param BasicAttribute $attr
146  */
148  {
149  $this->attr[$attr->id] = $attr;
150  if (is_numeric($attr->ordered)) {
151  $this->absoluteOrders[$attr->id] = $attr->ordered;
152  } else {
153  $this->absoluteOrders[$attr->id] = (count($this->absoluteOrders) + 1) * 10;
154  }
155  }
156 }
getAttrIds()
Definition: Class.ADoc.php:58
print< H1 > Check Database< i > $dbaccess</i ></H1 > $a
Definition: checklist.php:45
orderAttributes($force=true)
Definition: Class.ADoc.php:129
__construct()
Definition: Class.ADoc.php:40
GetNormalAttributes($onlyopt=false)
Definition: Class.ADoc.php:67
getAttr($id)
Definition: Class.ADoc.php:48
$force
$fromids
Definition: Class.ADoc.php:38
const HIDDENFIELD
Definition: Class.ADoc.php:30
getParamAttributes()
Definition: Class.ADoc.php:95
$absoluteOrders
Definition: Class.ADoc.php:29
addAttribute(\BasicAttribute $attr)
Definition: Class.ADoc.php:147
$isOrdered
Definition: Class.ADoc.php:28
GetActionAttributes()
Definition: Class.ADoc.php:82
getArrayElements($id)
Definition: Class.ADoc.php:110
$fromname
Definition: Class.ADoc.php:27
← centre documentaire © anakeen