Permalink
Browse files

Updated the 1.x version

  • Loading branch information...
1 parent 3e240e0 commit 2aed006098211596a728b604e49ca0aadc925daa @aarongustafson aarongustafson committed Feb 21, 2011
View
68 EE1/system/plugins/Highlighter.php
@@ -0,0 +1,68 @@
+<?php
+/**********************************************************************************************
+ * highlighter.php
+ **********************************************************************************************
+ * This class highlights text matches a search string (keyword) in html based documents, without destroying html-tags.
+ * This was necessary to scan database-entry written in html by keywords, and display them in another style.
+ **********************************************************************************************
+ * @name Highlighter
+ * @description Advanced keyword highlighter, keep HTML tags safe.
+ * @author(s) Bojidar Naydenov a.k.a Bojo (bojo2000@mail.bg) & Antony Raijekov a.k.a Zeos (dev@strategma.bg)
+ * @country Bulgaria
+ * @version 2.1
+ * @copyright GPL
+ * @access public
+ *********************************************************************************************/
+class Highlighter
+{
+ var $keyword;
+ var $replacement;
+ var $hightlight_bad_tags = array( "A", "IMG" ); //add here more, if you want to filter them
+
+ //constructor
+ function Highlighter ( $keyword=FALSE, $replacement=FALSE )
+ {
+ $this->keyword = $keyword;
+ $this->replacement = $replacement;
+ } //end func highlight
+
+ //private
+ function highlight ( $matches )
+ {
+ //check for bad tags and keyword
+ if ( ! in_array( strtoupper($matches[2]), $this->hightlight_bad_tags ) )
+ {
+ //put template [replacement]
+ $proceed = preg_replace( "#(".$this->keyword.")#si",
+ str_replace( "{keyword}", $matches[3], $this->replacement ),
+ $matches[0] );
+ }
+ else //return as-is
+ {
+ $proceed = $matches[0];
+ }
+ return stripslashes( $proceed );
+ } //end func hightlighter
+
+ //main api
+ function process( $text, $keyword=FALSE, $replacement=FALSE )
+ {
+ //if there are specific keyword/replacement given
+ if ( $keyword != FALSE ) $this->keyword = $keyword;
+ if ( $replacement != FALSE ) $this->replacement = $replacement;
+
+ //process text array(&$this, 'method_name'),
+ if ( isset($this->keyword) AND
+ isset($this->replacement) ):
+ return preg_replace_callback( "#(<([A-Za-z]+)[^>]*[\>]*)*(".$this->keyword.")(.*?)(<\/\\2>)*#si",
+ array( &$this, 'highlight' ),
+ $text );
+ else:
+ return $text;
+ endif;
+ } //end func process
+
+} // end Highlighter
+
+/* End of file Highlighter.php */
+/* Location: ./system/expressionengine/third_party/easy_search_summary/Highlighter.php */
View
295 EE1/system/plugins/Summarizer.php
@@ -0,0 +1,295 @@
+<?php
+
+class Summarizer {
+
+ var $debug;
+
+ function Summarizer($debug=FALSE)
+ {
+ $this->debug = $debug;
+ }
+
+ function excerpt( $text, $words, $length=150, $prefix="&#8230;", $suffix=NULL, $options=array() )
+ {
+ $text = html_entity_decode( $text, ENT_QUOTES, 'UTF-8' );
+
+ // Set default score modifiers [tweak away...]
+ $options = array_merge( array(
+ 'exact_case_bonus' => 2,
+ 'exact_word_bonus' => 3,
+ 'abs_length_weight' => 0.0,
+ 'rel_length_weight' => 1.0,
+ 'debug' => $this->debug
+ ), $options);
+
+ // Null suffix defaults to same as prefix
+ if ( is_null($suffix) ) $suffix = $prefix;
+
+ // Not enough to work with?
+ if ( strlen($text) <= $length ) return $text;
+
+ // Just in case
+ if ( ! is_array($words) ) $words = array($words);
+
+ // Build the event list
+ // [also calculate maximum word length for relative weight bonus]
+ $events = array();
+ $maxWordLength = 0;
+
+ foreach ($words as $word) {
+
+ if (strlen($word) > $maxWordLength) $maxWordLength = strlen($word);
+
+ $i = -1;
+ while ( ($i = stripos($text, $word, $i+1)) !== false )
+ {
+
+ // Basic score for a match is always 1
+ $score = 1;
+
+ // Apply modifiers
+ // Case matches exactly
+ if (substr($text, $i, strlen($word)) == $word) $score += $options['exact_case_bonus'];
+
+ // Absolute length weight (longer words count for more)
+ if ($options['abs_length_weight'] != 0.0) $score += strlen($word) * $options['abs_length_weight'];
+
+ // Relative length weight (longer words count for more)
+ if ($options['rel_length_weight'] != 0.0) $score += strlen($word) / $maxWordLength * $options['rel_length_weight'];
+
+ // The start of the word matches exactly
+ if (preg_match('/\W/', substr($text, $i-1, 1))) $score += $options['exact_word_bonus'];
+
+ // The end of the word matches exactly
+ if (preg_match('/\W/', substr($text, $i+strlen($word), 1))) $score += $options['exact_word_bonus'];
+
+
+ // Push event occurs when the word comes into range
+ $events[] = array(
+ 'type' => 'push',
+ 'word' => $word,
+ 'pos' => max(0, $i + strlen($word) - $length),
+ 'score' => $score
+ );
+ // Pop event occurs when the word goes out of range
+ $events[] = array(
+ 'type' => 'pop',
+ 'word' => $word,
+ 'pos' => $i + 1,
+ 'score' => $score
+ );
+ // Bump event makes it more attractive for words to be in the
+ // middle of the excerpt [@todo: this needs work]
+ $events[] = array(
+ 'type' => 'bump',
+ 'word' => $word,
+ 'pos' => max(0, $i + floor(strlen($word)/2) - floor($length/2)),
+ 'score' => 0.5
+ );
+
+ } # end while
+
+ } # end foreach
+
+ // If nothing is found then just truncate from the beginning
+ if ( empty($events) ) return substr($text, 0, $length) . $suffix;
+
+ // We want to handle each event in the order it occurs in
+ // [i.e. we want an event queue]
+ $M = new MultiSort();
+ $events = $M->sortArray( $events, 'pos', 'rcmp' );
+
+ $scores = array();
+ $score = 0;
+ $current_words = array();
+
+ // Process each event in turn
+ foreach ($events as $idx => $event )
+ {
+ $thisPos = floor($event['pos']);
+
+ $word = strtolower($event['word']);
+
+ switch ($event['type'])
+ {
+ case 'push':
+ if ( ! isset( $current_words[$word] ) )
+ {
+ // First occurence of a word gets full value
+ $current_words[$word] = 1;
+ $score += $event['score'];
+ }
+ else
+ {
+ // Subsequent occurrences mean less and less
+ $current_words[$word]++;
+ $score += $event['score'] / $current_words[$word];
+ }
+ break;
+ case 'pop':
+ if ( isset( $current_words[$word] ) )
+ {
+ if ( $current_words[$word] == 1 )
+ {
+ unset( $current_words[$word] );
+ $score -= ($event['score']);
+ }
+ else
+ {
+ $current_words[$word]--;
+ if ( $current_words[$word] != 0 ) $score -= $event['score'] / $current_words[$word];
+ }
+ }
+ break;
+ case 'bump':
+ if (!empty($event['score'])) {
+ $score += $event['score'];
+ }
+ break;
+ default:
+ break;
+ }
+
+ // Close enough for government work...
+ $score = round($score, 2);
+
+ // Store the position/score entry
+ $scores[$thisPos] = $score;
+
+ // For use with debugging
+ $debugWords[$thisPos] = $current_words;
+
+ // Remove score bump
+ if ($event['type'] == 'bump') $score -= $event['score'];
+
+ } # end foreach ($events as $idx => $event )
+
+ // Calculate the best score
+ // Yeah, could have done this in the main event loop
+ // but it's better here
+ $bestScore = 0;
+ foreach ($scores as $pos => $score) if ($score > $bestScore) $bestScore = $score;
+
+
+ if ( $options['debug'] )
+ {
+ // This is really quick, really tatty debug information
+ // (but it works)
+ echo "<table>";
+ echo "<caption>Events</caption>";
+ echo "<tr><th>Pos</th><th>Type</th><th>Word</th><th>Score</th>";
+ foreach ($events as $event)
+ {
+ echo "<tr>";
+ echo "<td>{$event['pos']}</td><td>{$event['type']}</td><td>{$event['word']}</td><td>{$event['score']}</td>";
+ echo "</tr>";
+ }
+ echo "</table>";
+
+ echo "<table>";
+ echo "<caption>Positions and their scores</caption>";
+ $idx = 0;
+ foreach ($scores as $pos => $score)
+ {
+ $excerpt = substr($text, $pos, $length);
+ $style = ($score == $bestScore) ? 'background: #ff7;' : '';
+
+ echo "<tr>";
+ echo "<th style=\"$style\">" . $idx . "</th>";
+ echo "<td style=\"$style\">" . $pos . "</td>";
+ echo "<td style=\"$style\"><div style=\"float: left; width: 2em; margin-right: 1em; text-align right; background: #ddd\">" .
+ $score . "</div><code>" . str_repeat('*', $score) . "</code></td>";
+ echo "<td style=\"$style\"><table>";
+
+ foreach ($debugWords[$pos] as $word => $count) echo "<tr><td>$word</td><td>$count</td></tr>";
+
+ echo "</table></td>";
+ echo "<td style=\"$style\">" . (
+ preg_replace('/(' . implode('|', $words) . ')/i',
+ '<b style="border: 1px solid red;">\1</b>',
+ htmlentities($excerpt))
+ ) . "</td>";
+ echo "</tr>";
+ $idx++;
+ }
+ echo "</table>";
+ }
+
+
+ // Find all positions that correspond to the best score
+ $positions = array();
+ foreach ($scores as $pos => $score)
+ {
+ if ($score == $bestScore) $positions[] = $pos;
+ }
+
+ if ( count( $positions ) > 1)
+ {
+ // Scores are tied => do something clever to choose one
+ // @todo: Actually do something clever here
+ $pos = $positions[0];
+ }
+ else
+ {
+ $pos = $positions[0];
+ }
+
+ // Extract the excerpt from the position, (pre|ap)pend the (pre|suf)fix
+ $excerpt = htmlspecialchars( substr($text, $pos, $length) );
+
+ if ( $pos > 0 ) $excerpt = $prefix . $excerpt;
+
+ if ( $pos + $length < strlen($text) ) $excerpt .= $suffix;
+
+ return $excerpt;
+
+ } # end Summarizer::excerpt
+
+} # end Summarizer
+
+class MultiSort {
+
+ function sortArray($array,$parameter,$_function)
+ {
+ return $this->_uasort($array,$_function,$parameter);
+ }
+
+ function cmp ($a, $b, $p)
+ {
+ return (strcmp ($a[$p],$b[$p]));
+ }
+
+ function rcmp ($a, $b, $p)
+ {
+ return -1 * ( strcmp ( $a[$p], $b[$p] ) );
+ }
+
+ function _uasort( $array, $func, $param )
+ {
+ for( $i=0; $i<sizeof($array); $i++ )
+ {
+ $tmp = $i;
+ for ( $j=1; $j<sizeof($array); $j++ )
+ {
+ $result = $this->$func($array[$tmp],$array[$j],$param);
+ if ($result == -1)
+ {
+ $array = $this->arraySwap( $array, $tmp, $j );
+ $tmp = $j;
+ }
+ }
+ }
+ return $array;
+ }
+
+ function arrayswap($arr, $src, $dst)
+ {
+ $tmp = $arr[$dst];
+ $arr[$dst] = $arr[$src];
+ $arr[$src] = $tmp;
+ return $arr;
+ }
+} # end MultiSort
+
+/* End of file Summarizer.php */
+/* Location: ./system/expressionengine/third_party/easy_search_summary/Summarizer.php */
View
339 EE1/system/plugins/pi.easy_search_summary.php
@@ -17,178 +17,187 @@
*/
$plugin_info = array(
- 'pi_name' => 'Search Summary',
- 'pi_version' => '1.0',
- 'pi_author' => 'Aaron Gustafson',
- 'pi_author_url' => 'http://easy-designs.net/',
- 'pi_description' => 'Creates a summary from content, based on keywords',
- 'pi_usage' => Search_summary::usage()
+ 'pi_name' => 'Search Summary',
+ 'pi_version' => '1.0',
+ 'pi_author' => 'Aaron Gustafson',
+ 'pi_author_url' => 'http://easy-designs.net/',
+ 'pi_description' => 'Creates a summary from content, based on keywords',
+ 'pi_usage' => Search_summary::usage()
);
class Search_summary {
- var $return_data;
- var $keywords;
+ var $return_data;
+ var $keywords;
- # the HTML needed for output
- var $term = '<strong class="{class}">{keyword}</strong>';
-
- /**
- * Search_summary constructor
- * sets any overrides and triggers the processing
- *
- * @param str $str - the content to be parsed
- */
- function Search_summary ( $str='', $keywords=array(), $class=FALSE )
- {
-
- # get any overrides
- global $TMPL, $FNS, $PREFS, $DB;
-
- $hash = FALSE;
- if ( ! count( $keywords ) &&
- ! $hash ) $hash = ( $temp = $TMPL->fetch_param('hash') ) ? $temp : array();
- if ( ! $class ) $class = ( $temp = $TMPL->fetch_param('class') ) ? $temp : 'term';
-
- # find the keywords
- if ( $hash )
- {
- if ( strlen( $hash ) > 32 ) $hash = substr( $hash, 0, 32 );
- $keywords = $DB->query(
- "SELECT `keywords`
- FROM `{$PREFS->ini('db_prefix')}_search`
- WHERE `search_id` = '{$DB->escape_str($hash)}'"
- )->row['keywords'];
- }
-
- # manage the keywords
- $keywords = explode( ' ', str_replace( '+', '', $keywords ) );
- $i = 0;
- $temp = array();
- $mult = FALSE;
- $quote = FALSE;
- foreach ( $keywords as $k )
- {
- $length = strlen( $k );
- if ( strpos( $k, '-' ) === 0 )
- {
- unset( $k );
- }
- else
- {
- if ( ! $mult &&
- ( strpos( $k, '"' ) === 0 ||
- strpos( $k, "'" ) === 0 ) )
- {
- $quote = substr( $k, 0, 1 );
- $mult = TRUE;
- $temp[$i] = preg_replace( '/^["\'+]/', '', $k );
- }
- elseif ( $mult &&
- strpos( $k, $quote ) == $length-1 )
- {
- $mult = FALSE;
- $temp[$i++] .= ' ' . preg_replace( '/["\']$/', '', $k );
- }
- elseif ( $mult )
- {
- $temp[$i] .= ' ' . $k;
- }
- else
- {
- $temp[$i++] = $k;
- }
- }
- }
- $this->keywords = $temp;
-
- # manage the highlight string
- $this->term = $FNS->var_swap( $this->term, array( 'class' => $class ) );
-
- # Fetch string
- if ( empty( $str ) ) $str = strip_tags( $TMPL->tagdata );
-
- # return the processed string
- $this->return_data = ( ! empty( $str ) ? $this->process( $str ) : $str );
-
- } # end Search_summary constructor
+ # the HTML needed for output
+ var $term = '<{tag} class="{class}">{keyword}</{tag}>';
+
- /**
- * Search_summary::process()
- * processes the supplied content based on the configuration
- *
- * @param str $str - the content to be parsed
- */
- function process( $str )
- {
- require_once PATH . '../scripts/classes/Summarizer.php';
- $S = new Summarizer();
- $str = $S->excerpt( $str, $this->keywords );
-
- require_once PATH . '../scripts/classes/Highlighter.php';
- $h = new Highlighter();
- foreach ( $this->keywords as $k )
- {
- $str = $h->process( $str, $k, $this->term );
- }
-
- return $str;
- } # end Search_summary::process()
-
- /**
- * Search_summary::usage()
- * Describes how the plugin is used
- */
- function usage()
- {
- ob_start(); ?>
-Want to add some microformats support to your site _and_ gain additional CSS hooks around your images? If so, you've come to the right place. ItFigures comes with a set of sensible default that will allow you to use it right away. By default, it looks for images that sit inside a paragraph by themselves (or, optionally, with additional text).
-
-By implementing it with no options:
-
-{exp:itfigures}{body}{/exp:itfigures}
-
-when the plugin encounters
-
-<p><img src="foo.png" alt=""/></p>
-
-it will remake that as
-
-<div class="figure"><img class="image" src="foo.png" alt="" /></div>
-
-Providing it with additional element hooks in the content allows it to build a more robust figure:
-
-<p><img src="foo.png" alt="" style="float: right;"/> <em>Photo by Aaron</em> <strong>This is a sample image</strong></p>
-
-will become
-
-<div class="figure align-right">
- <img class="image" src="foo.png" alt="" />
- <p class="credit">Photo by Aaron</p>
- <p class="legend">This is a sample image</p>
-</div>
-
-making it quite simple to quickly generate figures without having to remember the markup.
-
-If you want to customize things further, you can use any or all of the optional properties:
-
-* left_class: the class for left-alignment ("align-left" by default)
-* right_class: the class for right-alignment ("align-right" by default)
-* figure_wrap: the wrapper element for the whole figure that we should look for ("p" by default)
-* credit_wrap: the wrapper element for the credit ("em" by default)
-* legend_wrap: the wrapper element for the legend ("strong" by default)
-* figure_el: the element you wish to use as the figure container ("div" by default)
-* content_el: the element you wish to use as the text content container (empty by default)
-* credit_el: the element you wish to use as the credit container ("p" by default)
-* legend_el: the element you wish to use as the legend container ("p" by default)
-* output_order: the order in which you want to output the contents into the figure ("img|credit|legend" by default, "img" must come first or last, but cannot come in the middle)
+ /**
+ * Search_summary constructor
+ * sets any overrides and triggers the processing
+ *
+ * @param str $str - the content to be parsed
+ */
+ function Search_summary ( $str='', $keywords=array(), $html_ver=5, $class=FALSE )
+ {
+
+ # get any overrides
+ global $TMPL, $FNS, $PREFS, $DB;
+
+ # get the hash
+ $hash = FALSE;
+ if ( ! count( $keywords ) && ! $hash )
+ {
+ $hash = ( $temp = $TMPL->fetch_param('hash') ) ? $temp : array();
+ }
+ # determine the tag to use
+ if ( $temp = $TMPL->fetch_param('html_version') ) $html_ver = $temp;
+ $tag = $html_ver==5 ? 'mark' : 'strong';
+ # determine the class of the keywords
+ if ( ! $class ) $class = ( $temp = $TMPL->fetch_param('class') ) ? $temp : 'term';
+ # any alternate content?
+ $alternates = array();
+ $i = 0;
+ while ( $i++ < 10 )
+ {
+ if ( $temp = $TMPL->fetch_param('alternate_'.$i) ) $alternates[] = $temp;
+ }
+
+ # find the keywords
+ if ( $hash )
+ {
+ if ( strlen( $hash ) > 32 ) $hash = substr( $hash, 0, 32 );
+ $keywords = $DB->query(
+ "SELECT `keywords`
+ FROM `{$PREFS->ini('db_prefix')}_search`
+ WHERE `search_id` = '{$DB->escape_str($hash)}'"
+ )->row['keywords'];
+ }
+
+ # manage the keywords
+ $keywords = explode( ' ', str_replace( '+', '', $keywords ) );
+ $i = 0;
+ $temp = array();
+ $mult = FALSE;
+ $quote = FALSE;
+ foreach ( $keywords as $k )
+ {
+ $length = strlen( $k );
+ if ( strpos( $k, '-' ) === 0 )
+ {
+ unset( $k );
+ }
+ else
+ {
+ if ( ! $mult &&
+ ( strpos( $k, '"' ) === 0 ||
+ strpos( $k, "'" ) === 0 ) )
+ {
+ $quote = substr( $k, 0, 1 );
+ $mult = TRUE;
+ $temp[$i] = preg_replace( '/^["\'+]/', '', $k );
+ }
+ elseif ( $mult && strpos( $k, $quote ) == $length-1 )
+ {
+ $mult = FALSE;
+ $temp[$i++] .= ' ' . preg_replace( '/["\']$/', '', $k );
+ }
+ elseif ( $mult )
+ {
+ $temp[$i] .= ' ' . $k;
+ }
+ else
+ {
+ $temp[$i++] = $k;
+ }
+ }
+ }
+ $this->keywords = $temp;
+
+ # build the highlight string
+ $this->term = $FNS->var_swap( $this->term, array( 'tag' => $tag, 'class' => $class ) );
+
+ # try the primary text
+ if ( empty( $str ) ) $str = strip_tags( $TMPL->tagdata );
+ $str = ! empty( $str ) ? $this->process( $str ) : $str;
+
+ if ( strpos( $str, "$tag class=\"$class\"" )===FALSE &&
+ count( $alternates ) )
+ {
+ foreach ( $alternates as $temp )
+ {
+ # search
+ $temp = $this->process( strip_tags( $temp ) );
+ if ( strpos( $temp, "$tag class=\"$class\"" )!==FALSE )
+ {
+ $str = $temp;
+ break;
+ }
+ }
+ }
+
+ $this->return_data = $str;
+ return $this->return_data;
+
+ } # end Search_summary constructor
+
+ /**
+ * Search_summary::process()
+ * processes the supplied content based on the configuration
+ *
+ * @param str $str - the content to be parsed
+ */
+ function process( $str )
+ {
+ require_once 'Summarizer.php';
+ $S = new Summarizer();
+ $str = $S->excerpt( $str, $this->keywords );
+
+ require_once 'Highlighter.php';
+ $h = new Highlighter();
+ foreach ( $this->keywords as $k )
+ {
+ $str = $h->process( $str, $k, $this->term );
+ }
+
+ return $str;
+ } # end Search_summary::process()
+
+ /**
+ * Search_summary::usage()
+ * Describes how the plugin is used
+ */
+ function usage()
+ {
+ ob_start(); ?>
+ To create nice search summaries, use the following syntax:
+
+ {exp:search_summary hash="{segment_2}"}{content_body}{/exp:search_summary}
+
+ Where {segment_2} is the search hash in the URL.
+
+ By default, the plugin uses HTML5 <code>&lt;mark&gt;</code> elements to wrap the keywords found. You can override that by setting the html version:
+
+ {exp:search_summary hash="{segment_2}" html_version="4"}{content_body}{/exp:search_summary}
+
+ By default, each found keyword is also classified as a “term,” but you can define your own class as well:
+
+ {exp:search_summary hash="{segment_2}" class="found"}{content_body}{/exp:search_summary}
+
+ You can also define (in order of priority) up to 10 alternate fields you’d like to summarize if a match isn’t found in the primary tag:
+
+ {exp:search_summary hash="{segment_2}" alternate_1="{content_sidebar}" alternate_2="{content_footer}"}{content_body}{/exp:search_summary}
<?php
- $buffer = ob_get_contents();
- ob_end_clean();
- return $buffer;
- } # end ItFigures::usage()
+ $buffer = ob_get_contents();
+ ob_end_clean();
+ return $buffer;
+ } # end Easy_search_summary::usage()
+
+} # end Easy_search_summary
-} # end ItFigures
-?>
+/* End of file pi.easy_search_summary.php */
+/* Location: ./system/expressionengine/plugins/pi.easy_search_summary.php */
View
16 EE2/system/expressionengine/third_party/easy_search_summary/pi.easy_search_summary.php
@@ -11,12 +11,12 @@
*/
$plugin_info = array(
- 'pi_name' => 'Easy Search Summary',
- 'pi_version' => '1.0',
- 'pi_author' => 'Aaron Gustafson',
+ 'pi_name' => 'Easy Search Summary',
+ 'pi_version' => '1.0',
+ 'pi_author' => 'Aaron Gustafson',
'pi_author_url' => 'http://easy-designs.net/',
'pi_description' => 'Creates a summary from content, based on keywords',
- 'pi_usage' => Easy_search_summary::usage()
+ 'pi_usage' => Easy_search_summary::usage()
);
class Easy_search_summary {
@@ -73,14 +73,14 @@ function __construct( $str='', $keywords=array(), $html_ver=5, $class=FALSE )
if ( strlen( $hash ) > 32 ) $hash = substr( $hash, 0, 32 );
$keywords = $this->EE->db->query(
"SELECT `keywords`
- FROM `exp_search`
- WHERE `search_id` = '{$this->EE->db->escape_str($hash)}'"
+ FROM `exp_search`
+ WHERE `search_id` = '{$this->EE->db->escape_str($hash)}'"
)->row('keywords');
}
# manage the keywords
$keywords = explode( ' ', str_replace( '+', '', $keywords ) );
- $i = 0;
+ $i = 0;
$temp = array();
$mult = FALSE;
$quote = FALSE;
@@ -116,7 +116,7 @@ function __construct( $str='', $keywords=array(), $html_ver=5, $class=FALSE )
}
$this->keywords = $temp;
- # manage the highlight string
+ # build the highlight string
$this->term = $this->EE->functions->var_swap( $this->term, array( 'tag' => $tag, 'class' => $class ) );
# try the primary text
View
23 LICENSE
@@ -0,0 +1,23 @@
+Copyright (c) 2008 Easy! Designs LLC
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or
+sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall
+be included in all copies or substantial portions of the
+Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
View
35 README.textile
@@ -0,0 +1,35 @@
+h1. Easy Search Summary
+
+Creates truncated search summaries that isolate searched keywords, highlighting them as well.
+
+h2. Current Version
+
+2.0 (20 February 2011)
+
+h2. Requirements
+
+None.
+
+h2. License
+
+Easy Search Summary is distributed under the liberal MIT License.
+
+h2. Usage
+
+To create nice search summaries, use the following syntax:
+
+<pre>{exp:search_summary hash="{segment_2}"}{content_body}{/exp:search_summary}</pre>
+
+Where {segment_2} is the search hash in the URL.
+
+By default, the plugin uses HTML5 <code>&lt;mark&gt;</code> elements to wrap the keywords found. You can override that by setting the html version:
+
+<pre>{exp:search_summary hash="{segment_2}" html_version="4"}{content_body}{/exp:search_summary}</pre>
+
+By default, each found keyword is also classified as a “term,” but you can define your own class as well:
+
+<pre>{exp:search_summary hash="{segment_2}" class="found"}{content_body}{/exp:search_summary}</pre>
+
+You can also define (in order of priority) up to 10 alternate fields you’d like to summarize if a match isn’t found in the primary tag:
+
+<pre>{exp:search_summary hash="{segment_2}" alternate_1="{content_sidebar}" alternate_2="{content_footer}"}{content_body}{/exp:search_summary}</pre>

0 comments on commit 2aed006

Please sign in to comment.