package DW::Setting::XPostAccounts; use base 'LJ::Setting'; use strict; use warnings; use Digest::MD5 qw(md5_hex); my $footer_length = 1024; # show this setting editor sub should_render { my ( $class, $u ) = @_; return 1; } # link to the help url sub helpurl { my ( $class, $u ) = @_; return "cross_post"; } # label; by default, displayed on the left side of the editor page sub label { my $class = shift; return $class->ml('setting.xpost.label'); } # option. this is where all of the entered info is displayed. in this case, # shows both the existing configured ExternalAccounts, as well as the UI for # adding new accounts. sub option { my ( $class, $u, $errs, $args, %opts ) = @_; return unless LJ::isu($u); # first load up the existing accounts. my @accounts = DW::External::Account->get_external_accounts($u); # label displayed at top of the option (right) section my $ret .= "
" . $class->ml('setting.xpost.option') . "
"; # check to see if we have an update message my $getargs = $opts{getargs}; if ($getargs) { if ( $getargs->{create} ) { my $acct = DW::External::Account->get_external_account( $u, $getargs->{create} ); # FIXME blue is temporary. move to css. $ret .= "| " . $class->ml('setting.xpost.option.username') . " | \n"; $ret .= "" . $class->ml('setting.xpost.option.server') . " | \n"; $ret .= "" . $class->ml('setting.xpost.option.xpostbydefault') . " | \n"; $ret .= "" . $class->ml('setting.xpost.option.recordlink') . " | \n"; $ret .= "" . $class->ml('setting.xpost.option.change') . " | \n"; $ret .= "" . $class->ml('setting.xpost.option.delete') . " | \n"; $ret .= "
|---|---|---|---|---|---|
| " . $externalacct->username . " | "; $ret .= "" . $externalacct->servername . " | "; $ret .= "" . LJ::html_check( { name => "${key}xpostbydefault[${acctid}]", value => 1, id => "${key}xpostbydefault[${acctid}]", selected => $externalacct->xpostbydefault } ) . " | "; $ret .= "" . LJ::html_check( { name => "${key}recordlink[${acctid}]", value => 1, id => "${key}recordlink[${acctid}]", selected => $externalacct->recordlink } ) . " | "; $ret .= "" . $class->ml('setting.xpost.option.change') . " | \n"; $ret .= "" . LJ::html_check( { name => "${key}delete[${acctid}]", value => 1, id => "${key}delete[${acctid}]", selected => 0 } ) . " | "; $ret .= "
| " . $class->ml('setting.xpost.noaccounts') . " |
" . $class->ml( 'setting.xpost.message.usage', { current => scalar @accounts, max => $max_accounts } ); # add account if ( scalar @accounts < $max_accounts ) { $ret .= "
\n"; } $ret .= "| " . $class->ml('setting.xpost.comments') . " | "; $ret .= LJ::html_check( { name => "${key}xpostdisablecomments", value => 1, id => "${key}xpostdisablecomments", selected => $u->prop('opt_xpost_disable_comments') } ) . ""; $ret .= " | |
| " . $class->ml('setting.xpost.footer') . " | "; my $append_when = $u->prop('crosspost_footer_append'); $ret .= LJ::html_select( { name => "${key}crosspost_footer_append", id => "${key}crosspost_footer_append", class => "select", selected => $append_when || 'D' }, 'A' => $class->ml('setting.xpost.option.footer.when.always'), 'D' => $class->ml('setting.xpost.option.footer.when.disabled'), 'N' => $class->ml('setting.xpost.option.footer.when.never') ); $ret .= " | |
|   | "; my $footer_text = $u->prop('crosspost_footer_text'); $ret .= LJ::html_textarea( { name => "${key}crosspost_footer_text", id => "${key}crosspost_footer_text", rows => 3, cols => 80, maxlength => "512", onkeyup => "javascript:updatePreview()", value => $footer_text } ) . " "; $ret .= "\n"; # define custom footer $ret .= " | |
|   | "; my $footer_nocomments = $u->prop('crosspost_footer_nocomments'); $ret .= LJ::html_textarea( { name => "${key}crosspost_footer_nocomments", id => "${key}crosspost_footer_nocomments", rows => 3, cols => 80, maxlength => "512", onkeyup => "javascript:updatePreviewNocomments()", value => $footer_nocomments } ) . " "; $ret .= "\n"; my $baseurl = $LJ::SITEROOT; my $alttext = $class->ml('setting.xpost.option.footer.vars.comment_image.alt'); my $default_comment = $class->ml( 'xpost.redirect.comment2', { postlink => "%%url%%", openidlink => "$LJ::SITEROOT/openid/" } ); my $default_nocomments = $class->ml( 'xpost.redirect', { postlink => "%%url%%" } ); # the javascript. we have to do some special magic to get the lengths # to line up for differing newline characters and for unicode characters # outside the basic multilingual plane. $ret .= qq [ ]; $ret .= " "
. $class->ml('setting.xpost.option.footer.vars') . " | |