Joomla Platform  13.1
Documentation des API du framework Joomla Platform
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Pages
node.php
Aller à la documentation de ce fichier.
1 <?php
2 /**
3  * @package Joomla.Legacy
4  * @subpackage Base
5  *
6  * @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
7  * @license GNU General Public License version 2 or later; see LICENSE
8  */
9 
10 defined('JPATH_PLATFORM') or die;
11 
12 /**
13  * Tree Node Class.
14  *
15  * @package Joomla.Legacy
16  * @subpackage Base
17  * @since 11.1
18  * @deprecated 12.3 (Platform) & 4.0 (CMS)
19  * @codeCoverageIgnore
20  */
21 class JNode extends JObject
22 {
23  /**
24  * Parent node
25  * @var object
26  *
27  * @since 11.1
28  */
29  protected $_parent = null;
30 
31  /**
32  * Array of Children
33  *
34  * @var array
35  * @since 11.1
36  */
37  protected $_children = array();
38 
39  /**
40  * Constructor
41  *
42  * @since 11.1
43  */
44  public function __construct()
45  {
46  JLog::add('JNode::__construct() is deprecated.', JLog::WARNING, 'deprecated');
47 
48  return true;
49  }
50 
51  /**
52  * Add child to this node
53  *
54  * If the child already has a parent, the link is unset
55  *
56  * @param JNode &$child The child to be added
57  *
58  * @return void
59  *
60  * @since 11.1
61  */
62  public function addChild(&$child)
63  {
64  JLog::add('JNode::addChild() is deprecated.', JLog::WARNING, 'deprecated');
65 
66  if ($child instanceof Jnode)
67  {
68  $child->setParent($this);
69  }
70  }
71 
72  /**
73  * Set the parent of a this node
74  *
75  * If the node already has a parent, the link is unset
76  *
77  * @param mixed &$parent The JNode for parent to be set or null
78  *
79  * @return void
80  *
81  * @since 11.1
82  */
83  public function setParent(&$parent)
84  {
85  JLog::add('JNode::setParent() is deprecated.', JLog::WARNING, 'deprecated');
86 
87  if ($parent instanceof JNode || is_null($parent))
88  {
89  $hash = spl_object_hash($this);
90  if (!is_null($this->_parent))
91  {
92  unset($this->_parent->children[$hash]);
93  }
94  if (!is_null($parent))
95  {
96  $parent->_children[$hash] = & $this;
97  }
98  $this->_parent = & $parent;
99  }
100  }
101 
102  /**
103  * Get the children of this node
104  *
105  * @return array The children
106  *
107  * @since 11.1
108  */
109  public function &getChildren()
110  {
111  JLog::add('JNode::getChildren() is deprecated.', JLog::WARNING, 'deprecated');
112 
113  return $this->_children;
114  }
115 
116  /**
117  * Get the parent of this node
118  *
119  * @return mixed JNode object with the parent or null for no parent
120  *
121  * @since 11.1
122  */
123  public function &getParent()
124  {
125  JLog::add('JNode::getParent() is deprecated.', JLog::WARNING, 'deprecated');
126 
127  return $this->_parent;
128  }
129 
130  /**
131  * Test if this node has children
132  *
133  * @return boolean True if there are children
134  *
135  * @since 11.1
136  */
137  public function hasChildren()
138  {
139  JLog::add('JNode::hasChildren() is deprecated.', JLog::WARNING, 'deprecated');
140 
141  return (bool) count($this->_children);
142  }
143 
144  /**
145  * Test if this node has a parent
146  *
147  * @return boolean True if there is a parent
148  *
149  * @since 11.1
150  */
151  public function hasParent()
152  {
153  JLog::add('JNode::hasParent() is deprecated.', JLog::WARNING, 'deprecated');
154 
155  return $this->getParent() != null;
156  }
157 }