mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-15 03:12:41 +01:00
0e07ef8d56
Summary: Still some big chunks left but this moves us a bit closer to getting everything device-ready. Stuff not addressed here but which I'm planning to do soon: - Posts don't have a live URI yet. - Post detail pages don't actually show the post content. I'm going to tweak PhabricatorObjectPropertyListView for this since we need it some other places. - Some of the hinting about use/states is gone (e.g., "This post is a draft, publish it to make it live to the world."); I'm planning to restore it. - Left nav is still a bit of a mess with states/highlighting. Major changes are: - If you click "New Post" you get a screen asking you to pick a blog to post to. - "Publish/Preview" and Unpublish are now separate actions from the post detail screen. - "Publish/Preview" renders a preview of the post in an iframe and gives you a "Publish" button. Test Plan: Will attach screenshots. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T1373 Differential Revision: https://secure.phabricator.com/D3697
103 lines
2.6 KiB
PHP
103 lines
2.6 KiB
PHP
<?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 phame
|
|
*/
|
|
final class PhamePostPublishController extends PhameController {
|
|
|
|
private $id;
|
|
|
|
public function willProcessRequest(array $data) {
|
|
$this->id = $data['id'];
|
|
}
|
|
|
|
public function processRequest() {
|
|
$request = $this->getRequest();
|
|
$user = $request->getUser();
|
|
|
|
$post = id(new PhamePostQuery())
|
|
->setViewer($user)
|
|
->withIDs(array($this->id))
|
|
->requireCapabilities(
|
|
array(
|
|
PhabricatorPolicyCapability::CAN_EDIT,
|
|
))
|
|
->executeOne();
|
|
if (!$post) {
|
|
return new Aphront404Response();
|
|
}
|
|
|
|
$view_uri = $this->getApplicationURI('/post/view/'.$post->getID().'/');
|
|
|
|
if ($request->isFormPost()) {
|
|
$post->setVisibility(PhamePost::VISIBILITY_PUBLISHED);
|
|
$post->setDatePublished(time());
|
|
$post->save();
|
|
|
|
return id(new AphrontRedirectResponse())->setURI($view_uri);
|
|
}
|
|
|
|
$header = id(new PhabricatorHeaderView())
|
|
->setHeader('Preview Post');
|
|
|
|
$form = id(new AphrontFormView())
|
|
->setUser($user)
|
|
->setFlexible(true)
|
|
->appendChild(
|
|
id(new AphrontFormSubmitControl())
|
|
->setValue(pht('Publish Post'))
|
|
->addCancelButton($view_uri));
|
|
|
|
$frame = $this->renderPreviewFrame($post);
|
|
|
|
$nav = $this->renderSideNavFilterView(null);
|
|
$nav->appendChild(
|
|
array(
|
|
$header,
|
|
$form,
|
|
$frame,
|
|
));
|
|
|
|
return $this->buildApplicationPage(
|
|
$nav,
|
|
array(
|
|
'title' => pht('Preview Post'),
|
|
'device' => true,
|
|
));
|
|
}
|
|
|
|
private function renderPreviewFrame(PhamePost $post) {
|
|
|
|
// TODO: Clean up this CSS.
|
|
|
|
return phutil_render_tag(
|
|
'div',
|
|
array(
|
|
'style' => 'text-align: center; padding: 1em;',
|
|
),
|
|
phutil_render_tag(
|
|
'iframe',
|
|
array(
|
|
'style' => 'width: 100%; height: 600px; '.
|
|
'border: 1px solid #303030; background: #303030;',
|
|
'src' => $this->getApplicationURI('/post/framed/'.$post->getID().'/'),
|
|
),
|
|
''));
|
|
}
|
|
}
|