From 88a5f1111b85d8a1dd17cabb7f90b019a27f8464 Mon Sep 17 00:00:00 2001 From: Dylan William Hardison Date: Mon, 10 Apr 2017 12:19:34 -0400 Subject: Bug 1355127 - rewrite field-descs.none.tmpl in perl --- Bugzilla/Template.pm | 3 + t/008filter.t | 2 +- template/en/default/global/field-descs.none.tmpl | 274 ++++++++++++----------- 3 files changed, 146 insertions(+), 133 deletions(-) diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm index 1f0892a32..9cac9ad87 100644 --- a/Bugzilla/Template.pm +++ b/Bugzilla/Template.pm @@ -681,6 +681,9 @@ sub create { INCLUDE_PATH => $opts{'include_path'} || _include_path($opts{'language'}), + # allow PERL/RAWPERL because doing so can boost performance + EVAL_PERL => 1, + # Remove white-space before template directives (PRE_CHOMP) and at the # beginning and end of templates and template blocks (TRIM) for better # looking, more compact content. Use the plus sign at the beginning diff --git a/t/008filter.t b/t/008filter.t index b8d05af8a..cae1e6880 100644 --- a/t/008filter.t +++ b/t/008filter.t @@ -164,7 +164,7 @@ sub directive_ok { BLOCK|USE|ELSE|NEXT|LAST|DEFAULT|FLUSH| ELSIF|SET|SWITCH|CASE|WHILE|RETURN|STOP| TRY|CATCH|FINAL|THROW|CLEAR|MACRO|FILTER| - CALL|WRAPPER)/x; + RAWPERL|PERL|CALL|WRAPPER)/x; # ? : if ($directive =~ /.+\?(.+):(.+)/) { diff --git a/template/en/default/global/field-descs.none.tmpl b/template/en/default/global/field-descs.none.tmpl index ff29ff184..3e0a528dc 100644 --- a/template/en/default/global/field-descs.none.tmpl +++ b/template/en/default/global/field-descs.none.tmpl @@ -21,145 +21,155 @@ [%# Remember to PROCESS rather than INCLUDE this template. %] -[% PROCESS global/variables.none.tmpl %] +[% RAWPERL %] -[% SET search_descs = { - "noop" => "---", - "equals" => "is equal to", - "notequals" => "is not equal to", - "anyexact" => "is equal to any of the strings", - "substring" => "contains the string", - "casesubstring" => "contains the string (exact case)", - "notsubstring" => "does not contain the string", - "anywordssubstr" => "contains any of the strings", - "allwordssubstr" => "contains all of the strings", - "nowordssubstr" => "contains none of the strings", - "regexp" => "matches regular expression", - "notregexp" => "does not match regular expression", - "lessthan" => "is less than", - "lessthaneq" => "is less than or equal to", - "greaterthan" => "is greater than", - "greaterthaneq" => "is greater than or equal to", - "anywords" => "contains any of the words", - "allwords" => "contains all of the words", - "nowords" => "contains none of the words", - "changedbefore" => "changed before", - "changedafter" => "changed after", - "changedfrom" => "changed from", - "changedto" => "changed to", - "changedby" => "changed by", - "matches" => "matches", - "notmatches" => "does not match", - "isempty" => "is empty", - "isnotempty" => "is not empty", -} %] +$context->process("global/variables.none.tmpl"); -[% field_types = { ${constants.FIELD_TYPE_UNKNOWN} => "Unknown Type", - ${constants.FIELD_TYPE_FREETEXT} => "Free Text", - ${constants.FIELD_TYPE_INTEGER} => "Integer", - ${constants.FIELD_TYPE_SINGLE_SELECT} => "Drop Down", - ${constants.FIELD_TYPE_MULTI_SELECT} => "Multiple-Selection Box", - ${constants.FIELD_TYPE_TEXTAREA} => "Large Text Box", - ${constants.FIELD_TYPE_DATETIME} => "Date/Time", - ${constants.FIELD_TYPE_DATE} => "Date", - ${constants.FIELD_TYPE_BUG_ID} => "$terms.Bug ID", - ${constants.FIELD_TYPE_EXTENSION} => "Extension", - } %] +my $terms = $stash->get("terms"); +$stash->set( + search_descs => { + "noop" => "---", + "equals" => "is equal to", + "notequals" => "is not equal to", + "anyexact" => "is equal to any of the strings", + "substring" => "contains the string", + "casesubstring" => "contains the string (exact case)", + "notsubstring" => "does not contain the string", + "anywordssubstr" => "contains any of the strings", + "allwordssubstr" => "contains all of the strings", + "nowordssubstr" => "contains none of the strings", + "regexp" => "matches regular expression", + "notregexp" => "does not match regular expression", + "lessthan" => "is less than", + "lessthaneq" => "is less than or equal to", + "greaterthan" => "is greater than", + "greaterthaneq" => "is greater than or equal to", + "anywords" => "contains any of the words", + "allwords" => "contains all of the words", + "nowords" => "contains none of the words", + "changedbefore" => "changed before", + "changedafter" => "changed after", + "changedfrom" => "changed from", + "changedto" => "changed to", + "changedby" => "changed by", + "matches" => "matches", + "notmatches" => "does not match", + "isempty" => "is empty", + "isnotempty" => "is not empty", + } +); -[% IF in_template_var %] - [% PROCESS "global/value-descs.none.tmpl" %] - [% SET vars.value_descs = value_descs %] - [% SET vars.terms = terms %] +$stash->set( + field_types => { + Bugzilla::Constants::FIELD_TYPE_UNKNOWN() => "Unknown Type", + Bugzilla::Constants::FIELD_TYPE_FREETEXT() => "Free Text", + Bugzilla::Constants::FIELD_TYPE_INTEGER() => "Integer", + Bugzilla::Constants::FIELD_TYPE_SINGLE_SELECT() => "Drop Down", + Bugzilla::Constants::FIELD_TYPE_MULTI_SELECT() => "Multiple-Selection Box", + Bugzilla::Constants::FIELD_TYPE_TEXTAREA() => "Large Text Box", + Bugzilla::Constants::FIELD_TYPE_DATETIME() => "Date/Time", + Bugzilla::Constants::FIELD_TYPE_DATE() => "Date", + Bugzilla::Constants::FIELD_TYPE_BUG_ID() => "$terms->{Bug} ID", + Bugzilla::Constants::FIELD_TYPE_EXTENSION() => "Extension", + } +); - [%# field_descs is loaded as a global template variable and cached +if ( $stash->get("in_template_var") ) { + my $vars = $stash->get("vars"); + $context->process("global/value-descs.none.tmpl"); + $vars->{value_descs} = $stash->get("value_descs"); + $vars->{terms} = $terms; + + # field_descs is loaded as a global template variable and cached # across all templates--see VARIABLES in Bugzilla/Template.pm. - #%] - [% vars.field_descs = { - "[Bug creation]" => "[$terms.Bug creation]", - "actual_time" => "Actual Hours", - "alias" => "Alias", - "assigned_to" => "Assignee", - "assigned_to_realname" => "Assignee Real Name", - "assignee_last_login" => "Assignee Last Login Date", - "attach_data.thedata" => "Attachment data", - "attachments.description" => "Attachment description", - "attachments.filename" => "Attachment filename", - "attachments.mimetype" => "Attachment mime type", - "attachments.ispatch" => "Attachment is patch", - "attachments.isobsolete" => "Attachment is obsolete", - "attachments.isprivate" => "Attachment is private", - "attachments.submitter" => "Attachment creator", - "blocked" => "Blocks", - "bug_file_loc" => "URL", - "bug_group" => "Group", - "bug_id" => "$terms.Bug ID", - "bug_severity" => "Severity", - "bug_status" => "Status", - "changeddate" => "Changed", - "cc" => "CC", - "classification" => "Classification", - "cclist_accessible" => "CC list accessible", - "commenter" => "Commenter", - "component_id" => "Component ID", - "component" => "Component", - "content" => "Content", - "creation_ts" => "Creation date", - "days_elapsed" => "Days since $terms.bug changed", - "deadline" => "Deadline", - "delta_ts" => "Changed", - "dependson" => "Depends on", - "dup_id" => "Duplicate", - "estimated_time" => "Orig. Est.", - "everconfirmed" => "Ever confirmed", - "flagtypes.name" => "Flags", - "keywords" => "Keywords", - "last_visit_ts" => "Last Visit", - "longdesc" => "Comment", - "longdescs.count" => "Number of Comments", - "longdescs.isprivate" => "Comment is private", - "newcc" => "CC", - "op_sys" => "OS", - "opendate" => "Opened", - "owner_idle_time" => "Time Since Assignee Touched", - "percentage_complete" => "%Complete", - "priority" => "Priority", - "product_id" => "Product ID", - "product" => "Product", - "qa_contact" => "QA Contact", - "qa_contact_realname" => "QA Contact Real Name", - "remaining_time" => "Hours Left", - "rep_platform" => "Hardware", - "reporter" => "Reporter", - "reporter_accessible" => "Reporter accessible", - "reporter_realname" => "Reporter Real Name", - "requestees.login_name" => "Flag Requestee", - "resolution" => "Resolution", - "see_also" => "See Also", - "setters.login_name" => "Flag Setter", - "setting" => "Setting", - "settings" => "Settings", - "short_desc" => "Summary", - "short_short_desc" => "Summary", - "status_whiteboard" => "Whiteboard", - "tag.name" => "Tags", - "target_milestone" => "Target Milestone", - "triage_owner" => "Triage Owner", - "version" => "Version", - "work_time" => "Hours Worked", - } %] + # + $vars->{field_descs} = { + "[Bug creation]" => "[$terms->{Bug} creation]", + "actual_time" => "Actual Hours", + "alias" => "Alias", + "assigned_to" => "Assignee", + "assigned_to_realname" => "Assignee Real Name", + "assignee_last_login" => "Assignee Last Login Date", + "attach_data.thedata" => "Attachment data", + "attachments.description" => "Attachment description", + "attachments.filename" => "Attachment filename", + "attachments.mimetype" => "Attachment mime type", + "attachments.ispatch" => "Attachment is patch", + "attachments.isobsolete" => "Attachment is obsolete", + "attachments.isprivate" => "Attachment is private", + "attachments.submitter" => "Attachment creator", + "blocked" => "Blocks", + "bug_file_loc" => "URL", + "bug_group" => "Group", + "bug_id" => "$terms->{Bug} ID", + "bug_severity" => "Severity", + "bug_status" => "Status", + "changeddate" => "Changed", + "cc" => "CC", + "classification" => "Classification", + "cclist_accessible" => "CC list accessible", + "commenter" => "Commenter", + "component_id" => "Component ID", + "component" => "Component", + "content" => "Content", + "creation_ts" => "Creation date", + "days_elapsed" => "Days since $terms->{bug} changed", + "deadline" => "Deadline", + "delta_ts" => "Changed", + "dependson" => "Depends on", + "dup_id" => "Duplicate", + "estimated_time" => "Orig. Est.", + "everconfirmed" => "Ever confirmed", + "flagtypes.name" => "Flags", + "keywords" => "Keywords", + "last_visit_ts" => "Last Visit", + "longdesc" => "Comment", + "longdescs.count" => "Number of Comments", + "longdescs.isprivate" => "Comment is private", + "newcc" => "CC", + "op_sys" => "OS", + "opendate" => "Opened", + "owner_idle_time" => "Time Since Assignee Touched", + "percentage_complete" => "%Complete", + "priority" => "Priority", + "product_id" => "Product ID", + "product" => "Product", + "qa_contact" => "QA Contact", + "qa_contact_realname" => "QA Contact Real Name", + "remaining_time" => "Hours Left", + "rep_platform" => "Hardware", + "reporter" => "Reporter", + "reporter_accessible" => "Reporter accessible", + "reporter_realname" => "Reporter Real Name", + "requestees.login_name" => "Flag Requestee", + "resolution" => "Resolution", + "see_also" => "See Also", + "setters.login_name" => "Flag Setter", + "setting" => "Setting", + "settings" => "Settings", + "short_desc" => "Summary", + "short_short_desc" => "Summary", + "status_whiteboard" => "Whiteboard", + "tag.name" => "Tags", + "target_milestone" => "Target Milestone", + "triage_owner" => "Triage Owner", + "version" => "Version", + "work_time" => "Hours Worked", + }; - [%# Also include any custom fields or fields which don't have a - Description here, by copying their Description from the - database. If you want to override this for your language - or your installation, just use a hook. %] - [% UNLESS Param('shutdownhtml') %] - [% FOREACH bz_field = bug_fields.values %] - [% SET vars.field_descs.${bz_field.name} = bz_field.description - IF !vars.field_descs.${bz_field.name}.defined %] - [% END %] - [% END %] + # Also include any custom fields or fields which don't have a + # Description here, by copying their Description from the + # database. If you want to override this for your language + # or your installation, just use a hook. %] + my $bug_fields = $stash->get("bug_fields"); + unless ( Bugzilla->params->{shutdownhtml} ) { + foreach my $bz_field ( values %$bug_fields ) { + $vars->{field_descs}{$bz_field->name} //= $bz_field->description; + } - [% PROCESS "bug/field-help.none.tmpl" %] + $context->process("bug/field-help.none.tmpl"); + } +} [% END %] [% Hook.process("end") %] -- cgit v1.2.3-24-g4f1b