mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 00:42:41 +01:00
Add Projects to Phame Blog and Phame Post
Summary: Allows setting of Projects to Blogs and Posts. Test Plan: Set a Project on a post and a blog, see on view page. Reviewers: btrahan, epriestley Reviewed By: epriestley Subscribers: epriestley, Korvin Differential Revision: https://secure.phabricator.com/D13669
This commit is contained in:
parent
a8cf612fe0
commit
690463b037
6 changed files with 60 additions and 10 deletions
|
@ -6967,6 +6967,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorMarkupInterface',
|
||||
'PhabricatorSubscribableInterface',
|
||||
'PhabricatorFlaggableInterface',
|
||||
'PhabricatorProjectInterface',
|
||||
'PhabricatorApplicationTransactionInterface',
|
||||
),
|
||||
'PhameBlogDeleteController' => 'PhameController',
|
||||
|
@ -6991,6 +6992,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorPolicyInterface',
|
||||
'PhabricatorMarkupInterface',
|
||||
'PhabricatorFlaggableInterface',
|
||||
'PhabricatorProjectInterface',
|
||||
'PhabricatorApplicationTransactionInterface',
|
||||
'PhabricatorSubscribableInterface',
|
||||
'PhabricatorTokenReceiverInterface',
|
||||
|
|
|
@ -5,8 +5,8 @@ final class PhameBlogEditController
|
|||
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$user = $request->getUser();
|
||||
|
||||
$id = $request->getURIData('id');
|
||||
|
||||
if ($id) {
|
||||
$blog = id(new PhameBlogQuery())
|
||||
->setViewer($user)
|
||||
|
@ -23,12 +23,19 @@ final class PhameBlogEditController
|
|||
$submit_button = pht('Save Changes');
|
||||
$page_title = pht('Edit Blog');
|
||||
$cancel_uri = $this->getApplicationURI('blog/view/'.$blog->getID().'/');
|
||||
|
||||
$v_projects = PhabricatorEdgeQuery::loadDestinationPHIDs(
|
||||
$blog->getPHID(),
|
||||
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
|
||||
$v_projects = array_reverse($v_projects);
|
||||
|
||||
} else {
|
||||
$blog = PhameBlog::initializeNewBlog($user);
|
||||
|
||||
$submit_button = pht('Create Blog');
|
||||
$page_title = pht('Create Blog');
|
||||
$cancel_uri = $this->getApplicationURI();
|
||||
$v_projects = array();
|
||||
}
|
||||
$name = $blog->getName();
|
||||
$description = $blog->getDescription();
|
||||
|
@ -50,6 +57,7 @@ final class PhameBlogEditController
|
|||
$can_view = $request->getStr('can_view');
|
||||
$can_edit = $request->getStr('can_edit');
|
||||
$can_join = $request->getStr('can_join');
|
||||
$v_projects = $request->getArr('projects');
|
||||
|
||||
$xactions = array(
|
||||
id(new PhameBlogTransaction())
|
||||
|
@ -75,6 +83,12 @@ final class PhameBlogEditController
|
|||
->setNewValue($can_join),
|
||||
);
|
||||
|
||||
$proj_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;
|
||||
$xactions[] = id(new PhameBlogTransaction())
|
||||
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
|
||||
->setMetadataValue('edge:type', $proj_edge_type)
|
||||
->setNewValue(array('=' => array_fuse($v_projects)));
|
||||
|
||||
$editor = id(new PhameBlogEditor())
|
||||
->setActor($user)
|
||||
->setContentSourceFromRequest($request)
|
||||
|
@ -147,6 +161,12 @@ final class PhameBlogEditController
|
|||
->setPolicies($policies)
|
||||
->setValue($can_join)
|
||||
->setName('can_join'))
|
||||
->appendControl(
|
||||
id(new AphrontFormTokenizerControl())
|
||||
->setLabel(pht('Projects'))
|
||||
->setName('projects')
|
||||
->setValue($v_projects)
|
||||
->setDatasource(new PhabricatorProjectDatasource()))
|
||||
->appendChild(
|
||||
id(new AphrontFormTextControl())
|
||||
->setLabel(pht('Custom Domain'))
|
||||
|
|
|
@ -72,8 +72,10 @@ final class PhameBlogViewController extends PhameController {
|
|||
require_celerity_resource('aphront-tooltip-css');
|
||||
Javelin::initBehavior('phabricator-tooltips');
|
||||
|
||||
$properties = new PHUIPropertyListView();
|
||||
$properties->setActionList($actions);
|
||||
$properties = id(new PHUIPropertyListView())
|
||||
->setUser($user)
|
||||
->setObject($blog)
|
||||
->setActionList($actions);
|
||||
|
||||
$properties->addProperty(
|
||||
pht('Skin'),
|
||||
|
@ -115,13 +117,18 @@ final class PhameBlogViewController extends PhameController {
|
|||
->addObject($blog, PhameBlog::MARKUP_FIELD_DESCRIPTION)
|
||||
->process();
|
||||
|
||||
$properties->addTextContent(
|
||||
phutil_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => 'phabricator-remarkup',
|
||||
),
|
||||
$engine->getOutput($blog, PhameBlog::MARKUP_FIELD_DESCRIPTION)));
|
||||
$properties->invokeWillRenderEvent();
|
||||
|
||||
if (strlen($blog->getDescription())) {
|
||||
$description = PhabricatorMarkupEngine::renderOneObject(
|
||||
id(new PhabricatorMarkupOneOff())->setContent($blog->getDescription()),
|
||||
'default',
|
||||
$user);
|
||||
$properties->addSectionHeader(
|
||||
pht('Description'),
|
||||
PHUIPropertyListView::ICON_SUMMARY);
|
||||
$properties->addTextContent($description);
|
||||
}
|
||||
|
||||
return $properties;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,11 @@ final class PhamePostEditController extends PhameController {
|
|||
$cancel_uri = $this->getApplicationURI('/post/view/'.$id.'/');
|
||||
$submit_button = pht('Save Changes');
|
||||
$page_title = pht('Edit Post');
|
||||
|
||||
$v_projects = PhabricatorEdgeQuery::loadDestinationPHIDs(
|
||||
$post->getPHID(),
|
||||
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
|
||||
$v_projects = array_reverse($v_projects);
|
||||
} else {
|
||||
$blog = id(new PhameBlogQuery())
|
||||
->setViewer($user)
|
||||
|
@ -35,6 +40,7 @@ final class PhamePostEditController extends PhameController {
|
|||
if (!$blog) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
$v_projects = array();
|
||||
|
||||
$post = PhamePost::initializePost($user, $blog);
|
||||
$cancel_uri = $this->getApplicationURI('/blog/view/'.$blog->getID().'/');
|
||||
|
@ -57,6 +63,7 @@ final class PhamePostEditController extends PhameController {
|
|||
$phame_title = PhabricatorSlug::normalize($phame_title);
|
||||
$body = $request->getStr('body');
|
||||
$comments_widget = $request->getStr('comments_widget');
|
||||
$v_projects = $request->getArr('projects');
|
||||
|
||||
$xactions = array(
|
||||
id(new PhamePostTransaction())
|
||||
|
@ -73,6 +80,12 @@ final class PhamePostEditController extends PhameController {
|
|||
->setNewValue($comments_widget),
|
||||
);
|
||||
|
||||
$proj_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;
|
||||
$xactions[] = id(new PhamePostTransaction())
|
||||
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
|
||||
->setMetadataValue('edge:type', $proj_edge_type)
|
||||
->setNewValue(array('=' => array_fuse($v_projects)));
|
||||
|
||||
$editor = id(new PhamePostEditor())
|
||||
->setActor($user)
|
||||
->setContentSourceFromRequest($request)
|
||||
|
@ -130,6 +143,12 @@ final class PhamePostEditController extends PhameController {
|
|||
->setID('post-body')
|
||||
->setUser($user)
|
||||
->setDisableMacros(true))
|
||||
->appendControl(
|
||||
id(new AphrontFormTokenizerControl())
|
||||
->setLabel(pht('Projects'))
|
||||
->setName('projects')
|
||||
->setValue($v_projects)
|
||||
->setDatasource(new PhabricatorProjectDatasource()))
|
||||
->appendChild(
|
||||
id(new AphrontFormSelectControl())
|
||||
->setLabel(pht('Comments Widget'))
|
||||
|
|
|
@ -6,6 +6,7 @@ final class PhameBlog extends PhameDAO
|
|||
PhabricatorMarkupInterface,
|
||||
PhabricatorSubscribableInterface,
|
||||
PhabricatorFlaggableInterface,
|
||||
PhabricatorProjectInterface,
|
||||
PhabricatorApplicationTransactionInterface {
|
||||
|
||||
const MARKUP_FIELD_DESCRIPTION = 'markup:description';
|
||||
|
|
|
@ -5,6 +5,7 @@ final class PhamePost extends PhameDAO
|
|||
PhabricatorPolicyInterface,
|
||||
PhabricatorMarkupInterface,
|
||||
PhabricatorFlaggableInterface,
|
||||
PhabricatorProjectInterface,
|
||||
PhabricatorApplicationTransactionInterface,
|
||||
PhabricatorSubscribableInterface,
|
||||
PhabricatorTokenReceiverInterface {
|
||||
|
|
Loading…
Reference in a new issue