2 include 'HTML/QuickForm.php';
4 echo '<script type="text/javascript" src="library/javascript/prototype.js" language="javascript"></script>';
5 echo '<script type="text/javascript" src="library/javascript/scriptaculous.js" language="javascript"></script>';
6 echo '<script type="text/javascript" src="library/cropper/cropper.js" language="javascript"></script>';
10 echo ' <img src="test.jpg" alt="Test image" id="testImage" width="500" height="333" />';
12 echo ' <script type="text/javascript" language="javascript">';
14 echo ' function onEndCrop( coords, dimensions ) {';
15 // echo ' $( "x1" ).value = coords.x1;';
16 // echo ' $( "y1" ).value = coords.y1;';
17 // echo ' $( "x2" ).value = coords.x2;';
18 // echo ' $( "y2" ).value = coords.y2;';
19 // echo ' $( "width" ).value = dimensions.width;';
20 // echo ' $( "height" ).value = dimensions.height;';
21 // echo 'console.log(coords.x1);';
22 // echo 'console.log(coords.x2);';
23 // echo ' style = clip:rect( + coords.x1 + "px " + coords.y1 + "px " + coords.x2 + "px " + coords.y2 + "px)\n"';
25 style = "clip:rect(0px 130px 130px 0px)";
26 $("hidden_0").value = new Array (coords.x1, coords.x2, coords.y1, coords.y2);
27 $("testImage").writeAttribute("style=" style);
30 Event.observe( "button_0", "click", function() { } );
31 // $("file_0").writeAttribute("src", "")
33 new Cropper.Img("testImage", {minWidth: 220,previewWrap: "previewWrap", onEndCrop: onEndCrop });
38 Event.observe( window, "load", function() {
44 echo '<h1> Cropper votre image v0.1</h1>';
46 $label = 'file_default';
48 $form = new HTML_QuickForm ('cropper_form', "", "img-cropped.php", '', 'enctype=multipart/form-data');
50 $form->addElement ('file', 'file_0', $label);
51 $form->addElement ('hidden', 'hidden_0');
52 $form->addElement ('button', 'button_0');
53 $form->updateElementAttr(array('button_0'), array ('id' => 'button_0'));
54 $form->addElement ('submit', 'submit_0', 'Envoyer!');
55 $form->updateElementAttr(array('file_0'), array ('id' => 'file_0'));
56 $form->updateElementAttr(array('hidden_0'), array ('id' => 'hidden_0'));
57 echo $form->toHtml ();
59 if (isset ($_POST['file_0'])):
60 $image = $_POST['file_0'];
62 echo $_POST['file_0'];
64 echo sys_get_temp_dir ();