mourningdove/htdocs/imgupload.bml

169 lines
5.9 KiB
Text
Raw Normal View History

2026-05-24 01:03:05 +00:00
<?_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;
use vars qw(%GET);
# $_[1] is a pre-request scratch area
# put variables here so that we can access them later
# outside of this _code block
my $head = \$_[1]->{'head'};
my $body = \$_[1]->{'body'};
my $u = LJ::User->remote;
LJ::need_res('stc/lj_base-app.css',
'stc/imgupload.css',
'stc/display_none.css');
if ($GET{upload_count} || LJ::did_post()) {
my $js = "";
if (my $ct = $GET{upload_count}) {
for my $pn (1..$ct) {
my $swidth = int($GET{"sw_$pn"});
my $sheight = int($GET{"sh_$pn"});
my $esurl = LJ::ejs($GET{"su_$pn"});
my $eppurl = LJ::ejs($GET{"pp_$pn"});
$js .= "InOb.onUpload(\"$esurl\", \"$eppurl\", $swidth, $sheight);\n";
}
# From URL, with optional alt text
} else {
my $img = LJ::ejs($POST{'url'});
my $alt = LJ::ejs($POST{'alt'});
$js = "InOb.onInsURL(\"$img\", 0, 0, \"$alt\")\n";
}
my $ret = qq{
<html>
<body>
<script>
if (window.parent.parent && window.parent.parent.InOb) {
window.parent.parent.$js
window.parent.parent.InOb.onClosePopup();
} else if (window.parent && window.parent.InOb) {
window.parent.$js
window.parent.InOb.onClosePopup();
}
</script>
</body>
</html>
};
return $ret;
}
my $step = 1;
my $ret = '';
$$head .= qq~
<script type="text/javascript">
var urlaction = 'imgupload';
function onCancel () {
window.parent.InOb.onClosePopup();
}
function setTab(tab) {
clearTabs();
\$(tab).className = 'on';
}
function clearTabs() {
\$('tabInsert').className = '';~;
$$head .= qq~
}
</script>
~;
$ret .= "<div class='insob-wrapper' role='dialog' aria-label='Insert Image'>";
$ret .= "<div class='insobjOuter' id='insobjOuter'>";
$ret .= "<form id='insobjform' enctype='multipart/form-data' action='imgupload' method='post' onsubmit='return window.parent.InOb.onSubmit()' >";
$ret .= "<div class='tabs'><ul><li id='tabInsert' class='on'><a href='javascript: void(0);' onclick='window.parent.InOb.showSelectorPage();setTab(\"tabInsert\");return false;'>Insert Image</a></li>";
$ret .= "</ul></div><div id='close'><a href='#close' onclick='onCancel();return false;'>close</a></div>";
# content
$ret .= "<div class='insobjContent' id='img_iframe_holder' style='display: none; margin: 0px 0px 0px 0px;'></div><div id='img_fromwhere' class='insobjContent'>";
$ret .= "<p class='wintitle' id='wintitle'></p>";
$ret .= "<div id='formcontent'>";
$ret .= "<div id='img_error' class='errorbar'></div>";
# from URL
$ret .= "<p class='inputs pkg'>\n";
$ret .= LJ::html_check({
'type' => 'radio',
'name' => 'method',
'id' => 'fromurl',
'class' => 'check',
'value' => 'url',
'selected' => 1,
});
$ret .= "<label for='fromurl' class='left'>Image from URL:</label>";
$ret .= "<span class='inputcontainer'>";
$ret .= LJ::html_text({
'name' => 'url',
'id' => 'fromurlentry',
'size' => '50',
});
$ret .= "</span>";
$ret .= "</p>";
$ret .= "<p class='ex'><strong>$ML{'.insertimage.example'}:</strong> http://www.example.com/some-picture.jpg</p>";
# alt. Indented by 1.5em so in most browsers that lines it up with the form element above.
$ret .= "<p style='margin-left: 1.5em;' class='inputs pkg'>\n";
$ret .= "<label for='alt' class='left'>$ML{'.insertimage.alt.label'}:</label>";
$ret .= "<span class='inputcontainer'>";
$ret .= LJ::html_text({
'name' => 'alt',
'id' => 'alttext',
'size' => '50',
});
$ret .= "</span>";
$ret .= "</p>\n";
my $faq;
unless ( $faq = LJ::Hooks::run_hook( 'faqlink', 'alttext', $ML{'/imgupload.bml.insertimage.alt.faqlink'} ) ) {
$faq = $ML{'/imgupload.bml.insertimage.alt.faqlink'};
}
$ret .= "<p class='ex'>$ML{'.insertimage.alt.body'}$faq.</p>";
$ret .= "</div><!-- end #formcontent -->";
$ret .= "<div class='insobjNav' id='insobjNav'>";
$ret .= "<input type='button' name='btn:prev' id='btnPrev' style='display:none' value='&lt;-- Back' />";
$ret .= LJ::html_submit('btn:next', 'Insert', { 'id' => 'btnNext' }) . "\n";
$ret .= "</div>\n";
$ret .= "</form></div><script type='text/javascript'>window.parent.InOb.setupIframeHandlers();</script>";
$ret .= "</div><!-- end #insob-wrapper -->\n";
$$body = $ret;
$$head .= LJ::res_includes();
return;
}
_code?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Insert Image</title>
<?_code return $_[1]->{'head'}; _code?>
</head>
<body>
<?_code return $_[1]->{'body'}; _code?>
</body>
</html>