part.cropphoto.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. $id = $_['id'];
  3. $tmpkey = $_['tmpkey'];
  4. $requesttoken = $_['requesttoken'];
  5. OCP\Util::writeLog('contacts','templates/part.cropphoto.php: tmpkey: '.$tmpkey, OCP\Util::DEBUG);
  6. ?>
  7. <script type="text/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. <?php if(OC_Cache::hasKey($tmpkey)) { ?>
  42. <img id="cropbox" src="<?php echo OCP\Util::linkToAbsolute('contacts', 'tmpphoto.php'); ?>?tmpkey=<?php echo $tmpkey; ?>" />
  43. <form id="cropform"
  44. class="coords"
  45. method="post"
  46. enctype="multipart/form-data"
  47. target="crop_target"
  48. action="<?php echo OCP\Util::linkToAbsolute('contacts', 'ajax/savecrop.php'); ?>">
  49. <input type="hidden" id="id" name="id" value="<?php echo $id; ?>" />
  50. <input type="hidden" name="requesttoken" value="<?php echo $requesttoken; ?>">
  51. <input type="hidden" id="tmpkey" name="tmpkey" value="<?php echo $tmpkey; ?>" />
  52. <fieldset id="coords">
  53. <input type="hidden" id="x1" name="x1" value="" />
  54. <input type="hidden" id="y1" name="y1" value="" />
  55. <input type="hidden" id="x2" name="x2" value="" />
  56. <input type="hidden" id="y2" name="y2" value="" />
  57. <input type="hidden" id="w" name="w" value="" />
  58. <input type="hidden" id="h" name="h" value="" />
  59. </fieldset>
  60. <iframe name="crop_target" id='crop_target' src=""></iframe>
  61. </form>
  62. <?php
  63. } else {
  64. echo $l->t('The temporary image has been removed from cache.');
  65. }
  66. ?>