advanced_search.shtml revision 2603
1116N/A## -*- coding: utf-8 -*-
1116N/A##
1116N/A## CDDL HEADER START
1116N/A##
1116N/A## The contents of this file are subject to the terms of the
1116N/A## Common Development and Distribution License (the "License").
1116N/A## You may not use this file except in compliance with the License.
1116N/A##
1116N/A## You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
1116N/A## or http://www.opensolaris.org/os/licensing.
1116N/A## See the License for the specific language governing permissions
1116N/A## and limitations under the License.
1116N/A##
1116N/A## When distributing Covered Code, include this CDDL HEADER in each
1116N/A## file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1116N/A## If applicable, add the following below this CDDL HEADER, with the
1116N/A## fields enclosed by brackets "[]" replaced with your own identifying
1116N/A## information: Portions Copyright [yyyy] [name of copyright owner]
1116N/A##
1116N/A## CDDL HEADER END
1116N/A##
2603N/A## Copyright 2009, 2011 Oracle and/or its affiliates. All rights reserved.
1116N/A##
1116N/A<%!
1116N/A import pkg.query_parser as qp
1116N/A import urllib
1116N/A%>\
1116N/A<%inherit file="search.shtml"/>\
1116N/A<%page args="g_vars"/>\
1116N/A<%
1116N/A catalog = g_vars["catalog"]
1116N/A request = g_vars["request"]
1116N/A%>\
1116N/A<%def name="page_title(g_vars)"><%
1116N/A return "Advanced Package Search"
1116N/A%></%def>\
1116N/A<%def name="get_search_criteria(request)"><%
1116N/A # Based on the request parameters, return a dict representing the
1116N/A # search criteria.
1116N/A criteria = parent.get_search_criteria(request)
1116N/A
1116N/A versions = self.shared.get_releases(g_vars)
1116N/A if versions:
1116N/A # Add an "All" selection to be used as the default.
1116N/A versions.insert(0, ("", "", "All"))
1116N/A
1116N/A # The string value representing the user's selection.
1116N/A selected_val = urllib.unquote(request.params.get("v", ""))
1116N/A
1116N/A # The version object matching the string value of the user's selection.
1116N/A selected_ver = None
1116N/A
1116N/A if selected_val:
1116N/A for v in versions:
1116N/A ver, val, label = v
1116N/A if selected_val == val:
1116N/A selected_ver = ver
1116N/A break
1116N/A
1116N/A if versions and selected_val and not selected_ver:
1116N/A # The version provided didn't match a valid one, so default to
1116N/A # the first one in the list.
1116N/A selected_ver = versions[0][0]
1116N/A selected_val = versions[0][1]
1116N/A
1116N/A criteria["versions"] = versions
1116N/A criteria["selected_ver"] = selected_ver
1116N/A criteria["selected_val"] = selected_val
1116N/A
1116N/A return criteria
1116N/A%></%def>\
1116N/A<%def name="display_search_form(criteria, request)"><%
1116N/A return_types = [
1116N/A ("a", "Actions"),
1116N/A ("p", "Packages")
1116N/A ]
1116N/A
1116N/A rpp_values = (10, 20, 30, 50, 100, 250, 500)
1116N/A
1116N/A token_val = criteria["token"]
1116N/A if criteria["return_type"] == qp.Query.RETURN_PACKAGES:
1116N/A show = "p"
1116N/A elif criteria["return_type"] == qp.Query.RETURN_ACTIONS:
1116N/A show = "a"
1116N/A
1116N/A rpp_val = criteria["rpp"]
1116N/A%>\
1116N/A<form class="search advanced-search" action="advanced_search.shtml">
2603N/A <table role="presentation" summary="Additional criteria to alter how search results are
1116N/A obtained and presented.">
1116N/A <tr>
1116N/A <td colspan="3">
1116N/A <input id="search-field" type="text" size="80"
1116N/A maxlength="512" name="token"
2603N/A value="${token_val | h}" title="search field"/>
1116N/A </td>
1116N/A </tr>
1116N/A <tr>
1116N/A <td class="label">Show results as:</td>
1116N/A <td>
1116N/A% for val, label in return_types:
1116N/A <input id="show-${val}" type="radio"
1116N/A% if val == show:
1116N/A checked="checked"
1116N/A% endif
1116N/A name="show" value="${val}"/>
1116N/A <label for="show-${val}">${label}</label>
1116N/A% endfor
1116N/A <span class="tip" title="You can return packages
1116N/A in standard search by enclosing your entire query within '&lt;&gt;'.">tip</span>
1116N/A </td>
1116N/A <td></td>
1116N/A </tr>
1116N/A <tr>
1116N/A <td class="label">
1116N/A <label for="show-all-versions">Show all
1116N/Aversions:</label>
1116N/A </td>
1116N/A <td>
1116N/A <input id="show-all-versions" type="checkbox"
1116N/A% if criteria["sav"]:
1116N/A checked="checked"
1116N/A% endif
1116N/A name="sav" value="1"/>
1116N/A <span class="tip" title="By default, only the
1116N/A latest versions of packages are shown. To show all versions, check this
1116N/A checkbox. This option is ignored when results are shown as Actions.">
1116N/Atip</span>
1116N/A </td>
1116N/A </tr>
1116N/A <tr>
1116N/A <td class="label">
1116N/A <label for="case-sensitive">Perform case-sensitive search:</label>
1116N/A </td>
1116N/A <td>
1116N/A <input id="case-sensitive" type="checkbox"
1116N/A% if criteria["cs"]:
1116N/A checked="checked"
1116N/A% endif
1116N/A name="cs" value="1"/>
1116N/A <span class="tip" title="By default, searches
1116N/A are not case-sensitive. To perform a case-sensitive search, check this
1116N/A checkbox.">
1116N/Atip</span>
1116N/A </td>
1116N/A </tr>
1116N/A <tr>
1116N/A <td class="label">
1116N/A <label for="rpp">Results per page:</label>
1116N/A </td>
1116N/A <td>
1116N/A <select id="rpp" name="rpp">
1116N/A
1116N/A% for val in rpp_values:
1116N/A <option
1116N/A% if val == rpp_val:
1116N/A selected="selected"
1116N/A% endif
1116N/A value="${val}">${val}</option>
1116N/A% endfor
1116N/A </select>
1116N/A </td>
1116N/A <td></td>
1116N/A </tr>
1116N/A<%
1116N/A versions = criteria["versions"]
1116N/A selected_val = criteria["selected_val"]
1116N/A selected_ver = criteria["selected_ver"]
1116N/A%>\
1116N/A% if versions:
1116N/A <tr>
1116N/A <td class="label">
1116N/A <label for="version">Release and Branch:</label>
1116N/A </td>
1116N/A <td>
1116N/A <select id="version" name="v">
1116N/A<%
1116N/A for v in versions:
1116N/A ver, val, label = v
1116N/A attrs = ""
1116N/A if val == selected_val:
1116N/A attrs = 'selected="selected" '
1116N/A
1116N/A context.write("""<option %svalue="%s">%s</option>""" % (
1116N/A attrs, urllib.quote(val, ""), label))
1116N/A%>\
1116N/A </select>
1116N/A </td>
1116N/A </tr>
1116N/A% endif
1116N/A <tr>
1116N/A <td></td>
1116N/A <td></td>
1116N/A <td class="submit">
1116N/A <input id="submit-search" type="submit"
1116N/A name="action" value="Advanced Search"/>
1116N/A </td>
1116N/A </tr>
1116N/A </table>
1116N/A</form>
1116N/A</%def>\