375 lines
13 KiB
Text
375 lines
13 KiB
Text
|
|
<?_c
|
||
|
|
# This code was forked from the LiveJournal project owned and operated
|
||
|
|
# by Live Journal, Inc. The code has been modified and expanded by
|
||
|
|
# Dreamwidth Studios, LLC. These files were originally licensed under
|
||
|
|
# the terms of the license supplied by Live Journal, Inc, which can
|
||
|
|
# currently be found at:
|
||
|
|
#
|
||
|
|
# http://code.livejournal.org/trac/livejournal/browser/trunk/LICENSE-LiveJournal.txt
|
||
|
|
#
|
||
|
|
# In accordance with the original license, this code and all its
|
||
|
|
# modifications are provided under the GNU General Public License.
|
||
|
|
# A copy of that license can be found in the LICENSE file included as
|
||
|
|
# part of this distribution.
|
||
|
|
_c?>
|
||
|
|
<?_code
|
||
|
|
{
|
||
|
|
use strict;
|
||
|
|
return "<?requirepost?>" unless LJ::did_post();
|
||
|
|
|
||
|
|
my $ret;
|
||
|
|
my $remote = LJ::get_remote();
|
||
|
|
my $styleid; my $stylesys = 1;
|
||
|
|
|
||
|
|
|
||
|
|
my $username = $POST{user} || $POST{username};
|
||
|
|
my $altlogin = $GET{altlogin} || $POST{post_as_other};
|
||
|
|
my $usejournal = $altlogin ? $POST{postas_usejournal} : $POST{usejournal};
|
||
|
|
|
||
|
|
### Figure out poster/journal
|
||
|
|
my ( $u, $up );
|
||
|
|
if ( $usejournal ) {
|
||
|
|
$u = LJ::load_user( $usejournal );
|
||
|
|
$up = $username ? LJ::load_user( $username ) : $remote;
|
||
|
|
} elsif ( $username && $altlogin ) {
|
||
|
|
$u = LJ::load_user( $username );
|
||
|
|
} else {
|
||
|
|
$u = $remote;
|
||
|
|
}
|
||
|
|
$up = $u unless $up;
|
||
|
|
|
||
|
|
### Set up preview variables
|
||
|
|
my ($ditemid, $anum, $itemid);
|
||
|
|
my %req = ( 'usejournal' => $POST{'usejournal'}, );
|
||
|
|
LJ::entry_form_decode(\%req, \%POST);
|
||
|
|
|
||
|
|
my ($event, $subject) = ($req{'event'}, $req{'subject'});
|
||
|
|
LJ::CleanHTML::clean_subject(\$subject);
|
||
|
|
|
||
|
|
# preview poll
|
||
|
|
if ( LJ::Poll->contains_new_poll( \$event ) ) {
|
||
|
|
my $error;
|
||
|
|
my @polls = LJ::Poll->new_from_html( \$event, \$error, {
|
||
|
|
'journalid' => $u->userid,
|
||
|
|
'posterid' => $up->userid,
|
||
|
|
});
|
||
|
|
|
||
|
|
my $can_create_poll = $up->can_create_polls || ( $u->is_community && $u->can_create_polls );
|
||
|
|
my $poll_preview = sub {
|
||
|
|
my $poll = shift @polls;
|
||
|
|
return '' unless $poll;
|
||
|
|
return $can_create_poll ? $poll->preview : qq{<div class="highlight-box">} . LJ::Lang::ml( '/poll/create.bml.error.accttype2' ) . qq{</div>};
|
||
|
|
};
|
||
|
|
|
||
|
|
$event =~ s/<poll-placeholder>/$poll_preview->()/eg;
|
||
|
|
}
|
||
|
|
|
||
|
|
# existing polls
|
||
|
|
LJ::Poll->expand_entry( \$event );
|
||
|
|
|
||
|
|
# parse out embed tags from the RTE
|
||
|
|
$event = LJ::EmbedModule->transform_rte_post($event);
|
||
|
|
# do first expand_embedded pass with the preview flag to extract
|
||
|
|
# embedded content before cleaning and replace with tags
|
||
|
|
# the cleaner won't eat
|
||
|
|
LJ::EmbedModule->parse_module_embed($u, \$event, preview => 1,);
|
||
|
|
# clean content normally
|
||
|
|
LJ::CleanHTML::clean_event(\$event, {
|
||
|
|
preformatted => $req{'prop_opt_preformatted'},
|
||
|
|
});
|
||
|
|
# expand the embedded content for reals
|
||
|
|
LJ::EmbedModule->expand_entry($u, \$event, preview => 1,);
|
||
|
|
|
||
|
|
my $apache_r = BML::get_request();
|
||
|
|
my $ctx;
|
||
|
|
|
||
|
|
# Get the preview message to hand to S2 or use in $ret.
|
||
|
|
my $preview_warn_text = $ML{".entry.preview_warn_text"};
|
||
|
|
|
||
|
|
if ($u && $up) {
|
||
|
|
$apache_r->notes->{_journal} = $u->{user};
|
||
|
|
$apache_r->notes->{journalid} = $u->{userid};
|
||
|
|
|
||
|
|
### Load necessary props
|
||
|
|
my @needed_props = qw( stylesys s2_style url urlname
|
||
|
|
opt_usesharedpic journaltitle
|
||
|
|
journalsubtitle );
|
||
|
|
|
||
|
|
$u->preload_props( @needed_props );
|
||
|
|
|
||
|
|
### Determine style system to preview with
|
||
|
|
my $get_styleinfo = sub {
|
||
|
|
if ( $u->{'stylesys'} == 2 ) {
|
||
|
|
my $forceflag = 0;
|
||
|
|
LJ::Hooks::run_hooks("force_s1", $u, \$forceflag);
|
||
|
|
|
||
|
|
# check whether to use custom comment pages
|
||
|
|
$ctx = LJ::S2::s2_context( $u->{s2_style} );
|
||
|
|
my $view_entry_disabled = ! LJ::S2::use_journalstyle_entry_page( $u );
|
||
|
|
|
||
|
|
return (2, $u->{'s2_style'}) unless $forceflag || $view_entry_disabled;
|
||
|
|
}
|
||
|
|
# no special case and not s2, fall through to s1
|
||
|
|
return (1, 0);
|
||
|
|
};
|
||
|
|
|
||
|
|
($stylesys, $styleid) = $get_styleinfo->();
|
||
|
|
} else {
|
||
|
|
$stylesys = 1; $styleid = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
# TODO: clean up this codepath/logic
|
||
|
|
# "stylesys == 1" in here means that you're viewing a BML page, not customized comemnts
|
||
|
|
if ($stylesys == 1) {
|
||
|
|
# pre-load common strings for little speed and less typing later
|
||
|
|
# (we're doing this *after* set_language_scope is called, because
|
||
|
|
# two below are relative strings)
|
||
|
|
my %T = qw(postcomments talk.commentpost
|
||
|
|
readcomments talk.commentsread
|
||
|
|
link talk.commentpermlink
|
||
|
|
nosubject .nosubject
|
||
|
|
);
|
||
|
|
foreach (keys %T) { $T{$_} = $ML{$T{$_}}; }
|
||
|
|
# make the title
|
||
|
|
{
|
||
|
|
my $subject = $req{'subject'} || $req{'event'};
|
||
|
|
LJ::CleanHTML::clean_subject_all(\$subject);
|
||
|
|
$subject =~ s/\n.*//s;
|
||
|
|
# yes, the 3 param to text_trim is chars, and length returns bytes, but
|
||
|
|
# it works, as bytes >= chars:
|
||
|
|
$subject = LJ::text_trim($subject, 0, length($req{'subject'}) || 40);
|
||
|
|
}
|
||
|
|
|
||
|
|
LJ::need_res( qw( stc/talkpage.css ) );
|
||
|
|
|
||
|
|
$ret .= "<?page\n";
|
||
|
|
$ret .= "windowtitle=>" . BML::ml( ".title", { sitenameshort => $LJ::SITENAMESHORT } ) . "\n";
|
||
|
|
$ret .= "body<=\n";
|
||
|
|
|
||
|
|
$ret .= "<p>";
|
||
|
|
|
||
|
|
if ($u) {
|
||
|
|
$ret .= "<table summary=''><tr valign='middle'>";
|
||
|
|
|
||
|
|
my $pic = LJ::Userpic->new_from_keyword( $up, $req{prop_picture_keyword} );
|
||
|
|
my $imgtag = $pic ? $pic->imgtag : undef;
|
||
|
|
$ret .= "<td>$imgtag</td>" if $imgtag;
|
||
|
|
|
||
|
|
$ret .= "<td>";
|
||
|
|
if ( $u->is_community ) {
|
||
|
|
$ret .= BML::ml("talk.somebodywrote_comm", { 'realname' => LJ::ehtml($up->{'name'}),
|
||
|
|
'userlink' => LJ::ljuser($up),
|
||
|
|
'commlink' => LJ::ljuser($u) });
|
||
|
|
} else {
|
||
|
|
$ret .= BML::ml("talk.somebodywrote", { 'realname' => LJ::ehtml($up->{'name'}),
|
||
|
|
'userlink' => LJ::ljuser($up) });
|
||
|
|
}
|
||
|
|
|
||
|
|
my $etime = LJ::date_to_view_links($u, "$req{'year'}-$req{'mon'}-$req{'day'}");
|
||
|
|
|
||
|
|
$req{'hour'} = int($req{'hour'});
|
||
|
|
$req{'min'} = int($req{'min'});
|
||
|
|
|
||
|
|
$ret .= "<br /><span class='time'>@ $etime $req{'hour'}:$req{'min'}:00</span>";
|
||
|
|
$ret .= "</td></tr></table>";
|
||
|
|
}
|
||
|
|
|
||
|
|
## dump the log entry, unless we're browsing a thread.
|
||
|
|
my %current = LJ::currents( \%req, $up, { key => 'prop_' } );
|
||
|
|
|
||
|
|
# custom friend groups
|
||
|
|
if ( $u ) {
|
||
|
|
$current{Groups} = $u->security_group_display( $req{allowmask} );
|
||
|
|
delete $current{Groups} unless $current{Groups};
|
||
|
|
}
|
||
|
|
|
||
|
|
my @taglist = ();
|
||
|
|
LJ::Tags::is_valid_tagstring( $POST{prop_taglist}, \@taglist );
|
||
|
|
if ( @taglist ) {
|
||
|
|
my $base = $u ? $u->journal_base : "";
|
||
|
|
$current{Tags} = join( ', ',
|
||
|
|
map { "<a href='$base/tag/" . LJ::eurl( $_ ) . "'>" . LJ::ehtml( $_ ) . "</a>" }
|
||
|
|
@taglist
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
$ret .= "<div id='entry' class='usercontent' style='margin-left: 30px'>";
|
||
|
|
|
||
|
|
$ret .= LJ::currents_table( %current );
|
||
|
|
|
||
|
|
### security indicator
|
||
|
|
my $sec = "";
|
||
|
|
if ($req{'security'} eq "private") {
|
||
|
|
$sec = BML::fill_template("securityprivate");
|
||
|
|
} elsif ($req{'security'} eq "usemask") {
|
||
|
|
$sec = BML::fill_template("securityprotected");
|
||
|
|
}
|
||
|
|
|
||
|
|
$sec .= "<br />\n" unless $sec eq "" or $req{'subject'};
|
||
|
|
$ret .= $sec;
|
||
|
|
|
||
|
|
###
|
||
|
|
if ($subject) {
|
||
|
|
BML::ebml( \$subject );
|
||
|
|
$ret .= "<div id='entrysubj'>$subject</div><br />\n";
|
||
|
|
}
|
||
|
|
|
||
|
|
$ret .= BML::ebml( $event );
|
||
|
|
$ret .= "</div>";
|
||
|
|
$ret .= "<hr/><div class='highlight-box'><p>\n";
|
||
|
|
$ret .= $preview_warn_text . "\n";
|
||
|
|
$ret .= "</p></div>";
|
||
|
|
|
||
|
|
|
||
|
|
$ret .= "<br clear='all' /><hr width='100%' size='2' align='center' />";
|
||
|
|
|
||
|
|
$ret .= "\n<=body";
|
||
|
|
$ret .= "\npage?>";
|
||
|
|
|
||
|
|
} else {
|
||
|
|
$LJ::S2::ret_ref = \$ret;
|
||
|
|
my $opts;
|
||
|
|
$opts->{'r'} = $apache_r;
|
||
|
|
|
||
|
|
$u->{'_s2styleid'} = $styleid + 0;
|
||
|
|
$u->{'_journalbase'} = $u->journal_base;
|
||
|
|
|
||
|
|
$LJ::S2::CURR_CTX = $ctx;
|
||
|
|
|
||
|
|
my $p = LJ::S2::Page($u, $opts);
|
||
|
|
$p->{'_type'} = "EntryPreviewPage";
|
||
|
|
$p->{'view'} = "entry";
|
||
|
|
$p->{'comment_pages'} = undef;
|
||
|
|
$p->{'comments'} = [];
|
||
|
|
$p->{'comment_pages'} = undef;
|
||
|
|
$p->{'preview_warn_text'} = $preview_warn_text;
|
||
|
|
|
||
|
|
my $userlite_journal = LJ::S2::UserLite($u);
|
||
|
|
my $userlite_poster = LJ::S2::UserLite($up);
|
||
|
|
|
||
|
|
my $userpic = LJ::S2::Image_userpic($up, 0, $req{'prop_picture_keyword'});
|
||
|
|
|
||
|
|
my $comments = LJ::S2::CommentInfo({
|
||
|
|
'read_url' => "#",
|
||
|
|
'post_url' => "#",
|
||
|
|
'permalink_url' => "#",
|
||
|
|
'count' => "0",
|
||
|
|
'maxcomments' => 0,
|
||
|
|
'enabled' => ($u->{'opt_showtalklinks'} eq "Y" && !
|
||
|
|
$req{'prop_opt_nocomments'}) ? 1 : 0,
|
||
|
|
'screened' => 0,
|
||
|
|
});
|
||
|
|
|
||
|
|
# build tag objects, faking kwid as '-1'
|
||
|
|
# * invalid tags will be stripped by is_valid_tagstring()
|
||
|
|
my @taglist = ();
|
||
|
|
LJ::Tags::is_valid_tagstring($POST{prop_taglist}, \@taglist);
|
||
|
|
@taglist = map { LJ::S2::Tag($u, -1, $_) } @taglist;
|
||
|
|
|
||
|
|
# build metadata props
|
||
|
|
$req{props}->{$_} = $req{"prop_".$_}
|
||
|
|
foreach ( qw( current_music current_location current_coords current_moodid current_mood ) );
|
||
|
|
|
||
|
|
# custom friends groups
|
||
|
|
my $group_names = $u ? $u->security_group_display( $req{allowmask} ) : undef;
|
||
|
|
|
||
|
|
# format it
|
||
|
|
my $raw_subj = $req{'subject'};
|
||
|
|
my $s2entry = LJ::S2::Entry($u, {
|
||
|
|
'subject' => $subject,
|
||
|
|
'text' => $event,
|
||
|
|
'dateparts' => "$req{'year'} $req{'mon'} $req{'day'} $req{'hour'} $req{'min'} 00 ",
|
||
|
|
'security' => $req{'security'},
|
||
|
|
'allowmask' => $req{'allowmask'},
|
||
|
|
'props' => $req{'props'},
|
||
|
|
'itemid' => -1,
|
||
|
|
'comments' => $comments,
|
||
|
|
'journal' => $userlite_journal,
|
||
|
|
'poster' => $userlite_poster,
|
||
|
|
'new_day' => 0,
|
||
|
|
'end_day' => 0,
|
||
|
|
'tags' => \@taglist,
|
||
|
|
'userpic' => $userpic,
|
||
|
|
'permalink_url' => "#",
|
||
|
|
adult_content_level => $req{prop_adult_content},
|
||
|
|
group_names => $group_names,
|
||
|
|
});
|
||
|
|
|
||
|
|
$p->{'multiform_on'} = 0;
|
||
|
|
|
||
|
|
if ($u->should_block_robots) {
|
||
|
|
$p->{'head_content'} .= LJ::robot_meta_tags();
|
||
|
|
}
|
||
|
|
|
||
|
|
$p->{'head_content'} .= '<meta http-equiv="Content-Type" content="text/html; charset='.$opts->{'saycharset'}."\" />\n";
|
||
|
|
|
||
|
|
# Don't show the navigation strip or invisible content
|
||
|
|
$p->{'head_content'} .= qq{
|
||
|
|
<style type="text/css">
|
||
|
|
html body {
|
||
|
|
padding-top: 0 !important;
|
||
|
|
}
|
||
|
|
#lj_controlstrip {
|
||
|
|
display: none !important;
|
||
|
|
}
|
||
|
|
.invisible {
|
||
|
|
position: absolute;
|
||
|
|
left: -10000px;
|
||
|
|
top: auto;
|
||
|
|
}
|
||
|
|
.highlight-box {
|
||
|
|
border: 1px solid #c1272c;
|
||
|
|
background-color: #ffd8d8;
|
||
|
|
color: #000;
|
||
|
|
}
|
||
|
|
/* lj_embedcontent styling copied from lj_base.css */
|
||
|
|
.lj_embedcontent-wrapper {
|
||
|
|
overflow: hidden;
|
||
|
|
}
|
||
|
|
.lj_embedcontent-ratio {
|
||
|
|
position: relative;
|
||
|
|
height: 0;
|
||
|
|
/* this technique requires a padding top, but we
|
||
|
|
calculate that dynamically and put it inline */
|
||
|
|
}
|
||
|
|
iframe.lj_embedcontent {
|
||
|
|
position: absolute;
|
||
|
|
top: 0;
|
||
|
|
left: 0;
|
||
|
|
width: 100%;
|
||
|
|
height: 100%;
|
||
|
|
border: 0;
|
||
|
|
}
|
||
|
|
</style>
|
||
|
|
};
|
||
|
|
|
||
|
|
$p->{'entry'} = $s2entry;
|
||
|
|
|
||
|
|
$p->{'comments'} = [];
|
||
|
|
|
||
|
|
$p->{'viewing_thread'} = 0;
|
||
|
|
|
||
|
|
my $copts;
|
||
|
|
|
||
|
|
$copts->{'out_pages'} = $copts->{'out_page'} = 1;
|
||
|
|
$copts->{'out_items'} = 0;
|
||
|
|
$copts->{'out_itemfirst'} = $copts->{'out_itemlast'} = undef;
|
||
|
|
|
||
|
|
$p->{'comment_pages'} = LJ::S2::ItemRange({
|
||
|
|
'all_subitems_displayed' => ($copts->{'out_pages'} == 1),
|
||
|
|
'current' => $copts->{'out_page'},
|
||
|
|
'from_subitem' => $copts->{'out_itemfirst'},
|
||
|
|
'num_subitems_displayed' => 0,
|
||
|
|
'to_subitem' => $copts->{'out_itemlast'},
|
||
|
|
'total' => $copts->{'out_pages'},
|
||
|
|
'total_subitems' => $copts->{'out_items'},
|
||
|
|
'_url_of' => sub { return "#"; },
|
||
|
|
});
|
||
|
|
|
||
|
|
LJ::S2::s2_run($apache_r, $ctx, $opts, "EntryPage::print()", $p);
|
||
|
|
BML::ebml(\$ret);
|
||
|
|
}
|
||
|
|
return $ret;
|
||
|
|
}
|
||
|
|
_code?>
|