diff options
author | ctrlaltca <> | 2012-07-12 11:21:01 +0000 |
---|---|---|
committer | ctrlaltca <> | 2012-07-12 11:21:01 +0000 |
commit | 903ae8a581fac1e6917fc3e31d2ad8fb91df80c3 (patch) | |
tree | e08bf04f0823650a231227ac3499121270172a23 /demos/quickstart/protected/pages/Search.php | |
parent | 3e4e6e66aeb3f8fea4e1eb4237498ef9d2358f63 (diff) |
standardize the use of unix eol; use svn properties to enforce native eol
Diffstat (limited to 'demos/quickstart/protected/pages/Search.php')
-rw-r--r-- | demos/quickstart/protected/pages/Search.php | 110 |
1 files changed, 55 insertions, 55 deletions
diff --git a/demos/quickstart/protected/pages/Search.php b/demos/quickstart/protected/pages/Search.php index d2dfa7da..c36eba54 100644 --- a/demos/quickstart/protected/pages/Search.php +++ b/demos/quickstart/protected/pages/Search.php @@ -1,56 +1,56 @@ -<?php
-/*
- * Created on 7/05/2006
- */
-
-class Search extends TPage
-{
- public function onLoad($param)
- {
- if(!$this->IsPostBack && strlen($text = $this->search->getText()) > 0)
- {
- $quickstart = $this->getApplication()->getModule("quickstart_search");
- $hits_1 = $quickstart->find($text);
- $this->quickstart_results->setDataSource($hits_1);
- $this->quickstart_results->dataBind();
-
- $this->emptyResult->setVisible(!count($hits_1));
- }
- }
-
- public function highlightSearch($text)
- {
- $words = str_word_count($text, 1);
- $keys = str_word_count(strtolower($this->search->getText()),1);
- $where = 0;
- $t = count($words);
- for($i = 0; $i<$t; $i++)
- {
- if($this->containsKeys(strtolower($words[$i]), $keys))
- {
- $words[$i] = '<span class="searchterm">'.$words[$i].'</span>';
- $where = $i;
- break;
- }
- }
-
- $min = $where - 15 < 0 ? 0 : $where - 15;
- $max = $where + 15 > $t ? $t : $where + 15;
- $subtext = array_splice($words, $min, $max-$min);
- $prefix = $min == 0 ? '' : '...';
- $suffix = $max == $t ? '' : '...';
- return $prefix.implode(' ', $subtext).$suffix;
- }
-
- protected function containsKeys($word, $keys)
- {
- foreach($keys as $key)
- {
- if(is_int(strpos($word, $key)))
- return true;
- }
- return false;
- }
-}
-
+<?php +/* + * Created on 7/05/2006 + */ + +class Search extends TPage +{ + public function onLoad($param) + { + if(!$this->IsPostBack && strlen($text = $this->search->getText()) > 0) + { + $quickstart = $this->getApplication()->getModule("quickstart_search"); + $hits_1 = $quickstart->find($text); + $this->quickstart_results->setDataSource($hits_1); + $this->quickstart_results->dataBind(); + + $this->emptyResult->setVisible(!count($hits_1)); + } + } + + public function highlightSearch($text) + { + $words = str_word_count($text, 1); + $keys = str_word_count(strtolower($this->search->getText()),1); + $where = 0; + $t = count($words); + for($i = 0; $i<$t; $i++) + { + if($this->containsKeys(strtolower($words[$i]), $keys)) + { + $words[$i] = '<span class="searchterm">'.$words[$i].'</span>'; + $where = $i; + break; + } + } + + $min = $where - 15 < 0 ? 0 : $where - 15; + $max = $where + 15 > $t ? $t : $where + 15; + $subtext = array_splice($words, $min, $max-$min); + $prefix = $min == 0 ? '' : '...'; + $suffix = $max == $t ? '' : '...'; + return $prefix.implode(' ', $subtext).$suffix; + } + + protected function containsKeys($word, $keys) + { + foreach($keys as $key) + { + if(is_int(strpos($word, $key))) + return true; + } + return false; + } +} + ?>
\ No newline at end of file |