aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2013-04-30 13:54:50 +0200
committerJoas Schilling <nickvergessen@gmx.de>2013-04-30 13:58:03 +0200
commit67f2edae170576104e619ffb38672cabf44e20fa (patch)
tree5306bf9e398a2613efe633c37a35b6d8bc6a0687
parent4810c61fd7b912ea2914b99f7db502b6f503068f (diff)
downloadforums-67f2edae170576104e619ffb38672cabf44e20fa.tar
forums-67f2edae170576104e619ffb38672cabf44e20fa.tar.gz
forums-67f2edae170576104e619ffb38672cabf44e20fa.tar.bz2
forums-67f2edae170576104e619ffb38672cabf44e20fa.tar.xz
forums-67f2edae170576104e619ffb38672cabf44e20fa.zip
[ticket/11495] Use descendants and ancestors instead of parents/children
PHPBB3-11495
-rw-r--r--phpBB/includes/tree/interface.php28
-rw-r--r--phpBB/includes/tree/nestedset.php18
-rw-r--r--tests/tree/nestedset_forum_get_data_test.php12
3 files changed, 29 insertions, 29 deletions
diff --git a/phpBB/includes/tree/interface.php b/phpBB/includes/tree/interface.php
index bd8181beb2..e09fcea4fa 100644
--- a/phpBB/includes/tree/interface.php
+++ b/phpBB/includes/tree/interface.php
@@ -65,9 +65,9 @@ interface phpbb_tree_interface
public function move_up($item_id);
/**
- * Moves all children of one item to another item
+ * Moves all descendants of one item to another item
*
- * If the new parent already has children, the new children are appended
+ * If the new parent already has descendants, the new descendants are appended
* to the list.
*
* @param int $current_parent_id The current parent item
@@ -88,35 +88,35 @@ interface phpbb_tree_interface
public function change_parent($item_id, $new_parent_id);
/**
- * Get all items that are either a parent or part of the subtree of the item
+ * Get all items that are either an ancestors or descendants of the item
*
- * @param int $item_id The item id to get the parents/children from
- * @param bool $order_desc Order the items descending (most outer parent first)
+ * @param int $item_id The item to get the ancestors/descendants from
+ * @param bool $order_asc Order the items ascending (most outer ancestor first)
* @param bool $include_item Should the item (matching the given item id) be included in the list aswell
* @return array Array of items (containing all columns from the item table)
* ID => Item data
*/
- public function get_path_and_subtree_data($item_id, $order_desc, $include_item);
+ public function get_path_and_subtree_data($item_id, $order_asc, $include_item);
/**
- * Get all parent items of the item
+ * Get all ancestors items of the item
*
- * @param int $item_id The item id to get the parents from
- * @param bool $order_desc Order the items descending (most outer parent first)
+ * @param int $item_id The item id to get the ancestors from
+ * @param bool $order_asc Order the items ascending (most outer ancestor first)
* @param bool $include_item Should the item (matching the given item id) be included in the list aswell
* @return array Array of items (containing all columns from the item table)
* ID => Item data
*/
- public function get_path_data($item_id, $order_desc, $include_item);
+ public function get_path_data($item_id, $order_asc, $include_item);
/**
- * Get all items of the item's subtree
+ * Get all descendants of the item
*
- * @param int $item_id The item id to get the children from
- * @param bool $order_desc Order the items descending (most outer parent first)
+ * @param int $item_id The item id to get the descendants from
+ * @param bool $order_asc Order the items ascending
* @param bool $include_item Should the item (matching the given item id) be included in the list aswell
* @return array Array of items (containing all columns from the item table)
* ID => Item data
*/
- public function get_subtree_data($item_id, $order_desc, $include_item);
+ public function get_subtree_data($item_id, $order_asc, $include_item);
}
diff --git a/phpBB/includes/tree/nestedset.php b/phpBB/includes/tree/nestedset.php
index 89a91ccb16..7710895a25 100644
--- a/phpBB/includes/tree/nestedset.php
+++ b/phpBB/includes/tree/nestedset.php
@@ -529,32 +529,32 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
/**
* @inheritdoc
*/
- public function get_path_and_subtree_data($item_id, $order_desc = true, $include_item = true)
+ public function get_path_and_subtree_data($item_id, $order_asc = true, $include_item = true)
{
$condition = 'i2.' . $this->column_left_id . ' BETWEEN i1.' . $this->column_left_id . ' AND i1.' . $this->column_right_id . '
OR i1.' . $this->column_left_id . ' BETWEEN i2.' . $this->column_left_id . ' AND i2.' . $this->column_right_id;
- return $this->get_set_of_nodes_data($item_id, $condition, $order_desc, $include_item);
+ return $this->get_set_of_nodes_data($item_id, $condition, $order_asc, $include_item);
}
/**
* @inheritdoc
*/
- public function get_path_data($item_id, $order_desc = true, $include_item = true)
+ public function get_path_data($item_id, $order_asc = true, $include_item = true)
{
$condition = 'i1.' . $this->column_left_id . ' BETWEEN i2.' . $this->column_left_id . ' AND i2.' . $this->column_right_id . '';
- return $this->get_set_of_nodes_data($item_id, $condition, $order_desc, $include_item);
+ return $this->get_set_of_nodes_data($item_id, $condition, $order_asc, $include_item);
}
/**
* @inheritdoc
*/
- public function get_subtree_data($item_id, $order_desc = true, $include_item = true)
+ public function get_subtree_data($item_id, $order_asc = true, $include_item = true)
{
$condition = 'i2.' . $this->column_left_id . ' BETWEEN i1.' . $this->column_left_id . ' AND i1.' . $this->column_right_id . '';
- return $this->get_set_of_nodes_data($item_id, $condition, $order_desc, $include_item);
+ return $this->get_set_of_nodes_data($item_id, $condition, $order_asc, $include_item);
}
/**
@@ -562,12 +562,12 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
*
* @param int $item_id The item id to get the node set from
* @param string $condition Query string restricting the item list
- * @param bool $order_desc Order the items descending (most outer parent first)
+ * @param bool $order_asc Order the items ascending by their left_id
* @param bool $include_item Should the item (matching the given item id) be included in the list aswell
* @return array Array of items (containing all columns from the item table)
* ID => Item data
*/
- protected function get_set_of_nodes_data($item_id, $condition, $order_desc = true, $include_item = true)
+ protected function get_set_of_nodes_data($item_id, $condition, $order_asc = true, $include_item = true)
{
$rows = array();
@@ -577,7 +577,7 @@ abstract class phpbb_tree_nestedset implements phpbb_tree_interface
ON (($condition) " . $this->get_sql_where('AND', 'i2.') . ')
WHERE i1.' . $this->column_item_id . ' = ' . (int) $item_id . '
' . $this->get_sql_where('AND', 'i1.') . '
- ORDER BY i2.' . $this->column_left_id . ' ' . ($order_desc ? 'ASC' : 'DESC');
+ ORDER BY i2.' . $this->column_left_id . ' ' . ($order_asc ? 'ASC' : 'DESC');
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
diff --git a/tests/tree/nestedset_forum_get_data_test.php b/tests/tree/nestedset_forum_get_data_test.php
index 7a4fada880..49586fbade 100644
--- a/tests/tree/nestedset_forum_get_data_test.php
+++ b/tests/tree/nestedset_forum_get_data_test.php
@@ -34,9 +34,9 @@ class phpbb_tests_tree_nestedset_forum_get_data_test extends phpbb_tests_tree_ne
/**
* @dataProvider get_path_and_subtree_data_data
*/
- public function test_get_path_and_subtree_data($forum_id, $order_desc, $include_item, $expected)
+ public function test_get_path_and_subtree_data($forum_id, $order_asc, $include_item, $expected)
{
- $this->assertEquals($expected, array_keys($this->set->get_path_and_subtree_data($forum_id, $order_desc, $include_item)));
+ $this->assertEquals($expected, array_keys($this->set->get_path_and_subtree_data($forum_id, $order_asc, $include_item)));
}
public function get_path_data_data()
@@ -62,9 +62,9 @@ class phpbb_tests_tree_nestedset_forum_get_data_test extends phpbb_tests_tree_ne
/**
* @dataProvider get_path_data_data
*/
- public function test_get_path_data($forum_id, $order_desc, $include_item, $expected)
+ public function test_get_path_data($forum_id, $order_asc, $include_item, $expected)
{
- $this->assertEquals($expected, array_keys($this->set->get_path_data($forum_id, $order_desc, $include_item)));
+ $this->assertEquals($expected, array_keys($this->set->get_path_data($forum_id, $order_asc, $include_item)));
}
public function get_subtree_data_data()
@@ -90,9 +90,9 @@ class phpbb_tests_tree_nestedset_forum_get_data_test extends phpbb_tests_tree_ne
/**
* @dataProvider get_subtree_data_data
*/
- public function test_get_subtree_data($forum_id, $order_desc, $include_item, $expected)
+ public function test_get_subtree_data($forum_id, $order_asc, $include_item, $expected)
{
- $this->assertEquals($expected, array_keys($this->set->get_subtree_data($forum_id, $order_desc, $include_item)));
+ $this->assertEquals($expected, array_keys($this->set->get_subtree_data($forum_id, $order_asc, $include_item)));
}
public function get_path_basic_data_data()