#!/usr/bin/perl
#
# 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.
package LJ;
use strict;
use Carp;
use POSIX;
use Digest::MD5;
use Digest::SHA1;
use DW::Auth::Challenge;
use DW::External::Site;
use DW::Request;
use DW::Formats;
use LJ::Utils qw(rand_chars);
use LJ::Global::Constants;
use LJ::Event;
use LJ::Subscription::Pending;
use LJ::Directory::Search;
use LJ::Directory::Constraint;
use LJ::PageStats;
use LJ::JSON;
# {src}\" width=\"$i->{width}\" "
. "height=\"$i->{height}\" alt=\"$alt\" title=\"$alt\" "
. "border='0'$attrs />";
}
if ( $type eq "input" ) {
return
"{'src'}\" "
. "width=\"$i->{'width'}\" height=\"$i->{'height'}\" title=\"$alt\" "
. "alt=\"$alt\" border='0'$attrs />";
}
return "XXX";
}
#
"; $nav .= LJ::Lang::ml( 'ljlib.pageofpages', { page => $page, total => $pages } ); $nav .= "
\n"; my $linkify = sub { "( $_[0] ) . ">$_[1]\n"; }; my ( $left, $right ) = ( "<<", ">>" ); $left = $linkify->( $page - 1, $left ) if $page > 1; $right = $linkify->( $page + 1, $right ) if $page < $pages; my @pagelinks; for ( my $i = 1 ; $i <= $pages ; $i++ ) { my $link = "[$i]"; $link = ( $i != $page ) ? $linkify->( $i, $link ) : "$link"; push @pagelinks, "\n"; $out .= "\n"; $out .= LJ::ljuser($usejournal); $out .= LJ::html_hidden( { name => 'usejournal', value => $usejournal, id => 'usejournal_username' } ); $out .= LJ::html_hidden( usejournal_set => 'true' ); $out .= "
\n"; } elsif ( $res && ref $res->{'usejournals'} eq 'ARRAY' ) { my $submitprefix = BML::ml('entryform.update3'); $out .= "\n"; $out .= "\n"; $out .= LJ::html_select( { 'name' => 'usejournal', 'id' => 'usejournal', 'selected' => $usejournal, 'tabindex' => $tabindex->(), 'class' => 'select', "onchange" => "changeSubmit('" . $submitprefix . "','" . $remote->{'user'} . "'); getUserTags('$remote->{user}'); changeSecurityOptions('$remote->{user}'); XPostAccount.updateXpostFromJournal('$remote->{user}');" }, "", $remote->{'user'}, map { $_, $_ } @{ $res->{'usejournals'} } ) . "\n"; $out .= "
\n"; } } # Authentication box $out .= "{'auth'} inerr?>
\n" if $errors->{'auth'}; # Date / Time { my ( $year, $mon, $mday, $hour, $min ) = split( /\D/, $opts->{'datetime'} ); my $monthlong = LJ::Lang::month_long($mon); # date entry boxes / formatting note my $datetime = LJ::html_datetime( { name => 'date_ymd', notime => 1, default => "$year-$mon-$mday", tabindex => $tabindex->(), disabled => $opts->{'disabled_save'} } ); $datetime .= " "; $datetime .= LJ::html_text( { size => 2, class => 'text', maxlength => 2, value => $hour, name => "hour", tabindex => $tabindex->(), disabled => $opts->{'disabled_save'} } ) . ":"; $datetime .= LJ::html_text( { size => 2, class => 'text', maxlength => 2, value => $min, name => "min", tabindex => $tabindex->(), disabled => $opts->{'disabled_save'} } ); # JavaScript sets this value, so we know that the time we get is correct # but always trust the time if we've been through the form already my $date_diff = ( $opts->{'mode'} eq "edit" || $opts->{'spellcheck_html'} ) ? 1 : 0; $datetime .= LJ::html_hidden( "date_diff", $date_diff ); # but if we don't have JS, give a signal to trust the given time $datetime .= ""; $out .= "\n";
$out .=
"\n";
$out .=
"$monthlong $mday, $year, $hour"
. ":"
. "$min "
. BML::ml('entryform.date.edit')
. "\n";
$out .=
"$datetime
\n";
$out .= LJ::html_check(
{
'type' => "check",
'id' => "prop_opt_backdated",
'name' => "prop_opt_backdated",
"value" => 1,
'selected' => $opts->{'prop_opt_backdated'},
'tabindex' => $tabindex->()
}
);
$out .=
"\n";
$out .= LJ::help_icon_html( "backdate", "", "" ) . "\n";
$out .= "\n";
$out .= "
"; $out .= ""; $out .= LJ::html_text( { 'name' => 'prop_taglist', 'id' => 'prop_taglist', 'class' => 'text', 'size' => '35', 'value' => $opts->{'prop_taglist'}, 'tabindex' => $tabindex->(), 'raw' => "autocomplete='off'", } ); $out .= LJ::help_icon_html('addtags'); $out .= "
"; } $out .= "\n";
$out .= "\n";
$out .=
"";
# Current Mood
{
my @moodlist = ( '', BML::ml('entryform.mood.noneother') );
my $sel;
my $moods = DW::Mood->get_moods;
foreach ( sort { $moods->{$a}->{'name'} cmp $moods->{$b}->{'name'} } keys %$moods ) {
push @moodlist, ( $_, $moods->{$_}->{'name'} );
if ( $opts->{prop_current_mood}
&& $opts->{prop_current_mood} eq $moods->{$_}->{name}
|| $opts->{prop_current_moodid} && $opts->{prop_current_moodid} == $_ )
{
$sel = $_;
}
}
if ($remote) {
my $r_theme = DW::Mood->new( $remote->{'moodthemeid'} );
foreach my $mood ( keys %$moods ) {
my $moodid = $moods->{$mood}->{id};
if ( $r_theme && $r_theme->get_picture( $moodid, \my %pic ) ) {
$moodlist .= " moods[" . $moodid;
$moodlist .= "] = \"";
$moodlist .= $moods->{$mood}->{name} . "\";\n";
$moodpics .= " moodpics[" . $moodid;
$moodpics .= "] = \"";
$moodpics .= $pic{pic} . "\";\n";
}
}
$$onload .= " mood_preview();";
$$head .= <
"; if ( LJ::is_enabled('web_current_location') ) { $out .= ""; $out .= ""; $out .= LJ::html_text( { name => 'prop_current_location', value => $opts->{prop_current_location}, id => 'prop_current_location', class => 'text', size => '35', maxlength => LJ::std_max_length(), tabindex => $tabindex->() } ) . "\n"; $out .= ""; } # Comment Screening settings $out .= "\n"; $out .= "\n"; my $opt_default_screen = $opts->{prop_opt_default_screening} || ''; my $screening_levels_default = $opt_default_screen eq 'N' ? BML::ml('label.screening.none2') : $opt_default_screen eq 'R' ? BML::ml('label.screening.anonymous2') : $opt_default_screen eq 'F' ? BML::ml('label.screening.nonfriends2') : $opt_default_screen eq 'A' ? BML::ml('label.screening.all2') : BML::ml('label.screening.none2'); my @levels = ( '', BML::ml( 'label.screening.default4', { 'aopts' => $screening_levels_default } ), 'N', BML::ml('label.screening.none2'), 'R', BML::ml('label.screening.anonymous2'), 'F', BML::ml('label.screening.nonfriends2'), 'A', BML::ml('label.screening.all2') ); $out .= LJ::html_select( { 'name' => 'prop_opt_screening', 'id' => 'prop_opt_screening', 'class' => 'select', 'selected' => $opts->{'prop_opt_screening'}, 'tabindex' => $tabindex->() }, @levels ); $out .= LJ::help_icon_html( "screening", "", " " ); $out .= "\n"; $out .= "
\n"; # Current Music $out .= "\n"; $out .= "\n"; $out .= "\n"; # BML::ml('entryform.music') $out .= LJ::html_text( { name => 'prop_current_music', value => $opts->{prop_current_music}, id => 'prop_current_music', class => 'text', size => '35', maxlength => LJ::std_max_length(), tabindex => $tabindex->() } ) . "\n"; $out .= "\n"; $out .= ""; # Content Flag if ( LJ::is_enabled('adult_content') ) { my @adult_content_menu = ( "" => BML::ml('entryform.adultcontent.default'), none => BML::ml('entryform.adultcontent.none'), concepts => BML::ml('entryform.adultcontent.concepts'), explicit => BML::ml('entryform.adultcontent.explicit'), ); $out .= "\n"; $out .= LJ::html_select( { name => 'prop_adult_content', id => 'prop_adult_content', class => 'select', selected => $opts->{prop_adult_content} || "", tabindex => $tabindex->(), }, @adult_content_menu ); $out .= LJ::help_icon_html( "adult_content", "", " " ); } $out .= "\n"; $out .= "
\n"; if ( LJ::is_enabled('adult_content') ) { $out .= ""; $out .= ""; $out .= LJ::html_text( { 'name' => 'prop_adult_content_reason', 'id' => 'prop_adult_content_reason', 'class' => 'text', 'size' => '35', 'maxlength' => '255', 'value' => $opts->{'prop_adult_content_reason'}, 'tabindex' => $tabindex->(), } ); $out .= LJ::help_icon_html('adult_content_reason'); $out .= "
"; } if ( $remote && !$altlogin ) { # crosspost my @accounts = DW::External::Account->get_external_accounts($remote); # populate the per-account html first, so that we only have to # go through them once. my $accthtml = ""; my $xpostbydefault = 0; my $xpost_tabindex = $tabindex->(); my $did_spellcheck = $opts->{spellcheck_html} ? 1 : 0; if ( scalar @accounts ) { my $xpoststring = $opts->{prop_xpost}; my $xpost_selected = DW::External::Account->xpost_string_to_hash($xpoststring); foreach my $acct (@accounts) { # print the checkbox for each account my $acctid = $acct->acctid; my $acctname = $acct->displayname; my $selected; if ( $opts->{mode} eq 'edit' ) { $selected = $xpost_selected->{ $acct->acctid } ? "1" : "0"; } elsif ($did_spellcheck) { $selected = $opts->{"prop_xpost_$acctid"}; } else { $selected = $acct->xpostbydefault; } $accthtml .= ""; $out .= LJ::html_check( { 'type' => 'checkbox', 'name' => 'prop_xpost_check', 'id' => 'prop_xpost_check', 'class' => 'check', 'value' => '1', 'selected' => $xpostbydefault, 'disabled' => ( scalar @accounts ) ? '0' : '1', 'tabindex' => $xpost_tabindex, 'onchange' => 'XPostAccount.xpostButtonUpdated();', } ); $out .= LJ::help_icon_html('prop_xpost_check'); $out .= "" . BML::ml('entryform.xpost.manage') . ""; $out .= "
\n
];
}
### Other Posting Options
$out .=
LJ::Hooks::run_hook( 'add_extra_entryform_fields',
{ opts => $opts, tabindex => $tabindex } )
|| '';
$out .= "";
# extra submit button so make sure it posts the form when person presses enter key
if ( $opts->{'mode'} eq "edit" ) {
$out .= "";
}
if ( $opts->{'mode'} eq "update" ) {
$out .=
"";
}
# submit_value field to emulate the submit button selected if we
# have to submit with javascript
$out .= "";
my $preview;
$preview =
"";
if ( !$opts->{'disabled_save'} ) {
$out .= <
\n"; $out .= "" . BML::ml('entryform.maintainer') . "\n"; $out .= "
\n"; # adult content settings if ( LJ::is_enabled('adult_content') ) { $out .= "\n"; my %poster_adult_content_menu = ( "" => BML::ml('entryform.adultcontent.default'), none => BML::ml('entryform.adultcontent.none'), concepts => BML::ml('entryform.adultcontent.concepts'), explicit => BML::ml('entryform.adultcontent.explicit'), ); my @adult_content_menu = ( "" => BML::ml( 'entryform.adultcontent.poster', { setting => $poster_adult_content_menu{ $opts->{prop_adult_content} } } ), none => BML::ml('entryform.adultcontent.none'), concepts => BML::ml('entryform.adultcontent.concepts'), explicit => BML::ml('entryform.adultcontent.explicit'), ); $out .= "\n"; $out .= LJ::html_select( { name => 'prop_adult_content_maintainer', id => 'prop_adult_content_maintainer', class => 'select', selected => $opts->{prop_adult_content_maintainer} || "", tabindex => $tabindex->(), }, @adult_content_menu ); $out .= LJ::help_icon_html( "adult_content", "", " " ); $out .= "
\n"; $out .= ""; $out .= ""; $out .= LJ::html_text( { 'name' => 'prop_adult_content_maintainer_reason', 'id' => 'prop_adult_content_maintainer_reason', 'class' => 'text', 'size' => '35', 'maxlength' => '255', 'value' => $opts->{'prop_adult_content_maintainer_reason'}, 'tabindex' => $tabindex->(), } ); $out .= LJ::help_icon_html('adult_content_reason'); $out .= "
"; } # comment disabling/enabling # only possible if comments weren't disabled by poster unless ( $opts->{prop_opt_nocomments} ) { $out .= ""; $out .= ""; # comment disabling is done via a checkbox as it has only two settings # if we got this far, this is always set to the maintainer setting my $selected = $opts->{prop_opt_nocomments_maintainer}; $out .= LJ::html_check( { type => 'checkbox', name => "prop_opt_nocomments_maintainer", id => "prop_opt_nocomments_maintainer", class => 'check', value => '1', selected => $selected, tabindex => $tabindex->(), } ); $out .= "
"; } } $out .= "(?: |\s)+
| )\s*?!!gm; $event = '' unless $attempt =~ /\S/; $req->{'prop_opt_preformatted'} = 0; } else { # Old methods, left in for compatibility during code push $event =~ s!