Commit bdcce7bd authored by Clément Démoulins's avatar Clément Démoulins
Browse files

Remove temporary files.

parent a70a602f
<?php
include_once "inc/config.php";
class DisplayPage
{
protected function menu()
{
global $demos;
global $modules;
echo <<<MENU
<div class="layout">
<ul id="list-nav">
<li><img src="images/olena.jpg" border="0" width="25" height="25"></li>
<li><a href="http://www.lrde.epita.fr" target="_parent">LRDE</a></li>
<li><a href="http://olena.lrde.epita.fr" target="_parent">Olena</a></li>
<li><a href="changelog.php">Changelog</a></li>
<li><a href="mailto:olena@lrde.epita.fr">Contact</a></li>
<li class="demoitem">
Demos:
<form name="ex2" method="POST">
<param align="left">
<select name="xfer" size="1"
onChange= "window.location = this.options[this.selectedIndex].value;">
MENU;
// Handling index page entry.
if ("index.php" == basename($_SERVER['PHP_SELF']))
$selected = "selected";
echo "<option value=\"#\"".$selected.">-- Select A Demo</option>";
foreach($modules as $key => $value)
{
print "<optgroup label=\"".$value[1]."\">";
for ($i = 0; $i < sizeof($demos); $i++)
{
// FIXME: not optimal!
if ($demos[$i][3] != $key)
continue;
$script = get_script_name($i);
$selected = "";
if ("$script" == basename($_SERVER['PHP_SELF']))
$selected = "selected";
print "<option value=\"".$script."\" ".$selected.">".get_demo_name($i)."</option>";
}
}
echo<<<MENU
</select>
</param>
</form>
</li>
</ul>
<span style="display:inline-block;width:100%"/>
<span class="lastmodif">
MENU;
echo last_modifications(true);
echo<<<MENU
</span>
<p>&nbsp;</p>
</div>
MENU;
}
protected function page_headers($page)
{
global $base_url;
echo<<<HEADER
<!doctype html><html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE-edge">
<meta content="text/html; charset="UTF-8" http-equiv="content-type">
<title>Research and Development Laboratory of EPITA - Olena - {$page->page_title()}</title>
<link rel="icon" type="image/png" <href="images/favicon.png" />
<link rel="stylesheet" type="text/css" href="http://www.lrde.epita.fr/twiki/pub/TWiki/PatternSkin/layout.css" />
<link rel="stylesheet" type="text/css" href="http://www.lrde.epita.fr/twiki/pub/Olena/WebPreferences/style.css" />
<link rel="stylesheet" type="text/css" href="{$page->base_url()}/style.css" />
<!-- Add fancyBox main CSS file -->
<link rel="stylesheet" type="text/css" href="$base_url/lib/jquery.fancybox.css?v=2.1.2" media="screen" />
<!-- Add Button helper (this is optional) -->
<link rel="stylesheet" type="text/css" href="$base_url/lib/helpers/jquery.fancybox-buttons.css?v=1.0.5" />
<!-- Add Thumbnail helper (this is optional) -->
<link rel="stylesheet" type="text/css" href="$base_url/lib/helpers/jquery.fancybox-thumbs.css?v=1.0.7" />
<!-- Add jQuery library -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"></script>
<!-- Add mousewheel plugin (this is optional) -->
<script type="text/javascript" src="$base_url/lib/jquery.mousewheel-3.0.6.pack.js"></script>
<!-- Add fancyBox main JS file -->
<script type="text/javascript" src="$base_url/lib/jquery.fancybox.js?v=2.1.3"></script>
<!-- Add Button helper (this is optional) -->
<script type="text/javascript" src="$base_url/lib/helpers/jquery.fancybox-buttons.js?v=1.0.5"></script>
<!-- Add Thumbnail helper (this is optional) -->
<script type="text/javascript" src="$base_url/lib/helpers/jquery.fancybox-thumbs.js?v=1.0.7"></script>
<!-- Add Media helper (this is optional) -->
<script type="text/javascript" src="$base_url/lib/helpers/jquery.fancybox-media.js?v=1.0.5"></script>
<!-- Add jQuery form plugin -->
<script src="http://malsup.github.com/jquery.form.js"></script>
<script type="text/javascript">
$(document).ready(function() {
// Disable animations, change title type
$(".fancybox").fancybox({
openEffect : 'none',
closeEffect: 'none',
prevEffect : 'none',
nextEffect : 'none',
helpers : {
title : {
type : 'inside'
}
}
});
// bind 'my_form' (upload form) and provide a simple callback function
$('#my_form').ajaxForm(function() {
alert("Result should appear!");
});
});
(function() {
var bar = $('.bar');
var percent = $('.percent');
var status = $('#status');
$('my_form').ajaxForm({
beforeSend: function() {
status.empty();
var percentVal = '0%';
bar.width(percentVal)
percent.html(percentVal);
},
uploadProgress: function(event, position, total, percentComplete) {
var percentVal = percentComplete + '%';
bar.width(percentVal)
percent.html(percentVal);
},
complete: function(xhr) {
status.html(xhr.responseText);
}
});
})();
</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-26433563-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
{$page->header_script()}
</script>
</head>
<body class="twikiViewPage;background-color:white" onLoad="{$page->onload()}">
HEADER;
}
// Display the name of the demo and its description.
//
protected function body_preambule($page)
{
// Global Config
global $modules;
echo<<<PREAMBULE
<div class="layout">
<table width="800px" style="border-collapse:collapse;margin:auto;" cellpadding="5" border="1">
<tr>
<td valign="center" align="center"><a href="{$modules[$page->module()][0]}"><img src="images/{$page->module()}_logo.png" border="0" width="60"></a></td>
<td><span class="demotitle">{$page->title()}</span></td>
</tr>
<tr>
<td class="header" width="12%" valign="top">Description</td><td class="cell">{$page->description()}</td></tr><tr>
<td class="header" width="12%" valign="top">Specifications</td><td class="cell">{$page->specifications()}
PREAMBULE;
if ($page->specifications())
echo "<br>";
echo<<<PREAMBULE
Estimated processing time: {$page->estimated_run_time()}</td></tr><tr>
<td class="header" width="12%" valign="top">Status</td><td class="cell">{$page->status()}<br><b>Last update</b>: {$page->last_update()}</td></tr><tr>
</tr>
<tr>
<td class="header" valign="top">Disclaimer</td><td class="cell">We will never use/read/save any uploaded data for personal use. Only the last uploaded file and its associated results are stored on our servers during 15min for technical reasons.</td>
</tr>
</tr>
<tr>
<td valign="top" class="header">Terms and conditions</td><td class="cell">
You are free to use the generated results for any usage.
PREAMBULE;
if ($page->paper())
echo " However, if they are used for research purpose, please refer to our library by citing the following paper:{$page->paper()}.</td></tr>";
echo<<<PREAMBULE
</table>
<span style="margin:43px;"><span class="warning" style="font-weight:bold">Warning</span><span class="warning">: do not open several tabs to send several images at the same time. You may not retrieve the expected results.</span></span>
<br><br>
</div>
PREAMBULE;
}
// Display example images
// FIXME: Move code details into demopage class.
function display_example()
{
if (! isset($_GET['t']))
die("Something is wrong...");
$args = get_example_info($_GET['t']);
$dir = $args[0];
$file = $args[1];
$_SESSION['original_name_lastfile'] = "examples/$dir/input/{$file}.png";
if (! is_valid_file($dir, $file))
{
echo "invalid file";
echo "examples/$dir/input/{$file}.png";
return;
}
display_result($_GET['t'], $dir, $file, "");
}
// Display page footer.
//
function page_footer($page)
{
global $trac_browser_url;
echo "<div class=\"layout\">";
if (have_example_selected())
copyright();
if ($page->type() == "demo" && $page->source_code())
{
$path = str_replace($trac_browser_url, "", $page->source_code());
echo<<<FOOTER
<br>
<br>
<hr>
FOOTER;
if ($page->context())
echo "<span id=\"context\">{$page->context()}</span>";
echo<<<FOOTER
<br/><br/><b>Source code</b> is released under <a href="http://www.gnu.org/licenses/gpl-2.0.html" target="_parent">GNU GPLv2 license</a> in our Git repository (See <a href="http://www.lrde.epita.fr/cgi-bin/twiki/view/Olena/Download" target="_parent"> Download section</a>) and available online in <a href="{$page->source_code()}">$path</a>.</td>
<br/>
<br/>
<hr>
FOOTER;
}
else
{
echo "<br><br><hr>";
}
echo<<<FOOTER
<p style="text-align:center">
<a href="http://olena.lrde.epita.fr"><img src="http://www.lrde.epita.fr/dload/olena/logos/powered_by_olena.png" border="0" width="102" height="27"></a></center>
<br><a href="http://www.epita.fr"><img src="images/epita_logo.png" width="90" height="56"></a> - Copyright (C) 2010-2012 EPITA Research and Development Laboratory (<a href="http://www.lrde.epita.fr">LRDE</a>) - <a href="http://www.lrde.epita.fr"><img src="images/lrde_logo.png" width="64" height="52"></a>
</p>
</div>
</body>
</html>
FOOTER;
}
protected function content($page)
{
echo $page->content();
}
protected function display_form($page)
{
$page->display_form();
}
protected function display_results($page)
{
$page->display_results();
}
protected function display_wait_for_action($page)
{
echo <<<DISPLAY
<div id="result-area">
Results will be displayed here.
</div>
DISPLAY;
return;
}
public function displayDemo(PageDemo $page)
{
$this->page_headers($page);
$this->menu();
if ($page->type() == "demo")
{
$this->body_preambule($page);
$this->display_form($page);
if (have_uploaded_file())
$this->display_results($page);
else if (have_example_selected())
$this->display_example($page);
else
$this->display_wait_for_action($page);
}
else if ($page->type() == "info")
{
}
$this->page_footer($page);
}
public function displayInfo(PageInfo $page)
{
$this->page_headers($page);
$this->menu();
$this->content($page);
$this->page_footer($page);
}
};
\ No newline at end of file
<?php
// Return the full name of a given demo.
function get_demo_name($t)
{
global $demos;
if ($t > sizeof($demos) || $t < 0)
return "";
return $demos[$t][0];
}
// Return the corresponding php script name.
function get_script_name($t)
{
global $demos;
if ($t > sizeof($demos) || $t < 0)
return "";
return $demos[$t][1];
}
// Return the corresponding example path.
function get_example_dir($t)
{
global $demos;
if ($t > sizeof($demos) || $t < 0)
return "";
return $demos[$t][2];
}
function copyright()
{
if (!have_example_selected())
return;
$args = get_example_info($_GET['t']);
$dir = $args[0];
$file = $args[1];
if (! is_valid_file($dir, $file))
return;
if ($dir == "doc")
{
switch ($file)
{
case 1:
echo "<b>Source <a href='http://commons.wikimedia.org/wiki/File:Kongebrev_front_1850_old_document_100.jpg'>Wikimedia commons</a></b>";
break;
case 2:
echo "<b>Source <a href='http://commons.wikimedia.org/wiki/File:Kanonismospolykatoikias.jpg'>Wikimedia commons</a></b>";
break;
case 3:
echo "<b>Source <a href='http://commons.wikimedia.org/wiki/File:Lettera_Boratto_p1.JPG'>Wikimedia commons</a></b>";
break;
case 4:
echo "<b>Source <a href='http://commons.wikimedia.org/wiki/File:Petit_Francais_150.jpg'>Wikimedia commons</a></b>";
break;
case 5:
echo "<b>Copyright Himalayan Academy Publications, Kapaa, Kauai, Hawaii - Source <a href='http://commons.wikimedia.org/wiki/File:January_2007,_Hinduism_Today.jpg'>wikimedia</a></b>";
break;
case 6:
echo "<b>Source <a href='http://commons.wikimedia.org/wiki/File:Deutsches_Reichsgesetzblatt_1901_027_227.jpg'>Wikimedia commons</a></b>";
break;
default:
echo "<b>Source Wikimedia commons</b>";
break;
}
}
else if ($dir == "pic")
{
switch ($file)
{
case 2:
echo "<b>Source <a href='http://commons.wikimedia.org/wiki/File:Real-Estate-Signs-Building.jpg'>Wikimedia commons</a></b>";
break;
case 3:
echo "<b>Source <a href='http://commons.wikimedia.org/wiki/File:Skyline_Drive_Truck_Signs.jpg'>Wikimedia commons</a></b>";
break;
case 4:
echo "<b>Shangai, 18/01/2008, Copyright AFP/Mark Ralston.</b>";
break;
default:
echo "<b>Source Wikimedia commons</b>";
break;
}
}
else if ($dir == "docsnr")
{
switch($file)
{
case 1:
echo "<b>Original document: News of the Industry, April 1947, Source <a href='http://www.flickr.com/photos/hugo90/4079123260/'>John Lloyd on Flickr.</a></b>";
break;
case 2:
echo "<b>Original document: Gotham Magazine February 2008, Source <a href='http://www.flickr.com/photos/84568447@N00/2249778718/'>Fred Seibert on Flickr.</a></b>";
break;
case 3:
echo "<b>Original document: <a href='http://www.ljsl.com'>Le journal de saone et loire</a>, mars 2009, Source <a href='http://www.flickr.com/photos/benkamorvan/4231062698/'>Benoit Kubiak on Flickr.</a></b>";
break;
default:
echo "<b>Source Wikimedia commons</b>";
break;
}
}
else if ($dir == "showthrough")
{
switch($file)
{
case 1:
echo "<b>News of the Industry, April 1947, source <a href='http://www.flickr.com/photos/hugo90/4079123260/'>John Lloyd on Flickr.</a></b>";
break;
case 2:
echo "<b>Forbes Magazine, 2007, source <a href='http://www.flickr.com/photos/ideali/803512404/'>on Flickr.</a></b>";
break;
case 3:
echo "<b>The Cosby Show, The Economist, July 10th 2004, source <a href='http://www.flickr.com/photos/w5nyv/66004688/'>Abraxas3d on Flickr.</a></b>";
break;
case 4:
echo "<b>Maximum Branding, Nascom featured, Yet Another Magazine, source <a href='http://www.flickr.com/photos/heymans/431508040/'>Bert Heymans on Flick.</a></b>";
break;
case 5:
echo "<b>Source <a href='http://commons.wikimedia.org/wiki/File:AlbaniaPeriodical.jpg'>Wikimedia commons</a></b>";
break;
default:
echo "<b>Source Wikimedia commons</b>";
break;
}
}
else if ($dir == "regadjgraph")
{
switch($file)
{
case 2:
echo "<b>Source <a href='http://commons.wikimedia.org/wiki/File:Mural_in_Northeast_Pavillion,_Thomas_Jefferson_Building_by_Elmer_E._Garnsey_11670u_edit.jpg'>Wikimedia commons</a></b>";
}
}
}
// Generic result display function
//
function display_result($t, $dir, $file, $output)
{
switch($t)
{
default:
if (have_example_selected())
{
$res1 = "examples/$dir/results/{$file}_1.png";
$res2 = "examples/$dir/results/{$file}_2.png";
display_image_result($output, 'time_functor', $res1, $res2, false);
}
else
display_image_result($output);
break;
case 2:
if (have_example_selected())
{
$res1 = "examples/$dir/results/{$file}.pdf";
$res2 = "examples/$dir/results/{$file}.html";
$res3 = "examples/$dir/results/{$file}_page.xml";
$regions = "examples/$dir/results/{$file}_regions.png";
$fullres = "examples/$dir/input/{$file}.jpg";
display_docsnr_result($res1, $res2, $res3, $regions, $fullres, false);
}
else
display_docsnr_result();
break;
}
}
// Display the upload form.
//
function make_form($page, $caption, $options_functor = '')
{
global $base_url;
echo <<<FORM
<div class="layout">
<form name='my_form' id='my_form' action='{$_SERVER['PHP_SELF']}' enctype='multipart/form-data' method='post'>
<table class="tables" cellpadding="5" border="1">
FORM;
$size_mo = $page->file_size_limit() / 1048576;
$id = $page->id();
if (isset($_GET['t']))
{
$args = get_example_info($_GET['t']);
$selected = $args[1];
}
echo <<<FORM
<tr>
<td class="header" style="text-indent:10px;">Choose one of the examples</td>
<td class="header" style="text-indent:10px;">Upload an image</td>
</tr>
<tr>
<td><iframe src='$base_url/thumbs.php?t=$id&s=$selected' width='100%' height='142px' scrolling='auto' frameborder='0'></iframe></td>
<td style="width:45%;text-indent:20px">It must fulfill the following conditions:
<br><lu>
<li>JPG, PNG, PNM, GIF, BMP</li>
<li> $size_mo MB maximum. </li>
</lu>
<p><input type='file' name='datafile' size='40'></p>
<input type='hidden' name='MAX_FILE_SIZE' value='{$page->file_size_limit()}' />
<div class="progress">
<div class="bar"></div >
<div class="percent">0%</div >
</div>
<div id="status"></div>
FORM;
// No option, the 'send' button is set up here.
if (!$options_functor)
echo <<<FORM
<br>
<div style="text-align:right"><input name='submit' type='submit' value='$caption'></div></form></td>
FORM;
echo <<<FORM
</tr>
</table>
FORM;