do not show search box when no search adapter configured
authorChristian Weiske <cweiske@cweiske.de>
Mon, 7 May 2012 19:17:26 +0000 (21:17 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Mon, 7 May 2012 19:17:26 +0000 (21:17 +0200)
data/templates/base.htm
src/phorkie/Database.php
www/www-header.php

index 906453e..8c6b4b0 100644 (file)
       <li>
        <a href="/list">List all</a>
       </li>
+      {% if db.adapter %}
       <li>
        <form class="navbar-search pull-left" action="/search" method="get">
         <input type="text" class="search-query" name="q" placeholder="Search" value="{{query}}"/>
        </form>
       </li>
+      {% endif %}
      </ul>
     </div>
    </div>
index 786cfe0..1f214e8 100644 (file)
@@ -3,12 +3,14 @@ namespace phorkie;
 
 class Database
 {
+    public $adapter = null;
     public $prefix = '\phorkie\Database_Adapter_Null';
 
     public function __construct()
     {
         if ($GLOBALS['phorkie']['cfg']['elasticsearch'] != '') {
-            $this->prefix = '\phorkie\Database_Adapter_Elasticsearch';
+            $this->adapter = 'Elasticsearch';
+            $this->prefix  = '\phorkie\Database_Adapter_Elasticsearch';
         }
     }
     public function getSearch()
index c0b18d3..72a2e67 100644 (file)
@@ -63,6 +63,7 @@ function render($tplname, $vars)
     $vars['css'] = $GLOBALS['phorkie']['cfg']['css'];
     $vars['title'] = $GLOBALS['phorkie']['cfg']['title'];
     $vars['topbar'] = $GLOBALS['phorkie']['cfg']['topbar'];
+    $vars['db'] = new Database();
 
     $template = $GLOBALS['twig']->loadTemplate($tplname . '.htm');
     echo $template->render($vars);