]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
updated search plugin for new html/css
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Tue, 8 Feb 2011 12:23:04 +0000 (12:23 +0000)
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Tue, 8 Feb 2011 12:23:04 +0000 (12:23 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@8075 36083f99-b078-4883-b0ff-0f9b5a30f544

mod/search/start.php
mod/search/views/default/search/comments/entity.php
mod/search/views/default/search/css.php
mod/search/views/default/search/entity.php
mod/search/views/default/search/list.php

index 4f57a64c5f22fafa5502ce76068feea7e768f683..401bf84a5ea4fa68c8b6599f856fdd2006d4d551 100644 (file)
@@ -249,8 +249,8 @@ function search_highlight_words($words, $string) {
        $replace_html = array(
                'strong' => rand(10000, 99999),
                'class' => rand(10000, 99999),
-               'searchMatch' => rand(10000, 99999),
-               'searchMatchColor' => rand(10000, 99999)
+               'search-highlight' => rand(10000, 99999),
+               'search-highlight-color' => rand(10000, 99999)
        );
 
        foreach ($words as $word) {
@@ -262,16 +262,17 @@ function search_highlight_words($words, $string) {
                
                $search = "/($word)/i";
 
+               // @todo
                // must replace with placeholders in case one of the search terms is
                // in the html string.
                // later, will replace the placeholders with the actual html.
                // Yeah this is hacky.  I'm tired.
                $strong = $replace_html['strong'];
                $class = $replace_html['class'];
-               $searchMatch = $replace_html['searchMatch'];
-               $searchMatchColor = $replace_html['searchMatchColor'];
+               $highlight = $replace_html['search-highlight'];
+               $color = $replace_html['search-highlight-color'];
 
-               $replace = "<$strong $class=\"$searchMatch $searchMatchColor{$i}\">$1</$strong>";
+               $replace = "<$strong $class=\"$highlight $color{$i}\">$1</$strong>";
                $string = preg_replace($search, $replace, $string);
                $i++;
        }
index eddb36547036f50633b8fe86d5ad3984f5321506..005bb270c4b5a4f2ecded81673de692660e13249 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * Default view for a comment
+ * Default search view for a comment
  *
  * @uses $vars['entity']
  */
@@ -46,14 +46,7 @@ $description = $entity->getVolatileData('search_matched_comment');
 $tc = $entity->getVolatileData('search_matched_comment_time_created');;
 $time = elgg_view_friendly_time($tc);
 
-echo <<<___END
-       <div class="search_listing clearfix">
-               <div class="search_listing_icon">$icon</div>
-               <div class="search_listing_info">
-                       <p class="entity-title">$title</p>$description
-                       <p class="entity-subtext">$time</p>
-               </div>
-       </div>
-___END;
-
-?>
\ No newline at end of file
+$body = "<p class=\"mbn\">$title</p>$description";
+$body .= "<p class=\"elgg-subtext\">$time</p>";
+
+echo elgg_view_image_block($icon, $body);
index d6e905bf0e01e4342f3d59b013b2a2e28296403b..02e43bf8b20a5423ff7d2337eae0dc188f094452 100644 (file)
@@ -2,10 +2,12 @@
 /**
  * Elgg Search css
  * 
- * @package search
  */
 ?>
 
+/**********************************
+ Search plugin
+***********************************/
 .elgg-page-header .elgg-search {
        bottom: 5px;
        height: 23px;
@@ -15,6 +17,9 @@
 .elgg-page-header .elgg-search input[type=text] {
        width: 198px;
 }
+.elgg-page-header .elgg-search input[type=submit] {
+       display: none;
+}
 .elgg-search input[type=text] {
        -webkit-border-radius: 10px;
        -moz-border-radius: 10px;
        border: 1px solid white;
        background-position: 2px -257px;
 }
-.elgg-page-header .elgg-search input[type=submit] {
-       display: none;
-}
 
-.search_listing  {
-       background:none;
-       border-bottom:1px dotted #CCCCCC;
-       clear:both;
-       display:block;
-       margin:0;
-       padding:5px 0 7px;
-       position:relative;
-}
-.search_listing_icon {
-       float:left;
-       margin-left:3px;
-       margin-top:3px;
-}
-.search_listing_icon .avatar_menu_button img {
-       width: 15px;
-       margin:0;
-}
-.search_listing_info {
-       float:left;
-       margin-left:7px;
-       min-height:28px;
-       width:693px;
+.search-list li {
+       padding: 5px 0 0;
 }
-.search_listing_info p {
-       margin:0;
-}
-.search_listing_category_title {
-       margin-top:20px;
-}
-.search_listing_category_title h2 {
-       color:#666666;
-}
-.search_listing.more {
-       display: block;
+.search-heading-category {
+       margin-top: 20px;
+       color: #666666;
 }
 
-
-/* search matches */
-.searchtype {
-       background: #FFFACD;
-       color: black;
-}
-.searchtypes {
-       border: 1px #EEEEEE solid;
-       padding: 4px;
-       margin: 6px;
-}
-.searchMatch {
+.search-highlight {
        background-color: #bbdaf7;
 }
-.searchMatchColor1 {
+.search-highlight-color1 {
        background-color: #bbdaf7;
 }
-.searchMatchColor2 {
+.search-highlight-color2 {
        background-color: #A0FFFF;
 }
-.searchMatchColor3 {
+.search-highlight-color3 {
        background-color: #FDFFC3;
 }
-.searchMatchColor4 {
+.search-highlight-color4 {
        background-color: #cccccc;
 }
-.searchMatchColor5 {
+.search-highlight-color5 {
        background-color: #4690d6;
 }
-
-/* formatting for the search results */
-
-.search_listing .item_timestamp {
-       font-style: italic;
-}
index ae3d43e0135b60f878b6274b9b09396c7004322e..2193a70d8b52925a4628b2591de99ced9caccb0a 100644 (file)
@@ -47,21 +47,11 @@ if (!$time) {
        $tu = $entity->time_updated;
        $time = elgg_view_friendly_time(($tu > $tc) ? $tu : $tc);
 }
-?>
-<div class="search_listing clearfix">
-       <div class="search_listing_icon">
-               <?php echo $icon; ?>
-       </div>
-       <div class="search_listing_info">
-               <p class="entity-title"><?php echo $title; ?></p>
-               <?php echo $description; ?>
-<?php 
+
+$body = "<p class=\"mbn\">$title</p>$description";
 if ($extra_info) {
-?>
-               <p class="entity-subtext"><?php echo $extra_info; ?></p>
-<?php
+       $body .= "<p class=\"elgg-subtext\">$extra_info</p>";
 }
-?>
-               <p class="entity-subtext"><?php echo $time; ?></p>
-       </div>
-</div>
+$body .= "<p class=\"elgg-subtext\">$time</p>";
+
+echo elgg_view_image_block($icon, $body);
index 27916a363eae12180d4960b6f40d11e6e7be13f0..6f09ae52157ddd9df6be432cbf8c8a2e902ab037 100644 (file)
@@ -10,8 +10,8 @@
  *                          - 'type'        Entity type
  *                          - 'subtype'     Entity subtype
  *                          - 'search_type' Type of search: 'entities', 'comments', 'tags'
- *                          - 'offset'
- *                          - 'limit'
+ *                          - 'offset'      Offset in search results
+ *                          - 'limit'       Number of results per page
  *                          - 'pagination'  Display pagination?
  */
 
@@ -22,14 +22,13 @@ if (!is_array($entities) || !count($entities)) {
        return FALSE;
 }
 
-// @todo why are limit and offset pulled from input here and from $vars['params'] later
 $query = http_build_query(
        array(
                'q' => $vars['params']['query'],
                'entity_type' => $vars['params']['type'],
                'entity_subtype' => $vars['params']['subtype'],
-               'limit' => get_input('limit', 10),
-               'offset' => get_input('offset', 0),
+               'limit' => $vars['params']['limit'],
+               'offset' => $vars['params']['offset'],
                'search_type' => $vars['params']['search_type'],
        //@todo include vars for sorting, order, and friend-only.
        )
@@ -76,18 +75,6 @@ if (array_key_exists('search_type', $vars['params'])
        $type_str = $search_type_str;
 }
 
-// get pagination
-if (array_key_exists('pagination', $vars['params']) && $vars['params']['pagination']) {
-       $nav .= elgg_view('navigation/pagination',array(
-               'baseurl' => $url,
-               'offset' => $vars['params']['offset'],
-               'count' => $vars['results']['count'],
-               'limit' => $vars['params']['limit'],
-       ));
-} else {
-       $nav = '';
-}
-
 // get any more links.
 $more_check = $vars['results']['count'] - ($vars['params']['offset'] + $vars['params']['limit']);
 $more = ($more_check > 0) ? $more_check : 0;
@@ -95,22 +82,33 @@ $more = ($more_check > 0) ? $more_check : 0;
 if ($more) {
        $title_key = ($more == 1) ? 'comment' : 'comments';
        $more_str = elgg_echo('search:more', array($count, $type_str));
-       $more_link = "<div class='search_listing'><a href=\"$url\">$more_str</a></div>";
+       $more_link = "<li class='elgg-list-item'><a href=\"$url\">$more_str</a></li>";
 } else {
        $more_link = '';
 }
 
-$body = "<div class='search_listing_category_title'>" . elgg_view_title($type_str) . "</div>";
-
-foreach ($entities as $entity) {
-       if ($view = search_get_search_view($vars['params'], 'entity')) {
+// @todo once elgg_view_title() supports passing a $vars array use it
+$body = elgg_view('layout/elements/title', array(
+       'title' => $type_str,
+       'class' => 'search-heading-category',
+));
+
+$view = search_get_search_view($vars['params'], 'entity');
+if ($view) {
+       $body .= '<ul class="elgg-list search-list">';
+       foreach ($entities as $entity) {
+               $id = "elgg-{$entity->getType()}-{$entity->getGUID()}";
+               $body .= "<li id=\"$id\" class=\"elgg-list-item\">";
                $body .= elgg_view($view, array(
                        'entity' => $entity,
                        'params' => $vars['params'],
                        'results' => $vars['results']
                ));
+               $body .= '</li>';
        }
+       $body .= $more_link;
+       $body .= '</ul>';
 }
+
 echo $body;
-echo $more_link;
 echo $nav;