Something went wrong. Try again.
@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
Something went wrong. Try again.
1.5 kB · 71 lines
PHP
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172<?php
final class PasteEmbedView extends AphrontView {
private $paste; private $handle; private $highlights = array(); private $lines = 24;
public function setPaste(PhabricatorPaste $paste) { $this->paste = $paste; return $this; }
public function setHandle(PhabricatorObjectHandle $handle) { $this->handle = $handle; return $this; }
public function setHighlights(array $highlights) { $this->highlights = $highlights; return $this; }
public function setLines($lines) { $this->lines = $lines; return $this; }
public function render() { if (!$this->paste) { throw new PhutilInvalidStateException('setPaste'); }
$lines = phutil_split_lines($this->paste->getContent()); require_celerity_resource('paste-css');
$link = phutil_tag( 'a', array( 'href' => '/P'.$this->paste->getID(), ), $this->handle->getFullName());
$head = phutil_tag( 'div', array( 'class' => 'paste-embed-head', ), $link);
$body_attributes = array('class' => 'paste-embed-body'); if ($this->lines != null) { $body_attributes['style'] = 'max-height: '.$this->lines * (1.15).'em;'; }
$body = phutil_tag( 'div', $body_attributes, id(new PhabricatorSourceCodeView()) ->setLines($lines) ->setHighlights($this->highlights) ->disableHighlightOnClick());
return phutil_tag( 'div', array('class' => 'paste-embed'), array($head, $body));
}}