Code Duplication    Length = 29-34 lines in 2 locations

mod/etherpad/lib/pages.php 1 location

@@ 83-111 (lines=29) @@
80
		'container_guid' => $container->getGUID(),
81
	));
82
83
	foreach ($top_pages as $page) {
84
		elgg_register_menu_item('pages_nav', array(
85
			'name' => $page->getGUID(),
86
			'text' => $page->title,
87
			'href' => $page->getURL(),
88
		));
89
90
		$stack = array();
91
		array_push($stack, $page);
92
		while (count($stack) > 0) {
93
			$parent = array_pop($stack);
94
			$children = elgg_get_entities_from_metadata(array(
95
				'type' => 'object',
96
				'subtypes' => array('page', 'subpad'),
97
				'metadata_name' => 'parent_guid',
98
				'metadata_value' => $parent->getGUID(),
99
			));
100
			
101
			foreach ($children as $child) {
102
				elgg_register_menu_item('pages_nav', array(
103
					'name' => $child->getGUID(),
104
					'text' => $child->title,
105
					'href' => $child->getURL(),
106
					'parent_name' => $parent->getGUID(),
107
				));
108
				array_push($stack, $child);
109
			}
110
		}
111
	}
112
}
113

mod/tasks/lib/tasks.php 1 location

@@ 96-129 (lines=34) @@
93
	));
94
95
	if ($top_tasks) {
96
		foreach ($top_tasks as $task) {
97
			elgg_register_menu_item('tasks_nav', array(
98
				'name' => $task->getGUID(),
99
				'text' => $task->title,
100
				'href' => $task->getURL(),
101
			));
102
	
103
			$stack = array();
104
			array_push($stack, $task);
105
			while (count($stack) > 0) {
106
				$parent = array_pop($stack);
107
				$children = elgg_get_entities_from_metadata(array(
108
					'type' => 'object',
109
					'subtype' => 'task',
110
					'limit' => false,
111
					'metadata_name_value_pairs' => array(
112
						'name' => 'parent_guid',
113
						'value' => $parent->getGUID()
114
					)
115
				));
116
				
117
				if ($children) {
118
					foreach ($children as $child) {
119
						elgg_register_menu_item('tasks_nav', array(
120
							'name' => $child->getGUID(),
121
							'text' => $child->title,
122
							'href' => $child->getURL(),
123
							'parent_name' => $parent->getGUID(),
124
						));
125
						array_push($stack, $child);
126
					}
127
				}
128
			}
129
		}
130
	}
131
}
132