From 03e3d4694c22fcc9eb7df6b90c44b9a5c3617614 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Wed, 23 Sep 2009 21:50:42 -0400 Subject: [PATCH] improve search results --- classes/WhatDidTheySayAdmin.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/classes/WhatDidTheySayAdmin.php b/classes/WhatDidTheySayAdmin.php index e48aec7..17ee34c 100644 --- a/classes/WhatDidTheySayAdmin.php +++ b/classes/WhatDidTheySayAdmin.php @@ -188,7 +188,6 @@ class WhatDidTheySayAdmin { } function the_matching_transcript_excerpts($transcripts, $search_string = '', $output = "") { - var_dump($search_string); ob_start(); if (!empty($search_string)) { $language_options = new WDTSLanguageOptions(); @@ -198,7 +197,7 @@ class WhatDidTheySayAdmin { if (($pos = strpos($transcript['transcript'], $search_string)) !== false) { $l = strlen($transcript['transcript']) - 1; echo '
'; - echo '

' . sprintf(__("%s transcript:", 'what-did-they-say'), $language_options->get_language_name($transcript['language'])) . '

'; + echo '

' . sprintf(__("%s transcript excerpt:", 'what-did-they-say'), $language_options->get_language_name($transcript['language'])) . '

'; echo '

'; $start_ellipsis = $end_ellipsis = true; foreach (array( @@ -207,14 +206,16 @@ class WhatDidTheySayAdmin { ) as $variable => $direction) { ${$variable} = $pos + ($options['excerpt_distance'] * $direction); + if ($variable == "end") { ${$variable} += strlen($search_string); } + if (${$variable} < 0) { ${$variable} = 0; $start_ellipsis = false; } if (${$variable} > $l) { ${$variable} = $l; $end_ellipsis = false; } } $output = ""; - if ($start_ellipsis) { $output .= "... "; } - $output .= str_replace($search_string, "" . $search_string . "", $transcript['transcript']); - if ($end_ellipsis) { $output .= " ..."; } + if ($start_ellipsis) { $output .= "..."; } + $output .= str_replace($search_string, "" . $search_string . "", trim(substr($transcript['transcript'], $start, $end - $start))); + if ($end_ellipsis) { $output .= "..."; } echo $output; echo '

';