Parcourir la source

! Move all button_strip arrays to the source

IMO, there's no point having the button_strip arrays (such as
$mod_buttons or $normal_buttons) in the templates. It makes more sense
to have them in their corresponding source files, as with the main menu
in 2.0. Themes rarely need to modify them and if they do, they can still
do so (changing the image instance (which doesn't actually do much, does
it?) and so on) by just using the "new" array.

Also made sure there are hooks for all of them. One may argue that some
of them probably will never be used, but I feel that the hook system
won't have reached its full potential until as much as possible is
editable via hooks, so why not play it safe?
marcusforsberg il y a 12 ans
Parent
commit
8b80f02811

+ 8 - 0
Sources/BoardIndex.php

@@ -108,6 +108,14 @@ function BoardIndex()
 		$context['show_calendar'] = false;
 
 	$context['page_title'] = sprintf($txt['forum_index'], $context['forum_name']);
+	
+	// Mark read button
+	$context['mark_read_button'] = array(
+		'markread' => array('text' => 'mark_as_read', 'image' => 'markread.png', 'lang' => true, 'url' => $scripturl . '?action=markasread;sa=all;' . $context['session_var'] . '=' . $context['session_id']),
+	);
+	
+	// Allow mods to add additional buttons here
+	call_integration_hook('integrate_mark_read_button', array(&$context['mark_read_button'])); 
 }
 
 /**

+ 8 - 0
Sources/Calendar.php

@@ -144,6 +144,14 @@ function CalendarMain()
 			'url' => $scripturl . '?action=calendar;viewweek;year=' . $context['current_year'] . ';month=' . $context['current_month'] . ';day=' . $context['current_day'],
 			'name' => $txt['calendar_week'] . ' ' . $context['calendar_grid_main']['week_number']
 		);
+		
+	// Build the calendar button array.
+	$context['calendar_buttons'] = array(
+		'post_event' => array('test' => 'can_post', 'text' => 'calendar_post_event', 'image' => 'calendarpe.png', 'lang' => true, 'url' => $scripturl . '?action=calendar;sa=post;month=' . $context['current_month'] . ';year=' . $context['current_year'] . ';' . $context['session_var'] . '=' . $context['session_id']),
+	);
+	
+	// Allow mods to add additional buttons here
+	call_integration_hook('integrate_calendar_buttons', array(&$context['calendar_buttons']));
 }
 
 /**

+ 43 - 0
Sources/Display.php

@@ -755,6 +755,19 @@ function Display()
 				'vote_button' => '<input type="' . ($pollinfo['max_votes'] > 1 ? 'checkbox' : 'radio') . '" name="options[]" id="options-' . $i . '" value="' . $i . '" class="input_' . ($pollinfo['max_votes'] > 1 ? 'check' : 'radio') . '" />'
 			);
 		}
+		
+		// Build the poll moderation button array.
+		$context['poll_buttons'] = array(
+			'vote' => array('test' => 'allow_return_vote', 'text' => 'poll_return_vote', 'image' => 'poll_options.png', 'lang' => true, 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start']),
+			'results' => array('test' => 'show_view_results_button', 'text' => 'poll_results', 'image' => 'poll_results.png', 'lang' => true, 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start'] . ';viewresults'),
+			'change_vote' => array('test' => 'allow_change_vote', 'text' => 'poll_change_vote', 'image' => 'poll_change_vote.png', 'lang' => true, 'url' => $scripturl . '?action=vote;topic=' . $context['current_topic'] . '.' . $context['start'] . ';poll=' . $context['poll']['id'] . ';' . $context['session_var'] . '=' . $context['session_id']),
+			'lock' => array('test' => 'allow_lock_poll', 'text' => (!$context['poll']['is_locked'] ? 'poll_lock' : 'poll_unlock'), 'image' => 'poll_lock.png', 'lang' => true, 'url' => $scripturl . '?action=lockvoting;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']),
+			'edit' => array('test' => 'allow_edit_poll', 'text' => 'poll_edit', 'image' => 'poll_edit.png', 'lang' => true, 'url' => $scripturl . '?action=editpoll;topic=' . $context['current_topic'] . '.' . $context['start']),
+			'remove_poll' => array('test' => 'can_remove_poll', 'text' => 'poll_remove', 'image' => 'admin_remove_poll.png', 'lang' => true, 'custom' => 'onclick="return confirm(\'' . $txt['poll_remove_warn'] . '\');"', 'url' => $scripturl . '?action=removepoll;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']),
+		);
+		
+		// Allow mods to add additional buttons here
+		call_integration_hook('integrate_poll_buttons', array(&$context['poll_buttons']));
 	}
 	
 	// Editing poll output, eh?
@@ -1103,6 +1116,36 @@ function Display()
 				$context['icons'][count($context['icons']) - 1]['is_last'] = true;
 		}
 	}
+	
+	// Build the normal button array.
+	$context['normal_buttons'] = array(
+		'reply' => array('test' => 'can_reply', 'text' => 'reply', 'image' => 'reply.png', 'lang' => true, 'url' => $scripturl . '?action=post;topic=' . $context['current_topic'] . '.' . $context['start'] . ';last_msg=' . $context['topic_last_message'], 'active' => true),
+		'add_poll' => array('test' => 'can_add_poll', 'text' => 'add_poll', 'image' => 'add_poll.png', 'lang' => true, 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start']),
+		'notify' => array('test' => 'can_mark_notify', 'text' => $context['is_marked_notify'] ? 'unnotify' : 'notify', 'image' => ($context['is_marked_notify'] ? 'un' : '') . 'notify.png', 'lang' => true, 'custom' => 'onclick="return confirm(\'' . ($context['is_marked_notify'] ? $txt['notification_disable_topic'] : $txt['notification_enable_topic']) . '\');"', 'url' => $scripturl . '?action=notify;sa=' . ($context['is_marked_notify'] ? 'off' : 'on') . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']),
+		'mark_unread' => array('test' => 'can_mark_unread', 'text' => 'mark_unread', 'image' => 'markunread.png', 'lang' => true, 'url' => $scripturl . '?action=markasread;sa=topic;t=' . $context['mark_unread_time'] . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']),
+		'send' => array('test' => 'can_send_topic', 'text' => 'send_topic', 'image' => 'sendtopic.png', 'lang' => true, 'url' => $scripturl . '?action=emailuser;sa=sendtopic;topic=' . $context['current_topic'] . '.0'),
+		'print' => array('test' => 'can_print', 'text' => 'print', 'image' => 'print.png', 'lang' => true, 'custom' => 'rel="new_win nofollow"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0'),
+	);
+
+	// Allow adding new buttons easily.
+	call_integration_hook('integrate_display_buttons', array(&$context['normal_buttons']));	
+	
+	// Build the mod button array
+	$context['mod_buttons'] = array(
+		'move' => array('test' => 'can_move', 'text' => 'move_topic', 'image' => 'admin_move.png', 'lang' => true, 'url' => $scripturl . '?action=movetopic;current_board=' . $context['current_board'] . ';topic=' . $context['current_topic'] . '.0'),
+		'delete' => array('test' => 'can_delete', 'text' => 'remove_topic', 'image' => 'admin_rem.png', 'lang' => true, 'custom' => 'onclick="return confirm(\'' . $txt['are_sure_remove_topic'] . '\');"', 'url' => $scripturl . '?action=removetopic2;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']),
+		'lock' => array('test' => 'can_lock', 'text' => empty($context['is_locked']) ? 'set_lock' : 'set_unlock', 'image' => 'admin_lock.png', 'lang' => true, 'url' => $scripturl . '?action=lock;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']),
+		'sticky' => array('test' => 'can_sticky', 'text' => empty($context['is_sticky']) ? 'set_sticky' : 'set_nonsticky', 'image' => 'admin_sticky.png', 'lang' => true, 'url' => $scripturl . '?action=sticky;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']),
+		'merge' => array('test' => 'can_merge', 'text' => 'merge', 'image' => 'merge.png', 'lang' => true, 'url' => $scripturl . '?action=mergetopics;board=' . $context['current_board'] . '.0;from=' . $context['current_topic']),
+		'calendar' => array('test' => 'calendar_post', 'text' => 'calendar_link', 'image' => 'linktocal.png', 'lang' => true, 'url' => $scripturl . '?action=post;calendar;msg=' . $context['topic_first_message'] . ';topic=' . $context['current_topic'] . '.0'),
+	);
+
+	// Restore topic. eh?  No monkey business.
+	if ($context['can_restore_topic'])
+		$context['mod_buttons'][] = array('text' => 'restore_topic', 'image' => '', 'lang' => true, 'url' => $scripturl . '?action=restoretopic;topics=' . $context['current_topic'] . ';' . $context['session_var'] . '=' . $context['session_id']);
+
+	// Allow adding new mod buttons easily.
+	call_integration_hook('integrate_mod_buttons', array(&$context['mod_buttons']));
 }
 
 /**

+ 13 - 0
Sources/Memberlist.php

@@ -175,6 +175,15 @@ function Memberlist()
 
 	$context['can_send_pm'] = allowedTo('pm_send');
 	$context['can_send_email'] = allowedTo('send_email_to_members');
+	
+	// Build the memberlist button array.
+	$context['memberlist_buttons'] = array(
+		'view_all_members' => array('text' => 'view_all_members', 'image' => 'mlist.png', 'lang' => true, 'url' => $scripturl . '?action=mlist' . ';sa=all', 'active'=> true),
+		'mlist_search' => array('text' => 'mlist_search', 'image' => 'mlist.png', 'lang' => true, 'url' => $scripturl . '?action=mlist' . ';sa=search'),
+	);
+	
+	// Allow mods to add additional buttons here
+	call_integration_hook('integrate_memberlist_buttons', array(&$context['memberlist_buttons']));	
 
 	// Jump to the sub action.
 	if (isset($subActions[$context['listing_by']]))
@@ -565,6 +574,10 @@ function MLSearch()
 		'url' => $scripturl . '?action=mlist;sa=search',
 		'name' => &$context['page_title']
 	);
+	
+	// Highlight the correct button, too!
+	unset($context['memberlist_buttons']['view_all_members']['active']);
+	$context['memberlist_buttons']['mlist_search']['active'] = true;
 }
 
 /**

+ 11 - 0
Sources/MessageIndex.php

@@ -632,6 +632,17 @@ function MessageIndex()
 
 	// If there are children, but no topics and no ability to post topics...
 	$context['no_topic_listing'] = !empty($context['boards']) && empty($context['topics']) && !$context['can_post_new'];
+	
+	// Build the message index button array.
+	$context['normal_buttons'] = array(
+		'new_topic' => array('test' => 'can_post_new', 'text' => 'new_topic', 'image' => 'new_topic.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true),
+		'post_poll' => array('test' => 'can_post_poll', 'text' => 'new_poll', 'image' => 'new_poll.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll'),
+		'notify' => array('test' => 'can_mark_notify', 'text' => $context['is_marked_notify'] ? 'unnotify' : 'notify', 'image' => ($context['is_marked_notify'] ? 'un' : ''). 'notify.png', 'lang' => true, 'custom' => 'onclick="return confirm(\'' . ($context['is_marked_notify'] ? $txt['notification_disable_board'] : $txt['notification_enable_board']) . '\');"', 'url' => $scripturl . '?action=notifyboard;sa=' . ($context['is_marked_notify'] ? 'off' : 'on') . ';board=' . $context['current_board'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']),
+		'markread' => array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']),
+	);
+	
+	// Allow adding new buttons easily.
+	call_integration_hook('integrate_messageindex_buttons', array(&$context['normal_buttons']));
 }
 
 /**

+ 12 - 0
Sources/PersonalMessage.php

@@ -842,6 +842,18 @@ function MessageFolder()
 		elseif (!empty($context['current_pm']))
 			markMessages($display_pms, $context['current_label_id']);
 	}
+	
+	// Build the conversation button array.
+	if ($context['display_mode'] == 2)
+	{
+		$context['conversation_buttons'] = array(
+			'reply' => array('text' => 'reply_to_all', 'image' => 'reply.png', 'lang' => true, 'url' => $scripturl . '?action=pm;sa=send;f=' . $context['folder'] . ($context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '') . ';pmsg=' . $context['current_pm'] . ';u=all', 'active' => true),
+			'delete' => array('text' => 'delete_conversation', 'image' => 'delete.png', 'lang' => true, 'url' => $scripturl . '?action=pm;sa=pmactions;pm_actions[' . $context['current_pm'] . ']=delete;conversation;f=' . $context['folder'] . ';start=' . $context['start'] . ($context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '') . ';' . $context['session_var'] . '=' . $context['session_id'], 'custom' => 'onclick="return confirm(\'' . addslashes($txt['remove_message']) . '?\');"'),
+		);
+		
+		// Allow mods to add additional buttons here
+		call_integration_hook('integrate_conversation_buttons', array(&$context['conversation_buttons']));
+	}
 }
 
 /**

+ 41 - 0
Sources/Recent.php

@@ -1317,6 +1317,47 @@ function UnreadTopics()
 	$context['querystring_board_limits'] = sprintf($context['querystring_board_limits'], $_REQUEST['start']);
 	$context['topics_to_mark'] = implode('-', $topic_ids);
 	
+	$context['showCheckboxes'] = !empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $settings['show_mark_read'];
+	
+	if ($settings['show_mark_read'])
+	{
+		// Build the recent button array.
+		if ($is_topics)
+		{
+			$context['recent_buttons'] = array(
+				'markread' => array('text' => !empty($context['no_board_limits']) ? 'mark_as_read' : 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'url' => $scripturl . '?action=markasread;sa=' . (!empty($context['no_board_limits']) ? 'all' : 'board' . $context['querystring_board_limits']) . ';' . $context['session_var'] . '=' . $context['session_id']),
+			);
+
+			if ($context['showCheckboxes'])
+				$context['recent_buttons']['markselectread'] = array(
+					'text' => 'quick_mod_markread',
+					'image' => 'markselectedread.png',
+					'lang' => true,
+					'url' => 'javascript:document.quickModForm.submit();',
+				);
+				
+			if (!empty($context['topics']) && !$context['showing_all_topics'])
+				$context['recent_buttons']['readall'] = array('text' => 'unread_topics_all', 'image' => 'markreadall.png', 'lang' => true, 'url' => $scripturl . '?action=unread;all' . $context['querystring_board_limits'], 'active' => true);	
+		}
+		elseif (!$is_topics && isset($context['topics_to_mark']))
+		{
+			$context['recent_buttons'] = array(
+				'markread' => array('text' => 'mark_as_read', 'image' => 'markread.png', 'lang' => true, 'url' => $scripturl . '?action=markasread;sa=unreadreplies;topics=' . $context['topics_to_mark'] . ';' . $context['session_var'] . '=' . $context['session_id']),
+			);
+
+			if ($context['showCheckboxes'])
+				$context['recent_buttons']['markselectread'] = array(
+					'text' => 'quick_mod_markread',
+					'image' => 'markselectedread.png',
+					'lang' => true,
+					'url' => 'javascript:document.quickModForm.submit();',
+				);
+		}
+
+		// Allow mods to add additional buttons here
+		call_integration_hook('integrate_recent_buttons', array(&$context['recent_buttons']));
+	}
+	
 	// Allow helpdesks and bug trackers and what not to add their own unread data (just add a template_layer to show custom stuff in the template!)
  	call_integration_hook('integrate_unread_list');
 }

+ 10 - 0
Sources/Reports.php

@@ -103,6 +103,16 @@ function ReportsMain()
 
 	// Make the page title more descriptive.
 	$context['page_title'] .= ' - ' . (isset($txt['gr_type_' . $context['report_type']]) ? $txt['gr_type_' . $context['report_type']] : $context['report_type']);
+	
+	// Build the reports button array.
+	$context['report_buttons'] = array(
+		'generate_reports' => array('text' => 'generate_reports', 'image' => 'print.png', 'lang' => true, 'url' => $scripturl . '?action=admin;area=reports', 'active' => true),
+		'print' => array('text' => 'print', 'image' => 'print.png', 'lang' => true, 'url' => $scripturl . '?action=admin;area=reports;rt=' . $context['report_type']. ';st=print', 'custom' => 'target="_blank"'),
+	);
+	
+	// Allow mods to add additional buttons here
+	call_integration_hook('integrate_report_buttons', array(&$context['report_buttons']));	
+	
 	// Now generate the data.
 	$context['report_types'][$context['report_type']]['function']();
 

+ 1 - 6
Themes/default/BoardIndex.template.php

@@ -234,11 +234,6 @@ function template_main()
 		echo '
 	<div id="posting_icons" class="floatleft">';
 
-		// Mark read button.
-		$mark_read_button = array(
-			'markread' => array('text' => 'mark_as_read', 'image' => 'markread.png', 'lang' => true, 'url' => $scripturl . '?action=markasread;sa=all;' . $context['session_var'] . '=' . $context['session_id']),
-		);
-
 		echo '
 		<ul class="reset">
 			<li class="floatleft"><img src="', $settings['images_url'], '/', $context['theme_variant_url'], 'new_some.png" alt="" /> ', $txt['new_posts'], '</li>
@@ -249,7 +244,7 @@ function template_main()
 
 		// Show the mark all as read button?
 		if ($settings['show_mark_read'] && !empty($context['categories']))
-			echo '<div class="mark_read">', template_button_strip($mark_read_button, 'right'), '</div>';
+			echo '<div class="mark_read">', template_button_strip($context['mark_read_button'], 'right'), '</div>';
 	}
 	else
 	{

+ 1 - 6
Themes/default/Calendar.template.php

@@ -25,12 +25,7 @@ function template_main()
 			<div id="main_grid" style="', isBrowser('is_ie') && !isBrowser('is_ie8') ? 'float: ' . ($context['right_to_left'] ? 'right; padding-right' : 'left; padding-left') . ': 20px;' : 'margin-' . ($context['right_to_left'] ? 'right' : 'left') . ': 220px; ', '">
 				', $context['view_week'] ? template_show_week_grid('main') : template_show_month_grid('main');
 
-	// Build the calendar button array.
-	$calendar_buttons = array(
-		'post_event' => array('test' => 'can_post', 'text' => 'calendar_post_event', 'image' => 'calendarpe.png', 'lang' => true, 'url' => $scripturl . '?action=calendar;sa=post;month=' . $context['current_month'] . ';year=' . $context['current_year'] . ';' . $context['session_var'] . '=' . $context['session_id']),
-	);
-
-	template_button_strip($calendar_buttons, 'right');
+	template_button_strip($context['calendar_buttons'], 'right');
 
 	// Show some controls to allow easy calendar navigation.
 	echo '

+ 4 - 43
Themes/default/Display.template.php

@@ -114,17 +114,7 @@ function template_main()
 			</div>
 			<div id="pollmoderation">';
 
-		// Build the poll moderation button array.
-		$poll_buttons = array(
-			'vote' => array('test' => 'allow_return_vote', 'text' => 'poll_return_vote', 'image' => 'poll_options.png', 'lang' => true, 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start']),
-			'results' => array('test' => 'show_view_results_button', 'text' => 'poll_results', 'image' => 'poll_results.png', 'lang' => true, 'url' => $scripturl . '?topic=' . $context['current_topic'] . '.' . $context['start'] . ';viewresults'),
-			'change_vote' => array('test' => 'allow_change_vote', 'text' => 'poll_change_vote', 'image' => 'poll_change_vote.png', 'lang' => true, 'url' => $scripturl . '?action=vote;topic=' . $context['current_topic'] . '.' . $context['start'] . ';poll=' . $context['poll']['id'] . ';' . $context['session_var'] . '=' . $context['session_id']),
-			'lock' => array('test' => 'allow_lock_poll', 'text' => (!$context['poll']['is_locked'] ? 'poll_lock' : 'poll_unlock'), 'image' => 'poll_lock.png', 'lang' => true, 'url' => $scripturl . '?action=lockvoting;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']),
-			'edit' => array('test' => 'allow_edit_poll', 'text' => 'poll_edit', 'image' => 'poll_edit.png', 'lang' => true, 'url' => $scripturl . '?action=editpoll;topic=' . $context['current_topic'] . '.' . $context['start']),
-			'remove_poll' => array('test' => 'can_remove_poll', 'text' => 'poll_remove', 'image' => 'admin_remove_poll.png', 'lang' => true, 'custom' => 'onclick="return confirm(\'' . $txt['poll_remove_warn'] . '\');"', 'url' => $scripturl . '?action=removepoll;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']),
-		);
-
-		template_button_strip($poll_buttons);
+		template_button_strip($context['poll_buttons']);
 
 		echo '
 			</div>';
@@ -157,23 +147,10 @@ function template_main()
 			</div>';
 	}
 
-	// Build the normal button array.
-	$normal_buttons = array(
-		'reply' => array('test' => 'can_reply', 'text' => 'reply', 'image' => 'reply.png', 'lang' => true, 'url' => $scripturl . '?action=post;topic=' . $context['current_topic'] . '.' . $context['start'] . ';last_msg=' . $context['topic_last_message'], 'active' => true),
-		'add_poll' => array('test' => 'can_add_poll', 'text' => 'add_poll', 'image' => 'add_poll.png', 'lang' => true, 'url' => $scripturl . '?action=editpoll;add;topic=' . $context['current_topic'] . '.' . $context['start']),
-		'notify' => array('test' => 'can_mark_notify', 'text' => $context['is_marked_notify'] ? 'unnotify' : 'notify', 'image' => ($context['is_marked_notify'] ? 'un' : '') . 'notify.png', 'lang' => true, 'custom' => 'onclick="return confirm(\'' . ($context['is_marked_notify'] ? $txt['notification_disable_topic'] : $txt['notification_enable_topic']) . '\');"', 'url' => $scripturl . '?action=notify;sa=' . ($context['is_marked_notify'] ? 'off' : 'on') . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']),
-		'mark_unread' => array('test' => 'can_mark_unread', 'text' => 'mark_unread', 'image' => 'markunread.png', 'lang' => true, 'url' => $scripturl . '?action=markasread;sa=topic;t=' . $context['mark_unread_time'] . ';topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']),
-		'send' => array('test' => 'can_send_topic', 'text' => 'send_topic', 'image' => 'sendtopic.png', 'lang' => true, 'url' => $scripturl . '?action=emailuser;sa=sendtopic;topic=' . $context['current_topic'] . '.0'),
-		'print' => array('test' => 'can_print', 'text' => 'print', 'image' => 'print.png', 'lang' => true, 'custom' => 'rel="new_win nofollow"', 'url' => $scripturl . '?action=printpage;topic=' . $context['current_topic'] . '.0'),
-	);
-
-	// Allow adding new buttons easily.
-	call_integration_hook('integrate_display_buttons', array(&$normal_buttons));
-
 	// Show the page index... "Pages: [1]".
 	echo '
 			<div class="pagesection">
-				<div class="nextlinks">', $context['previous_next'], '</div>', template_button_strip($normal_buttons, 'right'), '
+				<div class="nextlinks">', $context['previous_next'], '</div>', template_button_strip($context['normal_buttons'], 'right'), '
 				<div class="pagelinks floatleft">', $txt['pages'], ': ', $context['page_index'], !empty($modSettings['topbottomEnable']) ? $context['menu_separator'] . ' &nbsp;&nbsp;<a href="#lastPost"><strong>' . $txt['go_down'] . '</strong></a>' : '', '</div>
 			</div>';
 
@@ -664,7 +641,7 @@ function template_main()
 	// Show the page index... "Pages: [1]".
 	echo '
 			<div class="pagesection">
-				', template_button_strip($normal_buttons, 'right'), '
+				', template_button_strip($context['normal_buttons'], 'right'), '
 				<div class="pagelinks floatleft">', $txt['pages'], ': ', $context['page_index'], !empty($modSettings['topbottomEnable']) ? $context['menu_separator'] . ' &nbsp;&nbsp;<a href="#top"><strong>' . $txt['go_up'] . '</strong></a>' : '', '</div>
 				<div class="nextlinks_bottom">', $context['previous_next'], '</div>
 			</div>';
@@ -672,24 +649,8 @@ function template_main()
 	// Show the lower breadcrumbs.
 	theme_linktree();
 
-	$mod_buttons = array(
-		'move' => array('test' => 'can_move', 'text' => 'move_topic', 'image' => 'admin_move.png', 'lang' => true, 'url' => $scripturl . '?action=movetopic;current_board=' . $context['current_board'] . ';topic=' . $context['current_topic'] . '.0'),
-		'delete' => array('test' => 'can_delete', 'text' => 'remove_topic', 'image' => 'admin_rem.png', 'lang' => true, 'custom' => 'onclick="return confirm(\'' . $txt['are_sure_remove_topic'] . '\');"', 'url' => $scripturl . '?action=removetopic2;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id']),
-		'lock' => array('test' => 'can_lock', 'text' => empty($context['is_locked']) ? 'set_lock' : 'set_unlock', 'image' => 'admin_lock.png', 'lang' => true, 'url' => $scripturl . '?action=lock;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']),
-		'sticky' => array('test' => 'can_sticky', 'text' => empty($context['is_sticky']) ? 'set_sticky' : 'set_nonsticky', 'image' => 'admin_sticky.png', 'lang' => true, 'url' => $scripturl . '?action=sticky;topic=' . $context['current_topic'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']),
-		'merge' => array('test' => 'can_merge', 'text' => 'merge', 'image' => 'merge.png', 'lang' => true, 'url' => $scripturl . '?action=mergetopics;board=' . $context['current_board'] . '.0;from=' . $context['current_topic']),
-		'calendar' => array('test' => 'calendar_post', 'text' => 'calendar_link', 'image' => 'linktocal.png', 'lang' => true, 'url' => $scripturl . '?action=post;calendar;msg=' . $context['topic_first_message'] . ';topic=' . $context['current_topic'] . '.0'),
-	);
-
-	// Restore topic. eh?  No monkey business.
-	if ($context['can_restore_topic'])
-		$mod_buttons[] = array('text' => 'restore_topic', 'image' => '', 'lang' => true, 'url' => $scripturl . '?action=restoretopic;topics=' . $context['current_topic'] . ';' . $context['session_var'] . '=' . $context['session_id']);
-
-	// Allow adding new mod buttons easily.
-	call_integration_hook('integrate_mod_buttons', array(&$mod_buttons));
-
 	echo '
-			<div id="moderationbuttons">', template_button_strip($mod_buttons, 'bottom', array('id' => 'moderationbuttons_strip')), '</div>';
+			<div id="moderationbuttons">', template_button_strip($context['mod_buttons'], 'bottom', array('id' => 'moderationbuttons_strip')), '</div>';
 
 	// Show the jumpto box, or actually...let Javascript do it.
 	echo '

+ 2 - 14
Themes/default/Memberlist.template.php

@@ -15,12 +15,6 @@ function template_main()
 {
 	global $context, $settings, $options, $scripturl, $txt;
 
-	// Build the memberlist button array.
-	$memberlist_buttons = array(
-			'view_all_members' => array('text' => 'view_all_members', 'image' => 'mlist.png', 'lang' => true, 'url' => $scripturl . '?action=mlist' . ';sa=all', 'active'=> true),
-			'mlist_search' => array('text' => 'mlist_search', 'image' => 'mlist.png', 'lang' => true, 'url' => $scripturl . '?action=mlist' . ';sa=search'),
-		);
-
 	echo '
 	<div class="main_section" id="memberlist">
 		<div class="cat_bar">
@@ -33,7 +27,7 @@ function template_main()
 			</h4>
 		</div>
 		<div class="pagesection">
-			', template_button_strip($memberlist_buttons, 'right'), '
+			', template_button_strip($context['memberlist_buttons'], 'right'), '
 			<div class="pagelinks floatleft">', $txt['pages'], ': ', $context['page_index'], '</div>
 		</div>';
 
@@ -165,12 +159,6 @@ function template_search()
 {
 	global $context, $settings, $options, $scripturl, $txt;
 
-	// Build the memberlist button array.
-	$memberlist_buttons = array(
-			'view_all_members' => array('text' => 'view_all_members', 'image' => 'mlist.png', 'lang' => true, 'url' => $scripturl . '?action=mlist' . ';sa=all'),
-			'mlist_search' => array('text' => 'mlist_search', 'image' => 'mlist.png', 'lang' => true, 'url' => $scripturl . '?action=mlist' . ';sa=search', 'active' => true),
-		);
-
 	// Start the submission form for the search!
 	echo '
 	<form action="', $scripturl, '?action=mlist;sa=search" method="post" accept-charset="', $context['character_set'], '">
@@ -181,7 +169,7 @@ function template_search()
 				</h3>
 			</div>
 			<div class="pagesection">
-				', template_button_strip($memberlist_buttons, 'right'), '
+				', template_button_strip($context['memberlist_buttons'], 'right'), '
 			</div>';
 	
 	// Display the input boxes for the form.

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

@@ -121,27 +121,16 @@ function template_main()
 		echo '
 	<p class="description_board">', $context['description'], '</p>';
 
-	// Create the button set...
-	$normal_buttons = array(
-		'new_topic' => array('test' => 'can_post_new', 'text' => 'new_topic', 'image' => 'new_topic.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0', 'active' => true),
-		'post_poll' => array('test' => 'can_post_poll', 'text' => 'new_poll', 'image' => 'new_poll.png', 'lang' => true, 'url' => $scripturl . '?action=post;board=' . $context['current_board'] . '.0;poll'),
-		'notify' => array('test' => 'can_mark_notify', 'text' => $context['is_marked_notify'] ? 'unnotify' : 'notify', 'image' => ($context['is_marked_notify'] ? 'un' : ''). 'notify.png', 'lang' => true, 'custom' => 'onclick="return confirm(\'' . ($context['is_marked_notify'] ? $txt['notification_disable_board'] : $txt['notification_enable_board']) . '\');"', 'url' => $scripturl . '?action=notifyboard;sa=' . ($context['is_marked_notify'] ? 'off' : 'on') . ';board=' . $context['current_board'] . '.' . $context['start'] . ';' . $context['session_var'] . '=' . $context['session_id']),
-		'markread' => array('text' => 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'url' => $scripturl . '?action=markasread;sa=board;board=' . $context['current_board'] . '.0;' . $context['session_var'] . '=' . $context['session_id']),
-	);
-
 	// They can only mark read if they are logged in and it's enabled!
 	if (!$context['user']['is_logged'] || !$settings['show_mark_read'])
-		unset($normal_buttons['markread']);
-
-	// Allow adding new buttons easily.
-	call_integration_hook('integrate_messageindex_buttons', array(&$normal_buttons));
+		unset($context['normal_buttons']['markread']);
 
 	if (!$context['no_topic_listing'])
 	{
 		echo '
 	<div class="pagesection">
 		<div class="pagelinks floatleft">', $txt['pages'], ': ', $context['page_index'], !empty($modSettings['topbottomEnable']) ? $context['menu_separator'] . '&nbsp;&nbsp;<a href="#bot"><strong>' . $txt['go_down'] . '</strong></a>' : '', '</div>
-		', template_button_strip($normal_buttons, 'right'), '
+		', template_button_strip($context['normal_buttons'], 'right'), '
 	</div>';
 
 		// If Quick Moderation is enabled start the form.
@@ -362,7 +351,7 @@ function template_main()
 
 		echo '
 	<div class="pagesection">
-		', template_button_strip($normal_buttons, 'right'), '
+		', template_button_strip($context['normal_buttons'], 'right'), '
 		<div class="pagelinks">', $txt['pages'], ': ', $context['page_index'], !empty($modSettings['topbottomEnable']) ? $context['menu_separator'] . '&nbsp;&nbsp;<a href="#top"><strong>' . $txt['go_up'] . '</strong></a>' : '', '</div>
 	</div>';
 	}

+ 3 - 9
Themes/default/PersonalMessage.template.php

@@ -158,17 +158,11 @@ function template_folder()
 		// Show a few buttons if we are in conversation mode and outputting the first message.
 		if ($context['display_mode'] == 2)
 		{
-			// Build the normal button array.
-			$conversation_buttons = array(
-				'reply' => array('text' => 'reply_to_all', 'image' => 'reply.png', 'lang' => true, 'url' => $scripturl . '?action=pm;sa=send;f=' . $context['folder'] . ($context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '') . ';pmsg=' . $context['current_pm'] . ';u=all', 'active' => true),
-				'delete' => array('text' => 'delete_conversation', 'image' => 'delete.png', 'lang' => true, 'url' => $scripturl . '?action=pm;sa=pmactions;pm_actions[' . $context['current_pm'] . ']=delete;conversation;f=' . $context['folder'] . ';start=' . $context['start'] . ($context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '') . ';' . $context['session_var'] . '=' . $context['session_id'], 'custom' => 'onclick="return confirm(\'' . addslashes($txt['remove_message']) . '?\');"'),
-			);
-
 			// Show the conversation buttons.
 			echo '
 					<div class="pagesection">';
 
-			template_button_strip($conversation_buttons, 'right');
+			template_button_strip($context['conversation_buttons'], 'right');
 
 			echo '
 					</div>';
@@ -504,13 +498,13 @@ function template_folder()
 	</div>';
 
 		// Show a few buttons if we are in conversation mode and outputting the first message.
-		elseif ($context['display_mode'] == 2 && isset($conversation_buttons))
+		elseif ($context['display_mode'] == 2 && isset($context['conversation_buttons']))
 		{
 			echo '
 
 	<div class="pagesection">';
 
-			template_button_strip($conversation_buttons, 'right');
+			template_button_strip($context['conversation_buttons'], 'right');
 
 			echo '
 	</div>';

+ 22 - 61
Themes/default/Recent.template.php

@@ -89,38 +89,20 @@ function template_unread()
 	echo '
 	<div id="recent" class="main_content">';
 
-	$showCheckboxes = !empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $settings['show_mark_read'];
-
-	if ($showCheckboxes)
+	if ($context['showCheckboxes'])
 		echo '
 		<form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="quickModForm" id="quickModForm" style="margin: 0;">
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
 			<input type="hidden" name="qaction" value="markread" />
 			<input type="hidden" name="redirect_url" value="action=unread', (!empty($context['showing_all_topics']) ? ';all' : ''), $context['querystring_board_limits'], '" />';
 
-	if ($settings['show_mark_read'])
-	{
-		// Generate the button strip.
-		$mark_read = array(
-			'markread' => array('text' => !empty($context['no_board_limits']) ? 'mark_as_read' : 'mark_read_short', 'image' => 'markread.png', 'lang' => true, 'url' => $scripturl . '?action=markasread;sa=' . (!empty($context['no_board_limits']) ? 'all' : 'board' . $context['querystring_board_limits']) . ';' . $context['session_var'] . '=' . $context['session_id']),
-		);
-
-		if ($showCheckboxes)
-			$mark_read['markselectread'] = array(
-				'text' => 'quick_mod_markread',
-				'image' => 'markselectedread.png',
-				'lang' => true,
-				'url' => 'javascript:document.quickModForm.submit();',
-			);
-	}
-
 	if (!empty($context['topics']))
 	{
 		echo '
 			<div class="pagesection">';
 
-		if (!empty($mark_read) && !empty($settings['use_tabs']))
-			template_button_strip($mark_read, 'right');
+		if (!empty($context['recent_buttons']) && !empty($settings['use_tabs']))
+			template_button_strip($context['recent_buttons'], 'right');
 
 		echo '
 				<span>', $txt['pages'], ': ', $context['page_index'], '</span>
@@ -140,7 +122,7 @@ function template_unread()
 							</th>';
 
 		// Show a "select all" box for quick moderation?
-		if ($showCheckboxes)
+		if ($context['showCheckboxes'])
 			echo '
 							<th scope="col" width="22%">
 								<a href="', $scripturl, '?action=unread', $context['showing_all_topics'] ? ';all' : '', $context['querystring_board_limits'], ';sort=last_post', $context['sort_by'] == 'last_post' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt['last_post'], $context['sort_by'] == 'last_post' ? ' <img class="sort" src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.png" alt="" />' : '', '</a>
@@ -198,7 +180,7 @@ function template_unread()
 								', $txt['by'], ' ', $topic['last_post']['member']['link'], '
 							</td>';
 
-			if ($showCheckboxes)
+			if ($context['showCheckboxes'])
 				echo '
 							<td class="' . (!empty($color_class) ? $color_class : 'windowbg2') . '" valign="middle" align="center">
 								<input type="checkbox" name="topics[]" value="', $topic['id'], '" class="input_check" />
@@ -207,14 +189,11 @@ function template_unread()
 						</tr>';
 		}
 
-		if (!empty($context['topics']) && !$context['showing_all_topics'])
-			$mark_read['readall'] = array('text' => 'unread_topics_all', 'image' => 'markreadall.png', 'lang' => true, 'url' => $scripturl . '?action=unread;all' . $context['querystring_board_limits'], 'active' => true);
-
-		if (empty($settings['use_tabs']) && !empty($mark_read))
+		if (empty($settings['use_tabs']) && !empty($context['recent_buttons']))
 			echo '
 						<tr class="catbg">
-							<td colspan="', $showCheckboxes ? '6' : '5', '" align="right">
-								', template_button_strip($mark_read, 'top'), '
+							<td colspan="', $context['showCheckboxes'] ? '6' : '5', '" align="right">
+								', template_button_strip($context['recent_buttons'], 'top'), '
 							</td>
 						</tr>';
 
@@ -228,8 +207,8 @@ function template_unread()
 			</div>
 			<div class="pagesection" id="readbuttons">';
 
-		if (!empty($settings['use_tabs']) && !empty($mark_read))
-			template_button_strip($mark_read, 'right');
+		if (!empty($settings['use_tabs']) && !empty($context['recent_buttons']))
+			template_button_strip($context['recent_buttons'], 'right');
 
 		echo '
 				<span>', $txt['pages'], ': ', $context['page_index'], '</span>
@@ -243,7 +222,7 @@ function template_unread()
 				</h3>
 			</div>';
 
-	if ($showCheckboxes)
+	if ($context['showCheckboxes'])
 		echo '
 		</form>';
 
@@ -272,38 +251,20 @@ function template_replies()
 	echo '
 	<div id="recent">';
 
-	$showCheckboxes = !empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $settings['show_mark_read'];
-
-	if ($showCheckboxes)
+	if ($context['showCheckboxes'])
 		echo '
 		<form action="', $scripturl, '?action=quickmod" method="post" accept-charset="', $context['character_set'], '" name="quickModForm" id="quickModForm" style="margin: 0;">
 			<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
 			<input type="hidden" name="qaction" value="markread" />
 			<input type="hidden" name="redirect_url" value="action=unreadreplies', (!empty($context['showing_all_topics']) ? ';all' : ''), $context['querystring_board_limits'], '" />';
 
-	if (isset($context['topics_to_mark']) && !empty($settings['show_mark_read']))
-	{
-		// Generate the button strip.
-		$mark_read = array(
-			'markread' => array('text' => 'mark_as_read', 'image' => 'markread.png', 'lang' => true, 'url' => $scripturl . '?action=markasread;sa=unreadreplies;topics=' . $context['topics_to_mark'] . ';' . $context['session_var'] . '=' . $context['session_id']),
-		);
-
-		if ($showCheckboxes)
-			$mark_read['markselectread'] = array(
-				'text' => 'quick_mod_markread',
-				'image' => 'markselectedread.png',
-				'lang' => true,
-				'url' => 'javascript:document.quickModForm.submit();',
-			);
-	}
-
 	if (!empty($context['topics']))
 	{
 		echo '
 			<div class="pagesection">';
 
-		if (!empty($mark_read) && !empty($settings['use_tabs']))
-			template_button_strip($mark_read, 'right');
+		if (!empty($context['recent_buttons']) && !empty($settings['use_tabs']))
+			template_button_strip($context['recent_buttons'], 'right');
 
 		echo '
 				<span>', $txt['pages'], ': ', $context['page_index'], '</span>
@@ -323,7 +284,7 @@ function template_replies()
 							</th>';
 
 		// Show a "select all" box for quick moderation?
-		if ($showCheckboxes)
+		if ($context['showCheckboxes'])
 				echo '
 							<th scope="col" width="22%">
 								<a href="', $scripturl, '?action=unreadreplies', $context['querystring_board_limits'], ';sort=last_post', $context['sort_by'] === 'last_post' && $context['sort_direction'] === 'up' ? ';desc' : '', '">', $txt['last_post'], $context['sort_by'] === 'last_post' ? ' <img class="sort" src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.png" alt="" />' : '', '</a>
@@ -381,7 +342,7 @@ function template_replies()
 								', $txt['by'], ' ', $topic['last_post']['member']['link'], '
 							</td>';
 
-			if ($showCheckboxes)
+			if ($context['showCheckboxes'])
 				echo '
 							<td class="' . (!empty($color_class) ? $color_class : 'windowbg2') . '" valign="middle" align="center">
 								<input type="checkbox" name="topics[]" value="', $topic['id'], '" class="input_check" />
@@ -390,11 +351,11 @@ function template_replies()
 						</tr>';
 		}
 
-		if (empty($settings['use_tabs']) && !empty($mark_read))
+		if (empty($settings['use_tabs']) && !empty($context['recent_buttons']))
 			echo '
 						<tr class="catbg">
-							<td colspan="', $showCheckboxes ? '6' : '5', '" align="right">
-								', template_button_strip($mark_read, 'top'), '
+							<td colspan="', $context['showCheckboxes'] ? '6' : '5', '" align="right">
+								', template_button_strip($context['recent_buttons'], 'top'), '
 							</td>
 						</tr>';
 
@@ -404,8 +365,8 @@ function template_replies()
 			</div>
 			<div class="pagesection">';
 
-		if (!empty($settings['use_tabs']) && !empty($mark_read))
-			template_button_strip($mark_read, 'right');
+		if (!empty($settings['use_tabs']) && !empty($context['recent_buttons']))
+			template_button_strip($context['recent_buttons'], 'right');
 
 		echo '
 				<span>', $txt['pages'], ': ', $context['page_index'], '</span>
@@ -419,7 +380,7 @@ function template_replies()
 				</h3>
 			</div>';
 
-	if ($showCheckboxes)
+	if ($context['showCheckboxes'])
 		echo '
 		</form>';
 

+ 2 - 8
Themes/default/Reports.template.php

@@ -63,12 +63,6 @@ function template_main()
 {
 	global $context, $settings, $options, $scripturl, $txt, $modSettings;
 
-	// Build the reports button array.
-	$report_buttons = array(
-			'generate_reports' => array('text' => 'generate_reports', 'image' => 'print.png', 'lang' => true, 'url' => $scripturl . '?action=admin;area=reports', 'active' => true),
-			'print' => array('text' => 'print', 'image' => 'print.png', 'lang' => true, 'url' => $scripturl . '?action=admin;area=reports;rt=' . $context['report_type']. ';st=print', 'custom' => 'target="_blank"'),
-		);
-
 	echo '
 	<div id="admincenter">
 		<div class="title_bar">
@@ -76,8 +70,8 @@ function template_main()
 		</div>
 		<div id="report_buttons">';
 
-	if (!empty($report_buttons) && !empty($settings['use_tabs']))
-		template_button_strip($report_buttons, 'right');
+	if (!empty($context['report_buttons']) && !empty($settings['use_tabs']))
+		template_button_strip($context['report_buttons'], 'right');
 
 	echo '
 		</div>';