⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 quicksearch.pm

📁 bugzilla
💻 PM
📖 第 1 页 / 共 2 页
字号:
# -*- Mode: perl; indent-tabs-mode: nil -*-## The contents of this file are subject to the Mozilla Public# License Version 1.1 (the "License"); you may not use this file# except in compliance with the License. You may obtain a copy of# the License at http://www.mozilla.org/MPL/## Software distributed under the License is distributed on an "AS# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or# implied. See the License for the specific language governing# rights and limitations under the License.## The Original Code is the Bugzilla Bug Tracking System.## Contributor(s): C. Begle#                 Jesse Ruderman#                 Andreas Franke <afranke@mathweb.org>#                 Stephen Lee <slee@uk.bnsmc.com>#                 Marc Schumann <wurblzap@gmail.com>package Bugzilla::Search::Quicksearch;# Make it harder for us to do dangerous things in Perl.use strict;use Bugzilla::Error;use Bugzilla::Constants;use Bugzilla::Keyword;use Bugzilla::Bug;use Bugzilla::Field;use Bugzilla::Util;use base qw(Exporter);@Bugzilla::Search::Quicksearch::EXPORT = qw(quicksearch);# Word renamingsuse constant MAPPINGS => {                # Status, Resolution, Platform, OS, Priority, Severity                "status" => "bug_status",                "resolution" => "resolution",  # no change                "platform" => "rep_platform",                "os" => "op_sys",                "opsys" => "op_sys",                "priority" => "priority",    # no change                "pri" => "priority",                "severity" => "bug_severity",                "sev" => "bug_severity",                # People: AssignedTo, Reporter, QA Contact, CC, Added comment (?)                "owner" => "assigned_to",    # deprecated since bug 76507                "assignee" => "assigned_to",                "assignedto" => "assigned_to",                "reporter" => "reporter",    # no change                "rep" => "reporter",                "qa" => "qa_contact",                "qacontact" => "qa_contact",                "cc" => "cc",          # no change                # Product, Version, Component, Target Milestone                "product" => "product",     # no change                "prod" => "product",                "version" => "version",     # no change                "ver" => "version",                "component" => "component",   # no change                "comp" => "component",                "milestone" => "target_milestone",                "target" => "target_milestone",                "targetmilestone" => "target_milestone",                # Summary, Description, URL, Status whiteboard, Keywords                "summary" => "short_desc",                "shortdesc" => "short_desc",                "desc" => "longdesc",                "description" => "longdesc",                #"comment" => "longdesc",    # ???                          # reserve "comment" for "added comment" email search?                "longdesc" => "longdesc",                "url" => "bug_file_loc",                "whiteboard" => "status_whiteboard",                "statuswhiteboard" => "status_whiteboard",                "sw" => "status_whiteboard",                "keywords" => "keywords",    # no change                "kw" => "keywords",                # Attachments                "attachment" => "attachments.description",                "attachmentdesc" => "attachments.description",                "attachdesc" => "attachments.description",                "attachmentdata" => "attach_data.thedata",                "attachdata" => "attach_data.thedata",                "attachmentmimetype" => "attachments.mimetype",                "attachmimetype" => "attachments.mimetype"};# We might want to put this into localconfig or somewhereuse constant PLATFORMS => ('pc', 'sun', 'macintosh', 'mac');use constant PRODUCT_EXCEPTIONS => (    'row',   # [Browser]             #   ^^^    'new',   # [MailNews]             #      ^^^);use constant COMPONENT_EXCEPTIONS => (    'hang'   # [Bugzilla: Component/Keyword Changes]             #                               ^^^^);# Quicksearch-wide globals for boolean charts.our ($chart, $and, $or);sub quicksearch {    my ($searchstring) = (@_);    my $cgi = Bugzilla->cgi;    my $urlbase = correct_urlbase();    $chart = 0;    $and   = 0;    $or    = 0;    # Remove leading and trailing commas and whitespace.    $searchstring =~ s/(^[\s,]+|[\s,]+$)//g;    ThrowUserError('buglist_parameters_required') unless ($searchstring);    if ($searchstring =~ m/^[0-9,\s]*$/) {        # Bug number(s) only.        # Allow separation by comma or whitespace.        $searchstring =~ s/[,\s]+/,/g;        if (index($searchstring, ',') < $[) {            # Single bug number; shortcut to show_bug.cgi.            print $cgi->redirect(-uri => "${urlbase}show_bug.cgi?id=$searchstring");            exit;        }        else {            # List of bug numbers.            $cgi->param('bug_id', $searchstring);            $cgi->param('order', 'bugs.bug_id');            $cgi->param('bugidtype', 'include');        }    }    else {        # It's not just a bug number or a list of bug numbers.        # Maybe it's an alias?        if ($searchstring =~ /^([^,\s]+)$/) {            if (Bugzilla->dbh->selectrow_array(q{SELECT COUNT(*)                                                   FROM bugs                                                  WHERE alias = ?},                                               undef,                                               $1)) {                print $cgi->redirect(-uri => "${urlbase}show_bug.cgi?id=$1");                exit;            }        }        # It's no alias either, so it's a more complex query.        my $legal_statuses = get_legal_field_values('bug_status');        my $legal_resolutions = get_legal_field_values('resolution');        # Globally translate " AND ", " OR ", " NOT " to space, pipe, dash.        $searchstring =~ s/\s+AND\s+/ /g;        $searchstring =~ s/\s+OR\s+/|/g;        $searchstring =~ s/\s+NOT\s+/ -/g;        my @words = splitString($searchstring);        my $searchComments =             $#words < Bugzilla->params->{'quicksearch_comment_cutoff'};        my @openStates = BUG_STATE_OPEN;        my @closedStates;        my @unknownFields;        my (%states, %resolutions);        foreach (@$legal_statuses) {            push(@closedStates, $_) unless is_open_state($_);        }        foreach (@openStates) { $states{$_} = 1 }        if ($words[0] eq 'ALL') {            foreach (@$legal_statuses) { $states{$_} = 1 }            shift @words;        }        elsif ($words[0] eq 'OPEN') {            shift @words;        }        elsif ($words[0] =~ /^\+[A-Z]+(,[A-Z]+)*$/) {            # e.g. +DUP,FIX            if (matchPrefixes(\%states,                              \%resolutions,                              [split(/,/, substr($words[0], 1))],                              \@closedStates,                              $legal_resolutions)) {                shift @words;                # Allowing additional resolutions means we need to keep                # the "no resolution" resolution.                $resolutions{'---'} = 1;            }            else {                # Carry on if no match found.            }        }        elsif ($words[0] =~ /^[A-Z]+(,[A-Z]+)*$/) {            # e.g. NEW,ASSI,REOP,FIX            undef %states;            if (matchPrefixes(\%states,                              \%resolutions,                              [split(/,/, $words[0])],                              $legal_statuses,                              $legal_resolutions)) {                shift @words;            }            else {                # Carry on if no match found                foreach (@openStates) { $states{$_} = 1 }            }        }        else {            # Default: search for unresolved bugs only.            # Put custom code here if you would like to change this behaviour.        }        # If we have wanted resolutions, allow closed states        if (keys(%resolutions)) {            foreach (@closedStates) { $states{$_} = 1 }        }        $cgi->param('bug_status', keys(%states));        $cgi->param('resolution', keys(%resolutions));        # Loop over all main-level QuickSearch words.        foreach my $qsword (@words) {            my $negate = substr($qsword, 0, 1) eq '-';            if ($negate) {                $qsword = substr($qsword, 1);            }            my $firstChar = substr($qsword, 0, 1);            my $baseWord = substr($qsword, 1);            my @subWords = split(/[\|,]/, $baseWord);            if ($firstChar eq '+') {                foreach (@subWords) {                    addChart('short_desc', 'substring', $qsword, $negate);                }            }            elsif ($firstChar eq '#') {                addChart('short_desc', 'anywords', $baseWord, $negate);                if ($searchComments) {                    addChart('longdesc', 'anywords', $baseWord, $negate);                }            }            elsif ($firstChar eq ':') {                foreach (@subWords) {                    addChart('product', 'substring', $_, $negate);                    addChart('component', 'substring', $_, $negate);                }            }            elsif ($firstChar eq '@') {                foreach (@subWords) {                    addChart('assigned_to', 'substring', $_, $negate);                }            }            elsif ($firstChar eq '[') {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -