[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class AphrontFormCropControl extends AphrontFormControl { 4 5 private $width = 50; 6 private $height = 50; 7 8 public function setHeight($height) { 9 $this->height = $height; 10 return $this; 11 } 12 public function getHeight() { 13 return $this->height; 14 } 15 16 public function setWidth($width) { 17 $this->width = $width; 18 return $this; 19 } 20 public function getWidth() { 21 return $this->width; 22 } 23 24 protected function getCustomControlClass() { 25 return 'aphront-form-crop'; 26 } 27 28 protected function renderInput() { 29 $file = $this->getValue(); 30 31 if ($file === null) { 32 return phutil_tag( 33 'img', 34 array( 35 'src' => PhabricatorUser::getDefaultProfileImageURI(), 36 ), 37 ''); 38 } 39 40 $c_id = celerity_generate_unique_node_id(); 41 $metadata = $file->getMetadata(); 42 $scale = PhabricatorImageTransformer::getScaleForCrop( 43 $file, 44 $this->getWidth(), 45 $this->getHeight()); 46 47 Javelin::initBehavior( 48 'aphront-crop', 49 array( 50 'cropBoxID' => $c_id, 51 'width' => $this->getWidth(), 52 'height' => $this->getHeight(), 53 'scale' => $scale, 54 'imageH' => $metadata[PhabricatorFile::METADATA_IMAGE_HEIGHT], 55 'imageW' => $metadata[PhabricatorFile::METADATA_IMAGE_WIDTH], 56 )); 57 58 return javelin_tag( 59 'div', 60 array( 61 'id' => $c_id, 62 'sigil' => 'crop-box', 63 'mustcapture' => true, 64 'class' => 'crop-box', 65 ), 66 array( 67 javelin_tag( 68 'img', 69 array( 70 'src' => $file->getBestURI(), 71 'class' => 'crop-image', 72 'sigil' => 'crop-image', 73 ), 74 ''), 75 javelin_tag( 76 'input', 77 array( 78 'type' => 'hidden', 79 'name' => 'image_x', 80 'sigil' => 'crop-x', 81 ), 82 ''), 83 javelin_tag( 84 'input', 85 array( 86 'type' => 'hidden', 87 'name' => 'image_y', 88 'sigil' => 'crop-y', 89 ), 90 ''), 91 )); 92 } 93 94 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |