mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-11 17:32:41 +01:00
1e8d20d9fc
Summary: Probably not the ideal way to deal showing only certain amount of lines. Size vary by browsers, zooming will mess it up albeit only a little and will definitely not work with IE. Test Plan: {F35989} Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T1770 Differential Revision: https://secure.phabricator.com/D5347
60 lines
1.5 KiB
PHP
60 lines
1.5 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @group markup
|
|
*/
|
|
final class PhabricatorPasteRemarkupRule
|
|
extends PhabricatorRemarkupRuleObject {
|
|
|
|
protected function getObjectNamePrefix() {
|
|
return 'P';
|
|
}
|
|
|
|
protected function loadObjects(array $ids) {
|
|
$viewer = $this->getEngine()->getConfig('viewer');
|
|
|
|
return id(new PhabricatorPasteQuery())
|
|
->setViewer($viewer)
|
|
->withIDs($ids)
|
|
->needContent(true)
|
|
->execute();
|
|
|
|
}
|
|
|
|
protected function renderObjectEmbed($object, $handle, $options) {
|
|
$embed_paste = id(new PasteEmbedView())
|
|
->setPaste($object)
|
|
->setHandle($handle);
|
|
|
|
if (strlen($options)) {
|
|
$parser = new PhutilSimpleOptions();
|
|
$opts = $parser->parse(substr($options, 1));
|
|
|
|
foreach ($opts as $key => $value) {
|
|
if ($key == 'lines') {
|
|
$embed_paste->setLines(preg_replace('/[^0-9]/', '', $value));
|
|
} else if ($key == 'highlight') {
|
|
$highlights = preg_split('/,|&/', preg_replace('/\s+/', '', $value));
|
|
|
|
$to_highlight = array();
|
|
foreach ($highlights as $highlight) {
|
|
$highlight = explode('-', $highlight);
|
|
|
|
if (!empty($highlight)) {
|
|
sort($highlight);
|
|
$to_highlight = array_merge(
|
|
$to_highlight,
|
|
range(head($highlight), last($highlight)));
|
|
}
|
|
}
|
|
|
|
$embed_paste->setHighlights(array_unique($to_highlight));
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
return $embed_paste->render();
|
|
|
|
}
|
|
}
|