Skip to content
Permalink
Browse files

Do not display selector when only one Namespace available

  • Loading branch information...
gamma committed Sep 8, 2014
1 parent bfe0f88 commit 42f66780be541427c07b852f08c941dee1c3e669
Showing with 16 additions and 7 deletions.
  1. +13 −7 helper.php
  2. +3 −0 style.css
@@ -24,13 +24,19 @@ function tpl_searchform($namespaces, $return = false) {
$searchForm = ob_get_contents();
ob_end_clean();
// Default Selct
$namespaceSelect = '<select class="fancysearch_namespace" name="namespace">';
foreach ($namespaces as $element) {
list($ns, $name, $class) = $element;
$namespaceSelect .= '<option class="fancysearch_ns_'.hsc($class).'" value="'.hsc($ns).'"'.($cur_val === $ns ? ' selected="selected"' : '').'>'.$name.'</option>';
}
$namespaceSelect .= '</select>';
// Default Select
if ( count($namespaces) == 1 ) {
// Only one of them. All of them.
list($ns, $name, $class) = $namespaces[0];
$namespaceSelect = '<input name="namespace" value="'.hsc($ns).'" type="hidden"/>';
} else {
$namespaceSelect = '<select class="fancysearch_namespace" name="namespace">';
foreach ($namespaces as $element) {
list($ns, $name, $class) = $element;
$namespaceSelect .= '<option class="fancysearch_ns_'.hsc($class).'" value="'.hsc($ns).'"'.($cur_val === $ns ? ' selected="selected"' : '').'>'.$name.'</option>';
}
$namespaceSelect .= '</select>';
}
// Insert reight at the beginning.
$searchForm = substr_replace($searchForm, $namespaceSelect, strpos($searchForm, '<input'), 0);
@@ -43,6 +43,9 @@ select.fancysearch_namespace option {

#dokuwiki__sitetools form.search #qsearch__in {
width: 36em;
}

#dokuwiki__sitetools form.search select ~ #qsearch__in {
box-sizing: border-box;
padding-left: 50%;
}

0 comments on commit 42f6678

Please sign in to comment.
You can’t perform that action at this time.