[livejournal] r11157: Support for sponsored styles.

Apr 23, 2007 17:08


Committer: janineSupport for sponsored styles.

http://rt.livejournal.org/Ticket/Display.html?id=3798

U branches/r6/htdocs/customize/index.bml
U branches/r6/htdocs/customize/preview.bml
U branches/r6/htdocs/customize/preview.bml.text
U branches/r6/htdocs/customize/style.bml

Modified: branches/r6/htdocs/customize/index.bml
===================================================================
--- branches/r6/htdocs/customize/index.bml 2007-04-23 07:50:54 UTC (rev 11156)
+++ branches/r6/htdocs/customize/index.bml 2007-04-23 17:08:57 UTC (rev 11157)
@@ -82,6 +82,10 @@
{
$ret .= "
";
$ret .= LJ::cmize::display_current_summary($u);
+ my $hook_rv = LJ::run_hook("extra_sidebar_content", $u);
+ if ($hook_rv) {
+ $ret .= "
$hook_rv";
+ }
$ret .= "";
}

Modified: branches/r6/htdocs/customize/preview.bml
===================================================================
--- branches/r6/htdocs/customize/preview.bml 2007-04-23 07:50:54 UTC (rev 11156)
+++ branches/r6/htdocs/customize/preview.bml 2007-04-23 17:08:57 UTC (rev 11157)
@@ -54,16 +54,31 @@
LJ::set_active_crumb('preview');
$ret .= "
" . BML::ml('Backlink', {'link' => "$LJ::SITEROOT/customize/?journal=$journal", 'text' => $ML{'.back2'}}) . "
";

+ my $u;
+ if ($journal) {
+ $u = LJ::load_user($journal);
+ } elsif ($remote) {
+ $u = $remote;
+ }
+
my @layouts =
sort { $a->{'name'} cmp $b->{'name'} }
map { $pub->{$_} }
- grep { /^\d+$/ && $pub->{$_}->{'type'} eq "layout" } keys %$pub;
+ grep {
+ /^\d+$/ &&
+ $pub->{$_}->{type} eq "layout" &&
+ $pub->{$_}->{uniq} ne "s1shortcomings/layout" &&
+ $pub->{$_}->{uniq} ne "hostedcomments/layout"
+ } keys %$pub;

+ my @special_layouts = LJ::run_hook("modify_layout_list", \@layouts, user => $u);
+ my %special_uniqs = map { $_->{uniq} => 1 } @special_layouts;
+
my $first = 1;

- foreach my $l (@layouts) {
- next if ($l->{'uniq'} eq 's1shortcomings/layout');
- next if ($l->{'uniq'} eq 'hostedcomments/layout');
+ my $print_layout_preview = sub {
+ my $l = shift;
+
if (!$first) {
$ret .= "";
}
@@ -85,13 +100,6 @@

$layerdesc->($l);

- my $u;
- if ($journal) {
- $u = LJ::load_user($journal);
- } elsif ($remote) {
- $u = $remote;
- }
-
unless (LJ::S2::can_use_layer($u, $l->{'uniq'})) {
$ret .= $u ? "" : "";
$ret .= " " . LJ::help_icon("s2propoff");
@@ -105,7 +113,23 @@
$ret .= "";

$ret .= "\n";
+ };
+
+ if (@special_layouts) {
+ $ret .= "
";
+ $ret .= "$ML{'.specialstyles.header'}
";
+ foreach my $l (@special_layouts) {
+ $print_layout_preview->($l);
+ }
+ $ret .= "";
}
+
+ $first = 1;
+
+ foreach my $l (@layouts) {
+ next if $special_uniqs{$l->{uniq}};
+ $print_layout_preview->($l);
+ }
}

return $ret;

Modified: branches/r6/htdocs/customize/preview.bml.text
===================================================================
--- branches/r6/htdocs/customize/preview.bml.text 2007-04-23 07:50:54 UTC (rev 11156)
+++ branches/r6/htdocs/customize/preview.bml.text 2007-04-23 17:08:57 UTC (rev 11157)
@@ -5,6 +5,8 @@

.nopreviews=No previews available.

+.specialstyles.header=Special Styles
+
.title=Layout Previews

.unavailable=Layout currently unavailable to the selected account.

Modified: branches/r6/htdocs/customize/style.bml
===================================================================
--- branches/r6/htdocs/customize/style.bml 2007-04-23 07:50:54 UTC (rev 11156)
+++ branches/r6/htdocs/customize/style.bml 2007-04-23 17:08:57 UTC (rev 11157)
@@ -432,9 +432,16 @@

# add user/disabled ones
push @layouts, LJ::cmize::s2_custom_layer_list($u, 'layout', 'core');
+ LJ::run_hook("modify_layout_list", \@layouts, user => $u, pub => $pub, add_seps => 1);

$ret .= "Layout & Language";
- $ret .= LJ::run_hook('customize_style_upsell', $u, $remote);
+ my $upsell_hook = LJ::run_hook('customize_style_upsell', $u, $remote);
+ my $extra_hook = LJ::run_hook('extra_sidebar_content', $u);
+ if ($upsell_hook || $extra_hook) {
+ $ret .= "
$upsell_hook";
+ $ret .= "
" if $upsell_hook && $extra_hook;
+ $ret .= "$extra_hook";
+ }
$ret .= "";
$ret .= "
";
$ret .= LJ::html_select({ 'id' => "s2_layoutid", 'name' => 's2_layoutid', 'selected' => $style{'layout'}, }, @layouts);

Previous post Next post
Up