Skip to content
Permalink
Browse files

Update tabs to spaces.

  • Loading branch information...
gamma committed May 15, 2017
1 parent fbe2b05 commit 024a4f381c581eb3fb5893dc0c34dd02fb809178
Showing with 149 additions and 149 deletions.
  1. +19 −19 helper.php
  2. +26 −26 style.css
  3. +104 −104 syntax.php
@@ -18,34 +18,34 @@ function tpl_searchform($namespaces, $return = false) {
$lang = preg_quote($this->getLangCode(), '/');
$cur_val = preg_replace('/^'.$lang.':/', '', $cur_val);
ob_start();
$QUERY = hsc(preg_replace('/ ?@\S+/','',$QUERY));
tpl_searchform(true, false);
$searchForm = ob_get_contents();
ob_end_clean();
ob_start();
$QUERY = hsc(preg_replace('/ ?@\S+/','',$QUERY));
tpl_searchform(true, false);
$searchForm = ob_get_contents();
ob_end_clean();
// Default Select
if ( count($namespaces) == 1 ) {
// Only one of them. All of them.
list($ns, $name, $class) = $namespaces[0];
// 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 {
} else {
$namespaceSelect = '<select class="namespacesearch_namespace" name="namespace">';
foreach ($namespaces as $element) {
list($ns, $name, $class) = $element;
list($ns, $name, $class) = $element;
$namespaceSelect .= '<option class="namespacesearch_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);
// Insert reight at the beginning.
$searchForm = substr_replace($searchForm, $namespaceSelect, strpos($searchForm, '<input'), 0);
if ( $return ) {
return '<div id="dokuwiki__sitetools" class="namespacesearch__container">'.$searchForm.'</div>';
} else {
print '<div class="namespacesearch__container">'.$searchForm.'</div>';
}
if ( $return ) {
return '<div id="dokuwiki__sitetools" class="namespacesearch__container">'.$searchForm.'</div>';
} else {
print '<div class="namespacesearch__container">'.$searchForm.'</div>';
}
}
private function translatedNamespace($id) {
@@ -1,51 +1,51 @@
#dokuwiki__sitetools.namespacesearch__container {
font-size: 1em;
font-size: 1em;
}

div.namespacesearch__container form.search {
margin-left: auto;
margin-right: auto;
display: block;
margin-left: auto;
margin-right: auto;
display: block;
}

div.namespacesearch__container form.search div.no {
display: inline-block;
display: inline-block;
}

select.namespacesearch_namespace {
background: transparent;
border: none;
display: inline-block;
left: 0px;
top: 0px;
bottom: 0px;
width: 49%;
z-index: 100;
position: absolute;
outline: none;
-webkit-appearance: none;
margin: 2px;
padding: 0px 10px;
background: transparent;
border: none;
display: inline-block;
left: 0px;
top: 0px;
bottom: 0px;
width: 49%;
z-index: 100;
position: absolute;
outline: none;
-webkit-appearance: none;
margin: 2px;
padding: 0px 10px;
}

select.namespacesearch_namespace:hover {
background: __highlight__;
background: __highlight__;
}

select.namespacesearch_namespace option:nth-child(2n+1) {
background: __light__;
background: __light__;
}

select.namespacesearch_namespace option {
background: __highlight__;
background: __highlight__;
}

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

#dokuwiki__sitetools form.search select ~ #qsearch__in {
box-sizing: border-box;
padding-left: 50%;
}
box-sizing: border-box;
padding-left: 50%;
}
@@ -24,121 +24,121 @@ function connectTo($mode) {
}
function handle($match, $state, $pos, Doku_Handler $handler) {
global $ID;
$match = substr($match, 14, -2); // strip markup
$spaces = array();
foreach( explode(' ', $match) as $ns ) {
$ns = cleanID($ns);
if (($ns == '*') || ($ns == ':')) { $ns = ''; }
elseif ($ns == '.') { $ns = getNS($ID); }
$spaces[] = $ns;
}
global $ID;
$match = substr($match, 14, -2); // strip markup
$spaces = array();
foreach( explode(' ', $match) as $ns ) {
$ns = cleanID($ns);
if (($ns == '*') || ($ns == ':')) { $ns = ''; }
elseif ($ns == '.') { $ns = getNS($ID); }
$spaces[] = $ns;
}
return array($state, $spaces);
return array($state, $spaces);
}
}
function render($mode, Doku_Renderer $renderer, $data) {
global $conf, $ID, $FANCYDATA;
list($state, $spaces) = $data;
list($state, $spaces) = $data;
if ($mode == 'xhtml' && $state = DOKU_LEXER_SPECIAL ) {
$renderer->nocache();
$helper = &plugin_load('helper', 'namespacesearch');
$form = new Doku_Form('namespacesearchForm', wl($ID));
$form->addElement(form_makeTextField('namespacesearchField', $FANCYDATA['namespacesearchField'], $this->getLang('keywords') . ':', 'namespacesearchField', null, array('autocomplete'=>'off')));
/* List of Namespaces for the scope */
$names = array();
$allScopes = implode(' ', $spaces);
$names[] = array("$allScopes", $this->getLang('all_scopes'), 'allscopes');
foreach ( $spaces as $dir ) {
$namespaces = array();
list($dir, $class) = explode('|', $dir);
search($namespaces,$conf['datadir'],'search_namespaces',null,$dir);
foreach ($namespaces as $namespace) {
list($id, $type, $lvl) = array_values($namespace);
$names[] = array($id, ucwords(preg_replace('/[-_:]/', ' ', str_replace("$ID:", '', $id))), $class);
}
}
$renderer->doc .= $helper->tpl_searchform($names, true);
// $this->namespacesearchSuggestionInserter($renderer);
$renderer->nocache();
$helper = &plugin_load('helper', 'namespacesearch');
$form = new Doku_Form('namespacesearchForm', wl($ID));
$form->addElement(form_makeTextField('namespacesearchField', $FANCYDATA['namespacesearchField'], $this->getLang('keywords') . ':', 'namespacesearchField', null, array('autocomplete'=>'off')));
/* List of Namespaces for the scope */
$names = array();
$allScopes = implode(' ', $spaces);
$names[] = array("$allScopes", $this->getLang('all_scopes'), 'allscopes');
foreach ( $spaces as $dir ) {
$namespaces = array();
list($dir, $class) = explode('|', $dir);
search($namespaces,$conf['datadir'],'search_namespaces',null,$dir);
foreach ($namespaces as $namespace) {
list($id, $type, $lvl) = array_values($namespace);
$names[] = array($id, ucwords(preg_replace('/[-_:]/', ' ', str_replace("$ID:", '', $id))), $class);
}
}
$renderer->doc .= $helper->tpl_searchform($names, true);
// $this->namespacesearchSuggestionInserter($renderer);
return true;
}
return false;
}
function _capture_form_output($form) {
if ( !$form ) { return ''; }
ob_start();
$form->printForm();
$output = ob_get_contents();
ob_end_clean();
return trim($output);
}
function namespacesearchSuggestionInserter(&$renderer) {
global $FANCYDATA, $lang, $conf, $ID;
if ( !empty($FANCYDATA['query']) ) {
//do fulltext search
$ns = explode('@', $FANCYDATA['query']);
$query = array();
foreach ( explode(' ', array_shift($ns)) as $part) {
if (empty($part)) { continue; }
if ( substr($part, 0, 1) != '"' && substr($part, 0, 1) != '*' ) $part = '*' . $part;
if ( substr($part, -1) != '"' && substr($part, -1) != '*' ) $part = $part. '*';
$query[] = $part;
}
$query = implode(' ', $query);
array_unshift($ns, $query);
$query2 = array();
foreach( $ns as $namespace ) {
if (empty($namespace)) { continue; }
$query2[] = trim(cleanID($namespace));
}
$query = implode('@', $query2);
$data = ft_pageSearch($query,$regex);
$renderer->doc .= '<h2>Search Result</h2>';
if(count($data)){
$num = 1;
foreach($data as $id => $cnt){
if ( $id == $ID ) { continue; }
$renderer->doc .= '<div class="search_result">';
$renderer->doc .= html_wikilink(':'.$id, $conf['useheading']?NULL:$id, $regex);
$renderer->doc .= ': <span class="search_cnt">'.$cnt.' '.$lang['hits'].'</span><br />';
if($num < 15){ // create snippets for the first number of matches only #FIXME add to conf ?
$renderer->doc .= '<div class="search_snippet">'.ft_snippet($id,$regex).'</div>';
}
$renderer->doc .= '</div>';
$num++;
}
}else{
$renderer->doc .= '<div class="nothing">'.$lang['nothingfound'].'</div>';
}
}
}
function _capture_form_output($form) {
if ( !$form ) { return ''; }
ob_start();
$form->printForm();
$output = ob_get_contents();
ob_end_clean();
return trim($output);
}
function namespacesearchSuggestionInserter(&$renderer) {
global $FANCYDATA, $lang, $conf, $ID;
if ( !empty($FANCYDATA['query']) ) {
//do fulltext search
$ns = explode('@', $FANCYDATA['query']);
$query = array();
foreach ( explode(' ', array_shift($ns)) as $part) {
if (empty($part)) { continue; }
if ( substr($part, 0, 1) != '"' && substr($part, 0, 1) != '*' ) $part = '*' . $part;
if ( substr($part, -1) != '"' && substr($part, -1) != '*' ) $part = $part. '*';
$query[] = $part;
}
$query = implode(' ', $query);
array_unshift($ns, $query);
$query2 = array();
foreach( $ns as $namespace ) {
if (empty($namespace)) { continue; }
$query2[] = trim(cleanID($namespace));
}
$query = implode('@', $query2);
$data = ft_pageSearch($query,$regex);
$renderer->doc .= '<h2>Search Result</h2>';
if(count($data)){
$num = 1;
foreach($data as $id => $cnt){
if ( $id == $ID ) { continue; }
$renderer->doc .= '<div class="search_result">';
$renderer->doc .= html_wikilink(':'.$id, $conf['useheading']?NULL:$id, $regex);
$renderer->doc .= ': <span class="search_cnt">'.$cnt.' '.$lang['hits'].'</span><br />';
if($num < 15){ // create snippets for the first number of matches only #FIXME add to conf ?
$renderer->doc .= '<div class="search_snippet">'.ft_snippet($id,$regex).'</div>';
}
$renderer->doc .= '</div>';
$num++;
}
}else{
$renderer->doc .= '<div class="nothing">'.$lang['nothingfound'].'</div>';
}
}
}
}
// vim:ts=4:sw=4:et:enc=utf-8:

0 comments on commit 024a4f3

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