madeon (madeon) wrote in changelog,
madeon
madeon
changelog

[livejournal] r22095: LJSUP-12369: Need to get in Entry text b...

Committer: sbelyaev
LJSUP-12369: Need to get in Entry text before cut
U   trunk/bin/upgrading/s2layers/core1.s2
U   trunk/cgi-bin/LJ/S2.pm
Modified: trunk/bin/upgrading/s2layers/core1.s2
===================================================================
--- trunk/bin/upgrading/s2layers/core1.s2	2012-05-29 11:18:04 UTC (rev 22094)
+++ trunk/bin/upgrading/s2layers/core1.s2	2012-05-29 12:07:04 UTC (rev 22095)
@@ -364,6 +364,10 @@
 
     var int itemid "Server stored ID number for this entry";
 
+    
+    function builtin get_cutted_text() : string
+        "Returns text withiout text that has been cutted. Doesn't print anything in some contexts, such as on a month view or in a collapsed comment.";
+
     function print_metadata ();
     function builtin plain_subject () : string
         "Return entry's subject as plain text, with all HTML removed.";
@@ -622,6 +626,9 @@
     function builtin get_last_entries( string ljname, int count ) : Entry[]
     "Returns last 'count' entries from selected journal for LJTimes verticals.";
 
+    function builtin get_entry_by_id(int id) : Entry
+    "Returns entry by the specified id";
+
     function builtin get_alien_post( string url ) : Entry
     "Returns any public entry from any journal having give_posts_to_alien prop. Recipient must have get_alien_posts prop";
 }

Modified: trunk/cgi-bin/LJ/S2.pm
===================================================================
--- trunk/cgi-bin/LJ/S2.pm	2012-05-29 11:18:04 UTC (rev 22094)
+++ trunk/cgi-bin/LJ/S2.pm	2012-05-29 12:07:04 UTC (rev 22095)
@@ -4517,6 +4517,37 @@
     $S2::pout->($ad_html) if $ad_html;
 }
 
+sub Entry__get_cutted_text {
+    my ($ctx, $this) = @_;
+    
+    my $text = $this->{'text'};
+    my $url  = $this->{'permalink_url'};
+    
+    warn LJ::D($this);
+
+    my $journal = $this->{'journal'};
+    my $poster  = $this->{'poster'};
+    warn $journal;
+    warn $poster;
+
+    warn "cut cut cut: $text";
+    LJ::CleanHTML::clean_event( \$text, { 
+        'cuturl'                => $url,
+        'entry_url'             => $url,
+        'ljcut_disable'         => 0,
+        'journalid'             => $journal->{'userid'},
+        'posterid'              => $poster->{'userid'},
+
+        # suspended entries parts are not implemented here for now
+        'suspend_msg'           => '',
+        'unsuspend_supportid'   => 0,
+    } );
+
+    warn "text: $text";
+    return $text;
+}
+
+
 sub _get_colors_for_ad {
     my $ctx = shift;
 
@@ -4665,6 +4696,50 @@
 *EntryPage__get_latest_month = \&Page__get_latest_month;
 *ReplyPage__get_latest_month = \&Page__get_latest_month;
 
+
+sub Page__get_entry_by_id {
+    my ( $ctx, $this, $entry_id ) = @_;
+    my $journal = $this->{'_u'}; 
+
+    warn $entry_id;
+    my $remote = LJ::get_remote();
+    my $entry = LJ::Entry->new($journal, ditemid => $entry_id);
+
+    return undef unless ($entry && $entry->valid);
+    return undef unless $entry->visible_to($remote);
+
+    my $dateparts = $entry->{eventtime};
+    $dateparts =~ tr/-:/  /;
+    my $system_dateparts = $entry->{logtime};
+    $system_dateparts =~ tr/-:/  /;
+
+    my $pickw   = LJ::Entry->userpic_kw_from_props( $entry->props );
+    my $userpic = LJ::S2::Image_userpic( $entry->poster, 0, $pickw );
+
+    return LJ::S2::Entry(
+        $journal,
+        {
+            'subject'          => clear_entry_subject($entry),
+            'text'             => clear_entry_text($entry),
+            'dateparts'        => $dateparts,
+            'system_dateparts' => $system_dateparts,
+            'security'         => $entry->security,
+            'allowmask'        => $entry->allowmask,
+            'props'            => $entry->{'props'},
+            'itemid'           => $entry->ditemid,
+            'journal'          => LJ::S2::UserLite($journal),
+            'poster'           => LJ::S2::UserLite($entry->poster),
+            'comments'         => get_comments_info($entry),
+            'tags'             => get_sorted_tags($entry),
+            'userpic'          => $userpic,
+            'permalink_url'    => $entry->url,
+
+            # for now, these are not implemented
+            'new_day'          => 0,
+            'end_day'          => 0,
+        });
+}
+
 sub Page__get_last_entries {
     my ( $ctx, $this, $ljuser, $count ) = @_;
 

Tags: livejournal, madeon, pm, s2, sbelyaev
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