When tracking an entry, separate the dropdown to track by tag into two
groups: entry tags and other tags.
Patch by fu.
diffs (163 lines):
diff -r 6d97226eea40 -r 2c49481b423f bin/upgrading/en.dat
--- a/bin/upgrading/en.dat Thu Jul 01 18:58:17 2010 +0800
+++ b/bin/upgrading/en.dat Thu Jul 01 21:07:46 2010 +0800
@@ -1911,6 +1911,10 @@ event.journal_new_entry.tag.community=So
event.journal_new_entry.tag.user=[[user]] posts a new entry tagged [[tags]]
+event.journal_new_entry.taglist.entry=Entry tags
+
+event.journal_new_entry.taglist.full=Other tags
+
event.journal_new_entry.user=[[user]] posts a new entry.
event.officialpost=[[sitename]] makes a new announcement
diff -r 6d97226eea40 -r 2c49481b423f cgi-bin/LJ/Event/JournalNewEntry.pm
--- a/cgi-bin/LJ/Event/JournalNewEntry.pm Thu Jul 01 18:58:17 2010 +0800
+++ b/cgi-bin/LJ/Event/JournalNewEntry.pm Thu Jul 01 21:07:46 2010 +0800
@@ -325,12 +325,30 @@ sub subscription_as_html {
if ($arg1 eq '?') {
my @unsub_tags = $class->unsubscribed_tags($subscr);
- my @tagdropdown;
+ my %entry_tags = $subscr->entry ? map { $_ => 1 } $subscr->entry->tags
: ();
+
+ my @entrytagdropdown;
+ my @fulltagdropdown;
foreach my $unsub_tag (@unsub_tags) {
while (my ($tagid, $name) = each %$unsub_tag) {
- push @tagdropdown, ($tagid, $name);
+ if ( $entry_tags{$name} ) {
+ push @entrytagdropdown, { value => $tagid, text => $name };
+ } else {
+ push @fulltagdropdown, { value => $tagid, text => $name };
+ }
}
+ }
+
+ my @tagdropdown;
+
+ if ( @entrytagdropdown ) {
+ @tagdropdown = (
+ { optgroup => LJ::Lang::ml(
'event.journal_new_entry.taglist.entry' ), items => \...@entrytagdropdown },
+ { optgroup => LJ::Lang::ml(
'event.journal_new_entry.taglist.full' ), items => \...@fulltagdropdown },
+ );
+ } else {
+ @tagdropdown = @fulltagdropdown;
}
$usertags = LJ::html_select({
diff -r 6d97226eea40 -r 2c49481b423f cgi-bin/LJ/Subscription/Pending.pm
--- a/cgi-bin/LJ/Subscription/Pending.pm Thu Jul 01 18:58:17 2010 +0800
+++ b/cgi-bin/LJ/Subscription/Pending.pm Thu Jul 01 21:07:46 2010 +0800
@@ -38,6 +38,10 @@ sub new {
my $default_selected = delete $opts{default_selected} || 0;
my $flags = delete $opts{flags} || 0;
+ # optional entry arg
+ # used to provide need additional context, not saved
+ my $entry = delete $opts{entry};
+
$journalu = LJ::want_user($journalu) if $journalu;
croak "Invalid user object passed to LJ::Subscription::Pending->new" if
$journalu && ! LJ::isu($journalu);
@@ -70,6 +74,7 @@ sub new {
userid => $u->{userid},
u => $u,
journal => $journalu,
+ entry => $entry,
etypeid => $etypeid,
ntypeid => $ntypeid,
arg1 => $arg1,
@@ -86,6 +91,7 @@ sub pending { 1 }
sub journal { $_[0]->{journal}}
sub journalid { $_[0]->{journal} ? $_[0]->{journal}->{userid} : 0 }
+sub entry { $_[0]->{entry} };
sub default_selected { $_[0]->{default_selected} && ! $_[0]->disabled }
sub disabled {
diff -r 6d97226eea40 -r 2c49481b423f cgi-bin/htmlcontrols.pl
--- a/cgi-bin/htmlcontrols.pl Thu Jul 01 18:58:17 2010 +0800
+++ b/cgi-bin/htmlcontrols.pl Thu Jul 01 21:07:46 2010 +0800
@@ -138,6 +138,7 @@ sub html_datetime_decode
# des: Creates a drop-down box or listbox HTML form element (the <select> tag).
# info:
# args: opts
+# A hashref with an attribute of optgroup will be treated as a list of of
value => text pairs within an optgroup
# des-opts: A hashref of options. Special options are:
# 'raw' - inserts value unescaped into select tag;
# 'noescape' - won't escape key values if set to 1;
@@ -184,28 +185,42 @@ sub html_select
$text = shift @items;
}
- my $sel = "";
- # multiple-mode or single-mode?
- if (ref $selref eq 'HASH' && $selref->{$value} ||
- $opts->{'selected'} eq $value && !$did_sel++) {
-
- $sel = " selected='selected'";
+ if ( $it->{optgroup} ) {
+ $ret .= "<optgroup label='$it->{optgroup}'>";
+ $ret .= LJ::_html_option( $_->{value}, $_->{text}, {}, $opts,
$ehtml, $selref, \$did_sel )
+ foreach @{$it->{items} || []};
+ $ret .= "</optgroup>";
+ } else {
+ $ret .= LJ::_html_option( $value, $text, $it, $opts, $ehtml,
+ $selref, \$did_sel );
}
- $value = $ehtml ? ehtml($value) : $value;
-
- my $id;
- if ($opts->{'include_ids'} && $opts->{'name'} ne "" && $value ne "") {
- $id = " id='$opts->{'name'}_$value'";
- }
-
- # is this individual option disabled?
- my $dis = $it->{'disabled'} ? " disabled='disabled' style='color:
#999;'" : '';
-
- $ret .= "<option value=\"$value\"$id$sel$dis>" .
- ($ehtml ? ehtml($text) : $text) . "</option>\n";
}
$ret .= "</select>";
return $ret;
+}
+
+sub _html_option {
+ my ( $value, $text, $item, $opts, $ehtml, $selref, $did_sel ) = @_;
+
+ my $sel = "";
+ # multiple-mode or single-mode?
+ if ( ref $selref eq 'HASH' && $selref->{$value} ||
+ $opts->{selected} eq $value && ! $$did_sel++ ) {
+
+ $sel = " selected='selected'";
+ }
+ $value = $ehtml ? ehtml( $value ) : $value;
+
+ my $id;
+ if ( $opts->{include_ids} && $opts->{name} ne "" && $value ne "" ) {
+ $id = " id='$opts->{'name'}_$value'";
+ }
+
+ # is this individual option disabled?
+ my $dis = $item->{disabled} ? " disabled='disabled' style='color: #999;'"
: '';
+
+ return "<option value=\"$value\"$id$sel$dis>" .
+ ( $ehtml ? ehtml( $text ) : $text ) . "</option>\n";
}
# <LJFUNC>
diff -r 6d97226eea40 -r 2c49481b423f htdocs/manage/subscriptions/entry.bml
--- a/htdocs/manage/subscriptions/entry.bml Thu Jul 01 18:58:17 2010 +0800
+++ b/htdocs/manage/subscriptions/entry.bml Thu Jul 01 21:07:46 2010 +0800
@@ -79,6 +79,7 @@ body<=
event => "JournalNewEntry",
arg1 => '?',
journal => $journal,
+ entry => $entry,
flags => LJ::Subscription::TRACKING,
),
LJ::Subscription::Pending->new( $remote,
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog