Przeglądaj źródła

Merge branch 'release-2.1' of https://github.com/SimpleMachines/SMF2.1

emanuele 12 lat temu
rodzic
commit
bf2e8f49d4

+ 3 - 3
Sources/Admin.php

@@ -25,7 +25,7 @@ if (!defined('SMF'))
  */
 function AdminMain()
 {
-	global $txt, $context, $scripturl, $sc, $modSettings, $user_info, $settings, $sourcedir, $options, $smcFunc, $boarddir;
+	global $txt, $context, $scripturl, $modSettings, $settings, $sourcedir, $options, $boarddir;
 
 	// Load the language and templates....
 	loadLanguage('Admin');
@@ -510,7 +510,7 @@ function AdminMain()
 */
 function AdminHome()
 {
-	global $sourcedir, $forum_version, $txt, $scripturl, $context, $user_info, $boardurl, $modSettings, $smcFunc;
+	global $sourcedir, $forum_version, $txt, $scripturl, $context, $user_info;
 
 	// You have to be able to do at least one of the below to see this page.
 	isAllowedTo(array('admin_forum', 'manage_permissions', 'moderate_forum', 'manage_membergroups', 'manage_bans', 'send_mail', 'edit_news', 'manage_boards', 'manage_smileys', 'manage_attachments'));
@@ -1005,4 +1005,4 @@ function AdminEndSession()
 	redirectexit('action=admin');
 }
 
-?>
+?>

+ 1 - 1
Sources/Display.php

@@ -1812,4 +1812,4 @@ function QuickInTopicModeration()
 	redirectexit(!empty($topicGone) ? 'board=' . $board : 'topic=' . $topic . '.' . $_REQUEST['start']);
 }
 
-?>
+?>

+ 2 - 2
Sources/Load.php

@@ -1182,7 +1182,7 @@ function loadMemberContext($user, $display_custom_fields = false)
 			'group_id' => $profile['id_group'],
 			'post_group' => $profile['post_group'],
 			'post_group_color' => $profile['post_group_color'],
-			'group_icons' => str_repeat('<img src="' . str_replace('$language', $context['user']['language'], isset($profile['icons'][1]) ? $settings['images_url'] . '/' . $profile['icons'][1] : '') . '" alt="*" />', empty($profile['icons'][0]) || empty($profile['icons'][1]) ? 0 : $profile['icons'][0]),
+			'group_icons' => str_repeat('<img src="' . str_replace('$language', $context['user']['language'], isset($profile['icons'][1]) ? $settings['images_url'] . '/membericons/' . $profile['icons'][1] : '') . '" alt="*" />', empty($profile['icons'][0]) || empty($profile['icons'][1]) ? 0 : $profile['icons'][0]),
 			'warning' => $profile['warning'],
 			'warning_status' => !empty($modSettings['warning_mute']) && $modSettings['warning_mute'] <= $profile['warning'] ? 'mute' : (!empty($modSettings['warning_moderate']) && $modSettings['warning_moderate'] <= $profile['warning'] ? 'moderate' : (!empty($modSettings['warning_watch']) && $modSettings['warning_watch'] <= $profile['warning'] ? 'watch' : (''))),
 			'local_time' => timeformat(time() + ($profile['time_offset'] - $user_info['time_offset']) * 3600, false),
@@ -2947,4 +2947,4 @@ function get_memcached_server($level = 3)
 		get_memcached_server($level - 1);
 }
 
-?>
+?>

+ 36 - 2
Sources/ManageMembergroups.php

@@ -628,7 +628,7 @@ function DeleteMembergroup()
  */
 function EditMembergroup()
 {
-	global $context, $txt, $sourcedir, $modSettings, $smcFunc;
+	global $context, $txt, $sourcedir, $modSettings, $smcFunc, $settings;
 
 	$_REQUEST['group'] = isset($_REQUEST['group']) && $_REQUEST['group'] > 0 ? (int) $_REQUEST['group'] : 0;
 
@@ -1078,6 +1078,40 @@ function EditMembergroup()
 		if ($max_boards == 1)
 			$max_boards = 2;
 	}
+	
+	// Get a list of all the image formats we can select.
+	$imageExts = array('png', 'jpg', 'jpeg', 'bmp', 'gif');
+	
+	// Scan the directory.
+	$context['possible_icons'] = array();
+	if ($files = scandir($settings['default_theme_dir'] . '/images/membericons'))
+	{
+		// Loop through every file in the directory.
+		foreach ($files as $value)
+		{
+			// Grab the image extension.
+			$ext = pathinfo($settings['default_theme_dir'] . '/images/membericons/' . $value, PATHINFO_EXTENSION);
+			
+			// If the extension is not empty, and it is valid, 
+			if (!empty($ext) && in_array($ext, $imageExts))
+			{
+				// Get the size of the image.
+				$image_info = getimagesize($settings['default_theme_dir'] . '/images/membericons/' . $value);
+				
+				// If this is bigger than 128 in width or 32 in height, skip this one.
+				if ($image_info == false || $image_info[0] > 128 || $image_info[1] > 32)
+					continue;
+					
+				// Else it's valid. Add it in.
+				else
+					$context['possible_icons'][] = $value;
+			}
+		}
+	}
+	
+	// Insert our JS, if we have possible icons.
+	if (!empty($context['possible_icons']))
+		loadJavascriptFile('icondropdown.js', array('validate' => true));
 
 	// Finally, get all the groups this could be inherited off.
 	$request = $smcFunc['db_query']('', '
@@ -1157,4 +1191,4 @@ function ModifyMembergroupsettings()
 	prepareDBSettingContext($config_vars);
 }
 
-?>
+?>

+ 2 - 2
Sources/Subs-Membergroups.php

@@ -702,7 +702,7 @@ function list_getMembergroups($start, $items_per_page, $sort, $membergroup_type)
 			'type' => $row['group_type'],
 			'num_members' => $row['num_members'],
 			'moderators' => array(),
-			'icons' => !empty($row['icons'][0]) && !empty($row['icons'][1]) ? str_repeat('<img src="' . $settings['images_url'] . '/' . $row['icons'][1] . '" alt="*" />', $row['icons'][0]) : '',
+			'icons' => !empty($row['icons'][0]) && !empty($row['icons'][1]) ? str_repeat('<img src="' . $settings['images_url'] . '/membericons/' . $row['icons'][1] . '" alt="*" />', $row['icons'][0]) : '',
 		);
 
 		$context['can_moderate'] |= $row['can_moderate'];
@@ -794,4 +794,4 @@ function list_getMembergroups($start, $items_per_page, $sort, $membergroup_type)
 	return $groups;
 }
 
-?>
+?>

+ 29 - 6
Themes/default/ManageMembergroups.template.php

@@ -269,17 +269,40 @@ function template_edit_group()
 							<label for="icon_count_input"><strong>', $txt['membergroups_icon_count'], ':</strong></label>
 						</dt>
 						<dd>
-							<input type="text" name="icon_count" id="icon_count_input" value="', $context['group']['icon_count'], '" size="4" onkeyup="if (this.value.length > 2) this.value = 99;" onkeydown="this.onkeyup();" onchange="if (this.value != 0) this.form.icon_image.onchange();" class="input_text" />
-						</dd>
+							<input type="text" name="icon_count" id="icon_count_input" value="', $context['group']['icon_count'], '" size="4" class="input_text" />
+						</dd>';
+        
+        // Do we have any possible icons to select from?
+       	if (!empty($context['possible_icons']))
+       	{
+       		echo '
 						<dt>
 							<label for="icon_image_input"><strong>', $txt['membergroups_icon_image'], ':</strong></label><br />
 							<span class="smalltext">', $txt['membergroups_icon_image_note'], '</span>
 						</dt>
 						<dd>
 							', $txt['membergroups_images_url'], '
-							<input type="text" name="icon_image" id="icon_image_input" value="', $context['group']['icon_image'], '" onchange="if (this.value &amp;&amp; this.form.icon_count.value == 0) this.form.icon_count.value = 1; else if (!this.value) this.form.icon_count.value = 0; document.getElementById(\'star_preview\').src = smf_images_url + \'/\' + (this.value &amp;&amp; this.form.icon_count.value > 0 ? this.value.replace(/\$language/g, \'', $context['user']['language'], '\') : \'blank.png\');" size="20" class="input_text" />
-							<img id="star_preview" src="', $settings['images_url'], '/', $context['group']['icon_image'] == '' ? 'blank.png' : $context['group']['icon_image'], '" alt="*" />
-						</dd>
+							<select name="icon_image" id="icon_image_input">';
+
+		// For every possible icon, create an option.
+		foreach ($context['possible_icons'] as $icon)
+		{
+			echo '
+								<option value="', $icon, '"', $context['group']['icon_image'] == $icon ? ' selected="selected"' : '', '>', $icon, '</option>';
+		}
+	
+		echo '
+							</select>
+							<img id="icon_preview" src="" alt="*" />
+						</dd>';
+	}
+	
+	// No? Hide the entire control.
+	else
+		echo '
+						<input type="hidden" name="icon_image" value="" />';
+						
+	echo '
 						<dt>
 							<label for="max_messages_input"><strong>', $txt['membergroups_max_messages'], ':</strong></label><br />
 							<span class="smalltext">', $txt['membergroups_max_messages_note'], '</span>
@@ -684,4 +707,4 @@ function template_group_request_reason()
 	</div>';
 }
 
-?>
+?>

BIN
Themes/default/images/membericons/blank.png


+ 0 - 0
Themes/default/images/icon.png → Themes/default/images/membericons/icon.png


+ 0 - 0
Themes/default/images/iconadmin.png → Themes/default/images/membericons/iconadmin.png


+ 0 - 0
Themes/default/images/icongmod.png → Themes/default/images/membericons/icongmod.png


+ 0 - 0
Themes/default/images/iconmod.png → Themes/default/images/membericons/iconmod.png


+ 1 - 1
Themes/default/languages/ManageMaintenance.english.php

@@ -193,7 +193,7 @@ $txt['utf8_cannot_convert_fulltext'] = 'Your messages table is using a fulltext
 $txt['text_title'] = 'Convert to TEXT';
 $txt['mediumtext_title'] = 'Convert to MEDIUMTEXT';
 $txt['mediumtext_introduction'] = 'The default messages table can contain posts up to a size of 65535 characters, in order be able to store bigger texts the column must be converted to "MEDIUMTEXT". It is also possible to revert the column back to TEXT (that operation would reduce the space occupied), but <strong>only if</strong> none of the posts in your database exceed the size of 65535 characters. This condition will be verified before the conversion.';
-$txt['body_checking_introduction'] = 'This function will convert the column of your database that contains the text of the messages into a "TEXT" format (currently is "MEDIUMTEXT". This operation will allow to slightly reduce the amount of space occupied by each message (1 byte per message). If any message stored into the database is longer than 65535 characters it will be truncated and part of the text will be lost.';
+$txt['body_checking_introduction'] = 'This function will convert the column of your database that contains the text of the messages into a "TEXT" format (currently is "MEDIUMTEXT"). This operation will allow to slightly reduce the amount of space occupied by each message (1 byte per message). If any message stored into the database is longer than 65535 characters it will be truncated and part of the text will be lost.';
 $txt['exceeding_messages'] = 'The following messages are longer than 65535 characters and will be truncated by the process:';
 $txt['exceeding_messages_morethan'] = 'And other %1$d';
 $txt['convert_to_text'] = 'No messages are longer than 65535 characters. You can safely proceed with the conversion without losing any part of the text.';

+ 3 - 3
Themes/default/languages/ManageMembers.english.php

@@ -49,7 +49,7 @@ $txt['membergroups_min_posts'] = 'Required posts';
 $txt['membergroups_online_color'] = 'Color in online list';
 $txt['membergroups_icon_count'] = 'Number of icon images';
 $txt['membergroups_icon_image'] = 'Icon image filename';
-$txt['membergroups_icon_image_note'] = 'you can use $language for the language of the user';
+$txt['membergroups_icon_image_note'] = 'You can upload custom images to the default theme directory to be able to select them here.';
 $txt['membergroups_max_messages'] = 'Max personal messages';
 $txt['membergroups_max_messages_note'] = '0 = unlimited';
 $txt['membergroups_edit_save'] = 'Save';
@@ -74,7 +74,7 @@ $txt['membergroups_postgroups'] = 'Post groups';
 $txt['membergroups_settings'] = 'Membergroup Settings';
 $txt['groups_manage_membergroups'] = 'Groups allowed to change membergroups';
 $txt['membergroups_select_permission_type'] = 'Select permission profile';
-$txt['membergroups_images_url'] = '{theme URL}/images/';
+$txt['membergroups_images_url'] = 'Themes/{theme}/images/membericons/';
 $txt['membergroups_select_visible_boards'] = 'Show boards';
 $txt['membergroups_members_top'] = 'Members';
 $txt['membergroups_name'] = 'Name';
@@ -127,4 +127,4 @@ $txt['dont_check_for_duplicate'] = 'Don\'t check for duplicates';
 $txt['duplicates'] = 'Duplicates';
 
 $txt['not_activated'] = 'Not activated';
-?>
+?>

+ 1 - 1
Themes/default/languages/Themes.english.php

@@ -64,7 +64,7 @@ $txt['enable_random_news'] = 'Enable random news line in the forum header';
 $txt['show_group_key'] = 'Show group key on board index';
 $txt['additional_options_collapsable'] = 'Enable collapsible additional post options';
 $txt['message_index_preview'] = 'Show post previews on the message index';
-$txt['message_index_preview_first'] = 'When using post previews, Show the text of the first post';
+$txt['message_index_preview_first'] = 'When using post previews, show the text of the first post';
 $txt['message_index_preview_first_desc'] = 'Leave un-checked to show the text of the last post instead';
 $txt['allow_no_censored'] = 'Allow users to turn off word censoring';
 $txt['who_display_viewing'] = 'Show who is viewing the board index and posts';

+ 34 - 0
Themes/default/scripts/icondropdown.js

@@ -0,0 +1,34 @@
+$(document).ready(function()
+{	
+	$('#icon_count_input').change(function ()
+	{
+		var select_box = $('select#icon_image_input option:selected').val();
+		var icon_count = $('#icon_count_input');
+		if (icon_count.val() == 0 && select_box != 'blank.png')
+			icon_count.val(1);
+			
+		if (icon_count.val().length > 2)
+			icon_count.val(99);
+	});
+	
+	$('#icon_image_input').change(function ()
+	{
+		refreshIconPreview();
+	});
+
+	refreshIconPreview();
+});
+
+function refreshIconPreview()
+{
+	// Get the icon count element.
+	var icon_count = $('#icon_count_input');
+	var select_box = $('select#icon_image_input').val();
+
+	// If it's empty, set it to 1.
+	if (icon_count.val() == 0 && select_box != 'blank.png')
+		icon_count.val(1);
+
+	// Update the icon preview.
+	$('#icon_preview').attr('src', smf_default_theme_url + '/images/membericons/' + select_box);
+}