Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / pholio / view / PholioMockEmbedView.php
blob38b375b68b339e8c5364398656635fbe847b7129
1 <?php
3 final class PholioMockEmbedView extends AphrontView {
5 private $mock;
6 private $images = array();
8 public function setMock(PholioMock $mock) {
9 $this->mock = $mock;
10 return $this;
13 public function setImages(array $images) {
14 $this->images = $images;
15 return $this;
18 public function render() {
19 if (!$this->mock) {
20 throw new PhutilInvalidStateException('setMock');
22 $mock = $this->mock;
24 $images_to_show = array();
25 $thumbnail = null;
26 if (!empty($this->images)) {
27 $images_to_show = array_intersect_key(
28 $this->mock->getActiveImages(), array_flip($this->images));
31 $xform = PhabricatorFileTransform::getTransformByKey(
32 PhabricatorFileThumbnailTransform::TRANSFORM_PINBOARD);
34 if ($images_to_show) {
35 $image = head($images_to_show);
36 $thumbfile = $image->getFile();
37 $header = 'M'.$mock->getID().' '.$mock->getName().
38 ' (#'.$image->getID().')';
39 $uri = '/M'.$this->mock->getID().'/'.$image->getID().'/';
40 } else {
41 $thumbfile = $mock->getCoverFile();
42 $header = 'M'.$mock->getID().' '.$mock->getName();
43 $uri = '/M'.$this->mock->getID();
46 $thumbnail = $thumbfile->getURIForTransform($xform);
47 list($x, $y) = $xform->getTransformedDimensions($thumbfile);
49 $item = id(new PHUIPinboardItemView())
50 ->setUser($this->getUser())
51 ->setObject($mock)
52 ->setHeader($header)
53 ->setURI($uri)
54 ->setImageURI($thumbnail)
55 ->setImageSize($x, $y)
56 ->setDisabled($mock->isClosed())
57 ->addIconCount('fa-picture-o', count($mock->getActiveImages()))
58 ->addIconCount('fa-trophy', $mock->getTokenCount());
60 return $item;