Start support for search
This commit is contained in:
parent
7a74672e31
commit
0b2e7b691d
115
blocks/ORB/Search.pm
Normal file
115
blocks/ORB/Search.pm
Normal file
@ -0,0 +1,115 @@
|
||||
## @file
|
||||
# This file contains the implementation of the search page.
|
||||
#
|
||||
# @author Chris Page <chris@starforge.co.uk>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see http://www.gnu.org/licenses/.
|
||||
|
||||
## @class
|
||||
package ORB::Search;
|
||||
|
||||
use strict;
|
||||
use parent qw(ORB); # This class extends the ORB block class
|
||||
use experimental qw(smartmatch);
|
||||
use v5.14;
|
||||
|
||||
sub
|
||||
|
||||
|
||||
sub _generate_search {
|
||||
my $self = shift;
|
||||
|
||||
my ($term, $error) = $self -> validate_string('search',
|
||||
{
|
||||
required => 0,
|
||||
default => undef,
|
||||
nicename => "{L_SEARCH_SEARCH}",
|
||||
minlen => 4
|
||||
});
|
||||
|
||||
return $self -> _build_search_results($term)
|
||||
if($term);
|
||||
|
||||
return $self -> _build_search_form($error);
|
||||
}
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# UI handler/dispatcher functions
|
||||
|
||||
## @method private @ _fatal_error($error)
|
||||
# Generate the tile and content for an error page.
|
||||
#
|
||||
# @param error A string containing the error message to display
|
||||
# @return The title of the error page and an error message to place in the page.
|
||||
sub _fatal_error {
|
||||
my $self = shift;
|
||||
my $error = shift;
|
||||
|
||||
return ("{L_SEARCH_ERROR_FATAL}",
|
||||
$self -> {"template"} -> load_template("error/page_error.tem",
|
||||
{ "%(message)s" => $error,
|
||||
"%(url-logout)s" => $self -> build_url(block => "login", pathinfo => ["signout"])
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
## @method private $ _dispatch_ui()
|
||||
# Implements the core behaviour dispatcher for non-api functions. This will
|
||||
# inspect the state of the pathinfo and invoke the appropriate handler
|
||||
# function to generate content for the user.
|
||||
#
|
||||
# @return A string containing the page HTML.
|
||||
sub _dispatch_ui {
|
||||
my $self = shift;
|
||||
|
||||
my ($title, $body, $extrahead, $extrajs) = $self -> _generate_search();
|
||||
|
||||
# Done generating the page content, return the filled in page template
|
||||
return $self -> generate_orb_page(title => $title,
|
||||
content => $body,
|
||||
extrahead => $extrahead,
|
||||
extrajs => $extrajs,
|
||||
active => '',
|
||||
doclink => 'search');
|
||||
}
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# Module interface functions
|
||||
|
||||
## @method $ page_display()
|
||||
# Generate the page content for this module.
|
||||
sub page_display {
|
||||
my $self = shift;
|
||||
|
||||
# Is this an API call, or a normal page operation?
|
||||
my $apiop = $self -> is_api_operation();
|
||||
if(defined($apiop)) {
|
||||
# API call - dispatch to appropriate handler.
|
||||
given($apiop) {
|
||||
default {
|
||||
return $self -> api_response($self -> api_errorhash('bad_op',
|
||||
$self -> {"template"} -> replace_langvar("API_BAD_OP")))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return $self -> _dispatch_ui();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
1;
|
@ -86,6 +86,11 @@ sub block_display {
|
||||
pathinfo => [ ],
|
||||
params => {},
|
||||
forcessl => 1),
|
||||
"%(url-search)s" => $self -> build_url(block => "search",
|
||||
fullurl => 1,
|
||||
pathinfo => [ ],
|
||||
params => {},
|
||||
forcessl => 1),
|
||||
"%(url-shop)s" => $self -> build_url(block => "shop",
|
||||
fullurl => 1,
|
||||
pathinfo => [ ],
|
||||
|
@ -1,8 +1,8 @@
|
||||
<div class="top-bar">
|
||||
<div class="top-bar hide-for-print">
|
||||
<div class="top-bar-left">
|
||||
<ul class="menu">
|
||||
<li><button id="menubtn" class="menu-icon dark" type="button" data-open="offCanvas"></button></li>
|
||||
<li><input type="search" placeholder="Search"></li>
|
||||
<li><form action="%(url-search)s" method="POST"><input type="search" placeholder="Search"></form></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="top-bar-right show-for-medium">
|
||||
|
Loading…
x
Reference in New Issue
Block a user