Committer: amyshkin
LJSUP-10691: Image placeholders in commentsU trunk/cgi-bin/LJ/S2/EntryPage.pm U trunk/cgi-bin/LJ/S2/FriendsPage.pm U trunk/cgi-bin/LJ/Setting/ImagePlaceholders.pm U trunk/cgi-bin/LJ/User.pm U trunk/cgi-bin/ljviews.pl
Modified: trunk/cgi-bin/LJ/S2/EntryPage.pm =================================================================== --- trunk/cgi-bin/LJ/S2/EntryPage.pm 2012-01-27 08:00:16 UTC (rev 21019) +++ trunk/cgi-bin/LJ/S2/EntryPage.pm 2012-01-27 08:47:22 UTC (rev 21020) @@ -146,13 +146,7 @@ my $replace_images_in_comments = 0; if( $remote ) { - my $opt = $remote->prop("opt_imagelinks") || "0:0"; - $opt = "0:0" unless $opt; - $opt = "1:0" unless $opt =~ /^\d\:\d$/; - - if ( $opt =~ /^\d\:(\d)$/ ) { - $replace_images_in_comments = $1; - } + $replace_images_in_comments = $remote->opt_placeholders_comments; } foreach my $com (@$srclist) { Modified: trunk/cgi-bin/LJ/S2/FriendsPage.pm =================================================================== --- trunk/cgi-bin/LJ/S2/FriendsPage.pm 2012-01-27 08:00:16 UTC (rev 21019) +++ trunk/cgi-bin/LJ/S2/FriendsPage.pm 2012-01-27 08:47:22 UTC (rev 21020) @@ -221,13 +221,7 @@ my $replace_images_in_friendspage = 0; if( $u->equals($remote) ) { - my $opt = $u->prop("opt_imagelinks") || "0:0"; - $opt = "0:0" unless $opt; - $opt = "1:0" unless $opt =~ /^\d\:\d$/; - - if ( $opt =~ /^(\d)\:\d$/ ) { - $replace_images_in_friendspage = $1; - } + $replace_images_in_friendspage = $remote->opt_placeholders_friendspage; } ENTRY: Modified: trunk/cgi-bin/LJ/Setting/ImagePlaceholders.pm =================================================================== --- trunk/cgi-bin/LJ/Setting/ImagePlaceholders.pm 2012-01-27 08:00:16 UTC (rev 21019) +++ trunk/cgi-bin/LJ/Setting/ImagePlaceholders.pm 2012-01-27 08:47:22 UTC (rev 21020) @@ -26,12 +26,7 @@ my ($class, $u, $errs, $args) = @_; my $key = $class->pkgkey; - my $imgplaceholders = $u->prop("opt_imagelinks") || "0:0"; - - # just for a case - $imgplaceholders = "0:0" unless $imgplaceholders; - $imgplaceholders = "1:0" unless $imgplaceholders =~ /^\d\:\d$/; - + my $imgplaceholders = $u->get_opt_imagelinks; my( $chk1, $chk2 ); if ( $imgplaceholders =~ /^(\d)\:(\d)$/ ) { Modified: trunk/cgi-bin/LJ/User.pm =================================================================== --- trunk/cgi-bin/LJ/User.pm 2012-01-27 08:00:16 UTC (rev 21019) +++ trunk/cgi-bin/LJ/User.pm 2012-01-27 08:47:22 UTC (rev 21020) @@ -4071,6 +4071,40 @@ } } +# opt_imagelinks format: +# 0|1 - replace images with placeholders at friends page +# : - delimiter +# 0|1 - replace images with placeholders in comments at entry page +sub get_opt_imagelinks { + my $u = shift; + my $opt = $u->prop("opt_imagelinks") || "0:0"; + $opt = "0:0" unless $opt; + $opt = "1:0" unless $opt =~ /^\d\:\d$/; + return $opt; +} + +sub opt_placeholders_friendspage { + my $u = shift; + my $opt = $u->get_imagelinks; + + if ( $opt =~ /^(\d)\:\d$/ ) { + return $1; + } + + return 0; +} + +sub opt_placeholders_comments { + my $u = shift; + my $opt = $u->get_imagelinks; + + if ( $opt =~ /^\d\:(\d)$/ ) { + return $1; + } + + return 0; +} + sub opt_showmutualfriends { my $u = shift; return $u->raw_prop('opt_showmutualfriends') ? 1 : 0; Modified: trunk/cgi-bin/ljviews.pl =================================================================== --- trunk/cgi-bin/ljviews.pl 2012-01-27 08:00:16 UTC (rev 21019) +++ trunk/cgi-bin/ljviews.pl 2012-01-27 08:47:22 UTC (rev 21020) @@ -1782,13 +1782,7 @@ # load options for image links my $replace_images_in_friendspage = 0; if( $u->equals($remote) ) { - my $opt = $u->prop("opt_imagelinks") || "0:0"; - $opt = "0:0" unless $opt; - $opt = "1:0" unless $opt =~ /^\d\:\d$/; - - if ( $opt =~ /^(\d)\:\d$/ ) { - $replace_images_in_friendspage = $1; - } + $replace_images_in_friendspage = $remote->opt_placeholders_friendspage; } my %friends_events = ();