Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/pholio/remarkup/PholioRemarkupRule.php b/src/applications/pholio/remarkup/PholioRemarkupRule.php
index 2b1ca0f876..00025b6326 100644
--- a/src/applications/pholio/remarkup/PholioRemarkupRule.php
+++ b/src/applications/pholio/remarkup/PholioRemarkupRule.php
@@ -1,85 +1,88 @@
<?php
final class PholioRemarkupRule extends PhabricatorObjectRemarkupRule {
protected function getObjectNamePrefix() {
return 'M';
}
protected function getObjectIDPattern() {
// Match "M123", "M123/456", and "M123/456/". Users can hit the latter
// forms when clicking comment anchors on a mock page.
return '[1-9]\d*(?:/[1-9]\d*/?)?';
}
protected function getObjectHref(
$object,
PhabricatorObjectHandle $handle,
$id) {
$href = $handle->getURI();
// If the ID has a `M123/456` component, link to that specific image.
$id = explode('/', $id);
if (isset($id[1])) {
$href = $href.'/'.$id[1].'/';
}
if ($this->getEngine()->getConfig('uri.full')) {
$href = PhabricatorEnv::getURI($href);
}
return $href;
}
protected function loadObjects(array $ids) {
// Strip off any image ID components of the URI.
$map = array();
foreach ($ids as $id) {
$map[head(explode('/', $id))][] = $id;
}
$viewer = $this->getEngine()->getConfig('viewer');
$mocks = id(new PholioMockQuery())
->setViewer($viewer)
->needCoverFiles(true)
->needImages(true)
->needTokenCounts(true)
->withIDs(array_keys($map))
->execute();
$results = array();
foreach ($mocks as $mock) {
$ids = idx($map, $mock->getID(), array());
foreach ($ids as $id) {
$results[$id] = $mock;
}
}
return $results;
}
protected function renderObjectEmbed(
$object,
PhabricatorObjectHandle $handle,
$options) {
+ $viewer = $this->getEngine()->getConfig('viewer');
+
$embed_mock = id(new PholioMockEmbedView())
+ ->setUser($viewer)
->setMock($object);
if (strlen($options)) {
$parser = new PhutilSimpleOptions();
$opts = $parser->parse(substr($options, 1));
if (isset($opts['image'])) {
$images = array_unique(
explode('&', preg_replace('/\s+/', '', $opts['image'])));
$embed_mock->setImages($images);
}
}
return $embed_mock->render();
}
}
diff --git a/src/applications/pholio/view/PholioMockEmbedView.php b/src/applications/pholio/view/PholioMockEmbedView.php
index 3429cfd569..88f2f2ac55 100644
--- a/src/applications/pholio/view/PholioMockEmbedView.php
+++ b/src/applications/pholio/view/PholioMockEmbedView.php
@@ -1,61 +1,63 @@
<?php
final class PholioMockEmbedView extends AphrontView {
private $mock;
private $images = array();
public function setMock(PholioMock $mock) {
$this->mock = $mock;
return $this;
}
public function setImages(array $images) {
$this->images = $images;
return $this;
}
public function render() {
if (!$this->mock) {
throw new PhutilInvalidStateException('setMock');
}
$mock = $this->mock;
$images_to_show = array();
$thumbnail = null;
if (!empty($this->images)) {
$images_to_show = array_intersect_key(
$this->mock->getImages(), array_flip($this->images));
}
$xform = PhabricatorFileTransform::getTransformByKey(
PhabricatorFileThumbnailTransform::TRANSFORM_PINBOARD);
if ($images_to_show) {
$image = head($images_to_show);
$thumbfile = $image->getFile();
$header = 'M'.$mock->getID().' '.$mock->getName().
' (#'.$image->getID().')';
$uri = '/M'.$this->mock->getID().'/'.$image->getID().'/';
} else {
$thumbfile = $mock->getCoverFile();
$header = 'M'.$mock->getID().' '.$mock->getName();
$uri = '/M'.$this->mock->getID();
}
$thumbnail = $thumbfile->getURIForTransform($xform);
list($x, $y) = $xform->getTransformedDimensions($thumbfile);
$item = id(new PHUIPinboardItemView())
+ ->setUser($this->getUser())
+ ->setObject($mock)
->setHeader($header)
->setURI($uri)
->setImageURI($thumbnail)
->setImageSize($x, $y)
->setDisabled($mock->isClosed())
->addIconCount('fa-picture-o', count($mock->getImages()))
->addIconCount('fa-trophy', $mock->getTokenCount());
return $item;
}
}

File Metadata

Mime Type
text/x-diff
Expires
Fri, Oct 31, 2:09 PM (1 d, 10 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
312259
Default Alt Text
(4 KB)

Event Timeline