2013-04-16 23:07:48 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @package Nested Set
|
|
|
|
* @copyright (c) 2013 phpBB Group
|
|
|
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ignore
|
|
|
|
*/
|
|
|
|
if (!defined('IN_PHPBB'))
|
|
|
|
{
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface phpbb_nestedset_interface
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Insert an item into the nested set (also insert the rows into the table)
|
|
|
|
*
|
2013-04-18 00:13:19 +02:00
|
|
|
* @param array $item The item to be added
|
2013-04-16 23:07:48 +02:00
|
|
|
* @return array Array with item data as set in the database
|
|
|
|
*/
|
|
|
|
public function insert(array $additional_data);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add an item at the end of the nested set
|
|
|
|
*
|
2013-04-18 00:13:19 +02:00
|
|
|
* @param array $item The item to be added
|
2013-04-16 23:07:48 +02:00
|
|
|
* @return bool True if the item was added
|
|
|
|
*/
|
2013-04-18 00:13:19 +02:00
|
|
|
public function add(array $item);
|
2013-04-16 23:07:48 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove an item from the nested set
|
|
|
|
*
|
|
|
|
* Also removes all subitems from the nested set
|
|
|
|
*
|
2013-04-19 16:19:01 +02:00
|
|
|
* @param int $item_id The item to be deleted
|
|
|
|
* @return array Item ids that have been removed
|
2013-04-16 23:07:48 +02:00
|
|
|
*/
|
2013-04-19 16:19:01 +02:00
|
|
|
public function remove($item);
|
2013-04-16 23:07:48 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Delete an item from the nested set (also deletes the rows form the table)
|
|
|
|
*
|
|
|
|
* Also deletes all subitems from the nested set
|
|
|
|
*
|
2013-04-19 16:19:01 +02:00
|
|
|
* @param int $item_id The item to be deleted
|
|
|
|
* @return array Item ids that have been deleted
|
2013-04-16 23:07:48 +02:00
|
|
|
*/
|
2013-04-19 16:19:01 +02:00
|
|
|
public function delete($item);
|
2013-04-16 23:07:48 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Move an item by a given delta
|
|
|
|
*
|
2013-04-19 21:07:42 +02:00
|
|
|
* @param int $item_id The item to be moved
|
|
|
|
* @param int $delta Number of steps to move this item, < 0 => down, > 0 => up
|
2013-04-16 23:07:48 +02:00
|
|
|
* @return bool True if the item was moved
|
|
|
|
*/
|
2013-04-19 21:07:42 +02:00
|
|
|
public function move($item_id, $delta);
|
2013-04-16 23:07:48 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Move an item down by 1
|
|
|
|
*
|
2013-04-19 21:07:42 +02:00
|
|
|
* @param int $item_id The item to be moved
|
2013-04-16 23:07:48 +02:00
|
|
|
* @return bool True if the item was moved
|
|
|
|
*/
|
2013-04-19 21:07:42 +02:00
|
|
|
public function move_down($item_id);
|
2013-04-16 23:07:48 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Move an item up by 1
|
|
|
|
*
|
2013-04-19 21:07:42 +02:00
|
|
|
* @param int $item_id The item to be moved
|
2013-04-16 23:07:48 +02:00
|
|
|
* @return bool True if the item was moved
|
|
|
|
*/
|
2013-04-19 21:07:42 +02:00
|
|
|
public function move_up($item_id);
|
2013-04-16 23:07:48 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Moves all children of one item to another item
|
|
|
|
*
|
2013-04-19 21:07:42 +02:00
|
|
|
* @param int $current_parent_id The current parent item
|
|
|
|
* @param int $new_parent_id The new parent item
|
2013-04-16 23:07:48 +02:00
|
|
|
* @return bool True if any items where moved
|
|
|
|
*/
|
2013-04-19 21:07:42 +02:00
|
|
|
public function move_children($current_parent_id, $new_parent_id);
|
2013-04-16 23:07:48 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the parent item
|
|
|
|
*
|
2013-04-19 21:07:42 +02:00
|
|
|
* @param int $item_id The item to be moved
|
|
|
|
* @param int $new_parent_id The new parent item
|
2013-04-16 23:07:48 +02:00
|
|
|
* @return bool True if the parent was set successfully
|
|
|
|
*/
|
2013-04-19 21:07:42 +02:00
|
|
|
public function set_parent($item, $new_parent_id);
|
2013-04-16 23:07:48 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get branch of the item
|
|
|
|
*
|
|
|
|
* This method can return all parents, children or both of the given item
|
|
|
|
*
|
2013-04-19 16:18:03 +02:00
|
|
|
* @param int $item_id The item id to get the parents from
|
2013-04-16 23:07:48 +02:00
|
|
|
* @param string $type One of all|parent|children
|
|
|
|
* @param bool $order_desc Order the items descending (most outer parent first)
|
|
|
|
* @param bool $include_item Should the given item be included in the list aswell
|
|
|
|
* @return array Array of items (containing all columns from the item table)
|
|
|
|
* ID => Item data
|
|
|
|
*/
|
2013-04-19 16:18:03 +02:00
|
|
|
public function get_branch_data($item_id, $type, $order_desc, $include_item);
|
2013-04-16 23:07:48 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get base information of parent items
|
|
|
|
*
|
2013-04-19 16:18:03 +02:00
|
|
|
* @param array $item The item to get the branch from
|
2013-04-16 23:07:48 +02:00
|
|
|
* @return array Array of items (containing basic columns from the item table)
|
|
|
|
* ID => Item data
|
|
|
|
*/
|
2013-04-18 00:13:19 +02:00
|
|
|
public function get_parent_data(array $item);
|
2013-04-16 23:07:48 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Recalculate Nested Sets
|
|
|
|
*
|
|
|
|
* @param int $new_id First left_id to be used (should start with 1)
|
|
|
|
* @param int $parent_id parent_id of the current set (default = 0)
|
|
|
|
* @param bool $reset_ids Should we reset all left_id/right_id on the first call?
|
|
|
|
* @return int $new_id The next left_id/right_id that should be used
|
|
|
|
*/
|
|
|
|
public function recalculate_nested_set($new_id, $parent_id = 0, $reset_ids = false);
|
|
|
|
}
|