Browse Source

! Consistency is a beautiful thing...

Signed-off-by: Michael Eshom <[email protected]>
Michael Eshom 11 years ago
parent
commit
fe6be35659

+ 17 - 3
Sources/SplitTopics.php

@@ -900,7 +900,7 @@ function MergeIndex()
 
 	// Get a list of boards they can navigate to to merge.
 	$request = $smcFunc['db_query']('order_by_board_order', '
-		SELECT b.id_board, b.name AS board_name, c.name AS cat_name
+		SELECT b.id_board, b.name AS board_name, c.id_cat, c.name AS cat_name
 		FROM {db_prefix}boards AS b
 			LEFT JOIN {db_prefix}categories AS c ON (c.id_cat = b.id_cat)
 		WHERE {query_see_board}' . (!in_array(0, $merge_boards) ? '
@@ -910,12 +910,26 @@ function MergeIndex()
 		)
 	);
 	$context['boards'] = array();
+	$context['num_boards'] = 0;
 	while ($row = $smcFunc['db_fetch_assoc']($request))
-		$context['boards'][] = array(
+	{
+		if (!isset($context['merge_categories'][$row['id_cat']]))
+		{
+			$context['merge_categories'][$row['id_cat']] = array(
+				'id' => $row['id_cat'],
+				'name' => $row['cat_name'],
+				'boards' => array(),
+			);
+		}
+
+		$context['merge_categories'][$row['id_cat']]['boards'][$row['id_board']] = array(
 			'id' => $row['id_board'],
 			'name' => $row['board_name'],
-			'category' => $row['cat_name']
 		);
+
+		$context['num_boards']++;
+	}
+
 	$smcFunc['db_free_result']($request);
 
 	// Get some topics to merge it with.

+ 9 - 8
Themes/default/ManageMaintenance.template.php

@@ -487,13 +487,13 @@ function template_maintain_topics()
 	foreach ($context['categories'] as $category)
 	{
 		echo '
-						<option disabled="disabled">--------------------------------------</option>
-						<option disabled="disabled">', $category['name'], '</option>
-						<option disabled="disabled">--------------------------------------</option>';
+						<optgroup label="', $category['name'], '">';
 
 		foreach ($category['boards'] as $board)
 			echo '
-						<option value="', $board['id'], '"> ', str_repeat('==', $board['child_level']), '=&gt;&nbsp;', $board['name'], '</option>';
+							<option value="', $board['id'], '"> ', str_repeat('==', $board['child_level']), '=&gt;&nbsp;', $board['name'], '</option>';
+
+		echo '			</optgroup>';
 	}
 
 	echo '
@@ -506,13 +506,14 @@ function template_maintain_topics()
 	foreach ($context['categories'] as $category)
 	{
 		echo '
-						<option disabled="disabled">--------------------------------------</option>
-						<option disabled="disabled">', $category['name'], '</option>
-						<option disabled="disabled">--------------------------------------</option>';
+						<optgroup label="', $category['name'], '">';
 
 		foreach ($category['boards'] as $board)
 			echo '
-						<option value="', $board['id'], '"> ', str_repeat('==', $board['child_level']), '=&gt;&nbsp;', $board['name'], '</option>';
+							<option value="', $board['id'], '"> ', str_repeat('==', $board['child_level']), '=&gt;&nbsp;', $board['name'], '</option>';
+
+		echo '
+						</optgroup>';
 	}
 	echo '
 					</select></p>

+ 14 - 3
Themes/default/SplitTopics.template.php

@@ -276,7 +276,7 @@ function template_merge()
 							', $context['origin_subject'], '
 						</dd>';
 
-	if (!empty($context['boards']) && count($context['boards']) > 1)
+	if (count($context['num_boards']) > 1)
 	{
 			echo '
 						<dt>
@@ -286,9 +286,20 @@ function template_merge()
 							<form action="' . $scripturl . '?action=mergetopics;from=' . $context['origin_topic'] . ';targetboard=' . $context['target_board'] . ';board=' . $context['current_board'] . '.0" method="post" accept-charset="', $context['character_set'], '">
 								<input type="hidden" name="from" value="' . $context['origin_topic'] . '" />
 								<select name="targetboard" onchange="this.form.submit();">';
-			foreach ($context['boards'] as $board)
+			foreach ($context['merge_categories'] as $cat)
+			{
+				echo '
+									<optgroup label="', $cat['name'], '">';
+
+				foreach ($cat['boards'] as $board)
+				{
+					echo '
+										<option value="', $board['id'], '"', $board['id'] == $context['target_board'] ? ' selected="selected"' : '', '>', $board['category'], ' - ', $board['name'], '</option>';
+				}
+
 				echo '
-									<option value="', $board['id'], '"', $board['id'] == $context['target_board'] ? ' selected="selected"' : '', '>', $board['category'], ' - ', $board['name'], '</option>';
+									</optgroup>';
+			}
 			echo '
 								</select>
 								<input type="submit" value="', $txt['go'], '" class="button_submit" />