Apache-UploadMeter

 view release on metacpan or  search on metacpan

lib/Apache/UploadMeter/Resources/XML.pm  view on Meta::CPAN

package Apache::UploadMeter::Resources::XML;

# Static resources (XSL/XSD) for the UploadMeter widget

use strict;
use warnings;
use Apache2::RequestRec ();
use Apache2::RequestIO ();
use Apache2::Response ();
use Apache2::Const -compile=>qw(:common);

sub xsl {
    my $r = shift;
    $r->content_type("text/xml; charset=utf-8");
    $r->set_etag();
    return Apache2::Const::OK if $r->header_only();
    my $output=<<'XSL-END';
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
	<xsl:output method="html" indent="yes" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"/>
	<!-- root rule -->
	<xsl:template match="/">
		<xsl:apply-templates/>
	</xsl:template>
	<!-- main rule for document element -->
	<xsl:template match="APACHE_UPLOADMETER">
		<html>
			<head>
				<title>Downloading <xsl:value-of select="@FILE"/>
				</title>
			</head>
			<body style="background-color: #D0D9DF; text-align: center; margin: 0px 0px 0px 0px;">
				<span style="text-align: center; font-face: Arial; font-size: 12pt;">
					<span style="text-align: center; font-size: 14pt; font-weight: bold;">Apache Upload Meter</span>
					<table width="100%" border="0" cellspacing="5" cellpadding="0">
						<tbody>
							<tr>
								<td width="30%" align="right">Filename:</td>
								<td width="70%" align="left">
									<xsl:value-of select="@FILE"/>
								</td>
							</tr>
							<tr>
								<td align="right">Status:</td>
								<td align="left">
									<xsl:choose>
										<xsl:when test="@FINISHED = 1"><font color="#667799">Transfer complete  (<xsl:value-of select="TOTAL"/>)</font></xsl:when>
										<xsl:otherwise>
											<xsl:value-of select="RECEIVED"/> of <xsl:value-of select="TOTAL"/>
										</xsl:otherwise>
									</xsl:choose>
								</td>
							</tr>
							<tr>
								<td align="right">Elapsed Time:</td>
								<td align="left">
									<xsl:value-of select="ELAPSEDTIME"/>
								</td>
							</tr>
							<tr>
								<td align="right">Remaining Time:</td>
								<td align="left">
								<!--  my $rtime = ($finished) ? 0 : int ($etime / $len * $size) - $etime;-->
<!-- Calculates remaining time, but no formatting available :-(
									<xsl:choose>
										<xsl:when test="@FINISHED = 1">00:00:00</xsl:when>
										<xsl:otherwise>	<xsl:value-of select="((ELAPSEDTIME/@VALUE div RECEIVED/@VALUE) * TOTAL/@VALUE)"/></xsl:otherwise>
									</xsl:choose>-->
									<xsl:value-of select="REMAININGTIME"/>
								</td>
							</tr>
							<tr>
								<td align="right">Rate:</td>
								<td align="left">
									<xsl:value-of select="CURRENTRATE"/> (avg <xsl:value-of select="RATE"/>)</td>
							</tr>
						</tbody>
					</table>
					<br/>
					<xsl:variable name="umwidth" select="400"/>
					<xsl:variable name="received"  select="RECEIVED/@VALUE"/>
					<xsl:variable name="total" select="TOTAL/@VALUE"/>
					<xsl:variable name="percent" select="round($received div $total * 100)"/>
					<xsl:variable name="barwidth" select="round($received div $total * $umwidth)"/>
					<xsl:variable name="leftover" select="$umwidth - $barwidth"/>
					<div align="center">
						<table bgcolor="#667799" border="0" cellpadding="2" cellspacing="0">
							<tbody>
								<tr>
									<td>
										<table border="0" cellpadding="0" cellspacing="0">
											<xsl:attribute name="width"><xsl:value-of select="$umwidth"/></xsl:attribute>



( run in 1.887 second using v1.01-cache-2.11-cpan-f56aa216473 )