mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-09 16:32:39 +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
This commit is contained in:
parent
f4fa968770
commit
fc9ad37b26
19 changed files with 909 additions and 1 deletions
74
resources/sql/patches/pholio.sql
Normal file
74
resources/sql/patches/pholio.sql
Normal file
|
@ -0,0 +1,74 @@
|
|||
CREATE TABLE {$NAMESPACE}_pholio.pholio_mock (
|
||||
id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
phid VARCHAR(64) NOT NULL COLLATE utf8_bin,
|
||||
name VARCHAR(128) NOT NULL COLLATE utf8_general_ci,
|
||||
originalName VARCHAR(128) NOT NULL COLLATE utf8_general_ci,
|
||||
description LONGTEXT NOT NULL COLLATE utf8_general_ci,
|
||||
authorPHID VARCHAR(64) NOT NULL COLLATE utf8_bin,
|
||||
viewPolicy VARCHAR(64) NOT NULL COLLATE utf8_bin,
|
||||
coverPHID VARCHAR(64) NOT NULL COLLATE utf8_bin,
|
||||
mailKey VARCHAR(20) NOT NULL COLLATE utf8_bin,
|
||||
dateCreated INT UNSIGNED NOT NULL,
|
||||
dateModified INT UNSIGNED NOT NULL,
|
||||
UNIQUE KEY (phid),
|
||||
KEY (authorPHID)
|
||||
) ENGINE=InnoDB, COLLATE utf8_general_ci;
|
||||
|
||||
CREATE TABLE {$NAMESPACE}_pholio.edge (
|
||||
src VARCHAR(64) NOT NULL COLLATE utf8_bin,
|
||||
type VARCHAR(64) NOT NULL COLLATE utf8_bin,
|
||||
dst VARCHAR(64) NOT NULL COLLATE utf8_bin,
|
||||
dateCreated INT UNSIGNED NOT NULL,
|
||||
seq INT UNSIGNED NOT NULL,
|
||||
dataID INT UNSIGNED,
|
||||
PRIMARY KEY (src, type, dst),
|
||||
KEY (src, type, dateCreated, seq)
|
||||
) ENGINE=InnoDB, COLLATE utf8_general_ci;
|
||||
|
||||
CREATE TABLE {$NAMESPACE}_pholio.edgedata (
|
||||
id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
data LONGTEXT NOT NULL COLLATE utf8_bin
|
||||
) ENGINE=InnoDB, COLLATE utf8_general_ci;
|
||||
|
||||
CREATE TABLE {$NAMESPACE}_pholio.pholio_transaction (
|
||||
id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
authorPHID VARCHAR(64) NOT NULL COLLATE utf8_bin,
|
||||
mockID INT UNSIGNED NOT NULL,
|
||||
transactionType VARCHAR(32) NOT NULL COLLATE utf8_bin,
|
||||
oldValue LONGTEXT NOT NULL COLLATE utf8_bin,
|
||||
newValue LONGTEXT NOT NULL COLLATE utf8_bin,
|
||||
comment LONGTEXT NOT NULL COLLATE utf8_general_ci,
|
||||
metadata LONGTEXT NOT NULL COLLATE utf8_bin,
|
||||
contentSource LONGTEXT NOT NULL COLLATE utf8_bin,
|
||||
dateCreated INT UNSIGNED NOT NULL,
|
||||
dateModified INT UNSIGNED NOT NULL
|
||||
) ENGINE=InnoDB, COLLATE utf8_general_ci;
|
||||
|
||||
CREATE TABLE {$NAMESPACE}_pholio.pholio_image (
|
||||
id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
mockID INT UNSIGNED NOT NULL,
|
||||
filePHID VARCHAR(64) NOT NULL COLLATE utf8_bin,
|
||||
name VARCHAR(128) NOT NULL COLLATE utf8_general_ci,
|
||||
description LONGTEXT NOT NULL COLLATE utf8_general_ci,
|
||||
sequence INT UNSIGNED NOT NULL,
|
||||
dateCreated INT UNSIGNED NOT NULL,
|
||||
dateModified INT UNSIGNED NOT NULL,
|
||||
KEY (mockID, sequence)
|
||||
) ENGINE=InnoDB, COLLATE utf8_general_ci;
|
||||
|
||||
CREATE TABLE {$NAMESPACE}_pholio.pholio_pixelcomment (
|
||||
id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
mockID INT UNSIGNED NOT NULL,
|
||||
imageID INT UNSIGNED NOT NULL,
|
||||
transactionID INT UNSIGNED,
|
||||
authorPHID VARCHAR(64) NOT NULL COLLATE utf8_bin,
|
||||
x INT UNSIGNED NOT NULL,
|
||||
y INT UNSIGNED NOT NULL,
|
||||
width INT UNSIGNED NOT NULL,
|
||||
height INT UNSIGNED NOT NULL,
|
||||
comment LONGTEXT NOT NULL COLLATE utf8_general_ci,
|
||||
dateCreated INT UNSIGNED NOT NULL,
|
||||
dateModified INT UNSIGNED NOT NULL,
|
||||
KEY (mockID),
|
||||
KEY (authorPHID, transactionID)
|
||||
) ENGINE=InnoDB, COLLATE utf8_general_ci;
|
|
@ -582,6 +582,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorApplicationPaste' => 'applications/paste/application/PhabricatorApplicationPaste.php',
|
||||
'PhabricatorApplicationPeople' => 'applications/people/application/PhabricatorApplicationPeople.php',
|
||||
'PhabricatorApplicationPhame' => 'applications/phame/application/PhabricatorApplicationPhame.php',
|
||||
'PhabricatorApplicationPholio' => 'applications/pholio/application/PhabricatorApplicationPholio.php',
|
||||
'PhabricatorApplicationPhriction' => 'applications/phriction/application/PhabricatorApplicationPhriction.php',
|
||||
'PhabricatorApplicationPonder' => 'applications/ponder/application/PhabricatorApplicationPonder.php',
|
||||
'PhabricatorApplicationProject' => 'applications/project/application/PhabricatorApplicationProject.php',
|
||||
|
@ -1199,6 +1200,17 @@ phutil_register_library_map(array(
|
|||
'PhamePostViewController' => 'applications/phame/controller/post/PhamePostViewController.php',
|
||||
'PhameResourceController' => 'applications/phame/controller/PhameResourceController.php',
|
||||
'PhameSkinSpecification' => 'applications/phame/skins/PhameSkinSpecification.php',
|
||||
'PholioController' => 'applications/pholio/controller/PholioController.php',
|
||||
'PholioDAO' => 'applications/pholio/storage/PholioDAO.php',
|
||||
'PholioImage' => 'applications/pholio/storage/PholioImage.php',
|
||||
'PholioIndexer' => 'applications/pholio/indexer/PholioIndexer.php',
|
||||
'PholioMock' => 'applications/pholio/storage/PholioMock.php',
|
||||
'PholioMockEditor' => 'applications/pholio/editor/PholioMockEditor.php',
|
||||
'PholioMockListController' => 'applications/pholio/controller/PholioMockListController.php',
|
||||
'PholioMockQuery' => 'applications/pholio/query/PholioMockQuery.php',
|
||||
'PholioMockViewController' => 'applications/pholio/controller/PholioMockViewController.php',
|
||||
'PholioPixelComment' => 'applications/pholio/storage/PholioPixelComment.php',
|
||||
'PholioTransaction' => 'applications/pholio/storage/PholioTransaction.php',
|
||||
'PhortuneMonthYearExpiryControl' => 'applications/phortune/control/PhortuneMonthYearExpiryControl.php',
|
||||
'PhortuneStripeBaseController' => 'applications/phortune/stripe/controller/PhortuneStripeBaseController.php',
|
||||
'PhortuneStripePaymentFormView' => 'applications/phortune/stripe/view/PhortuneStripePaymentFormView.php',
|
||||
|
@ -1799,6 +1811,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorApplicationPaste' => 'PhabricatorApplication',
|
||||
'PhabricatorApplicationPeople' => 'PhabricatorApplication',
|
||||
'PhabricatorApplicationPhame' => 'PhabricatorApplication',
|
||||
'PhabricatorApplicationPholio' => 'PhabricatorApplication',
|
||||
'PhabricatorApplicationPhriction' => 'PhabricatorApplication',
|
||||
'PhabricatorApplicationPonder' => 'PhabricatorApplication',
|
||||
'PhabricatorApplicationProject' => 'PhabricatorApplication',
|
||||
|
@ -2377,6 +2390,35 @@ phutil_register_library_map(array(
|
|||
'PhamePostView' => 'AphrontView',
|
||||
'PhamePostViewController' => 'PhameController',
|
||||
'PhameResourceController' => 'CelerityResourceController',
|
||||
'PholioController' => 'PhabricatorController',
|
||||
'PholioDAO' => 'PhabricatorLiskDAO',
|
||||
'PholioImage' =>
|
||||
array(
|
||||
0 => 'PholioDAO',
|
||||
1 => 'PhabricatorMarkupInterface',
|
||||
),
|
||||
'PholioIndexer' => 'PhabricatorSearchDocumentIndexer',
|
||||
'PholioMock' =>
|
||||
array(
|
||||
0 => 'PholioDAO',
|
||||
1 => 'PhabricatorMarkupInterface',
|
||||
2 => 'PhabricatorPolicyInterface',
|
||||
3 => 'PhabricatorSubscribableInterface',
|
||||
),
|
||||
'PholioMockEditor' => 'PhabricatorEditor',
|
||||
'PholioMockListController' => 'PholioController',
|
||||
'PholioMockQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||
'PholioMockViewController' => 'PholioController',
|
||||
'PholioPixelComment' =>
|
||||
array(
|
||||
0 => 'PholioDAO',
|
||||
1 => 'PhabricatorMarkupInterface',
|
||||
),
|
||||
'PholioTransaction' =>
|
||||
array(
|
||||
0 => 'PholioDAO',
|
||||
1 => 'PhabricatorMarkupInterface',
|
||||
),
|
||||
'PhortuneMonthYearExpiryControl' => 'AphrontFormControl',
|
||||
'PhortuneStripeBaseController' => 'PhabricatorController',
|
||||
'PhortuneStripePaymentFormView' => 'AphrontView',
|
||||
|
|
|
@ -28,4 +28,6 @@ final class PhabricatorPHIDConstants {
|
|||
const PHID_TYPE_BLOG = 'BLOG';
|
||||
const PHID_TYPE_QUES = 'QUES';
|
||||
const PHID_TYPE_ANSW = 'ANSW';
|
||||
const PHID_TYPE_MOCK = 'MOCK';
|
||||
|
||||
}
|
||||
|
|
|
@ -88,12 +88,22 @@ final class PhabricatorObjectHandleData {
|
|||
break;
|
||||
case PhabricatorPHIDConstants::PHID_TYPE_QUES:
|
||||
$questions = id(new PonderQuestionQuery())
|
||||
->setViewer($this->viewer)
|
||||
->withPHIDs($phids)
|
||||
->execute();
|
||||
foreach ($questions as $question) {
|
||||
$objects[$question->getPHID()] = $question;
|
||||
}
|
||||
break;
|
||||
case PhabricatorPHIDConstants::PHID_TYPE_MOCK:
|
||||
$mocks = id(new PholioMockQuery())
|
||||
->setViewer($this->viewer)
|
||||
->withPHIDs($phids)
|
||||
->execute();
|
||||
foreach ($mocks as $mock) {
|
||||
$objects[$mock->getPHID()] = $mock;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -546,6 +556,29 @@ final class PhabricatorObjectHandleData {
|
|||
$handles[$phid] = $handle;
|
||||
}
|
||||
break;
|
||||
case PhabricatorPHIDConstants::PHID_TYPE_MOCK:
|
||||
$mocks = id(new PholioMockQuery())
|
||||
->withPHIDs($phids)
|
||||
->setViewer($this->viewer)
|
||||
->execute();
|
||||
$mocks = mpull($mocks, null, 'getPHID');
|
||||
|
||||
foreach ($phids as $phid) {
|
||||
$handle = new PhabricatorObjectHandle();
|
||||
$handle->setPHID($phid);
|
||||
$handle->setType($type);
|
||||
if (empty($mocks[$phid])) {
|
||||
$handle->setName('Unknown Mock');
|
||||
} else {
|
||||
$mock = $mocks[$phid];
|
||||
$handle->setName($mock->getName());
|
||||
$handle->setFullName($mock->getName());
|
||||
$handle->setURI('/M'.$mock->getID());
|
||||
$handle->setComplete(true);
|
||||
}
|
||||
$handles[$phid] = $handle;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$loader = null;
|
||||
if (isset($external_loaders[$type])) {
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group pholio
|
||||
*/
|
||||
final class PhabricatorApplicationPholio extends PhabricatorApplication {
|
||||
|
||||
public function shouldAppearInLaunchView() {
|
||||
// TODO: See getApplicationGroup().
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getBaseURI() {
|
||||
return '/pholio/';
|
||||
}
|
||||
|
||||
public function getShortDescription() {
|
||||
return 'Design Review';
|
||||
}
|
||||
|
||||
public function getAutospriteName() {
|
||||
return 'pholio';
|
||||
}
|
||||
|
||||
public function getTitleGlyph() {
|
||||
return "\xE2\x9D\xA6";
|
||||
}
|
||||
|
||||
public function getFlavorText() {
|
||||
return pht('Things before they were cool.');
|
||||
}
|
||||
|
||||
public function getApplicationGroup() {
|
||||
// TODO: Move to CORE, this just keeps it out of the side menu.
|
||||
return self::GROUP_COMMUNICATION;
|
||||
}
|
||||
|
||||
public function getRoutes() {
|
||||
return array(
|
||||
'/M(?P<id>[1-9]\d*)' => 'PholioMockViewController',
|
||||
'/pholio/' => array(
|
||||
'' => 'PholioMockListController',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
25
src/applications/pholio/controller/PholioController.php
Normal file
25
src/applications/pholio/controller/PholioController.php
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group pholio
|
||||
*/
|
||||
abstract class PholioController extends PhabricatorController {
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group pholio
|
||||
*/
|
||||
final class PholioMockListController extends PholioController {
|
||||
|
||||
public function processRequest() {
|
||||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
|
||||
$query = id(new PholioMockQuery())
|
||||
->setViewer($user);
|
||||
|
||||
$title = 'All Mocks';
|
||||
|
||||
$pager = new AphrontCursorPagerView();
|
||||
$pager->readFromRequest($request);
|
||||
|
||||
$mocks = $query->executeWithCursorPager($pager);
|
||||
|
||||
$board = new PhabricatorPinboardView();
|
||||
foreach ($mocks as $mock) {
|
||||
$board->addItem(
|
||||
id(new PhabricatorPinboardItemView())
|
||||
->setHeader($mock->getName())
|
||||
->setURI('/M'.$mock->getID()));
|
||||
}
|
||||
|
||||
$header = id(new PhabricatorHeaderView())
|
||||
->setHeader($title);
|
||||
|
||||
$content = array(
|
||||
$header,
|
||||
$board,
|
||||
$pager,
|
||||
);
|
||||
|
||||
return $this->buildApplicationPage(
|
||||
$content,
|
||||
array(
|
||||
'title' => $title,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group pholio
|
||||
*/
|
||||
final class PholioMockViewController extends PholioController {
|
||||
|
||||
private $id;
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$this->id = $data['id'];
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
|
||||
$mock = id(new PholioMockQuery())
|
||||
->setViewer($user)
|
||||
->withIDs(array($this->id))
|
||||
->executeOne();
|
||||
|
||||
if (!$mock) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
$title = 'M'.$mock->getID().' '.$mock->getName();
|
||||
|
||||
$header = id(new PhabricatorHeaderView())
|
||||
->setHeader($title);
|
||||
|
||||
$actions = id(new PhabricatorActionListView())
|
||||
->setUser($user)
|
||||
->setObject($mock);
|
||||
|
||||
$properties = new PhabricatorPropertyListView();
|
||||
|
||||
$content = array(
|
||||
$header,
|
||||
$actions,
|
||||
$properties
|
||||
);
|
||||
|
||||
return $this->buildApplicationPage(
|
||||
$content,
|
||||
array(
|
||||
'title' => $title,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
26
src/applications/pholio/editor/PholioMockEditor.php
Normal file
26
src/applications/pholio/editor/PholioMockEditor.php
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group pholio
|
||||
*/
|
||||
final class PholioMockEditor extends PhabricatorEditor {
|
||||
|
||||
|
||||
|
||||
}
|
44
src/applications/pholio/indexer/PholioIndexer.php
Normal file
44
src/applications/pholio/indexer/PholioIndexer.php
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group pholio
|
||||
*/
|
||||
final class PholioIndexer extends PhabricatorSearchDocumentIndexer {
|
||||
|
||||
public static function indexMock(PholioMock $mock) {
|
||||
$doc = new PhabricatorSearchAbstractDocument();
|
||||
$doc->setPHID($mock->getPHID());
|
||||
$doc->setDocumentType(phid_get_type($mock->getPHID()));
|
||||
$doc->setDocumentTitle($mock->getName());
|
||||
$doc->setDocumentCreated($mock->getDateCreated());
|
||||
$doc->setDocumentModified($mock->getDateModified());
|
||||
|
||||
$doc->addField(
|
||||
PhabricatorSearchField::FIELD_BODY,
|
||||
$mock->getDescription());
|
||||
|
||||
$doc->addRelationship(
|
||||
PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR,
|
||||
$mock->getAuthorPHID(),
|
||||
PhabricatorPHIDConstants::PHID_TYPE_USER,
|
||||
$mock->getDateCreated());
|
||||
|
||||
self::reindexAbstractDocument($doc);
|
||||
}
|
||||
}
|
88
src/applications/pholio/query/PholioMockQuery.php
Normal file
88
src/applications/pholio/query/PholioMockQuery.php
Normal file
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group pholio
|
||||
*/
|
||||
final class PholioMockQuery
|
||||
extends PhabricatorCursorPagedPolicyAwareQuery {
|
||||
|
||||
private $ids;
|
||||
private $phids;
|
||||
private $authorPHIDs;
|
||||
|
||||
public function withIDs(array $ids) {
|
||||
$this->ids = $ids;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function withPHIDs(array $phids) {
|
||||
$this->phids = $phids;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function withAuthorPHIDs(array $author_phids) {
|
||||
$this->authorPHIDs = $author_phids;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function loadPage() {
|
||||
$table = new PholioMock();
|
||||
$conn_r = $table->establishConnection('r');
|
||||
|
||||
$data = queryfx_all(
|
||||
$conn_r,
|
||||
'SELECT * FROM %T %Q %Q %Q',
|
||||
$table->getTableName(),
|
||||
$this->buildWhereClause($conn_r),
|
||||
$this->buildOrderClause($conn_r),
|
||||
$this->buildLimitClause($conn_r));
|
||||
|
||||
return $table->loadAllFromArray($data);
|
||||
}
|
||||
|
||||
private function buildWhereClause(AphrontDatabaseConnection $conn_r) {
|
||||
$where = array();
|
||||
|
||||
$where[] = $this->buildPagingClause($conn_r);
|
||||
|
||||
if ($this->ids) {
|
||||
$where[] = qsprintf(
|
||||
$conn_r,
|
||||
'id IN (%Ld)',
|
||||
$this->ids);
|
||||
}
|
||||
|
||||
if ($this->phids) {
|
||||
$where[] = qsprintf(
|
||||
$conn_r,
|
||||
'phid IN (%Ls)',
|
||||
$this->phids);
|
||||
}
|
||||
|
||||
if ($this->authorPHIDs) {
|
||||
$where[] = qsprintf(
|
||||
$conn_r,
|
||||
'authorPHID in (%Ls)',
|
||||
$this->authorPHIDs);
|
||||
}
|
||||
|
||||
return $this->formatWhereClause($where);
|
||||
}
|
||||
|
||||
}
|
28
src/applications/pholio/storage/PholioDAO.php
Normal file
28
src/applications/pholio/storage/PholioDAO.php
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group pholio
|
||||
*/
|
||||
abstract class PholioDAO extends PhabricatorLiskDAO {
|
||||
|
||||
public function getApplicationName() {
|
||||
return 'pholio';
|
||||
}
|
||||
|
||||
}
|
58
src/applications/pholio/storage/PholioImage.php
Normal file
58
src/applications/pholio/storage/PholioImage.php
Normal file
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group pholio
|
||||
*/
|
||||
final class PholioImage extends PholioDAO
|
||||
implements PhabricatorMarkupInterface {
|
||||
|
||||
const MARKUP_FIELD_DESCRIPTION = 'markup:description';
|
||||
|
||||
protected $mockID;
|
||||
protected $filePHID;
|
||||
protected $name;
|
||||
protected $description;
|
||||
protected $sequence;
|
||||
|
||||
|
||||
/* -( 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) {
|
||||
return $this->getDescription();
|
||||
}
|
||||
|
||||
public function didMarkupText($field, $output, PhutilMarkupEngine $engine) {
|
||||
return $output;
|
||||
}
|
||||
|
||||
public function shouldUseMarkupCache($field) {
|
||||
return (bool)$this->getID();
|
||||
}
|
||||
|
||||
}
|
113
src/applications/pholio/storage/PholioMock.php
Normal file
113
src/applications/pholio/storage/PholioMock.php
Normal file
|
@ -0,0 +1,113 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group pholio
|
||||
*/
|
||||
final class PholioMock extends PholioDAO
|
||||
implements
|
||||
PhabricatorMarkupInterface,
|
||||
PhabricatorPolicyInterface,
|
||||
PhabricatorSubscribableInterface {
|
||||
|
||||
const MARKUP_FIELD_DESCRIPTION = 'markup:description';
|
||||
|
||||
protected $authorPHID;
|
||||
protected $viewPolicy;
|
||||
|
||||
protected $name;
|
||||
protected $originalName;
|
||||
protected $description;
|
||||
protected $coverPHID;
|
||||
protected $mailKey;
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
/* -( 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());
|
||||
}
|
||||
|
||||
|
||||
/* -( 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) {
|
||||
return $this->getDescription();
|
||||
}
|
||||
|
||||
public function didMarkupText($field, $output, PhutilMarkupEngine $engine) {
|
||||
return $output;
|
||||
}
|
||||
|
||||
public function shouldUseMarkupCache($field) {
|
||||
return (bool)$this->getID();
|
||||
}
|
||||
|
||||
}
|
62
src/applications/pholio/storage/PholioPixelComment.php
Normal file
62
src/applications/pholio/storage/PholioPixelComment.php
Normal file
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group pholio
|
||||
*/
|
||||
final class PholioPixelComment extends PholioDAO
|
||||
implements PhabricatorMarkupInterface {
|
||||
|
||||
const MARKUP_FIELD_COMMENT = 'markup:comment';
|
||||
|
||||
protected $mockID;
|
||||
protected $transactionID;
|
||||
protected $authorPHID;
|
||||
protected $imageID;
|
||||
|
||||
protected $x;
|
||||
protected $y;
|
||||
protected $width;
|
||||
protected $height;
|
||||
protected $comment;
|
||||
|
||||
|
||||
/* -( PhabricatorMarkupInterface )----------------------------------------- */
|
||||
|
||||
|
||||
public function getMarkupFieldKey($field) {
|
||||
return 'MP:'.$this->getID();
|
||||
}
|
||||
|
||||
public function newMarkupEngine($field) {
|
||||
return PhabricatorMarkupEngine::newMarkupEngine(array());
|
||||
}
|
||||
|
||||
public function getMarkupText($field) {
|
||||
return $this->getComment();
|
||||
}
|
||||
|
||||
public function didMarkupText($field, $output, PhutilMarkupEngine $engine) {
|
||||
return $output;
|
||||
}
|
||||
|
||||
public function shouldUseMarkupCache($field) {
|
||||
return ($this->getID() && $this->getTransactionID());
|
||||
}
|
||||
|
||||
}
|
111
src/applications/pholio/storage/PholioTransaction.php
Normal file
111
src/applications/pholio/storage/PholioTransaction.php
Normal file
|
@ -0,0 +1,111 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group pholio
|
||||
*/
|
||||
final class PholioTransaction extends PholioDAO
|
||||
implements PhabricatorMarkupInterface {
|
||||
|
||||
const MARKUP_FIELD_COMMENT = 'markup:comment';
|
||||
|
||||
protected $mockID;
|
||||
protected $authorPHID;
|
||||
protected $transactionType;
|
||||
protected $oldValue;
|
||||
protected $newValue;
|
||||
protected $comment;
|
||||
protected $metadata = array();
|
||||
protected $contentSource;
|
||||
|
||||
public function getConfiguration() {
|
||||
return array(
|
||||
self::CONFIG_SERIALIZATION => array(
|
||||
'oldValue' => self::SERIALIZATION_JSON,
|
||||
'newValue' => self::SERIALIZATION_JSON,
|
||||
'metadata' => self::SERIALIZATION_JSON,
|
||||
),
|
||||
) + parent::getConfiguration();
|
||||
}
|
||||
|
||||
public function setContentSource(PhabricatorContentSource $content_source) {
|
||||
$this->contentSource = $content_source->serialize();
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getContentSource() {
|
||||
return PhabricatorContentSource::newFromSerialized($this->contentSource);
|
||||
}
|
||||
|
||||
|
||||
/* -( 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 hasAutomaticCapbility($capability, PhabricatorUser $viewer) {
|
||||
return ($viewer->getPHID() == $this->getAuthorPHID());
|
||||
}
|
||||
|
||||
|
||||
/* -( PhabricatorMarkupInterface )----------------------------------------- */
|
||||
|
||||
|
||||
public function getMarkupFieldKey($field) {
|
||||
return 'MX:'.$this->getID();
|
||||
}
|
||||
|
||||
public function newMarkupEngine($field) {
|
||||
return PhabricatorMarkupEngine::newMarkupEngine(array());
|
||||
}
|
||||
|
||||
public function getMarkupText($field) {
|
||||
return $this->getComment();
|
||||
}
|
||||
|
||||
public function didMarkupText($field, $output, PhutilMarkupEngine $engine) {
|
||||
return $output;
|
||||
}
|
||||
|
||||
public function shouldUseMarkupCache($field) {
|
||||
return (bool)$this->getID();
|
||||
}
|
||||
|
||||
}
|
|
@ -107,6 +107,8 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
|
|||
PhabricatorPHIDConstants::PHID_TYPE_POST => 'PhamePost',
|
||||
PhabricatorPHIDConstants::PHID_TYPE_QUES => 'PonderQuestion',
|
||||
PhabricatorPHIDConstants::PHID_TYPE_ANSW => 'PonderAnswer',
|
||||
PhabricatorPHIDConstants::PHID_TYPE_MOCK => 'PholioMock',
|
||||
|
||||
);
|
||||
|
||||
$class = idx($class_map, $phid_type);
|
||||
|
|
|
@ -155,6 +155,10 @@ final class PhabricatorBuiltinPatchList extends PhabricatorSQLPatchList {
|
|||
'type' => 'db',
|
||||
'name' => 'xhprof',
|
||||
),
|
||||
'db.pholio' => array(
|
||||
'type' => 'db',
|
||||
'name' => 'pholio',
|
||||
),
|
||||
'0000.legacy.sql' => array(
|
||||
'type' => 'sql',
|
||||
'name' => $this->getPatchPath('0000.legacy.sql'),
|
||||
|
@ -1032,6 +1036,10 @@ final class PhabricatorBuiltinPatchList extends PhabricatorSQLPatchList {
|
|||
'type' => 'sql',
|
||||
'name' => $this->getPatchPath('liskcounters-task.sql'),
|
||||
),
|
||||
'pholio.sql' => array(
|
||||
'type' => 'sql',
|
||||
'name' => $this->getPatchPath('pholio.sql'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ final class PhabricatorPinboardView extends AphrontView {
|
|||
|
||||
private $items = array();
|
||||
|
||||
public function addItem(PhabricatorPinBoardItemView $item) {
|
||||
public function addItem(PhabricatorPinboardItemView $item) {
|
||||
$this->items[] = $item;
|
||||
return $this;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue