[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/pholio/view/ -> PholioMockEmbedView.php (source)

   1  <?php
   2  
   3  final class PholioMockEmbedView extends AphrontView {
   4  
   5    private $mock;
   6    private $images = array();
   7  
   8    public function setMock(PholioMock $mock) {
   9      $this->mock = $mock;
  10      return $this;
  11    }
  12  
  13    public function setImages(array $images) {
  14      $this->images = $images;
  15      return $this;
  16    }
  17  
  18    public function render() {
  19      if (!$this->mock) {
  20        throw new Exception('Call setMock() before render()!');
  21      }
  22      $mock = $this->mock;
  23  
  24      $images_to_show = array();
  25      $thumbnail = null;
  26      if (!empty($this->images)) {
  27        $images_to_show = array_intersect_key(
  28          $this->mock->getImages(), array_flip($this->images));
  29      }
  30  
  31      if ($images_to_show) {
  32        foreach ($images_to_show as $image) {
  33          $thumbfile = $image->getFile();
  34          $thumbnail = $thumbfile->getThumb280x210URI();
  35        }
  36        $header = 'M'.$mock->getID().' '.$mock->getName().
  37          ' (#'.$image->getID().')';
  38        $uri = '/M'.$this->mock->getID().'/'.$image->getID().'/';
  39      } else {
  40        $thumbnail = $mock->getCoverFile()->getThumb280x210URI();
  41        $header = 'M'.$mock->getID().' '.$mock->getName();
  42        $uri = '/M'.$this->mock->getID();
  43      }
  44  
  45      $item = id(new PHUIPinboardItemView())
  46        ->setHeader($header)
  47        ->setURI($uri)
  48        ->setImageURI($thumbnail)
  49        ->setImageSize(280, 210)
  50        ->setDisabled($mock->isClosed())
  51        ->addIconCount('fa-picture-o', count($mock->getImages()))
  52        ->addIconCount('fa-trophy', $mock->getTokenCount());
  53  
  54      return $item;
  55    }
  56  
  57  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1