part.cropphoto.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. $id = $_['id'];
  3. $tmp_path = $_['tmp_path'];
  4. $requesttoken = $_['requesttoken'];
  5. OCP\Util::writeLog('contacts','templates/part.cropphoto.php: tmp_path: '.$tmp_path.', exists: '.file_exists($tmp_path), OCP\Util::DEBUG);
  6. ?>
  7. <script language="Javascript">
  8. jQuery(function($) {
  9. $('#cropbox').Jcrop({
  10. onChange: showCoords,
  11. onSelect: showCoords,
  12. onRelease: clearCoords,
  13. maxSize: [399, 399],
  14. bgColor: 'black',
  15. bgOpacity: .4,
  16. boxWidth: 400,
  17. boxHeight: 400,
  18. setSelect: [ 100, 130, 50, 50 ]//,
  19. //aspectRatio: 0.8
  20. });
  21. });
  22. // Simple event handler, called from onChange and onSelect
  23. // event handlers, as per the Jcrop invocation above
  24. function showCoords(c) {
  25. $('#x1').val(c.x);
  26. $('#y1').val(c.y);
  27. $('#x2').val(c.x2);
  28. $('#y2').val(c.y2);
  29. $('#w').val(c.w);
  30. $('#h').val(c.h);
  31. };
  32. function clearCoords() {
  33. $('#coords input').val('');
  34. };
  35. /*
  36. $('#coords').submit(function() {
  37. alert('Handler for .submit() called.');
  38. return true;
  39. });*/
  40. </script>
  41. <img id="cropbox" src="<?php echo OCP\Util::linkToAbsolute('contacts', 'dynphoto.php'); ?>?tmp_path=<?php echo urlencode($tmp_path); ?>" />
  42. <form id="cropform"
  43. class="coords"
  44. method="post"
  45. enctype="multipart/form-data"
  46. target="crop_target"
  47. action="<?php echo OCP\Util::linkToAbsolute('contacts', 'ajax/savecrop.php'); ?>">
  48. <input type="hidden" id="id" name="id" value="<?php echo $id; ?>" />
  49. <input type="hidden" id="requesttoken" name="requesttoken" value="<?php echo $requesttoken; ?>" />
  50. <input type="hidden" id="tmp_path" name="tmp_path" value="<?php echo $tmp_path; ?>" />
  51. <fieldset id="coords">
  52. <input type="hidden" id="x1" name="x1" value="" />
  53. <input type="hidden" id="y1" name="y1" value="" />
  54. <input type="hidden" id="x2" name="x2" value="" />
  55. <input type="hidden" id="y2" name="y2" value="" />
  56. <input type="hidden" id="w" name="w" value="" />
  57. <input type="hidden" id="h" name="h" value="" />
  58. </fieldset>
  59. <iframe name="crop_target" id='crop_target' src=""></iframe>
  60. </form>