diff --git a/phpBB/adm/style/acp_search.html b/phpBB/adm/style/acp_search.html
index deae1234bb..54d277ed39 100644
--- a/phpBB/adm/style/acp_search.html
+++ b/phpBB/adm/style/acp_search.html
@@ -36,6 +36,13 @@
{L_MAX_NUM_SEARCH_KEYWORDS_EXPLAIN}
+
+ -
+
+
{{ lang('DEFAULT_SEARCH_RETURN_CHARS_EXPLAIN') }}
+
+
+
{L_SEARCH_STORE_RESULTS_EXPLAIN}
- {L_SECONDS}
diff --git a/phpBB/includes/acp/acp_search.php b/phpBB/includes/acp/acp_search.php
index 538a28a926..e59e06e1cd 100644
--- a/phpBB/includes/acp/acp_search.php
+++ b/phpBB/includes/acp/acp_search.php
@@ -62,15 +62,16 @@ class acp_search
$search_types = $this->get_search_types();
- $settings = array(
- 'search_interval' => 'float',
- 'search_anonymous_interval' => 'float',
- 'load_search' => 'bool',
- 'limit_search_load' => 'float',
- 'min_search_author_chars' => 'integer',
- 'max_num_search_keywords' => 'integer',
- 'search_store_results' => 'integer',
- );
+ $settings = [
+ 'search_interval' => 'float',
+ 'search_anonymous_interval' => 'float',
+ 'load_search' => 'bool',
+ 'limit_search_load' => 'float',
+ 'min_search_author_chars' => 'integer',
+ 'max_num_search_keywords' => 'integer',
+ 'default_search_return_chars' => 'integer',
+ 'search_store_results' => 'integer',
+ ];
$search = null;
$error = false;
@@ -219,20 +220,21 @@ class acp_search
$this->tpl_name = 'acp_search';
$this->page_title = 'ACP_SEARCH_SETTINGS';
- $template->assign_vars(array(
- 'LIMIT_SEARCH_LOAD' => (float) $config['limit_search_load'],
- 'MIN_SEARCH_AUTHOR_CHARS' => (int) $config['min_search_author_chars'],
- 'SEARCH_INTERVAL' => (float) $config['search_interval'],
- 'SEARCH_GUEST_INTERVAL' => (float) $config['search_anonymous_interval'],
- 'SEARCH_STORE_RESULTS' => (int) $config['search_store_results'],
- 'MAX_NUM_SEARCH_KEYWORDS' => (int) $config['max_num_search_keywords'],
+ $template->assign_vars([
+ 'DEFAULT_SEARCH_RETURN_CHARS' => (int) $config['default_search_return_chars'],
+ 'LIMIT_SEARCH_LOAD' => (float) $config['limit_search_load'],
+ 'MIN_SEARCH_AUTHOR_CHARS' => (int) $config['min_search_author_chars'],
+ 'SEARCH_INTERVAL' => (float) $config['search_interval'],
+ 'SEARCH_GUEST_INTERVAL' => (float) $config['search_anonymous_interval'],
+ 'SEARCH_STORE_RESULTS' => (int) $config['search_store_results'],
+ 'MAX_NUM_SEARCH_KEYWORDS' => (int) $config['max_num_search_keywords'],
'S_SEARCH_TYPES' => $search_options,
'S_YES_SEARCH' => (bool) $config['load_search'],
'S_SETTINGS' => true,
- 'U_ACTION' => $this->u_action . '&hash=' . generate_link_hash('acp_search'))
- );
+ 'U_ACTION' => $this->u_action . '&hash=' . generate_link_hash('acp_search'),
+ ]);
}
function index($id, $mode)
diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql
index 86dc1fbebd..0dd0b52949 100644
--- a/phpBB/install/schemas/schema_data.sql
+++ b/phpBB/install/schemas/schema_data.sql
@@ -99,6 +99,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('display_last_subje
INSERT INTO phpbb_config (config_name, config_value) VALUES ('display_order', '0');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('edit_time', '0');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('extension_force_unstable', '0');
+INSERT INTO phpbb_config (config_name, config_value) VALUES ('default_search_return_chars', '300');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('delete_time', '0');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('email_check_mx', '1');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('email_enable', '1');
diff --git a/phpBB/language/en/acp/search.php b/phpBB/language/en/acp/search.php
index 443dbb7fb7..a79c67fd8e 100644
--- a/phpBB/language/en/acp/search.php
+++ b/phpBB/language/en/acp/search.php
@@ -49,6 +49,8 @@ $lang = array_merge($lang, array(
'CONTINUE_INDEXING_EXPLAIN' => 'An indexing process has been started. In order to access the search index page you will have to complete it or cancel it.',
'CREATE_INDEX' => 'Create index',
+ 'DEFAULT_SEARCH_RETURN_CHARS' => 'Default number of returned characters',
+ 'DEFAULT_SEARCH_RETURN_CHARS_EXPLAIN' => 'The default number of characters that will be returned while searching. A value of 0 will return the entire post.',
'DELETE_INDEX' => 'Delete index',
'DELETING_INDEX_IN_PROGRESS' => 'Deleting the index in progress',
'DELETING_INDEX_IN_PROGRESS_EXPLAIN' => 'The search backend is currently cleaning its index. This can take a few minutes.',
diff --git a/phpBB/language/en/search.php b/phpBB/language/en/search.php
index 13e5bf7a97..f89107ed1b 100644
--- a/phpBB/language/en/search.php
+++ b/phpBB/language/en/search.php
@@ -87,6 +87,7 @@ $lang = array_merge($lang, array(
'RESULT_DAYS' => 'Limit results to previous',
'RESULT_SORT' => 'Sort results by',
'RETURN_FIRST' => 'Return first',
+ 'RETURN_FIRST_EXPLAIN' => 'Set to 0 to display the entire post.',
'GO_TO_SEARCH_ADV' => 'Go to advanced search',
'SEARCHED_FOR' => 'Search term used',
diff --git a/phpBB/phpbb/db/migration/data/v33x/default_search_return_chars.php b/phpBB/phpbb/db/migration/data/v33x/default_search_return_chars.php
new file mode 100644
index 0000000000..ec1e7af11f
--- /dev/null
+++ b/phpBB/phpbb/db/migration/data/v33x/default_search_return_chars.php
@@ -0,0 +1,36 @@
+
+ * @license GNU General Public License, version 2 (GPL-2.0)
+ *
+ * For full copyright and license information, please see
+ * the docs/CREDITS.txt file.
+ *
+ */
+
+namespace phpbb\db\migration\data\v33x;
+
+class default_search_return_chars extends \phpbb\db\migration\migration
+{
+ public function effectively_installed()
+ {
+ return $this->config->offsetExists('default_search_return_chars');
+ }
+
+ public static function depends_on()
+ {
+ return [
+ '\phpbb\db\migration\data\v330\v330',
+ ];
+ }
+
+ public function update_data()
+ {
+ return [
+ ['config.add', ['default_search_return_chars', 300]],
+ ];
+ }
+}
diff --git a/phpBB/search.php b/phpBB/search.php
index 5d5e9f5f8a..678b4d9ff8 100644
--- a/phpBB/search.php
+++ b/phpBB/search.php
@@ -47,7 +47,7 @@ $sort_days = $request->variable('st', 0);
$sort_key = $request->variable('sk', 't');
$sort_dir = $request->variable('sd', 'd');
-$return_chars = $request->variable('ch', ($topic_id) ? -1 : 300);
+$return_chars = $request->variable('ch', $topic_id ? 0 : (int) $config['default_search_return_chars']);
$search_forum = $request->variable('fid', array(0));
// We put login boxes for the case if search_id is newposts, egosearch or unreadposts
@@ -692,7 +692,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
$u_search .= ($u_search_forum) ? '&fid%5B%5D=' . $u_search_forum : '';
$u_search .= (!$search_child) ? '&sc=0' : '';
$u_search .= ($search_fields != 'all') ? '&sf=' . $search_fields : '';
- $u_search .= ($return_chars != 300) ? '&ch=' . $return_chars : '';
+ $u_search .= $return_chars !== (int) $config['default_search_return_chars'] ? '&ch=' . $return_chars : '';
/**
* Event to add or modify search URL parameters
@@ -975,7 +975,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
strip_bbcode($text_only_message, $row['bbcode_uid']);
}
- if ($return_chars == -1 || utf8_strlen($text_only_message) < ($return_chars + 3))
+ if ($return_chars === 0 || utf8_strlen($text_only_message) < ($return_chars + 3))
{
$row['display_text_only'] = false;
@@ -1475,16 +1475,27 @@ if (!$s_forums)
trigger_error('NO_SEARCH');
}
-// Number of chars returned
-$s_characters = '';
-$s_characters .= '';
-$s_characters .= '';
-$s_characters .= '';
+/**
+ * Build options for a select list for the number of characters returned.
+ *
+ * If the admin defined amount is not within the predefined range,
+ * and the admin did not set it to unlimited (0), we add that option aswell.
+ *
+ * @deprecated 3.3.1-RC1 Templates should use an numeric input, in favor of a select.
+ */
+$s_characters = '';
+$i_characters = array_merge([25, 50], range(100, 1000, 100));
-for ($i = 100; $i <= 1000; $i += 100)
+if ($config['default_search_return_chars'] && !in_array((int) $config['default_search_return_chars'], $i_characters))
{
- $selected = ($i == 300) ? ' selected="selected"' : '';
- $s_characters .= '';
+ $i_characters[] = (int) $config['default_search_return_chars'];
+ sort($i_characters);
+}
+
+foreach ($i_characters as $i)
+{
+ $selected = $i === (int) $config['default_search_return_chars'] ? ' selected="selected"' : '';
+ $s_characters .= sprintf('', $i, $selected);
}
$s_hidden_fields = array('t' => $topic_id);
@@ -1504,6 +1515,7 @@ if (!empty($_EXTRA_URL))
}
$template->assign_vars(array(
+ 'DEFAULT_RETURN_CHARS' => (int) $config['default_search_return_chars'],
'S_SEARCH_ACTION' => append_sid("{$phpbb_root_path}search.$phpEx", false, true, 0), // We force no ?sid= appending by using 0
'S_HIDDEN_FIELDS' => build_hidden_fields($s_hidden_fields),
'S_CHARACTER_OPTIONS' => $s_characters,
diff --git a/phpBB/styles/prosilver/template/search_body.html b/phpBB/styles/prosilver/template/search_body.html
index b194175892..28ffbbd08b 100644
--- a/phpBB/styles/prosilver/template/search_body.html
+++ b/phpBB/styles/prosilver/template/search_body.html
@@ -79,8 +79,11 @@
- {S_SELECT_SORT_DAYS}
-
- - {L_POST_CHARACTERS}
+ -
+
+
{{ lang('RETURN_FIRST_EXPLAIN') }}
+
+ - {{ lang('POST_CHARACTERS') }}