Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/paste/view/PasteEmbedView.php b/src/applications/paste/view/PasteEmbedView.php
index 62014ad919..fa3295e2cb 100644
--- a/src/applications/paste/view/PasteEmbedView.php
+++ b/src/applications/paste/view/PasteEmbedView.php
@@ -1,69 +1,70 @@
<?php
final class PasteEmbedView extends AphrontView {
private $paste;
private $handle;
private $highlights = array();
private $lines = 30;
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;
}
public function render() {
if (!$this->paste) {
throw new Exception("Call setPaste() before render()!");
}
$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));
+ ->setHighlights($this->highlights)
+ ->disableHighlightOnClick());
return phutil_tag(
'div',
array('class' => 'paste-embed'),
array($head, $body));
}
}
diff --git a/src/view/layout/PhabricatorSourceCodeView.php b/src/view/layout/PhabricatorSourceCodeView.php
index 717de7f60c..b8396b78b2 100644
--- a/src/view/layout/PhabricatorSourceCodeView.php
+++ b/src/view/layout/PhabricatorSourceCodeView.php
@@ -1,118 +1,133 @@
<?php
final class PhabricatorSourceCodeView extends AphrontView {
private $lines;
private $limit;
private $uri;
private $highlights = array();
+ private $canClickHighlight = true;
public function setLimit($limit) {
$this->limit = $limit;
return $this;
}
public function setLines(array $lines) {
$this->lines = $lines;
return $this;
}
public function setURI(PhutilURI $uri) {
$this->uri = $uri;
return $this;
}
public function setHighlights(array $array) {
$this->highlights = array_fuse($array);
return $this;
}
+ public function disableHighlightOnClick() {
+ $this->canClickHighlight = false;
+ return $this;
+ }
+
public function render() {
require_celerity_resource('phabricator-source-code-view-css');
require_celerity_resource('syntax-highlighting-css');
Javelin::initBehavior('phabricator-oncopy', array());
- Javelin::initBehavior('phabricator-line-linker');
+ if ($this->canClickHighlight) {
+ Javelin::initBehavior('phabricator-line-linker');
+ }
$line_number = 1;
$rows = array();
foreach ($this->lines as $line) {
$hit_limit = $this->limit &&
($line_number == $this->limit) &&
(count($this->lines) != $this->limit);
if ($hit_limit) {
$content_number = '';
$content_line = phutil_tag(
'span',
array(
'class' => 'c',
),
pht('...'));
} else {
$content_number = $line_number;
$content_line = hsprintf("\xE2\x80\x8B%s", $line);
}
$row_attributes = array();
if (isset($this->highlights[$line_number])) {
$row_attributes['class'] = 'phabricator-source-highlight';
}
- $line_uri = $this->uri . "$" . $line_number;
- $line_href = (string) new PhutilURI($line_uri);
+ if ($this->canClickHighlight) {
+ $line_uri = $this->uri . "$" . $line_number;
+ $line_href = (string) new PhutilURI($line_uri);
- $tag_number = javelin_tag(
- 'a',
- array(
- 'href' => $line_href
- ),
- $line_number);
+ $tag_number = javelin_tag(
+ 'a',
+ array(
+ 'href' => $line_href
+ ),
+ $line_number);
+ } else {
+ $tag_number = javelin_tag(
+ 'span',
+ array(),
+ $line_number);
+ }
$rows[] = phutil_tag(
'tr',
$row_attributes,
array(
javelin_tag(
'th',
array(
'class' => 'phabricator-source-line',
'sigil' => 'phabricator-source-line'
),
$tag_number),
phutil_tag(
'td',
array(
'class' => 'phabricator-source-code'
),
$content_line)));
if ($hit_limit) {
break;
}
$line_number++;
}
$classes = array();
$classes[] = 'phabricator-source-code-view';
$classes[] = 'remarkup-code';
$classes[] = 'PhabricatorMonospaced';
return phutil_tag(
'div',
array(
'class' => 'phabricator-source-code-container',
),
javelin_tag(
'table',
array(
'class' => implode(' ', $classes),
'sigil' => 'phabricator-source'
),
phutil_implode_html('', $rows)));
}
}

File Metadata

Mime Type
text/x-diff
Expires
Sun, Jul 27, 5:07 PM (1 w, 11 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
186018
Default Alt Text
(5 KB)

Event Timeline