Browse Source

+ Add settings for message preview length, remove hard coded value
! Move preview message index preview setting to the theme settings page
! Provide option for first / last message preview via Settings
! Add titled span to the message subject to provide hovered preview

Spuds 13 years ago
parent
commit
8e50023464

+ 7 - 0
Sources/ManagePosts.php

@@ -196,6 +196,9 @@ function ModifyPostSettings($return_config = false)
 			array('int', 'spamWaitTime', 'postinput' => $txt['manageposts_seconds']),
 			array('int', 'edit_wait_time', 'postinput' => $txt['manageposts_seconds']),
 			array('int', 'edit_disable_time', 'subtext' => $txt['edit_disable_time_zero'], 'postinput' => $txt['manageposts_minutes']),
+		'',
+			// First & Last message preview lengths
+			array('int', 'preview_characters', 'subtext' => $txt['preview_characters_zero'], 'postinput' => $txt['preview_characters_units']),
 	);
 
 	call_integration_hook('integrate_modify_post_settings', array(&$config_vars));
@@ -249,6 +252,10 @@ function ModifyPostSettings($return_config = false)
 				$smcFunc['db_change_column']('{db_prefix}messages', 'body', array('type' => 'text'));
 			}
 		}
+		
+		// If we're changing the post preview length let's check its valid
+		if (!empty($_POST['preview_characters']))
+			$_POST['max_messageLength'] = (int) min(max(0, $_POST['max_messageLength']), 512);
 
 		call_integration_hook('integrate_save_post_settings');
 

+ 10 - 8
Sources/MessageIndex.php

@@ -365,8 +365,8 @@ function MessageIndex()
 				IFNULL(meml.real_name, ml.poster_name) AS last_display_name, t.id_first_msg,
 				mf.poster_time AS first_poster_time, mf.subject AS first_subject, mf.icon AS first_icon,
 				mf.poster_name AS first_member_name, mf.id_member AS first_id_member,
-				IFNULL(memf.real_name, mf.poster_name) AS first_display_name, SUBSTRING(ml.body, 1, 385) AS last_body,
-				SUBSTRING(mf.body, 1, 385) AS first_body, ml.smileys_enabled AS last_smileys, mf.smileys_enabled AS first_smileys
+				IFNULL(memf.real_name, mf.poster_name) AS first_display_name, SUBSTRING(ml.body, 1, ' . ($modSettings['preview_characters'] + 256) . ') AS last_body,
+				SUBSTRING(mf.body, 1, ' . ($modSettings['preview_characters'] + 256) . ') AS first_body, ml.smileys_enabled AS last_smileys, mf.smileys_enabled AS first_smileys
 			FROM {db_prefix}topics AS t
 				INNER JOIN {db_prefix}messages AS ml ON (ml.id_msg = t.id_last_msg)
 				INNER JOIN {db_prefix}messages AS mf ON (mf.id_msg = t.id_first_msg)
@@ -398,15 +398,17 @@ function MessageIndex()
 			if (!$pre_query)
 				$topic_ids[] = $row['id_topic'];
 
-			if (!empty($settings['message_index_preview']))
+			// Does the theme support message previews?
+			if (!empty($settings['message_index_preview']) && !empty($modSettings['preview_characters']))
 			{
-				// Limit them to 128 characters - do this FIRST because it's a lot of wasted censoring otherwise.
+				// Limit them to $modSettings['preview_characters'] characters
 				$row['first_body'] = strip_tags(strtr(parse_bbc($row['first_body'], $row['first_smileys'], $row['id_first_msg']), array('<br />' => '&#10;')));
-				if ($smcFunc['strlen']($row['first_body']) > 128)
-					$row['first_body'] = $smcFunc['substr']($row['first_body'], 0, 128) . '...';
+				if ($smcFunc['strlen']($row['first_body']) > $modSettings['preview_characters'])
+					$row['first_body'] = $smcFunc['substr']($row['first_body'], 0, $modSettings['preview_characters']) . '...';
+				
 				$row['last_body'] = strip_tags(strtr(parse_bbc($row['last_body'], $row['last_smileys'], $row['id_last_msg']), array('<br />' => '&#10;')));
-				if ($smcFunc['strlen']($row['last_body']) > 128)
-					$row['last_body'] = $smcFunc['substr']($row['last_body'], 0, 128) . '...';
+				if ($smcFunc['strlen']($row['last_body']) > $modSettings['preview_characters'])
+					$row['last_body'] = $smcFunc['substr']($row['last_body'], 0, $modSettings['preview_characters']) . '...';
 
 				// Censor the subject and message preview.
 				censorText($row['first_subject']);

+ 1 - 1
Themes/default/MessageIndex.template.php

@@ -255,7 +255,7 @@ function template_main()
 					</td>
 					<td class="subject ', $alternate_class, '">
 						<div ', (!empty($topic['quick_mod']['modify']) ? 'id="topic_' . $topic['first_post']['id'] . '" onmouseout="mouse_on_div = 0;" onmouseover="mouse_on_div = 1;" ondblclick="modify_topic(\'' . $topic['id'] . '\', \'' . $topic['first_post']['id'] . '\');"' : ''), '>
-							', $topic['is_sticky'] ? '<strong>' : '', '<span id="msg_' . $topic['first_post']['id'] . '">', $topic['first_post']['link'], ($context['can_approve_posts'] && !$topic['approved'] ? '&nbsp;<em>(' . $txt['awaiting_approval'] . ')</em>' : ''), '</span>', $topic['is_sticky'] ? '</strong>' : '';
+							', $topic['is_sticky'] ? '<strong>' : '', '<span title="', $topic[(empty($settings['message_index_preview_first']) ? 'last_post' : 'first_post')]['preview'], '"><span id="msg_' . $topic['first_post']['id'] . '">', $topic['first_post']['link'], ($context['can_approve_posts'] && !$topic['approved'] ? '&nbsp;<em>(' . $txt['awaiting_approval'] . ')</em>' : ''), '</span>', $topic['is_sticky'] ? '</strong>' : '';
 
 			// Is this topic new? (assuming they are logged in!)
 			if ($topic['new'] && $context['user']['is_logged'])

+ 2 - 2
Themes/default/Recent.template.php

@@ -179,7 +179,7 @@ function template_unread()
 							</td>
 							<td class="subject ', $color_class2, ' windowbg2">
 								<div>
-									', $topic['is_sticky'] ? '<strong>' : '', '<span id="msg_' . $topic['first_post']['id'] . '">', $topic['first_post']['link'], '</span>', $topic['is_sticky'] ? '</strong>' : '', '
+									', $topic['is_sticky'] ? '<strong>' : '', '<span title="', $topic[(empty($settings['message_index_preview_first']) ? 'last_post' : 'first_post')]['preview'], '"><span id="msg_' . $topic['first_post']['id'] . '">', $topic['first_post']['link'], '</span>', $topic['is_sticky'] ? '</strong>' : '', '
 									<a href="', $topic['new_href'], '" id="newicon', $topic['first_post']['id'], '"><span class="new_posts">' . $txt['new'] . '</span></a>
 									<p>
 										', $txt['started_by'], ' <strong>', $topic['first_post']['member']['link'], '</strong>
@@ -363,7 +363,7 @@ function template_replies()
 							</td>
 							<td class="subject ', $color_class2, ' windowbg2">
 								<div>
-									', $topic['is_sticky'] ? '<strong>' : '', '<span id="msg_' . $topic['first_post']['id'] . '">', $topic['first_post']['link'], '</span>', $topic['is_sticky'] ? '</strong>' : '', '
+									', $topic['is_sticky'] ? '<strong>' : '', '<span title="', $topic[(empty($settings['message_index_preview_first']) ? 'last_post' : 'first_post')]['preview'], '"><span id="msg_' . $topic['first_post']['id'] . '">', $topic['first_post']['link'], '</span>', $topic['is_sticky'] ? '</strong>' : '', '
 									<a href="', $topic['new_href'], '" id="newicon', $topic['first_post']['id'], '"><span class="new_posts">' . $txt['new'] . '</span></a>
 									<p>
 										', $txt['started_by'], ' <strong>', $topic['first_post']['member']['link'], '</strong>

+ 10 - 0
Themes/default/Settings.template.php

@@ -263,6 +263,16 @@ function template_settings()
 			'id' => 'additional_options_collapsable',
 			'label' => $txt['additional_options_collapsable'],
 		),
+	'',
+		array(
+			'id' => 'message_index_preview',
+			'label' => $txt['message_index_preview'],
+		),
+		array(
+			'id' => 'message_index_preview_first',
+			'label' => $txt['message_index_preview_first'],
+			'description' => $txt['message_index_preview_first_desc'],
+		),
 	);
 }
 

+ 1 - 4
Themes/default/index.template.php

@@ -68,9 +68,6 @@ function template_init()
 	// Does this theme use the strict doctype?
 	$settings['strict_doctype'] = false;
 
-	// Does this theme use post previews on the message index?
-	$settings['message_index_preview'] = false;
-
 	// Set the following variable to true if this theme requires the optional theme strings file to be loaded.
 	$settings['require_theme_strings'] = false;
 }
@@ -331,7 +328,7 @@ function template_body_above()
 		// If we're on a certain board, limit it to this board ;).
 		elseif (!empty($context['current_board']))
 			echo '
-				<input type="hidden" name="', (!empty($modSettings['search_dropdown']) ? 'sd_brd[' : 'brd['), $context['current_board'],   ']"', 'value="', $context['current_board'], '" />';
+				<input type="hidden" name="', (!empty($modSettings['search_dropdown']) ? 'sd_brd[' : 'brd['), $context['current_board'], ']"', ' value="', $context['current_board'], '" />';
 
 		echo '
 				<input type="submit" name="search2" value="', $txt['search'], '" class="button_submit" />

+ 3 - 0
Themes/default/languages/Admin.english.php

@@ -507,6 +507,9 @@ $txt['spamWaitTime'] = 'Time required between posts from the same IP';
 $txt['edit_wait_time'] = 'Courtesy edit wait time';
 $txt['edit_disable_time'] = 'Maximum time after posting to allow edit';
 $txt['edit_disable_time_zero'] = '0 to disable';
+$txt['preview_characters'] = 'Maximum length of last/first post preview';
+$txt['preview_characters_units'] = 'characters';
+$txt['preview_characters_zero'] = '0 to disable';
 
 $txt['enableBBC'] = 'Enable bulletin board code (BBC)';
 $txt['enablePostHTML'] = 'Enable <em>basic</em> HTML in posts';

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

@@ -391,6 +391,7 @@ $helptxt['loginHistoryDays'] = 'The number of days to keep login history under u
 $helptxt['oldTopicDays'] = 'If this option is enabled a warning will be displayed to the user when attempting to reply to a topic which has not had any new replies for the amount of time, in days, specified by this setting. Set this setting to 0 to disable the feature.';
 $helptxt['edit_wait_time'] = 'Number of seconds allowed for a post to be edited before logging the last edit date.';
 $helptxt['edit_disable_time'] = 'Number of minutes allowed to pass before a user can no longer edit a post they have made. Set to 0 disable. <br /><br /><em>Note: This will not affect any user who has permission to edit other people\'s posts.</em>';
+$helptxt['preview_characters'] = 'This option sets the number of available characters for the first and last message topic preview.  <strong>Note</strong> this only makes the information available to the theme, the theme must support the message_index_preview setting';
 $helptxt['posts_require_captcha'] = 'This setting will force users to pass anti-spam bot verification each time they make a post to a board. Only users with a post count below the number set will need to enter the code - this should help combat automated spamming scripts.';
 $helptxt['enableSpellChecking'] = 'Enable spell checking. You MUST have the pspell library installed on your server and your PHP configuration set up to use the pspell library. Your server ' . (function_exists('pspell_new') ? 'DOES' : 'DOES NOT') . ' appear to have this set up.';
 $helptxt['disable_wysiwyg'] = 'This setting disallows all users from using the WYSIWYG (&quot;What You See Is What You Get&quot;) editor on the post page.';

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

@@ -63,6 +63,9 @@ $txt['forum_width_desc'] = 'Set the forum width. Examples: 950px, 80%, 1240px.';
 $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 show 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';
 $txt['who_display_viewing_off'] = 'Don\'t show';