From: Christian Weiske Date: Mon, 7 May 2012 19:17:26 +0000 (+0200) Subject: do not show search box when no search adapter configured X-Git-Tag: v0.2.0~18 X-Git-Url: https://git.cweiske.de/phorkie.git/commitdiff_plain/fa61fdfea420bb770d4390f49fa5e2f379891d21 do not show search box when no search adapter configured --- diff --git a/data/templates/base.htm b/data/templates/base.htm index 906453e..8c6b4b0 100644 --- a/data/templates/base.htm +++ b/data/templates/base.htm @@ -23,11 +23,13 @@
  • List all
  • + {% if db.adapter %}
  • + {% endif %} diff --git a/src/phorkie/Database.php b/src/phorkie/Database.php index 786cfe0..1f214e8 100644 --- a/src/phorkie/Database.php +++ b/src/phorkie/Database.php @@ -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() diff --git a/www/www-header.php b/www/www-header.php index c0b18d3..72a2e67 100644 --- a/www/www-header.php +++ b/www/www-header.php @@ -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);