Page MenuHomePhabricator

D19921.diff
No OneTemporary

D19921.diff

diff --git a/src/applications/pholio/controller/PholioMockCommentController.php b/src/applications/pholio/controller/PholioMockCommentController.php
--- a/src/applications/pholio/controller/PholioMockCommentController.php
+++ b/src/applications/pholio/controller/PholioMockCommentController.php
@@ -24,7 +24,7 @@
$draft = PhabricatorDraft::buildFromRequest($request);
- $mock_uri = '/M'.$mock->getID();
+ $mock_uri = $mock->getURI();
$comment = $request->getStr('comment');
@@ -33,7 +33,7 @@
$inline_comments = id(new PholioTransactionComment())->loadAllWhere(
'authorphid = %s AND transactionphid IS NULL AND imageid IN (%Ld)',
$viewer->getPHID(),
- mpull($mock->getImages(), 'getID'));
+ mpull($mock->getActiveImages(), 'getID'));
if (!$inline_comments || strlen($comment)) {
$xactions[] = id(new PholioTransaction())
diff --git a/src/applications/pholio/controller/PholioMockEditController.php b/src/applications/pholio/controller/PholioMockEditController.php
--- a/src/applications/pholio/controller/PholioMockEditController.php
+++ b/src/applications/pholio/controller/PholioMockEditController.php
@@ -25,7 +25,7 @@
$title = pht('Edit Mock: %s', $mock->getName());
$is_new = false;
- $mock_images = $mock->getImages();
+ $mock_images = $mock->getActiveImages();
$files = mpull($mock_images, 'getFile');
$mock_images = mpull($mock_images, null, 'getFilePHID');
} else {
diff --git a/src/applications/pholio/query/PholioMockQuery.php b/src/applications/pholio/query/PholioMockQuery.php
--- a/src/applications/pholio/query/PholioMockQuery.php
+++ b/src/applications/pholio/query/PholioMockQuery.php
@@ -58,7 +58,7 @@
}
protected function loadPage() {
- $mocks = $this->loadStandardPage(new PholioMock());
+ $mocks = $this->loadStandardPage($this->newResultObject());
if ($mocks && $this->needImages) {
self::loadImages($this->getViewer(), $mocks, $this->needInlineComments);
@@ -127,9 +127,7 @@
foreach ($mocks as $mock) {
$mock_images = idx($image_groups, $mock->getPHID(), array());
- $mock->attachAllImages($mock_images);
- $active_images = mfilter($mock_images, 'getIsObsolete', true);
- $mock->attachImages(msort($active_images, 'getSequence'));
+ $mock->attachImages($mock_images);
}
}
diff --git a/src/applications/pholio/query/PholioMockSearchEngine.php b/src/applications/pholio/query/PholioMockSearchEngine.php
--- a/src/applications/pholio/query/PholioMockSearchEngine.php
+++ b/src/applications/pholio/query/PholioMockSearchEngine.php
@@ -111,7 +111,7 @@
->setImageURI($image_uri)
->setImageSize($x, $y)
->setDisabled($mock->isClosed())
- ->addIconCount('fa-picture-o', count($mock->getImages()))
+ ->addIconCount('fa-picture-o', count($mock->getActiveImages()))
->addIconCount('fa-trophy', $mock->getTokenCount());
if ($mock->getAuthorPHID()) {
diff --git a/src/applications/pholio/storage/PholioMock.php b/src/applications/pholio/storage/PholioMock.php
--- a/src/applications/pholio/storage/PholioMock.php
+++ b/src/applications/pholio/storage/PholioMock.php
@@ -30,7 +30,6 @@
protected $spacePHID;
private $images = self::ATTACHABLE;
- private $allImages = self::ATTACHABLE;
private $coverFile = self::ATTACHABLE;
private $tokenCount = self::ATTACHABLE;
@@ -93,33 +92,28 @@
return parent::save();
}
- /**
- * These should be the images currently associated with the Mock.
- */
public function attachImages(array $images) {
assert_instances_of($images, 'PholioImage');
+ $images = mpull($images, null, 'getPHID');
+ $images = msort($images, 'getSequence');
$this->images = $images;
return $this;
}
public function getImages() {
- $this->assertAttached($this->images);
- return $this->images;
+ return $this->assertAttached($this->images);
}
- /**
- * These should be *all* images associated with the Mock. This includes
- * images which have been removed and / or replaced from the Mock.
- */
- public function attachAllImages(array $images) {
- assert_instances_of($images, 'PholioImage');
- $this->allImages = $images;
- return $this;
- }
+ public function getActiveImages() {
+ $images = $this->getImages();
+
+ foreach ($images as $phid => $image) {
+ if ($image->getIsObsolete()) {
+ unset($images[$phid]);
+ }
+ }
- public function getAllImages() {
- $this->assertAttached($this->images);
- return $this->allImages;
+ return $images;
}
public function attachCoverFile(PhabricatorFile $file) {
@@ -143,7 +137,7 @@
}
public function getImageHistorySet($image_id) {
- $images = $this->getAllImages();
+ $images = $this->getImages();
$images = mpull($images, null, 'getID');
$selected_image = $images[$image_id];
diff --git a/src/applications/pholio/view/PholioMockEmbedView.php b/src/applications/pholio/view/PholioMockEmbedView.php
--- a/src/applications/pholio/view/PholioMockEmbedView.php
+++ b/src/applications/pholio/view/PholioMockEmbedView.php
@@ -25,7 +25,7 @@
$thumbnail = null;
if (!empty($this->images)) {
$images_to_show = array_intersect_key(
- $this->mock->getImages(), array_flip($this->images));
+ $this->mock->getActiveImages(), array_flip($this->images));
}
$xform = PhabricatorFileTransform::getTransformByKey(
@@ -54,7 +54,7 @@
->setImageURI($thumbnail)
->setImageSize($x, $y)
->setDisabled($mock->isClosed())
- ->addIconCount('fa-picture-o', count($mock->getImages()))
+ ->addIconCount('fa-picture-o', count($mock->getActiveImages()))
->addIconCount('fa-trophy', $mock->getTokenCount());
return $item;
diff --git a/src/applications/pholio/view/PholioMockImagesView.php b/src/applications/pholio/view/PholioMockImagesView.php
--- a/src/applications/pholio/view/PholioMockImagesView.php
+++ b/src/applications/pholio/view/PholioMockImagesView.php
@@ -74,7 +74,7 @@
$images = array();
$current_set = 0;
- foreach ($mock->getAllImages() as $image) {
+ foreach ($mock->getImages() as $image) {
$file = $image->getFile();
$metadata = $file->getMetadata();
$x = idx($metadata, PhabricatorFile::METADATA_IMAGE_WIDTH);
@@ -110,7 +110,7 @@
);
}
- $ids = mpull($mock->getImages(), 'getID');
+ $ids = mpull($mock->getActiveImages(), 'getID');
if ($this->imageID && isset($ids[$this->imageID])) {
$selected_id = $this->imageID;
} else {
@@ -118,7 +118,7 @@
}
$navsequence = array();
- foreach ($mock->getImages() as $image) {
+ foreach ($mock->getActiveImages() as $image) {
$navsequence[] = $image->getID();
}
diff --git a/src/applications/pholio/view/PholioMockThumbGridView.php b/src/applications/pholio/view/PholioMockThumbGridView.php
--- a/src/applications/pholio/view/PholioMockThumbGridView.php
+++ b/src/applications/pholio/view/PholioMockThumbGridView.php
@@ -12,7 +12,7 @@
public function render() {
$mock = $this->mock;
- $all_images = $mock->getAllImages();
+ $all_images = $mock->getImages();
$all_images = mpull($all_images, null, 'getPHID');
$history = mpull($all_images, 'getReplacesImagePHID', 'getPHID');
@@ -25,10 +25,10 @@
}
// Figure out the columns. Start with all the active images.
- $images = mpull($mock->getImages(), null, 'getPHID');
+ $images = mpull($mock->getActiveImages(), null, 'getPHID');
// Now, find deleted images: obsolete images which were not replaced.
- foreach ($mock->getAllImages() as $image) {
+ foreach ($mock->getImages() as $image) {
if (!$image->getIsObsolete()) {
// Image is current.
continue;
diff --git a/src/applications/pholio/view/PholioTransactionView.php b/src/applications/pholio/view/PholioTransactionView.php
--- a/src/applications/pholio/view/PholioTransactionView.php
+++ b/src/applications/pholio/view/PholioTransactionView.php
@@ -97,7 +97,7 @@
private function renderInlineContent(PholioTransaction $inline) {
$comment = $inline->getComment();
$mock = $this->getMock();
- $images = $mock->getAllImages();
+ $images = $mock->getImages();
$images = mpull($images, null, 'getID');
$image = idx($images, $comment->getImageID());
diff --git a/src/applications/pholio/xaction/PholioImageFileTransaction.php b/src/applications/pholio/xaction/PholioImageFileTransaction.php
--- a/src/applications/pholio/xaction/PholioImageFileTransaction.php
+++ b/src/applications/pholio/xaction/PholioImageFileTransaction.php
@@ -6,7 +6,7 @@
const TRANSACTIONTYPE = 'image-file';
public function generateOldValue($object) {
- $images = $object->getImages();
+ $images = $object->getActiveImages();
return array_values(mpull($images, 'getPHID'));
}
@@ -24,7 +24,7 @@
$new_map = array_fuse($this->getNewValue());
$obsolete_map = array_diff_key($old_map, $new_map);
- $images = $object->getImages();
+ $images = $object->getActiveImages();
foreach ($images as $seq => $image) {
if (isset($obsolete_map[$image->getPHID()])) {
$image->setIsObsolete(1);

File Metadata

Mime Type
text/plain
Expires
Mon, Oct 21, 7:52 PM (4 w, 7 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6736705
Default Alt Text
D19921.diff (9 KB)

Event Timeline