Formatting fixes to search view, its elements and style.css, a=chris

Chris Pollett [2012-06-16 16:06:22]
Formatting fixes to search view, its elements and style.css, a=chris
Filename
css/search.css
index.php
models/phrase_model.php
views/elements/footer_element.php
views/elements/signin_element.php
views/elements/subsearch_element.php
views/helpers/images_helper.php
views/helpers/pagination_helper.php
views/helpers/videourl_helper.php
views/layouts/web_layout.php
views/search_view.php
diff --git a/css/search.css b/css/search.css
index dc9935c..121ebd5 100755
--- a/css/search.css
+++ b/css/search.css
@@ -29,14 +29,14 @@
  * @copyright 2009 - 2012
  * @filesource
  */
-
- /*
+
+/*
     search.css
-
+
     Main stylesheet for Yioop search engine

     Contributors: Chris Pollett
- */
+ */

 /*
    We begin with some generic global styles
@@ -333,7 +333,8 @@ body.mobile
     width:100%;
 }

-.mobile .topbar, .mobile .landing-topbar
+.mobile .topbar,
+.mobile .landing-topbar
 {
     background: #DDD;
     background: -moz-linear-gradient(top, #FFF 0%,#EEF 30%,#EEF 70%, #FFF 100%);
@@ -619,7 +620,9 @@ body.mobile
    Styles for footers on various pages
  */

-.setting-footer, .signin-exit, .landing-footer
+.setting-footer,
+.signin-exit,
+.landing-footer
 {
     clear:both;
     margin-top: 0.25in;
@@ -680,14 +683,16 @@ body.mobile
 /*
    Styles for the login and settings pages
  */
-.html-ltr .login, .html-ltr .settings
+.html-ltr .login,
+.html-ltr .settings
 {
     font-size: 16pt;
     position:relative;
     left:2.25in;
 }

-.html-rtl .login, .html-rtl .settings
+.html-rtl .login,
+.html-rtl .settings
 {
     font-size: 16pt;
     position:relative;
@@ -700,7 +705,9 @@ body.mobile
     font-size:16pt;
 }

-.mobile .login, .mobile .settings, .mobile .statistics
+.mobile .login,
+.mobile .settings,
+.mobile .statistics
 {
     font-size: 14pt;
     position: relative;
@@ -708,12 +715,16 @@ body.mobile
     right: 10px;
 }

-.settings button, .settings select, .login button
+.settings button,
+.settings select,
+.login button
 {
     font-size: 16pt;
 }

-.mobile .settings button, .mobile .settings select, .mobile .login button
+.mobile .settings button,
+.mobile .settings select,
+.mobile .login button
 {
     font-size: 14pt;
 }
@@ -945,7 +956,8 @@ body.mobile
     margin-bottom: 10px
 }

-.html-ltr .pagination ul, .html-ltr .pagination ul li
+.html-ltr .pagination ul,
+.html-ltr .pagination ul li
 {
     font-size: 18pt;

@@ -954,7 +966,8 @@ body.mobile
     padding-right: 10px;
 }

-.html-rtl .pagination ul, .html-rtl .pagination ul li
+.html-rtl .pagination ul,
+.html-rtl .pagination ul li
 {
     font-size: 18pt;

@@ -1373,27 +1386,35 @@ body.mobile
 {
     font-size:12pt;
 }
-.html-ltr .roletable, .html-ltr .roletable th, .html-ltr .roletable td
+.html-ltr .roletable,
+.html-ltr .roletable th,
+.html-ltr .roletable td
 {
     margin-left: .2in;
     padding: 1px;
     border: 1px solid black;
 }

-.html-rtl .roletable, .html-rtl .roletable th, .html-rtl .roletable td
+.html-rtl .roletable,
+.html-rtl .roletable th,
+.html-rtl .roletable td
 {
     margin-right: .2in;
     padding: 1px;
     border: 1px solid black;
 }

-.html-ltr .localetable, .html-ltr .localetable th, .html-ltr .localetable td
+.html-ltr .localetable,
+.html-ltr .localetable th,
+.html-ltr .localetable td
 {
     margin-left: .2in;
     border: 1px ridge black;
 }

-.html-rtl .localetable, .html-rtl .localetable th, .html-rtl .localetable td
+.html-rtl .localetable,
+.html-rtl .localetable th,
+.html-rtl .localetable td
 {
     margin-right: .2in;
     border: 1px ridge black;
@@ -1438,33 +1459,44 @@ body.mobile
     z-index: 2;
 }

-.crawlstable, .mixestable, .crawlstable th, .mixestable th,
-.crawlstable td, .mixestable td, .filetypestable
+.crawlstable,
+.mixestable,
+.crawlstable th,
+.mixestable th,
+.crawlstable td,
+.mixestable td,
+.filetypestable
 {
     border: 1px ridge black;
     padding: 2px;
 }

-.crawlstable th,  .mixestable th, .crawlstable td, .mixestable td,
+.crawlstable th,
+.mixestable th,
+.crawlstable td,
+.mixestable td,
 .filetypestable td
 {
     border: 1px ridge black;
     padding: 2px;
 }

-.html-ltr .filetypestable, .html-ltr .ftypesall td
+.html-ltr .filetypestable,
+.html-ltr .ftypesall td
 {
    margin-left: .3in;
    vertical-align: top;
 }

-.html-rtl  .filetypestable, .html-rtl .ftypesall td
+.html-rtl  .filetypestable,
+.html-rtl .ftypesall td
 {
    margin-right: .3in;
    vertical-align: top;
 }

-.mobile .filetypestable, .mobile .ftypesall td
+.mobile .filetypestable,
+.mobile .ftypesall td
 {
    margin-left: 2px;
    margin-right: 2px;
@@ -1481,7 +1513,9 @@ body.mobile
     text-align: left;
 }

-.machinetable, .machinetable th, .machinetable td
+.machinetable,
+.machinetable th,
+.machinetable td
 {
     border: 1px ridge black;
     margin: 2px;
@@ -1493,7 +1527,10 @@ body.mobile
     border: 1px ridge black;
 }

-.translatetable, .translatetable th, .translatetable td, .filetypestable td
+.translatetable,
+.translatetable th,
+.translatetable td,
+.filetypestable td
 {
     border: 1px ridge black;
 }
@@ -1502,7 +1539,9 @@ body.mobile
 {
    width:100%;
 }
-.metawordstable, .metawordstable th, .metawordstable td
+.metawordstable,
+.metawordstable th,
+.metawordstable td
 {
     border: 1px ridge black;
 }
@@ -1535,7 +1574,9 @@ body.mobile
 {
    width:100%;
 }
-.indexingplugintable, .indexingplugintable th, .indexingplugintable td
+.indexingplugintable,
+.indexingplugintable th,
+.indexingplugintable td
 {
     border: 1px ridge black;
     text-align: center;
diff --git a/index.php b/index.php
index e79ab92..ce9028d 100755
--- a/index.php
+++ b/index.php
@@ -85,7 +85,7 @@ if(USE_MEMCACHE) {
 mb_internal_encoding("UTF-8");
 mb_regex_encoding("UTF-8");

-if ( false === function_exists('lcfirst') ) {
+if (function_exists('lcfirst') === false) {
     /**
      *  Lower cases the first letter in a string
      *
diff --git a/models/phrase_model.php b/models/phrase_model.php
index 6c9bc3b..3fee1d4 100755
--- a/models/phrase_model.php
+++ b/models/phrase_model.php
@@ -838,10 +838,11 @@ class PhraseModel extends ParallelModel
             while($num_retrieved < $to_retrieve  &&
                 is_array($next_docs =
                     $query_iterator->nextDocsWithWord()) ) {
-                $pages = array_merge($pages, $next_docs);
+                $pages += $next_docs;
                 $num_retrieved += count($next_docs);
             }
         }
+
         $pages = array_values($pages);
         $result_count = count($pages);

@@ -893,15 +894,15 @@ class PhraseModel extends ParallelModel
         }
         $lookups = array();
         foreach($pages as $page) {
+            $key = $page[CrawlConstants::KEY];
             if(isset($page[CrawlConstants::SUMMARY_OFFSET])) {
                 if(is_array($page[CrawlConstants::SUMMARY_OFFSET])) {
-                    $lookups[$page[CrawlConstants::KEY] ] =
-                        $page[CrawlConstants::SUMMARY_OFFSET];
+                    $lookups[$key] = $page[CrawlConstants::SUMMARY_OFFSET];
                 }else {
                     $machine_id = (isset($page[self::MACHINE_ID])) ?
                         $page[self::MACHINE_ID] :$this->current_machine;
-                        $lookups[$page[CrawlConstants::KEY] ][] =
-                            array($machine_id, $page[self::KEY],
+                        $lookups[$key][] =
+                            array($machine_id, $key,
                                 $page[self::CRAWL_TIME],
                                 $page[self::GENERATION],
                                 $page[self::SUMMARY_OFFSET]);
@@ -918,6 +919,7 @@ class PhraseModel extends ParallelModel
             }
             $summaries_time = microtime();
         }
+
         $summaries = $this->getCrawlItems($lookups, $queue_servers);
         $out_pages = array();
         foreach($pages as $page) {
@@ -945,7 +947,6 @@ class PhraseModel extends ParallelModel
         if(USE_CACHE) {
             $CACHE->set($summary_hash, $results);
         }
-
         return $results;
     }

diff --git a/views/elements/footer_element.php b/views/elements/footer_element.php
index 4b24a90..5000dfd 100755
--- a/views/elements/footer_element.php
+++ b/views/elements/footer_element.php
@@ -53,23 +53,26 @@ class FooterElement extends Element
     public function render($data)
     {
     ?>
-        <div>
-        - <a href="./blog.php"><?php
-        e(tl('footer_element_blog')); ?></a> -
-        <a href="./privacy.php"><?php
-        e(tl('footer_element_privacy')); ?></a> -
-        <a href="./bot.php"><?php
-        e(tl('footer_element_bot')); ?></a> - <?php if(MOBILE) {
-            e('<br /> - ');
-        }
-        ?><a href="http://www.seekquarry.com/"><?php
-        e(tl('footer_element_developed_seek_quarry')); ?></a> -
-        </div>
-        <div>
-        (c) 2012 Yioop! -
-        <a href="http://www.yioop.com/"><?php
-        e(tl('footer_element_php_search_engine')); ?></a>
-        </div>
+
+            <div>
+            - <a href="./blog.php"><?php
+            e(tl('footer_element_blog')); ?></a> -
+            <a href="./privacy.php"><?php
+            e(tl('footer_element_privacy')); ?></a> -
+            <a href="./bot.php"><?php
+            e(tl('footer_element_bot')); ?></a> - <?php if(MOBILE) {
+                e('<br /> - ');
+            }
+            ?>
+
+            <a href="http://www.seekquarry.com/"><?php
+            e(tl('footer_element_developed_seek_quarry')); ?></a> -
+            </div>
+            <div>
+            (c) 2012 Yioop! - <a href="http://www.yioop.com/"><?php
+            e(tl('footer_element_php_search_engine'));
+            ?></a>
+            </div>
     <?php
     }
 }
diff --git a/views/elements/signin_element.php b/views/elements/signin_element.php
index c284cc1..753f2aa 100755
--- a/views/elements/signin_element.php
+++ b/views/elements/signin_element.php
@@ -52,33 +52,33 @@ class SigninElement extends Element
     public function render($data)
     {
     ?>
+
         <div class="userNav" >
         <ul>
         <?php
-        if(WEB_ACCESS) { ?>
-        <li><a href="?c=settings&amp;YIOOP_TOKEN=<?php
+        if(WEB_ACCESS) {
+            ?>    <li><a href="?c=settings&amp;YIOOP_TOKEN=<?php
                 e($data['YIOOP_TOKEN'])?>&amp;l=<?php
                 e(getLocaleTag());
                 e((isset($data['its'])) ? '&amp;its='.$data['its'] : '');
                 ?>"><?php
-            e(tl('signin_element_settings')); ?></a></li>
-        <?php }
+            e(tl('signin_element_settings')); ?></a></li><?php
+        }
         if(SIGNIN_LINK) {
-            if(!isset($_SESSION['USER_ID'])) { ?>
-                <li><a href="?c=admin"><?php
-                    e(tl('signin_element_signin')); ?></a></li>
-            <?php
+            if(!isset($_SESSION['USER_ID'])) {
+                ?><li><a href="?c=admin"><?php
+                    e(tl('signin_element_signin')); ?></a></li><?php
             } else {
-            ?>
-                <li><a href="?c=admin&amp;YIOOP_TOKEN=<?php
+                ?><li><a href="?c=admin&amp;YIOOP_TOKEN=<?php
                     e($data['YIOOP_TOKEN'])?>"><?php
-                        e(tl('signin_element_admin')); ?></a></li>
-                <li><a href="?c=search&amp;a=signout"><?php
+                        e(tl('signin_element_admin')); ?></a></li><?php
+                ?><li><a href="?c=search&amp;a=signout"><?php
                     e(tl('signin_element_signout')); ?></a></li>
             <?php
             }
         }
         ?>
+
         </ul>
         </div>
     <?php
diff --git a/views/elements/subsearch_element.php b/views/elements/subsearch_element.php
index d88bc7c..d88d4c2 100644
--- a/views/elements/subsearch_element.php
+++ b/views/elements/subsearch_element.php
@@ -60,9 +60,10 @@ class SubsearchElement extends Element
             $data['MEDIA'] = "Web";
         }
     ?>
+
         <div class="subsearch" >
         <ul>
-        <?php
+            <?php
             foreach($media_links as $type => $link) {
                 if($type == $data['MEDIA']) {
                     e("<li><b>$type</b></li>");
@@ -78,9 +79,11 @@ class SubsearchElement extends Element
                     e("<li><a href='$link$query'>$type</a></li>");
                 }
             }
-        ?>
+            ?>
+
         </ul>
         </div>
+
     <?php
     }
 }
diff --git a/views/helpers/images_helper.php b/views/helpers/images_helper.php
index c80245b..9610a1b 100644
--- a/views/helpers/images_helper.php
+++ b/views/helpers/images_helper.php
@@ -76,7 +76,7 @@ class ImagesHelper extends Helper implements CrawlConstants
                     urlencode($page[self::URL]).
                     "&amp;its=".$page[self::CRAWL_TIME];
             } else {
-                $link = $page[self::URL];
+                $link = htmlentities($page[self::URL]);
             }
         ?>
             <a href="<?php e($link); ?>" rel="nofollow"
diff --git a/views/helpers/pagination_helper.php b/views/helpers/pagination_helper.php
index 2270939..cd7aa1e 100755
--- a/views/helpers/pagination_helper.php
+++ b/views/helpers/pagination_helper.php
@@ -52,7 +52,7 @@ class PaginationHelper extends Helper
      * previous links
      *  @var int
      */
-    const MAX_PAGES_TO_SHOW = 11;
+    const MAX_PAGES_TO_SHOW = 10;

     /**
      * Draws a strip of links which begins with a previous
@@ -86,36 +86,45 @@ class PaginationHelper extends Helper
             $last_page = $first_page + self::MAX_PAGES_TO_SHOW;
         }

-        echo "<div class='pagination'><ul>";
-        if(0 < $num_earlier_pages) {
-            $prev_limit = ($num_earlier_pages - 1)*$results_per_page;
-            echo "<li><span class='end'>&laquo;".
-                "<a href='$base_url&amp;limit=$prev_limit' rel='nofollow'>".
-                tl('pagination_helper_previous')."</a></span></li>";
-        }
-        if(MOBILE) {
-            if(0 < $num_earlier_pages && $num_earlier_pages < $total_pages - 1){
-                e("<li><span class='end'>--</span></li>");
+        ?>
+
+            <div class='pagination'>
+                <ul>
+                    <?php
+            if(0 < $num_earlier_pages) {
+                $prev_limit = ($num_earlier_pages - 1)*$results_per_page;
+                echo "<li><span class='end'>&laquo;".
+                    "<a href='$base_url&amp;limit=$prev_limit' rel='nofollow'>".
+                    tl('pagination_helper_previous')."</a></span></li>";
             }
-        } else {
-            for($i=$first_page; $i < $last_page; $i++) {
-                 if($i == $num_earlier_pages) {
-                    echo "<li><span class='item'>$i</span></li>";
-                 } else {
-                    $cur_limit = $i * $results_per_page;
-                    echo "<li><a class='item' href='$base_url".
-                        "&amp;limit=$cur_limit' rel='nofollow'>$i</a></li>";
-                 }
+            if(MOBILE) {
+                if(0 < $num_earlier_pages &&
+                    $num_earlier_pages < $total_pages - 1){
+                    e("<li><span class='end'>--</span></li>");
+                }
+            } else {
+                for($i=$first_page; $i < $last_page; $i++) {
+                     $k = $i+1;
+                     if($i == $num_earlier_pages) {
+                        echo "<li><span class='item'>$k</span></li>";
+                     } else {
+                        $cur_limit = $i * $results_per_page;
+                        echo "<li><a class='item' href='$base_url".
+                            "&amp;limit=$cur_limit' rel='nofollow'>$k</a></li>";
+                     }
+                }
             }
-        }
-        if($num_earlier_pages < $total_pages - 1) {
-            $next_limit = ($num_earlier_pages + 1)*$results_per_page;
-            echo "<li><span class='other end'><a href='$base_url".
-                "&amp;limit=$next_limit' rel='nofollow'>".
-                tl('pagination_helper_next')."</a>&raquo;</span></li>";
-        }
+            if($num_earlier_pages < $total_pages - 1) {
+                $next_limit = ($num_earlier_pages + 1)*$results_per_page;
+                echo "<li><span class='other end'><a href='$base_url".
+                    "&amp;limit=$next_limit' rel='nofollow'>".
+                    tl('pagination_helper_next')."</a>&raquo;</span></li>";
+            }
+            ?>

-        echo "</ul></div>";
+                </ul>
+            </div>
+        <?php
     }

 }
diff --git a/views/helpers/videourl_helper.php b/views/helpers/videourl_helper.php
index 88da921..cc391ef 100644
--- a/views/helpers/videourl_helper.php
+++ b/views/helpers/videourl_helper.php
@@ -59,8 +59,10 @@ class VideourlHelper extends Helper
         if(substr($url, 0, 3) == "url") {
             $link_url_parts = explode("|", $url);
             if(count($link_url_parts) > 1) {
-                $url = $link_url_parts[1];
+                $url = htmlentities($link_url_parts[1]);
             }
+        } else {
+            $url = htmlentities($url);
         }
         if(stripos($url, "http://www.youtube.com/watch?v=") !== false) {
             $id = substr($url, 31, 11);
diff --git a/views/layouts/web_layout.php b/views/layouts/web_layout.php
index 48cd009..f636e52 100755
--- a/views/layouts/web_layout.php
+++ b/views/layouts/web_layout.php
@@ -63,78 +63,80 @@ class WebLayout extends Layout
         ?>" dir="<?php e($data['LOCALE_DIR']);?>">

         <head>
-            <title><?php if(isset($data['page']) &&
-                isset($this->view->head_objects[$data['page']]['title']))
-                e($this->view->head_objects[$data['page']]['title']);
-            else e(tl('web_layout_title')); ?></title>
-        <?php if(isset($this->view->head_objects['robots'])) {?>
-            <meta name="ROBOTS" content="<?php
-                e($this->view->head_objects['robots']) ?>" />
+        <title><?php if(isset($data['page']) &&
+            isset($this->view->head_objects[$data['page']]['title']))
+            e($this->view->head_objects[$data['page']]['title']);
+        else e(tl('web_layout_title')); ?></title>
+    <?php if(isset($this->view->head_objects['robots'])) {?>
+        <meta name="ROBOTS" content="<?php
+            e($this->view->head_objects['robots']) ?>" />
+    <?php } ?>
+        <meta name="description" content="<?php
+    if(isset($data['page']) &&
+    isset($this->view->head_objects[$data['page']]['description']))
+                e($this->view->head_objects[$data['page']]['description']);
+                else e(tl('web_layout_description')); ?>" />
+        <meta name="Author" content="Christopher Pollett" />
+        <meta name="description" content="<?php
+            e(tl('web_layout_description')); ?>" />
+        <meta charset="utf-8" />
+        <?php if(MOBILE) {?>
+        <meta name="viewport" content="width=device-width, initial-scale=1">
         <?php } ?>
-            <meta name="description" content="<?php
-        if(isset($data['page']) &&
-        isset($this->view->head_objects[$data['page']]['description']))
-                    e($this->view->head_objects[$data['page']]['description']);
-                    else e(tl('web_layout_description')); ?>" />
-            <meta name="Author" content="Christopher Pollett" />
-            <meta name="description" content="<?php
-                e(tl('web_layout_description')); ?>" />
-            <meta charset="utf-8" />
-            <?php if(MOBILE) {?>
-            <meta name="viewport" content="width=device-width, initial-scale=1">
-            <?php } ?>
-            <link rel="shortcut icon"   href="favicon.ico" />
-            <link rel="stylesheet" type="text/css" href="css/search.css" />
-            <link rel="search" type="application/opensearchdescription+xml"
-                href="<?php e(NAME_SERVER."yioopbar.xml");?>"
-                title="Content search" />
-
+        <link rel="shortcut icon"   href="favicon.ico" />
+        <link rel="stylesheet" type="text/css" href="css/search.css" />
+        <link rel="search" type="application/opensearchdescription+xml"
+            href="<?php e(NAME_SERVER."yioopbar.xml");?>"
+            title="Content search" />
         </head>
         <?php
             $data['MOBILE'] = (MOBILE) ? 'mobile': '';
         ?>
+
         <body class="html-<?php e($data['BLOCK_PROGRESSION']);?> html-<?php
             e($data['LOCALE_DIR']);?> html-<?php e($data['WRITING_MODE'].' '.
             $data['MOBILE']);?>" >
-            <div id="message" ></div>
-            <?php
-                $this->view->renderView($data);
-                if(QUERY_STATISTICS) { ?>
-                <div class="query-statistics">
-                <?php
-                    e("<h1>".tl('web_layout_query_statistics')."</h1>");
-                    e("<div><b>".
-                        $data['YIOOP_INSTANCE']
-                        ."</b><br /><br />");
-                    e("<b>".tl('web_layout_total_elapsed_time',
-                         $data['TOTAL_ELAPSED_TIME'])."</b></div>");
-                    foreach($data['QUERY_STATISTICS'] as $query_info) {
-                        e("<div class='query'><div>".$query_info['QUERY'].
-                            "</div><div><b>".
-                            tl('web_layout_query_time',
-                                $query_info['ELAPSED_TIME']).
-                                "</b></div></div>");
-                    }
-                ?>
-                </div>
-                <?php }
-            ?>
-            <script type="text/javascript" src="./scripts/basic.js" ></script>
-            <?php
-            if(isset($data['INCLUDE_SCRIPTS'])) {
-                foreach($data['INCLUDE_SCRIPTS'] as $script_name) {
-                    e('<script type="text/javascript" src="./scripts/'.
-                        $script_name.'.js" ></script>');
-                }
+        <div id="message" ></div><?php
+        $this->view->renderView($data);
+        if(QUERY_STATISTICS) { ?>
+
+        <div class="query-statistics">
+        <?php
+            e("<h1>".tl('web_layout_query_statistics')."</h1>");
+            e("<div><b>".
+                $data['YIOOP_INSTANCE']
+                ."</b><br /><br />");
+            e("<b>".tl('web_layout_total_elapsed_time',
+                 $data['TOTAL_ELAPSED_TIME'])."</b></div>");
+            foreach($data['QUERY_STATISTICS'] as $query_info) {
+                e("<div class='query'><div>".$query_info['QUERY'].
+                    "</div><div><b>".
+                    tl('web_layout_query_time',
+                        $query_info['ELAPSED_TIME']).
+                        "</b></div></div>");
             }
-            ?>
-            <script type="text/javascript" >
-            <?php
-            if(isset($data['SCRIPT'])) {
-                e($data['SCRIPT']);
+        ?>
+
+        </div>
+        <?php
+        } ?>
+
+        <script type="text/javascript" src="./scripts/basic.js" ></script>
+        <?php
+        if(isset($data['INCLUDE_SCRIPTS'])) {
+            foreach($data['INCLUDE_SCRIPTS'] as $script_name) {
+                e('<script type="text/javascript" src="./scripts/'.
+                    $script_name.'.js" ></script>');
             }
-            ?>
-            </script>
+        }
+        ?>
+
+        <script type="text/javascript" >
+        <?php
+        if(isset($data['SCRIPT'])) {
+            e($data['SCRIPT']);
+        }
+        ?></script>

         </body>
     </html>
diff --git a/views/search_view.php b/views/search_view.php
index 91dd75f..ab020a5 100755
--- a/views/search_view.php
+++ b/views/search_view.php
@@ -73,52 +73,65 @@ class SearchView extends View implements CrawlConstants
      *
      */
     public function renderView($data)
-    {
+    {
         $data['LAND'] = (!isset($data['PAGES'])) ? 'landing-' : '';
-        if(SIGNIN_LINK || SUBSEARCH_LINK) {
-            ?>
-            <div class="<?php e($data['LAND']);?>topbar"><?php
+        if(SIGNIN_LINK || SUBSEARCH_LINK) {?>
+
+
+        <div class="<?php e($data['LAND']);?>topbar"><?php
             $this->subsearchElement->render($data);
             $this->signinElement->render($data);
             ?>
-            </div><?php
+
+        </div>
+
+        <?php
         }
         $logo = "resources/yioop.png";
-        if(!isset($data['PAGES'])) {
-            e('<div class="landing">');
+        if(!isset($data['PAGES'])) {?>
+
+        <div class="landing">
+        <?php
         } else if(MOBILE) {
             $logo = "resources/m-yioop.png";
         }
         ?>
+
         <h1 class="logo"><a href="./?YIOOP_TOKEN=<?php
             e($data['YIOOP_TOKEN'])?>"><img
-            src="<?php e($logo); ?>" alt="<?php e(tl('search_view_title')); ?>"
-            /></a></h1>
+            src="<?php e($logo); ?>" alt="<?php e(tl('search_view_title'));
+                 ?>"
+            /></a>
+        </h1>
+        <?php
+        if(isset($data['PAGES'])) {?>
+
+        <div class="serp">
         <?php
-        if(isset($data['PAGES'])) {
-            e('<div class="serp">');
         }
         ?>
+
         <div class="searchbox">
-        <form id="searchForm" method="get" action='?'>
-        <p>
-        <input type="hidden" name="YIOOP_TOKEN" value="<?php
-            e($data['YIOOP_TOKEN']); ?>" />
-        <input type="hidden" name="its" value="<?php e($data['its']); ?>" />
-        <input type="text" <?php if(WORD_SUGGEST) { ?>
-            autocomplete="off"  onkeyup="askeyup(event,this)"
-            <?php } ?>
-            title="<?php e(tl('search_view_input_label')); ?>"
-            id="search-name" name="q" value="<?php if(isset($data['QUERY'])) {
-            e(urldecode($data['QUERY']));} ?>"
-            placeholder="<?php e(tl('search_view_input_placeholder')); ?>" />
-        <button class="buttonbox" type="submit"><?php if(MOBILE) {
-                e('>');
-            } else {
-            e(tl('search_view_search')); } ?></button>
-        </p>
-        </form>
-            </div>
+            <form id="searchForm" method="get" action='?'>
+            <p>
+            <input type="hidden" name="YIOOP_TOKEN" value="<?php
+                e($data['YIOOP_TOKEN']); ?>" />
+            <input type="hidden" name="its" value="<?php e($data['its']); ?>" />
+            <input type="text" <?php if(WORD_SUGGEST) { ?>
+                autocomplete="off"  onkeyup="askeyup(event,this)"
+                <?php } ?>
+                title="<?php e(tl('search_view_input_label')); ?>"
+                id="search-name" name="q" value="<?php
+                if(isset($data['QUERY'])) {
+                    e(urldecode($data['QUERY']));} ?>"
+                placeholder="<?php e(tl('search_view_input_placeholder')); ?>"/>
+            <button class="buttonbox" type="submit"><?php if(MOBILE) {
+                    e('>');
+                } else {
+                e(tl('search_view_search')); } ?></button>
+            </p>
+            </form>
+        </div>
         <div id="asdropdown">
             <ul id="aslist" class="autoresult">
             </ul>
@@ -126,8 +139,10 @@ class SearchView extends View implements CrawlConstants
         <?php
         if(isset($data['PAGES'])) {
             ?>
-            </div>
-            <div class="serp-results">
+
+        </div>
+
+        <div class="serp-results">
             <h2><?php
                 if(MOBILE) {
                 } else {
@@ -140,18 +155,19 @@ class SearchView extends View implements CrawlConstants
                 }
             ?></h2>
             <?php
-            foreach($data['PAGES'] as $page) {?>
-                <div class='result'>
+            foreach($data['PAGES'] as $page) {
+            ?><div class='result'>
                 <?php if(isset($page['IMAGES'])) {
                     $image_query = "?YIOOP_TOKEN={$data['YIOOP_TOKEN']}".
                             "&amp;c=search&amp;q={$data['QUERY']}";
                     $this->imagesHelper->render($page['IMAGES'], $image_query);
                     continue;
                 }?>
+
                 <h2>
                 <a href="<?php if(isset($page[self::TYPE])
                     && $page[self::TYPE] != "link") {
-                        e($page[self::URL]);
+                        e(htmlentities($page[self::URL]));
                     } else {
                         e( strip_tags($page[self::TITLE]));
                     } ?>" rel="nofollow"><?php
@@ -166,18 +182,20 @@ class SearchView extends View implements CrawlConstants
                     }
                     $check_video = true;
                 }
-                ?></a></h2>
+                ?></a>
+                </h2>
                 <?php if($check_video) {
                     $this->videourlHelper->render($page[self::URL]);
                 }
                 ?>
+
                 <p><?php if(!isset($page[self::ROBOT_METAS]) ||
                     !in_array("NOSNIPPET", $page[self::ROBOT_METAS])) {
                         echo $this->displayresultsHelper->
                             render($page[self::DESCRIPTION]);
                     }?></p>
                 <p class="echolink" ><?php if(isset($page[self::URL])){
-                    e(substr($page[self::URL],0, 200)." ");}
+                    e(htmlentities(substr($page[self::URL],0, 200))." ");}
                     e(tl('search_view_rank',
                         number_format($page[self::DOC_RANK], 2)));
                     e(tl('search_view_relevancy',
@@ -190,7 +208,8 @@ class SearchView extends View implements CrawlConstants
                         !(in_array("NOARCHIVE", $page[self::ROBOT_METAS]) ||
                           in_array("NONE", $page[self::ROBOT_METAS])))) {
                     ?>
-                        <a href="?YIOOP_TOKEN=<?php e($data['YIOOP_TOKEN']);
+
+                    <a href="?YIOOP_TOKEN=<?php e($data['YIOOP_TOKEN']);
                             ?>&amp;c=search&amp;a=cache&amp;q=<?php
                             e($data['QUERY']); ?>&amp;arg=<?php
                             e(urlencode($page[self::URL]));
@@ -208,7 +227,8 @@ class SearchView extends View implements CrawlConstants
                     <?php
                     }
                     if(SIMILAR_LINK) {
-                    ?>
+                    ?>
+
                     <a href="?YIOOP_TOKEN=<?php e($data['YIOOP_TOKEN']);
                         ?>&amp;c=search&amp;a=related&amp;arg=<?php
                         e(urlencode($page[self::URL])); ?>&amp;<?php
@@ -220,7 +240,8 @@ class SearchView extends View implements CrawlConstants
                     }
                     if(IN_LINK) {
                     ?>
-                        <a href="?YIOOP_TOKEN=<?php e($data['YIOOP_TOKEN']);
+
+                    <a href="?YIOOP_TOKEN=<?php e($data['YIOOP_TOKEN']);
                         ?>&amp;c=search&amp;q=<?php
                         e(urlencode("link:".$page[self::URL])); ?>&amp;<?php
                         ?>its=<?php e($page[self::CRAWL_TIME]); ?>"
@@ -229,42 +250,54 @@ class SearchView extends View implements CrawlConstants
                     ?></a>.
                     <?php
                     }
-                    if(IP_LINK) {
-                    ?>
-                    <?php if(isset($page[self::IP_ADDRESSES])){
-                          foreach($page[self::IP_ADDRESSES] as $address) {?>
-                            <a href="?YIOOP_TOKEN=<?php e($data['YIOOP_TOKEN']);
-                                ?>&amp;c=search&amp;q=<?php
-                                e(urlencode('ip:'.$address));?>&amp;<?php
-                                ?>its=<?php e($data['its']); ?>"
-                                rel='nofollow'>IP:<?php
-                                e("$address");?></a>. <?php
-                          }
-                        }?></p>
+                    if(IP_LINK && isset($page[self::IP_ADDRESSES])){
+                    foreach($page[self::IP_ADDRESSES] as $address) {?>
+
+                    <a href="?YIOOP_TOKEN=<?php e($data['YIOOP_TOKEN']);
+                            ?>&amp;c=search&amp;q=<?php
+                            e(urlencode('ip:'.$address));?>&amp;<?php
+                            ?>its=<?php e($data['its']); ?>"
+                            rel='nofollow'>IP:<?php
+                            e("$address");?></a>. <?php
+                      }
+                    }?>
+
+                </p>
                 <?php
-                    }
                 } ?>
-                </div>
+
+            </div>

             <?php
             } //end foreach
             $this->paginationHelper->render(
                 $data['PAGING_QUERY']."&amp;YIOOP_TOKEN=".$data['YIOOP_TOKEN'],
                 $data['LIMIT'], $data['RESULTS_PER_PAGE'], $data['TOTAL_ROWS']);
-            e("</div>");
+            ?>
+
+        </div>
+        <?php
         }
-        ?><div class="landing-footer">
+        ?>
+
+        <div class="landing-footer">
             <div><b><?php e($data['INDEX_INFO']);?></b> <?php
-            if(isset($data["HAS_STATISTICS"]) && $data["HAS_STATISTICS"]) { ?>
-            [<a href="index.php?YIOOP_TOKEN=<?php e($data['YIOOP_TOKEN']);
+            if(isset($data["HAS_STATISTICS"]) && $data["HAS_STATISTICS"]) {
+            ?>[<a href="index.php?YIOOP_TOKEN=<?php e($data['YIOOP_TOKEN']);
                 ?>&amp;c=statistics&amp;its=<?php e($data['its']);?>"><?php
                 e(tl('search_view_more_statistics')); ?></a>]
-            <?php }?>
-            </div>
-            <?php  $this->footerElement->render($data);?>
-        </div><?php
-        if(!isset($data['PAGES'])) {
-            e("</div><div class='landing-spacer'></div>");
+            <?php
+            }
+            ?></div><?php  $this->footerElement->render($data);?>
+
+        </div>
+        <?php
+        if(!isset($data['PAGES'])) {?>
+
+        </div>
+
+        <div class='landing-spacer'></div>
+        <?php
         }

     }
ViewGit