Add very basic scaffolding for Pholio
Summary:
I'm not going to land this until it's a bit more fleshed out since it would just confuse users, but this is probably more reviewable as a few diffs adding a couple features than one ULTRA-diff adding everything. Implement application basics for Pholio. This does more or less nothing, but adds storage, subscribe, flag, markup, indexing, query basics, PHIDs, handle loads, a couple of realy really basic controllers, etc.
Basic hierarchy is:
- **Moleskine**: Top-level object like a Differential Revision, like "Ponder Feed Ideas".
- **Image**: Each Moleskine has one or more images, like the unexpanded / expanded / mobile / empty states of feed.
- **Transaction**: Comment or edit, like Maniphest. I generally want to move most apps to a transaction model so we can log edits.
- **PixelComment**: Equivalent of an inline comment.
Test Plan: Created a fake object and viewed it.
Reviewers: btrahan, chad
Reviewed By: btrahan
CC: aran, davidreuss
Maniphest Tasks: T2097
Differential Revision: https://secure.phabricator.com/D3817
2012-11-22 02:22:36 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @group pholio
|
|
|
|
*/
|
|
|
|
final class PholioMock extends PholioDAO
|
|
|
|
implements
|
|
|
|
PhabricatorMarkupInterface,
|
|
|
|
PhabricatorPolicyInterface,
|
2013-02-15 16:47:14 +01:00
|
|
|
PhabricatorSubscribableInterface,
|
2013-02-17 15:37:09 +01:00
|
|
|
PhabricatorTokenReceiverInterface,
|
2013-10-25 21:52:00 +02:00
|
|
|
PhabricatorFlaggableInterface,
|
2013-02-17 15:37:09 +01:00
|
|
|
PhabricatorApplicationTransactionInterface {
|
Add very basic scaffolding for Pholio
Summary:
I'm not going to land this until it's a bit more fleshed out since it would just confuse users, but this is probably more reviewable as a few diffs adding a couple features than one ULTRA-diff adding everything. Implement application basics for Pholio. This does more or less nothing, but adds storage, subscribe, flag, markup, indexing, query basics, PHIDs, handle loads, a couple of realy really basic controllers, etc.
Basic hierarchy is:
- **Moleskine**: Top-level object like a Differential Revision, like "Ponder Feed Ideas".
- **Image**: Each Moleskine has one or more images, like the unexpanded / expanded / mobile / empty states of feed.
- **Transaction**: Comment or edit, like Maniphest. I generally want to move most apps to a transaction model so we can log edits.
- **PixelComment**: Equivalent of an inline comment.
Test Plan: Created a fake object and viewed it.
Reviewers: btrahan, chad
Reviewed By: btrahan
CC: aran, davidreuss
Maniphest Tasks: T2097
Differential Revision: https://secure.phabricator.com/D3817
2012-11-22 02:22:36 +01:00
|
|
|
|
|
|
|
const MARKUP_FIELD_DESCRIPTION = 'markup:description';
|
|
|
|
|
|
|
|
protected $authorPHID;
|
|
|
|
protected $viewPolicy;
|
|
|
|
|
|
|
|
protected $name;
|
|
|
|
protected $originalName;
|
|
|
|
protected $description;
|
|
|
|
protected $coverPHID;
|
|
|
|
protected $mailKey;
|
|
|
|
|
2013-07-26 01:59:25 +02:00
|
|
|
private $images = self::ATTACHABLE;
|
|
|
|
private $allImages = self::ATTACHABLE;
|
|
|
|
private $coverFile = self::ATTACHABLE;
|
|
|
|
private $tokenCount = self::ATTACHABLE;
|
2013-01-25 22:27:49 +01:00
|
|
|
|
Add very basic scaffolding for Pholio
Summary:
I'm not going to land this until it's a bit more fleshed out since it would just confuse users, but this is probably more reviewable as a few diffs adding a couple features than one ULTRA-diff adding everything. Implement application basics for Pholio. This does more or less nothing, but adds storage, subscribe, flag, markup, indexing, query basics, PHIDs, handle loads, a couple of realy really basic controllers, etc.
Basic hierarchy is:
- **Moleskine**: Top-level object like a Differential Revision, like "Ponder Feed Ideas".
- **Image**: Each Moleskine has one or more images, like the unexpanded / expanded / mobile / empty states of feed.
- **Transaction**: Comment or edit, like Maniphest. I generally want to move most apps to a transaction model so we can log edits.
- **PixelComment**: Equivalent of an inline comment.
Test Plan: Created a fake object and viewed it.
Reviewers: btrahan, chad
Reviewed By: btrahan
CC: aran, davidreuss
Maniphest Tasks: T2097
Differential Revision: https://secure.phabricator.com/D3817
2012-11-22 02:22:36 +01:00
|
|
|
public function getConfiguration() {
|
|
|
|
return array(
|
|
|
|
self::CONFIG_AUX_PHID => true,
|
|
|
|
) + parent::getConfiguration();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function generatePHID() {
|
|
|
|
return PhabricatorPHID::generateNewPHID('MOCK');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function save() {
|
|
|
|
if (!$this->getMailKey()) {
|
|
|
|
$this->setMailKey(Filesystem::readRandomCharacters(20));
|
|
|
|
}
|
|
|
|
return parent::save();
|
|
|
|
}
|
|
|
|
|
2013-07-26 01:59:25 +02:00
|
|
|
/**
|
|
|
|
* These should be the images currently associated with the Mock.
|
|
|
|
*/
|
2013-01-25 22:27:49 +01:00
|
|
|
public function attachImages(array $images) {
|
|
|
|
assert_instances_of($images, 'PholioImage');
|
|
|
|
$this->images = $images;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getImages() {
|
2013-07-26 01:59:25 +02:00
|
|
|
$this->assertAttached($this->images);
|
2013-01-25 22:27:49 +01:00
|
|
|
return $this->images;
|
|
|
|
}
|
|
|
|
|
2013-07-26 01:59:25 +02:00
|
|
|
/**
|
|
|
|
* 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 getAllImages() {
|
|
|
|
$this->assertAttached($this->images);
|
|
|
|
return $this->allImages;
|
|
|
|
}
|
|
|
|
|
2013-01-25 22:27:49 +01:00
|
|
|
public function attachCoverFile(PhabricatorFile $file) {
|
|
|
|
$this->coverFile = $file;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCoverFile() {
|
2013-07-26 01:59:25 +02:00
|
|
|
$this->assertAttached($this->coverFile);
|
2013-01-25 22:27:49 +01:00
|
|
|
return $this->coverFile;
|
|
|
|
}
|
|
|
|
|
2013-03-04 20:47:58 +01:00
|
|
|
public function getTokenCount() {
|
2013-07-26 01:59:25 +02:00
|
|
|
$this->assertAttached($this->tokenCount);
|
2013-03-04 20:47:58 +01:00
|
|
|
return $this->tokenCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function attachTokenCount($count) {
|
|
|
|
$this->tokenCount = $count;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-07-26 01:59:25 +02:00
|
|
|
public function getImageHistorySet($image_id) {
|
|
|
|
$images = $this->getAllImages();
|
|
|
|
$images = mpull($images, null, 'getID');
|
|
|
|
$selected_image = $images[$image_id];
|
|
|
|
|
|
|
|
$replace_map = mpull($images, null, 'getReplacesImagePHID');
|
|
|
|
$phid_map = mpull($images, null, 'getPHID');
|
|
|
|
|
|
|
|
// find the earliest image
|
|
|
|
$image = $selected_image;
|
|
|
|
while (isset($phid_map[$image->getReplacesImagePHID()])) {
|
|
|
|
$image = $phid_map[$image->getReplacesImagePHID()];
|
|
|
|
}
|
|
|
|
|
|
|
|
// now build history moving forward
|
|
|
|
$history = array($image->getID() => $image);
|
|
|
|
while (isset($replace_map[$image->getPHID()])) {
|
|
|
|
$image = $replace_map[$image->getPHID()];
|
|
|
|
$history[$image->getID()] = $image;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $history;
|
|
|
|
}
|
|
|
|
|
Add very basic scaffolding for Pholio
Summary:
I'm not going to land this until it's a bit more fleshed out since it would just confuse users, but this is probably more reviewable as a few diffs adding a couple features than one ULTRA-diff adding everything. Implement application basics for Pholio. This does more or less nothing, but adds storage, subscribe, flag, markup, indexing, query basics, PHIDs, handle loads, a couple of realy really basic controllers, etc.
Basic hierarchy is:
- **Moleskine**: Top-level object like a Differential Revision, like "Ponder Feed Ideas".
- **Image**: Each Moleskine has one or more images, like the unexpanded / expanded / mobile / empty states of feed.
- **Transaction**: Comment or edit, like Maniphest. I generally want to move most apps to a transaction model so we can log edits.
- **PixelComment**: Equivalent of an inline comment.
Test Plan: Created a fake object and viewed it.
Reviewers: btrahan, chad
Reviewed By: btrahan
CC: aran, davidreuss
Maniphest Tasks: T2097
Differential Revision: https://secure.phabricator.com/D3817
2012-11-22 02:22:36 +01:00
|
|
|
|
|
|
|
/* -( PhabricatorSubscribableInterface Implementation )-------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
public function isAutomaticallySubscribed($phid) {
|
|
|
|
return ($this->authorPHID == $phid);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* -( PhabricatorPolicyInterface Implementation )-------------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
public function getCapabilities() {
|
|
|
|
return array(
|
|
|
|
PhabricatorPolicyCapability::CAN_VIEW,
|
|
|
|
PhabricatorPolicyCapability::CAN_EDIT,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPolicy($capability) {
|
|
|
|
switch ($capability) {
|
|
|
|
case PhabricatorPolicyCapability::CAN_VIEW:
|
|
|
|
return $this->getViewPolicy();
|
|
|
|
case PhabricatorPolicyCapability::CAN_EDIT:
|
|
|
|
return PhabricatorPolicies::POLICY_NOONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
|
|
|
|
return ($viewer->getPHID() == $this->getAuthorPHID());
|
|
|
|
}
|
|
|
|
|
2013-09-27 17:43:41 +02:00
|
|
|
public function describeAutomaticCapability($capability) {
|
|
|
|
return pht("A mock's owner can always view and edit it.");
|
|
|
|
}
|
|
|
|
|
Add very basic scaffolding for Pholio
Summary:
I'm not going to land this until it's a bit more fleshed out since it would just confuse users, but this is probably more reviewable as a few diffs adding a couple features than one ULTRA-diff adding everything. Implement application basics for Pholio. This does more or less nothing, but adds storage, subscribe, flag, markup, indexing, query basics, PHIDs, handle loads, a couple of realy really basic controllers, etc.
Basic hierarchy is:
- **Moleskine**: Top-level object like a Differential Revision, like "Ponder Feed Ideas".
- **Image**: Each Moleskine has one or more images, like the unexpanded / expanded / mobile / empty states of feed.
- **Transaction**: Comment or edit, like Maniphest. I generally want to move most apps to a transaction model so we can log edits.
- **PixelComment**: Equivalent of an inline comment.
Test Plan: Created a fake object and viewed it.
Reviewers: btrahan, chad
Reviewed By: btrahan
CC: aran, davidreuss
Maniphest Tasks: T2097
Differential Revision: https://secure.phabricator.com/D3817
2012-11-22 02:22:36 +01:00
|
|
|
|
|
|
|
/* -( PhabricatorMarkupInterface )----------------------------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
public function getMarkupFieldKey($field) {
|
|
|
|
$hash = PhabricatorHash::digest($this->getMarkupText($field));
|
|
|
|
return 'M:'.$hash;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function newMarkupEngine($field) {
|
|
|
|
return PhabricatorMarkupEngine::newMarkupEngine(array());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getMarkupText($field) {
|
2013-02-28 05:10:30 +01:00
|
|
|
if ($this->getDescription()) {
|
|
|
|
$description = $this->getDescription();
|
|
|
|
} else {
|
|
|
|
$description = pht('No Description Given');
|
|
|
|
}
|
|
|
|
|
|
|
|
return $description;
|
Add very basic scaffolding for Pholio
Summary:
I'm not going to land this until it's a bit more fleshed out since it would just confuse users, but this is probably more reviewable as a few diffs adding a couple features than one ULTRA-diff adding everything. Implement application basics for Pholio. This does more or less nothing, but adds storage, subscribe, flag, markup, indexing, query basics, PHIDs, handle loads, a couple of realy really basic controllers, etc.
Basic hierarchy is:
- **Moleskine**: Top-level object like a Differential Revision, like "Ponder Feed Ideas".
- **Image**: Each Moleskine has one or more images, like the unexpanded / expanded / mobile / empty states of feed.
- **Transaction**: Comment or edit, like Maniphest. I generally want to move most apps to a transaction model so we can log edits.
- **PixelComment**: Equivalent of an inline comment.
Test Plan: Created a fake object and viewed it.
Reviewers: btrahan, chad
Reviewed By: btrahan
CC: aran, davidreuss
Maniphest Tasks: T2097
Differential Revision: https://secure.phabricator.com/D3817
2012-11-22 02:22:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function didMarkupText($field, $output, PhutilMarkupEngine $engine) {
|
2013-03-01 16:33:25 +01:00
|
|
|
require_celerity_resource('phabricator-remarkup-css');
|
|
|
|
return phutil_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-remarkup',
|
|
|
|
),
|
|
|
|
$output);
|
Add very basic scaffolding for Pholio
Summary:
I'm not going to land this until it's a bit more fleshed out since it would just confuse users, but this is probably more reviewable as a few diffs adding a couple features than one ULTRA-diff adding everything. Implement application basics for Pholio. This does more or less nothing, but adds storage, subscribe, flag, markup, indexing, query basics, PHIDs, handle loads, a couple of realy really basic controllers, etc.
Basic hierarchy is:
- **Moleskine**: Top-level object like a Differential Revision, like "Ponder Feed Ideas".
- **Image**: Each Moleskine has one or more images, like the unexpanded / expanded / mobile / empty states of feed.
- **Transaction**: Comment or edit, like Maniphest. I generally want to move most apps to a transaction model so we can log edits.
- **PixelComment**: Equivalent of an inline comment.
Test Plan: Created a fake object and viewed it.
Reviewers: btrahan, chad
Reviewed By: btrahan
CC: aran, davidreuss
Maniphest Tasks: T2097
Differential Revision: https://secure.phabricator.com/D3817
2012-11-22 02:22:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function shouldUseMarkupCache($field) {
|
|
|
|
return (bool)$this->getID();
|
|
|
|
}
|
|
|
|
|
2013-02-17 15:37:09 +01:00
|
|
|
|
|
|
|
/* -( PhabricatorApplicationTransactionInterface )------------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
public function getApplicationTransactionEditor() {
|
|
|
|
return new PholioMockEditor();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getApplicationTransactionObject() {
|
|
|
|
return new PholioTransaction();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-19 02:44:45 +01:00
|
|
|
/* -( PhabricatorTokenReceiverInterface )---------------------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
public function getUsersToNotifyOfTokenGiven() {
|
|
|
|
return array(
|
|
|
|
$this->getAuthorPHID(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
Add very basic scaffolding for Pholio
Summary:
I'm not going to land this until it's a bit more fleshed out since it would just confuse users, but this is probably more reviewable as a few diffs adding a couple features than one ULTRA-diff adding everything. Implement application basics for Pholio. This does more or less nothing, but adds storage, subscribe, flag, markup, indexing, query basics, PHIDs, handle loads, a couple of realy really basic controllers, etc.
Basic hierarchy is:
- **Moleskine**: Top-level object like a Differential Revision, like "Ponder Feed Ideas".
- **Image**: Each Moleskine has one or more images, like the unexpanded / expanded / mobile / empty states of feed.
- **Transaction**: Comment or edit, like Maniphest. I generally want to move most apps to a transaction model so we can log edits.
- **PixelComment**: Equivalent of an inline comment.
Test Plan: Created a fake object and viewed it.
Reviewers: btrahan, chad
Reviewed By: btrahan
CC: aran, davidreuss
Maniphest Tasks: T2097
Differential Revision: https://secure.phabricator.com/D3817
2012-11-22 02:22:36 +01:00
|
|
|
}
|