sunnyman's (sunnyman) wrote in changelog,
sunnyman's
sunnyman
changelog

[livejournal] r20025: OPSC-364: S2 functions render_appview / ...

Committer: vtroitsky
OPSC-364: S2 functions render_appview / init_appviews to render applications views.
U   trunk/cgi-bin/LJ/S2.pm
Modified: trunk/cgi-bin/LJ/S2.pm
===================================================================
--- trunk/cgi-bin/LJ/S2.pm	2011-09-13 06:35:50 UTC (rev 20024)
+++ trunk/cgi-bin/LJ/S2.pm	2011-09-13 06:42:18 UTC (rev 20025)
@@ -4303,6 +4303,10 @@
     return $ret;
 }
 
+sub Page__init_appviews {
+    return LJ::need_res(LJ::Widget::ApplicationsViewsLayout->need_res());
+}
+
 sub Page__render_widget {
     my ($ctx, $this, $opts) = @_;
 
@@ -4310,6 +4314,40 @@
     $S2::pout->($rendered);
 }
 
+sub Page__appview
+{
+    my ($ctx, $this, $opts) = @_;
+
+    $opts->{'viewer'} = LJ::get_remote();
+    $opts->{'owner'} = $LJ::S2::CURR_PAGE->{'_u'};
+    $opts->{'journal'} = $LJ::S2::CURR_PAGE->{'journal'}->{'_u'};
+    $opts->{'GET'} = $LJ::S2::CURR_PAGE->{'_getargs'};
+    $opts->{'page_type'} =  $LJ::S2::CURR_PAGE->{'_type'};
+
+    my $page_id = $LJ::S2::CURR_PAGE->{'page_id'};
+    if ($page_id =~ /^journal\-\w+\-(\d+)$/ ) {
+        $opts->{ditemid} = $1;
+    }
+
+    my $ret = '';
+
+    eval { $ret = "LJ::Widget::ApplicationsViewsLayout"->render(%$opts); };
+
+    if ($@) {
+        warn "Error when Page::appview() try to call LJ::Widget::ApplicationsViewsLayout->render() from LJ::S2:\n$@\n";
+        return '';
+    }
+    return $ret;
+}
+
+sub Page__render_appview {
+    my ($ctx, $this, $opts) = @_;
+
+    my $rendered = Page__appview($ctx, $this, $opts);
+    $S2::pout->($rendered);
+}
+
+
 sub Entry__print_ebox {
     my $args = _get_Entry_ebox_args(@_);
     return unless $args;

Tags: livejournal, pm, sunnyman
Subscribe

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments