mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-26 23:40:57 +01:00
Modernize Phame
Summary: Updates Phame for new modern methods. Test Plan: New blog, edit blog, new post, edit post, publish post. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Differential Revision: https://secure.phabricator.com/D14419
This commit is contained in:
parent
e4806631a5
commit
5024560de1
22 changed files with 153 additions and 161 deletions
|
@ -3245,6 +3245,7 @@ phutil_register_library_map(array(
|
|||
'PhameBasicBlogSkin' => 'applications/phame/skins/PhameBasicBlogSkin.php',
|
||||
'PhameBasicTemplateBlogSkin' => 'applications/phame/skins/PhameBasicTemplateBlogSkin.php',
|
||||
'PhameBlog' => 'applications/phame/storage/PhameBlog.php',
|
||||
'PhameBlogController' => 'applications/phame/controller/blog/PhameBlogController.php',
|
||||
'PhameBlogDeleteController' => 'applications/phame/controller/blog/PhameBlogDeleteController.php',
|
||||
'PhameBlogEditController' => 'applications/phame/controller/blog/PhameBlogEditController.php',
|
||||
'PhameBlogEditor' => 'applications/phame/editor/PhameBlogEditor.php',
|
||||
|
@ -3263,6 +3264,7 @@ phutil_register_library_map(array(
|
|||
'PhameCreatePostConduitAPIMethod' => 'applications/phame/conduit/PhameCreatePostConduitAPIMethod.php',
|
||||
'PhameDAO' => 'applications/phame/storage/PhameDAO.php',
|
||||
'PhamePost' => 'applications/phame/storage/PhamePost.php',
|
||||
'PhamePostController' => 'applications/phame/controller/post/PhamePostController.php',
|
||||
'PhamePostDeleteController' => 'applications/phame/controller/post/PhamePostDeleteController.php',
|
||||
'PhamePostEditController' => 'applications/phame/controller/post/PhamePostEditController.php',
|
||||
'PhamePostEditor' => 'applications/phame/editor/PhamePostEditor.php',
|
||||
|
@ -7503,18 +7505,19 @@ phutil_register_library_map(array(
|
|||
'PhabricatorProjectInterface',
|
||||
'PhabricatorApplicationTransactionInterface',
|
||||
),
|
||||
'PhameBlogDeleteController' => 'PhameController',
|
||||
'PhameBlogEditController' => 'PhameController',
|
||||
'PhameBlogController' => 'PhameController',
|
||||
'PhameBlogDeleteController' => 'PhameBlogController',
|
||||
'PhameBlogEditController' => 'PhameBlogController',
|
||||
'PhameBlogEditor' => 'PhabricatorApplicationTransactionEditor',
|
||||
'PhameBlogFeedController' => 'PhameController',
|
||||
'PhameBlogListController' => 'PhameController',
|
||||
'PhameBlogLiveController' => 'PhameController',
|
||||
'PhameBlogFeedController' => 'PhameBlogController',
|
||||
'PhameBlogListController' => 'PhameBlogController',
|
||||
'PhameBlogLiveController' => 'PhameBlogController',
|
||||
'PhameBlogQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||
'PhameBlogSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||
'PhameBlogSite' => 'PhameSite',
|
||||
'PhameBlogSkin' => 'PhabricatorController',
|
||||
'PhameBlogTransaction' => 'PhabricatorApplicationTransaction',
|
||||
'PhameBlogViewController' => 'PhameController',
|
||||
'PhameBlogViewController' => 'PhameBlogController',
|
||||
'PhameCelerityResources' => 'CelerityResources',
|
||||
'PhameConduitAPIMethod' => 'ConduitAPIMethod',
|
||||
'PhameController' => 'PhabricatorController',
|
||||
|
@ -7530,22 +7533,23 @@ phutil_register_library_map(array(
|
|||
'PhabricatorSubscribableInterface',
|
||||
'PhabricatorTokenReceiverInterface',
|
||||
),
|
||||
'PhamePostDeleteController' => 'PhameController',
|
||||
'PhamePostEditController' => 'PhameController',
|
||||
'PhamePostController' => 'PhameController',
|
||||
'PhamePostDeleteController' => 'PhamePostController',
|
||||
'PhamePostEditController' => 'PhamePostController',
|
||||
'PhamePostEditor' => 'PhabricatorApplicationTransactionEditor',
|
||||
'PhamePostFramedController' => 'PhameController',
|
||||
'PhamePostListController' => 'PhameController',
|
||||
'PhamePostNewController' => 'PhameController',
|
||||
'PhamePostNotLiveController' => 'PhameController',
|
||||
'PhamePostPreviewController' => 'PhameController',
|
||||
'PhamePostPublishController' => 'PhameController',
|
||||
'PhamePostFramedController' => 'PhamePostController',
|
||||
'PhamePostListController' => 'PhamePostController',
|
||||
'PhamePostNewController' => 'PhamePostController',
|
||||
'PhamePostNotLiveController' => 'PhamePostController',
|
||||
'PhamePostPreviewController' => 'PhamePostController',
|
||||
'PhamePostPublishController' => 'PhamePostController',
|
||||
'PhamePostQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||
'PhamePostSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||
'PhamePostTransaction' => 'PhabricatorApplicationTransaction',
|
||||
'PhamePostTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
|
||||
'PhamePostUnpublishController' => 'PhameController',
|
||||
'PhamePostUnpublishController' => 'PhamePostController',
|
||||
'PhamePostView' => 'AphrontView',
|
||||
'PhamePostViewController' => 'PhameController',
|
||||
'PhamePostViewController' => 'PhamePostController',
|
||||
'PhameQueryConduitAPIMethod' => 'PhameConduitAPIMethod',
|
||||
'PhameQueryPostsConduitAPIMethod' => 'PhameConduitAPIMethod',
|
||||
'PhameResourceController' => 'CelerityResourceController',
|
||||
|
|
|
@ -2,27 +2,6 @@
|
|||
|
||||
abstract class PhameController extends PhabricatorController {
|
||||
|
||||
protected function renderSideNavFilterView() {
|
||||
|
||||
$base_uri = new PhutilURI($this->getApplicationURI());
|
||||
|
||||
$nav = new AphrontSideNavFilterView();
|
||||
$nav->setBaseURI($base_uri);
|
||||
|
||||
$nav->addLabel(pht('Posts'));
|
||||
$nav->addFilter('post/all', pht('Latest Posts'));
|
||||
$nav->addFilter('post/draft', pht('My Drafts'));
|
||||
$nav->addFilter('post', pht('My Posts'));
|
||||
|
||||
$nav->addLabel(pht('Blogs'));
|
||||
$nav->addFilter('blog/user', pht('Joinable Blogs'));
|
||||
$nav->addFilter('blog/all', pht('All Blogs'));
|
||||
|
||||
$nav->selectFilter(null);
|
||||
|
||||
return $nav;
|
||||
}
|
||||
|
||||
protected function renderPostList(
|
||||
array $posts,
|
||||
PhabricatorUser $viewer,
|
||||
|
@ -111,10 +90,6 @@ abstract class PhameController extends PhabricatorController {
|
|||
return $stories;
|
||||
}
|
||||
|
||||
public function buildApplicationMenu() {
|
||||
return $this->renderSideNavFilterView()->getMenu();
|
||||
}
|
||||
|
||||
protected function buildApplicationCrumbs() {
|
||||
$crumbs = parent::buildApplicationCrumbs();
|
||||
$crumbs->addAction(
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
abstract class PhameBlogController extends PhameController {
|
||||
|
||||
public function buildApplicationMenu() {
|
||||
return $this->newApplicationMenu()
|
||||
->setSearchEngine(new PhameBlogSearchEngine());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
<?php
|
||||
|
||||
final class PhameBlogDeleteController extends PhameController {
|
||||
final class PhameBlogDeleteController extends PhameBlogController {
|
||||
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$user = $request->getUser();
|
||||
$viewer = $request->getViewer();
|
||||
$id = $request->getURIData('id');
|
||||
|
||||
$blog = id(new PhameBlogQuery())
|
||||
->setViewer($user)
|
||||
->setViewer($viewer)
|
||||
->withIDs(array($id))
|
||||
->requireCapabilities(
|
||||
array(
|
||||
|
@ -27,7 +27,7 @@ final class PhameBlogDeleteController extends PhameController {
|
|||
$cancel_uri = $this->getApplicationURI('/blog/view/'.$blog->getID().'/');
|
||||
|
||||
$dialog = id(new AphrontDialogView())
|
||||
->setUser($user)
|
||||
->setUser($viewer)
|
||||
->setTitle(pht('Delete Blog?'))
|
||||
->appendChild(
|
||||
pht(
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
<?php
|
||||
|
||||
final class PhameBlogEditController
|
||||
extends PhameController {
|
||||
extends PhameBlogController {
|
||||
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$user = $request->getUser();
|
||||
$viewer = $request->getViewer();
|
||||
$id = $request->getURIData('id');
|
||||
|
||||
if ($id) {
|
||||
$blog = id(new PhameBlogQuery())
|
||||
->setViewer($user)
|
||||
->setViewer($viewer)
|
||||
->withIDs(array($id))
|
||||
->requireCapabilities(
|
||||
array(
|
||||
|
@ -30,7 +30,7 @@ final class PhameBlogEditController
|
|||
$v_projects = array_reverse($v_projects);
|
||||
|
||||
} else {
|
||||
$blog = PhameBlog::initializeNewBlog($user);
|
||||
$blog = PhameBlog::initializeNewBlog($viewer);
|
||||
|
||||
$submit_button = pht('Create Blog');
|
||||
$page_title = pht('Create Blog');
|
||||
|
@ -90,7 +90,7 @@ final class PhameBlogEditController
|
|||
->setNewValue(array('=' => array_fuse($v_projects)));
|
||||
|
||||
$editor = id(new PhameBlogEditor())
|
||||
->setActor($user)
|
||||
->setActor($viewer)
|
||||
->setContentSourceFromRequest($request)
|
||||
->setContinueOnNoEffect(true);
|
||||
|
||||
|
@ -111,7 +111,7 @@ final class PhameBlogEditController
|
|||
}
|
||||
|
||||
$policies = id(new PhabricatorPolicyQuery())
|
||||
->setViewer($user)
|
||||
->setViewer($viewer)
|
||||
->setObject($blog)
|
||||
->execute();
|
||||
|
||||
|
@ -119,7 +119,7 @@ final class PhameBlogEditController
|
|||
$skins = mpull($skins, 'getName');
|
||||
|
||||
$form = id(new AphrontFormView())
|
||||
->setUser($user)
|
||||
->setUser($viewer)
|
||||
->appendChild(
|
||||
id(new AphrontFormTextControl())
|
||||
->setLabel(pht('Name'))
|
||||
|
@ -129,16 +129,16 @@ final class PhameBlogEditController
|
|||
->setError($e_name))
|
||||
->appendChild(
|
||||
id(new PhabricatorRemarkupControl())
|
||||
->setUser($user)
|
||||
->setUser($viewer)
|
||||
->setLabel(pht('Description'))
|
||||
->setName('description')
|
||||
->setValue($description)
|
||||
->setID('blog-description')
|
||||
->setUser($user)
|
||||
->setUser($viewer)
|
||||
->setDisableMacros(true))
|
||||
->appendChild(
|
||||
id(new AphrontFormPolicyControl())
|
||||
->setUser($user)
|
||||
->setUser($viewer)
|
||||
->setCapability(PhabricatorPolicyCapability::CAN_VIEW)
|
||||
->setPolicyObject($blog)
|
||||
->setPolicies($policies)
|
||||
|
@ -147,7 +147,7 @@ final class PhameBlogEditController
|
|||
->setName('can_view'))
|
||||
->appendChild(
|
||||
id(new AphrontFormPolicyControl())
|
||||
->setUser($user)
|
||||
->setUser($viewer)
|
||||
->setCapability(PhabricatorPolicyCapability::CAN_EDIT)
|
||||
->setPolicyObject($blog)
|
||||
->setPolicies($policies)
|
||||
|
@ -155,7 +155,7 @@ final class PhameBlogEditController
|
|||
->setName('can_edit'))
|
||||
->appendChild(
|
||||
id(new AphrontFormPolicyControl())
|
||||
->setUser($user)
|
||||
->setUser($viewer)
|
||||
->setCapability(PhabricatorPolicyCapability::CAN_JOIN)
|
||||
->setPolicyObject($blog)
|
||||
->setPolicies($policies)
|
||||
|
@ -195,13 +195,12 @@ final class PhameBlogEditController
|
|||
$crumbs->addTextCrumb(pht('Blogs'), $this->getApplicationURI('blog/'));
|
||||
$crumbs->addTextCrumb($page_title, $this->getApplicationURI('blog/new'));
|
||||
|
||||
return $this->buildApplicationPage(
|
||||
array(
|
||||
$crumbs,
|
||||
$form_box,
|
||||
),
|
||||
array(
|
||||
'title' => $page_title,
|
||||
return $this->newPage()
|
||||
->setTitle($page_title)
|
||||
->setCrumbs($crumbs)
|
||||
->appendChild(
|
||||
array(
|
||||
$form_box,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
<?php
|
||||
|
||||
final class PhameBlogFeedController extends PhameController {
|
||||
final class PhameBlogFeedController extends PhameBlogController {
|
||||
|
||||
public function shouldRequireLogin() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$user = $request->getUser();
|
||||
$viewer = $request->getViewer();
|
||||
$id = $request->getURIData('id');
|
||||
|
||||
$blog = id(new PhameBlogQuery())
|
||||
->setViewer($user)
|
||||
->setViewer($viewer)
|
||||
->withIDs(array($id))
|
||||
->executeOne();
|
||||
if (!$blog) {
|
||||
|
@ -19,7 +19,7 @@ final class PhameBlogFeedController extends PhameController {
|
|||
}
|
||||
|
||||
$posts = id(new PhamePostQuery())
|
||||
->setViewer($user)
|
||||
->setViewer($viewer)
|
||||
->withBlogPHIDs(array($blog->getPHID()))
|
||||
->withVisibility(PhamePost::VISIBILITY_PUBLISHED)
|
||||
->execute();
|
||||
|
@ -47,7 +47,7 @@ final class PhameBlogFeedController extends PhameController {
|
|||
$content[] = phutil_tag('subtitle', array(), $description);
|
||||
}
|
||||
|
||||
$engine = id(new PhabricatorMarkupEngine())->setViewer($user);
|
||||
$engine = id(new PhabricatorMarkupEngine())->setViewer($viewer);
|
||||
foreach ($posts as $post) {
|
||||
$engine->addObject($post, PhamePost::MARKUP_FIELD_BODY);
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ final class PhameBlogFeedController extends PhameController {
|
|||
|
||||
$blogger_phids = mpull($posts, 'getBloggerPHID');
|
||||
$bloggers = id(new PhabricatorHandleQuery())
|
||||
->setViewer($user)
|
||||
->setViewer($viewer)
|
||||
->withPHIDs($blogger_phids)
|
||||
->execute();
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
final class PhameBlogListController extends PhameController {
|
||||
final class PhameBlogListController extends PhameBlogController {
|
||||
|
||||
public function shouldAllowPublic() {
|
||||
return true;
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<?php
|
||||
|
||||
final class PhameBlogLiveController extends PhameController {
|
||||
final class PhameBlogLiveController extends PhameBlogController {
|
||||
|
||||
public function shouldAllowPublic() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$user = $request->getUser();
|
||||
$viewer = $request->getViewer();
|
||||
|
||||
$site = $request->getSite();
|
||||
if ($site instanceof PhameBlogSite) {
|
||||
|
@ -16,7 +16,7 @@ final class PhameBlogLiveController extends PhameController {
|
|||
$id = $request->getURIData('id');
|
||||
|
||||
$blog = id(new PhameBlogQuery())
|
||||
->setViewer($user)
|
||||
->setViewer($viewer)
|
||||
->withIDs(array($id))
|
||||
->executeOne();
|
||||
if (!$blog) {
|
||||
|
@ -38,7 +38,7 @@ final class PhameBlogLiveController extends PhameController {
|
|||
|
||||
$dialog = id(new AphrontDialogView())
|
||||
->setTitle(pht('Blog Moved'))
|
||||
->setUser($user)
|
||||
->setUser($viewer)
|
||||
->appendParagraph(pht('This blog is now hosted here:'))
|
||||
->appendParagraph(
|
||||
phutil_tag(
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<?php
|
||||
|
||||
final class PhameBlogViewController extends PhameController {
|
||||
final class PhameBlogViewController extends PhameBlogController {
|
||||
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$user = $request->getUser();
|
||||
$viewer = $request->getViewer();
|
||||
$id = $request->getURIData('id');
|
||||
|
||||
$blog = id(new PhameBlogQuery())
|
||||
->setViewer($user)
|
||||
->setViewer($viewer)
|
||||
->withIDs(array($id))
|
||||
->executeOne();
|
||||
if (!$blog) {
|
||||
|
@ -18,20 +18,20 @@ final class PhameBlogViewController extends PhameController {
|
|||
->readFromRequest($request);
|
||||
|
||||
$posts = id(new PhamePostQuery())
|
||||
->setViewer($user)
|
||||
->setViewer($viewer)
|
||||
->withBlogPHIDs(array($blog->getPHID()))
|
||||
->executeWithCursorPager($pager);
|
||||
|
||||
$header = id(new PHUIHeaderView())
|
||||
->setHeader($blog->getName())
|
||||
->setUser($user)
|
||||
->setUser($viewer)
|
||||
->setPolicyObject($blog);
|
||||
|
||||
$actions = $this->renderActions($blog, $user);
|
||||
$properties = $this->renderProperties($blog, $user, $actions);
|
||||
$actions = $this->renderActions($blog, $viewer);
|
||||
$properties = $this->renderProperties($blog, $viewer, $actions);
|
||||
$post_list = $this->renderPostList(
|
||||
$posts,
|
||||
$user,
|
||||
$viewer,
|
||||
pht('This blog has no visible posts.'));
|
||||
|
||||
$post_list = id(new PHUIObjectBoxView())
|
||||
|
@ -46,27 +46,26 @@ final class PhameBlogViewController extends PhameController {
|
|||
->setHeader($header)
|
||||
->addPropertyList($properties);
|
||||
|
||||
return $this->buildApplicationPage(
|
||||
array(
|
||||
$crumbs,
|
||||
$object_box,
|
||||
$post_list,
|
||||
),
|
||||
array(
|
||||
'title' => $blog->getName(),
|
||||
return $this->newPage()
|
||||
->setTitle($blog->getName())
|
||||
->setCrumbs($crumbs)
|
||||
->appendChild(
|
||||
array(
|
||||
$object_box,
|
||||
$post_list,
|
||||
));
|
||||
}
|
||||
|
||||
private function renderProperties(
|
||||
PhameBlog $blog,
|
||||
PhabricatorUser $user,
|
||||
PhabricatorUser $viewer,
|
||||
PhabricatorActionListView $actions) {
|
||||
|
||||
require_celerity_resource('aphront-tooltip-css');
|
||||
Javelin::initBehavior('phabricator-tooltips');
|
||||
|
||||
$properties = id(new PHUIPropertyListView())
|
||||
->setUser($user)
|
||||
->setUser($viewer)
|
||||
->setObject($blog)
|
||||
->setActionList($actions);
|
||||
|
||||
|
@ -94,7 +93,7 @@ final class PhameBlogViewController extends PhameController {
|
|||
$feed_uri));
|
||||
|
||||
$descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions(
|
||||
$user,
|
||||
$viewer,
|
||||
$blog);
|
||||
|
||||
$properties->addProperty(
|
||||
|
@ -106,7 +105,7 @@ final class PhameBlogViewController extends PhameController {
|
|||
$descriptions[PhabricatorPolicyCapability::CAN_JOIN]);
|
||||
|
||||
$engine = id(new PhabricatorMarkupEngine())
|
||||
->setViewer($user)
|
||||
->setViewer($viewer)
|
||||
->addObject($blog, PhameBlog::MARKUP_FIELD_DESCRIPTION)
|
||||
->process();
|
||||
|
||||
|
@ -116,7 +115,7 @@ final class PhameBlogViewController extends PhameController {
|
|||
$description = PhabricatorMarkupEngine::renderOneObject(
|
||||
id(new PhabricatorMarkupOneOff())->setContent($blog->getDescription()),
|
||||
'default',
|
||||
$user);
|
||||
$viewer);
|
||||
$properties->addSectionHeader(
|
||||
pht('Description'),
|
||||
PHUIPropertyListView::ICON_SUMMARY);
|
||||
|
@ -126,19 +125,19 @@ final class PhameBlogViewController extends PhameController {
|
|||
return $properties;
|
||||
}
|
||||
|
||||
private function renderActions(PhameBlog $blog, PhabricatorUser $user) {
|
||||
private function renderActions(PhameBlog $blog, PhabricatorUser $viewer) {
|
||||
$actions = id(new PhabricatorActionListView())
|
||||
->setObject($blog)
|
||||
->setObjectURI($this->getRequest()->getRequestURI())
|
||||
->setUser($user);
|
||||
->setUser($viewer);
|
||||
|
||||
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
||||
$user,
|
||||
$viewer,
|
||||
$blog,
|
||||
PhabricatorPolicyCapability::CAN_EDIT);
|
||||
|
||||
$can_join = PhabricatorPolicyFilter::hasCapability(
|
||||
$user,
|
||||
$viewer,
|
||||
$blog,
|
||||
PhabricatorPolicyCapability::CAN_JOIN);
|
||||
|
||||
|
@ -152,7 +151,7 @@ final class PhameBlogViewController extends PhameController {
|
|||
|
||||
$actions->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setUser($user)
|
||||
->setUser($viewer)
|
||||
->setIcon('fa-globe')
|
||||
->setHref($blog->getLiveURI())
|
||||
->setName(pht('View Live')));
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
abstract class PhamePostController extends PhameController {
|
||||
|
||||
public function buildApplicationMenu() {
|
||||
return $this->newApplicationMenu()
|
||||
->setSearchEngine(new PhamePostSearchEngine());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
<?php
|
||||
|
||||
final class PhamePostDeleteController extends PhameController {
|
||||
final class PhamePostDeleteController extends PhamePostController {
|
||||
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$user = $request->getUser();
|
||||
$viewer = $request->getViewer();
|
||||
|
||||
$post = id(new PhamePostQuery())
|
||||
->setViewer($user)
|
||||
->setViewer($viewer)
|
||||
->withIDs(array($request->getURIData('id')))
|
||||
->requireCapabilities(
|
||||
array(
|
||||
|
@ -26,7 +26,7 @@ final class PhamePostDeleteController extends PhameController {
|
|||
$cancel_uri = $this->getApplicationURI('/post/view/'.$post->getID().'/');
|
||||
|
||||
$dialog = id(new AphrontDialogView())
|
||||
->setUser($user)
|
||||
->setUser($viewer)
|
||||
->setTitle(pht('Delete Post?'))
|
||||
->appendChild(
|
||||
pht(
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
final class PhamePostEditController extends PhameController {
|
||||
final class PhamePostEditController extends PhamePostController {
|
||||
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$viewer = $request->getViewer();
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<?php
|
||||
|
||||
final class PhamePostFramedController extends PhameController {
|
||||
final class PhamePostFramedController extends PhamePostController {
|
||||
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$user = $request->getViewer();
|
||||
$viewer = $request->getViewer();
|
||||
$id = $request->getURIData('id');
|
||||
|
||||
$post = id(new PhamePostQuery())
|
||||
->setViewer($user)
|
||||
->setViewer($viewer)
|
||||
->withIDs(array($id))
|
||||
->requireCapabilities(
|
||||
array(
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
final class PhamePostListController extends PhameController {
|
||||
final class PhamePostListController extends PhamePostController {
|
||||
|
||||
public function shouldAllowPublic() {
|
||||
return true;
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
<?php
|
||||
|
||||
final class PhamePostNewController extends PhameController {
|
||||
final class PhamePostNewController extends PhamePostController {
|
||||
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$user = $request->getUser();
|
||||
$viewer = $request->getViewer();
|
||||
$id = $request->getURIData('id');
|
||||
|
||||
$post = null;
|
||||
$view_uri = null;
|
||||
if ($id) {
|
||||
$post = id(new PhamePostQuery())
|
||||
->setViewer($user)
|
||||
->setViewer($viewer)
|
||||
->withIDs(array($id))
|
||||
->requireCapabilities(
|
||||
array(
|
||||
|
@ -26,7 +26,7 @@ final class PhamePostNewController extends PhameController {
|
|||
|
||||
if ($request->isFormPost()) {
|
||||
$blog = id(new PhameBlogQuery())
|
||||
->setViewer($user)
|
||||
->setViewer($viewer)
|
||||
->withIDs(array($request->getInt('blog')))
|
||||
->requireCapabilities(
|
||||
array(
|
||||
|
@ -49,7 +49,7 @@ final class PhamePostNewController extends PhameController {
|
|||
}
|
||||
|
||||
$blogs = id(new PhameBlogQuery())
|
||||
->setViewer($user)
|
||||
->setViewer($viewer)
|
||||
->requireCapabilities(
|
||||
array(
|
||||
PhabricatorPolicyCapability::CAN_JOIN,
|
||||
|
@ -58,9 +58,9 @@ final class PhamePostNewController extends PhameController {
|
|||
|
||||
$crumbs = $this->buildApplicationCrumbs();
|
||||
$crumbs->addTextCrumb($title, $view_uri);
|
||||
$display = array();
|
||||
$display[] = $crumbs;
|
||||
|
||||
$notification = null;
|
||||
$form_box = null;
|
||||
if (!$blogs) {
|
||||
$notification = id(new PHUIInfoView())
|
||||
->setSeverity(PHUIInfoView::SEVERITY_NODATA)
|
||||
|
@ -68,7 +68,6 @@ final class PhamePostNewController extends PhameController {
|
|||
pht('You do not have permission to join any blogs. Create a blog '.
|
||||
'first, then you can post to it.'));
|
||||
|
||||
$display[] = $notification;
|
||||
} else {
|
||||
$options = mpull($blogs, 'getName', 'getID');
|
||||
asort($options);
|
||||
|
@ -79,7 +78,7 @@ final class PhamePostNewController extends PhameController {
|
|||
}
|
||||
|
||||
$form = id(new AphrontFormView())
|
||||
->setUser($user)
|
||||
->setUser($viewer)
|
||||
->appendChild(
|
||||
id(new AphrontFormSelectControl())
|
||||
->setLabel(pht('Blog'))
|
||||
|
@ -102,19 +101,20 @@ final class PhamePostNewController extends PhameController {
|
|||
->setValue(pht('Continue')));
|
||||
}
|
||||
|
||||
|
||||
$form_box = id(new PHUIObjectBoxView())
|
||||
->setHeaderText($title)
|
||||
->setForm($form);
|
||||
|
||||
$display[] = $form_box;
|
||||
}
|
||||
|
||||
return $this->buildApplicationPage(
|
||||
$display,
|
||||
array(
|
||||
'title' => $title,
|
||||
return $this->newPage()
|
||||
->setTitle($title)
|
||||
->setCrumbs($crumbs)
|
||||
->appendChild(
|
||||
array(
|
||||
$notification,
|
||||
$form_box,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<?php
|
||||
|
||||
final class PhamePostNotLiveController extends PhameController {
|
||||
final class PhamePostNotLiveController extends PhamePostController {
|
||||
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$user = $request->getUser();
|
||||
$viewer = $request->getViewer();
|
||||
$id = $request->getURIData('id');
|
||||
|
||||
$post = id(new PhamePostQuery())
|
||||
->setViewer($user)
|
||||
->setViewer($viewer)
|
||||
->withIDs(array($id))
|
||||
->executeOne();
|
||||
if (!$post) {
|
||||
|
@ -32,7 +32,7 @@ final class PhamePostNotLiveController extends PhameController {
|
|||
$cancel_uri = $this->getApplicationURI('/post/view/'.$post->getID().'/');
|
||||
|
||||
$dialog = id(new AphrontDialogView())
|
||||
->setUser($user)
|
||||
->setUser($viewer)
|
||||
->setTitle(pht('Post Not Live'))
|
||||
->addCancelButton($cancel_uri);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
final class PhamePostPreviewController extends PhameController {
|
||||
final class PhamePostPreviewController extends PhamePostController {
|
||||
|
||||
protected function getSideNavFilter() {
|
||||
return null;
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<?php
|
||||
|
||||
final class PhamePostPublishController extends PhameController {
|
||||
final class PhamePostPublishController extends PhamePostController {
|
||||
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$user = $request->getUser();
|
||||
$viewer = $request->getViewer();
|
||||
$id = $request->getURIData('id');
|
||||
|
||||
$post = id(new PhamePostQuery())
|
||||
->setViewer($user)
|
||||
->setViewer($viewer)
|
||||
->withIDs(array($id))
|
||||
->requireCapabilities(
|
||||
array(
|
||||
|
@ -29,7 +29,7 @@ final class PhamePostPublishController extends PhameController {
|
|||
}
|
||||
|
||||
$form = id(new AphrontFormView())
|
||||
->setUser($user)
|
||||
->setUser($viewer)
|
||||
->appendChild(
|
||||
id(new AphrontFormSubmitControl())
|
||||
->setValue(pht('Publish Post'))
|
||||
|
@ -44,35 +44,30 @@ final class PhamePostPublishController extends PhameController {
|
|||
$crumbs = $this->buildApplicationCrumbs();
|
||||
$crumbs->addTextCrumb(pht('Preview'), $view_uri);
|
||||
|
||||
$nav = $this->renderSideNavFilterView(null);
|
||||
$nav->appendChild(
|
||||
array(
|
||||
$crumbs,
|
||||
$form_box,
|
||||
$frame,
|
||||
));
|
||||
|
||||
return $this->buildApplicationPage(
|
||||
$nav,
|
||||
array(
|
||||
'title' => pht('Preview Post'),
|
||||
return $this->newPage()
|
||||
->setTitle(pht('Preview Post'))
|
||||
->setCrumbs($crumbs)
|
||||
->appendChild(
|
||||
array(
|
||||
$form_box,
|
||||
$frame,
|
||||
));
|
||||
}
|
||||
|
||||
private function renderPreviewFrame(PhamePost $post) {
|
||||
|
||||
// TODO: Clean up this CSS.
|
||||
|
||||
return phutil_tag(
|
||||
'div',
|
||||
array(
|
||||
'style' => 'text-align: center; padding: 1em;',
|
||||
'style' => 'text-align: center; padding: 16px;',
|
||||
),
|
||||
phutil_tag(
|
||||
'iframe',
|
||||
array(
|
||||
'style' => 'width: 100%; height: 600px; '.
|
||||
'border: 1px solid #303030;',
|
||||
'border: 1px solid #BFCFDA; '.
|
||||
'background-color: #fff; '.
|
||||
'border-radius: 3px; ',
|
||||
'src' => $this->getApplicationURI('/post/framed/'.$post->getID().'/'),
|
||||
),
|
||||
''));
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<?php
|
||||
|
||||
final class PhamePostUnpublishController extends PhameController {
|
||||
final class PhamePostUnpublishController extends PhamePostController {
|
||||
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$user = $request->getUser();
|
||||
$viewer = $request->getViewer();
|
||||
$id = $request->getURIData('id');
|
||||
|
||||
$post = id(new PhamePostQuery())
|
||||
->setViewer($user)
|
||||
->setViewer($viewer)
|
||||
->withIDs(array($id))
|
||||
->requireCapabilities(
|
||||
array(
|
||||
|
@ -30,7 +30,7 @@ final class PhamePostUnpublishController extends PhameController {
|
|||
$cancel_uri = $this->getApplicationURI('/post/view/'.$post->getID().'/');
|
||||
|
||||
$dialog = id(new AphrontDialogView())
|
||||
->setUser($user)
|
||||
->setUser($viewer)
|
||||
->setTitle(pht('Unpublish Post?'))
|
||||
->appendChild(
|
||||
pht(
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
final class PhamePostViewController extends PhameController {
|
||||
final class PhamePostViewController extends PhamePostController {
|
||||
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$viewer = $request->getViewer();
|
||||
|
|
|
@ -30,7 +30,7 @@ final class PhameBlogSearchEngine
|
|||
|
||||
protected function getBuiltinQueryNames() {
|
||||
$names = array(
|
||||
'all' => pht('All'),
|
||||
'all' => pht('All Blogs'),
|
||||
);
|
||||
return $names;
|
||||
}
|
||||
|
|
|
@ -44,9 +44,9 @@ final class PhamePostSearchEngine
|
|||
|
||||
protected function getBuiltinQueryNames() {
|
||||
$names = array(
|
||||
'all' => pht('All'),
|
||||
'live' => pht('Live'),
|
||||
'draft' => pht('Draft'),
|
||||
'all' => pht('All Posts'),
|
||||
'live' => pht('Live Posts'),
|
||||
'draft' => pht('Draft Posts'),
|
||||
);
|
||||
return $names;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue