[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/paste/view/ -> PasteEmbedView.php (source)

   1  <?php
   2  
   3  final class PasteEmbedView extends AphrontView {
   4  
   5    private $paste;
   6    private $handle;
   7    private $highlights = array();
   8    private $lines = 30;
   9  
  10    public function setPaste(PhabricatorPaste $paste) {
  11      $this->paste = $paste;
  12      return $this;
  13    }
  14  
  15    public function setHandle(PhabricatorObjectHandle $handle) {
  16      $this->handle = $handle;
  17      return $this;
  18    }
  19  
  20    public function setHighlights(array $highlights) {
  21      $this->highlights = $highlights;
  22      return $this;
  23    }
  24  
  25    public function setLines($lines) {
  26      $this->lines = $lines;
  27    }
  28  
  29    public function render() {
  30      if (!$this->paste) {
  31        throw new Exception('Call setPaste() before render()!');
  32      }
  33  
  34      $lines = phutil_split_lines($this->paste->getContent());
  35      require_celerity_resource('paste-css');
  36  
  37      $link = phutil_tag(
  38        'a',
  39        array(
  40          'href' => '/P'.$this->paste->getID(),
  41        ),
  42        $this->handle->getFullName());
  43  
  44      $head = phutil_tag(
  45        'div',
  46        array(
  47          'class' => 'paste-embed-head',
  48        ),
  49        $link);
  50  
  51      $body_attributes = array('class' => 'paste-embed-body');
  52      if ($this->lines != null) {
  53        $body_attributes['style'] = 'max-height: '.$this->lines * (1.15).'em;';
  54      }
  55  
  56      $body = phutil_tag(
  57        'div',
  58        $body_attributes,
  59        id(new PhabricatorSourceCodeView())
  60        ->setLines($lines)
  61        ->setHighlights($this->highlights)
  62        ->disableHighlightOnClick());
  63  
  64      return phutil_tag(
  65        'div',
  66        array('class' => 'paste-embed'),
  67        array($head, $body));
  68  
  69    }
  70  }


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