<?page
title=><?_ml .title _ml?>

body<=

<?_code
{
    use strict;
    use vars qw(%GET);

    LJ::set_active_crumb('export');

    my $remote = LJ::get_remote();
    return "<?needlogin?>"
        unless $remote;

    my $ret;
    my $authas = $GET{'authas'} || $remote->{'user'};

    # no authentication needs to be done on this page, it's just a form anyway

    # user switcher
    $ret .= "<form action='export.bml' method='get'>\n";
    $ret .= LJ::make_authas_select($remote, { 'authas' => $GET{'authas'} });
    $ret .= "</form>\n\n";

    $ret .= "<?h1 <?_ml .title _ml?> h1?>\n";
    $ret .= "<?p <?_ml .description _ml?> p?>\n";

    $ret .= "<form action='export_do.bml?authas=$authas' method='post'>\n";
   
    # main form
    $ret .= <<'HTMLBLOCK';

<?standout
<table>
<tr valign='top'><td><?_ml .label.what _ml?></td>
<td>
    <select name="what" id="what">
    <option value="journal"><?_ml .what.entries _ml?></option>
    </select>
</td></tr>

<tr valign='middle'><td><?_ml .label.month _ml?></td>
<td>
    <?_ml .label.month.year _ml?> <input name="year" size='4' maxlength='4' /> - 
    <?_ml .label.month.month _ml?> <input name="month" size='2' maxlength='2' />
</td></tr>

<tr valign='top'><td><?_ml .label.format _ml?></td>
<td>
    <select name="format">
    <option value="csv"><?_ml .format.csv _ml?></option>
    <option value="xml"><?_ml .format.xml _ml?></option>
    </select><br />
    <input type='checkbox' name="header" id="header" checked='checked' /> <label for="header"><?_ml .label.header _ml?></label><br />
    <?_ml .label.encoding _ml?>
HTMLBLOCK

    # unicode encoding selection
    if ($LJ::UNICODE) {
        my (%encodings, %encnames);
        LJ::load_codes({ "encoding" => \%encodings } );
        LJ::load_codes({ "encname" => \%encnames } );
        my $selected = 0;
        foreach my $id (keys %encodings) {
            $selected = $id if lc($encodings{$id}) eq 'utf-8';
            delete $encnames{$id} if lc($encodings{$id}) eq 'none';
        }
        $ret .= LJ::html_select({'name'=>'encid', 'selected'=>$selected},
                                map { $_, $encnames{$_} } sort keys %encnames);
    } else {
        $ret .= "<input type='text' name='encoding' size='15' maxlength='15' value='iso-8859-1' />";
    }
    $ret .= "<br />\n";

    $ret .= <<'HTMLBLOCK';

 <input type='checkbox' name="notranslation" id="notranslation" /> <label for="notranslation"><?_ml .label.notranslation _ml?></label><br />

</td></tr>
<tr><td colspan='2'><hr /></td></tr>
<tr valign='top'><td><?_ml .fields _ml?></td>
<td>
  <input type='checkbox' name="field_itemid" id="field_itemid" checked='checked' /> <label for="field_itemid"><?_ml .label.field.itemid _ml?></label><br />
  <input type='checkbox' name="field_eventtime" id="field_eventtime" checked='checked' /> <label for="field_eventtime"><?_ml .label.field.eventtime _ml?></label><br />
  <input type='checkbox' name="field_logtime" id="field_logtime" checked='checked' /> <label for="field_logtime"><?_ml .label.field.logtime _ml?></label><br />
  <input type='checkbox' name="field_subject" id="field_subject" checked='checked' /> <label for="field_subject"><?_ml .label.field.subject _ml?></label><br />
  <input type='checkbox' name="field_event" id="field_event" checked='checked' /> <label for="field_event"><?_ml .label.field.event _ml?></label><br />
  <input type='checkbox' name="field_security" id="field_security" checked='checked' /> <label for="field_security"><?_ml .label.field.security _ml?></label><br />
  <input type='checkbox' name="field_allowmask" id="field_allowmask" checked='checked' /> <label for="field_allowmask"><?_ml .label.field.allowmask _ml?></label><br />
  <input type='checkbox' name='field_currents' id="field_currents" checked='checked' /> <label for="field_currents"><?_ml .label.field.currents _ml?></label><br />
</td></tr>

<tr><td></td><td><input type="submit" value="<?_ml .btn.proceed _ml?>" /></td></tr>
</table>
standout?>
</form>

<?h1 <?_ml lostinfo.head _ml?> h1?>
<?p <?_ml lostinfo.text _ml?> p?>
HTMLBLOCK

}
_code?>
<=body
page?><?_c <LJDEP>
post: htdocs/export_do.bml
</LJDEP> _c?>
