<?php

	define('IN_HUGLO', true);
	require_once('./../includes/constants.php');
	require_once(ROOT_PATH . 'cp/includes/sessions.php');
	
?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head>
<title>Huglo Lepage &bull; Administration</title>
<link href="global.css" rel="stylesheet" type="text/css" media="all" />
<!--[if lte IE 7]><script type="text/javascript" src="http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js"></script><![endif]-->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/mootools/1.2.2/mootools.js"></script>
<script type="text/javascript" src="js/Swiff.Uploader.js"></script>
<script type="text/javascript" src="js/Fx.ProgressBar.js"></script>
<script type="text/javascript" src="http://github.com/mootools/mootools-more/raw/master/Source/Core/Lang.js"></script>
<script type="text/javascript" src="js/FancyUpload2.js"></script>
<script type="text/javascript">
window.addEvent('domready', function() { // wait for the content

	// our uploader instance 
	
	var up = new FancyUpload2($('demo-status'), $('demo-list'), { // options object
		// we console.log infos, remove that in production!!
		verbose: true,
		
		// url is read from the form, so you just have to change one place
		url: $('form-demo').action,
		
		// path to the SWF file
		path: 'js/Swiff.Uploader.swf',
		
		// remove that line to select all files, or edit it, add more items
		typeFilter: {
			'Vidéo FLV (*.flv)': '*.flv',
			'Fichier PDF (*.pdf)': '*.pdf'
		},
		
		// this is our browse button, *target* is overlayed with the Flash movie
		target: 'demo-browse',
		
		// graceful degradation, onLoad is only called if all went well with Flash
		onLoad: function() {
			$('demo-status').removeClass('hide'); // we show the actual UI
			$('demo-fallback').destroy(); // ... and hide the plain form
			
			// We relay the interactions with the overlayed flash to the link
			this.target.addEvents({
				click: function() {
					return false;
				},
				mouseenter: function() {
					this.addClass('hover');
				},
				mouseleave: function() {
					this.removeClass('hover');
					this.blur();
				},
				mousedown: function() {
					this.focus();
				}
			});

			// Interactions for the 2 other buttons
			
			$('demo-clear').addEvent('click', function() {
				up.remove(); // remove all files
				return false;
			});

			$('demo-upload').addEvent('click', function() {
				up.start(); // start upload
				return false;
			});
		},
		
		// Edit the following lines, it is your custom event handling
		
		/**
		 * Is called when files were not added, "files" is an array of invalid File classes.
		 * 
		 * This example creates a list of error elements directly in the file list, which
		 * hide on click.
		 */ 
		onSelectFail: function(files) {
			files.each(function(file) {
				new Element('li', {
					'class': 'validation-error',
					html: file.validationErrorMessage || file.validationError,
					title: MooTools.lang.get('FancyUpload', 'removeTitle'),
					events: {
						click: function() {
							this.destroy();
						}
					}
				}).inject(this.list, 'top');
			}, this);
		},
		
		/**
		 * This one was directly in FancyUpload2 before, the event makes it
		 * easier for you, to add your own response handling (you probably want
		 * to send something else than JSON or different items).
		 */
		onFileSuccess: function(file, response) {
			var json = new Hash(JSON.decode(response, true) || {});
			
			if (json.get('status') == '1') {
				file.element.addClass('file-success');
				file.info.set('html', '<br /><strong>Transfert OK</strong>');
			} else {
				file.element.addClass('file-failed');
				file.info.set('html', '<br /><strong>Erreur pendant le transfert</strong>');
			}
		},
		
		/**
		 * onFail is called when the Flash movie got bashed by some browser plugin
		 * like Adblock or Flashblock.
		 */
		onFail: function(error) {
			switch (error) {
				case 'hidden': // works after enabling the movie and clicking refresh
					alert('To enable the embedded uploader, unblock it in your browser and refresh (see Adblock).');
					break;
				case 'blocked': // This no *full* fail, it works after the user clicks the button
					alert('To enable the embedded uploader, enable the blocked Flash movie (see Flashblock).');
					break;
				case 'empty': // Oh oh, wrong path
					alert('A required file was not found, please be patient and we fix this.');
					break;
				case 'flash': // no flash 9+ :(
					alert('To enable the embedded uploader, install the latest Adobe Flash plugin.')
			}
		}
		
	});
	
});
		//]]>
</script>
<body>
<?php include('menu.php'); ?>
<h1>Transfert de vidéo</h1>
<form action="upload.php?PHPSESSID=<?php echo session_id(); ?>" method="post" enctype="multipart/form-data" id="form-demo">
<table id="demo-status" class="hide">
	<tr>
		<td width="30%" class="bggrey">Choisissez les fichiers vidéos</td>
		<td width="70%">
			<input type="button" name="demo-browse" id="demo-browse" value="Parcourir..." class="bouton" /> - <a href="#" id="demo-clear">Vider la liste</a>
			<fieldset id="demo-fallback">
				<label for="demo-photoupload"><input type="file" name="Filedata" /></label>
			</fieldset>
		</td>
	</tr>
	<tr>
		<td class="bggrey">Informations</td>
		<td>
			<strong class="overall-title"></strong>
			<span class="progress overall-progress"></span><br /><br />
			<strong class="current-title"></strong>
			<span class="progress current-progress"></span>
			<ul id="demo-list"></ul>
			<div class="current-text"></div>
		</td>
	</tr>
	<tr>
		<td><input type="button" name="demo-upload" id="demo-upload" value="Lancer le transfert" class="bouton" /></td>
		<td>&nbsp;</td>
	</tr>
</table>
</form>
</body>
</html>
