Differential D14642 Diff 35424 src/applications/phame/controller/post/PhamePostPreviewController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phame/controller/post/PhamePostPreviewController.php
- This file was copied from src/applications/phame/controller/post/PhamePostPublishController.php.
<?php | <?php | ||||
final class PhamePostPublishController extends PhamePostController { | final class PhamePostPreviewController extends PhamePostController { | ||||
public function handleRequest(AphrontRequest $request) { | public function handleRequest(AphrontRequest $request) { | ||||
$viewer = $request->getViewer(); | $viewer = $request->getViewer(); | ||||
$id = $request->getURIData('id'); | $id = $request->getURIData('id'); | ||||
$post = id(new PhamePostQuery()) | $post = id(new PhamePostQuery()) | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->withIDs(array($id)) | ->withIDs(array($id)) | ||||
Show All 32 Lines | $form = id(new AphrontFormView()) | ||||
->addCancelButton($view_uri)); | ->addCancelButton($view_uri)); | ||||
$frame = $this->renderPreviewFrame($post); | $frame = $this->renderPreviewFrame($post); | ||||
$form_box = id(new PHUIObjectBoxView()) | $form_box = id(new PHUIObjectBoxView()) | ||||
->setHeaderText(pht('Preview Post')) | ->setHeaderText(pht('Preview Post')) | ||||
->setForm($form); | ->setForm($form); | ||||
$blog = $post->getBlog(); | |||||
$crumbs = $this->buildApplicationCrumbs(); | $crumbs = $this->buildApplicationCrumbs(); | ||||
$crumbs->addTextCrumb(pht('Preview'), $view_uri); | $crumbs->addTextCrumb( | ||||
$blog->getName(), | |||||
$this->getApplicationURI('blog/view/'.$blog->getID().'/')); | |||||
$crumbs->addTextCrumb(pht('Preview Post'), $view_uri); | |||||
return $this->newPage() | return $this->newPage() | ||||
->setTitle(pht('Preview Post')) | ->setTitle(pht('Preview Post')) | ||||
->setCrumbs($crumbs) | ->setCrumbs($crumbs) | ||||
->appendChild( | ->appendChild( | ||||
array( | array( | ||||
$form_box, | $form_box, | ||||
$frame, | $frame, | ||||
)); | )); | ||||
} | } | ||||
private function renderPreviewFrame(PhamePost $post) { | private function renderPreviewFrame(PhamePost $post) { | ||||
return phutil_tag( | return phutil_tag( | ||||
'div', | 'div', | ||||
array( | array( | ||||
'style' => 'text-align: center; padding: 16px;', | 'style' => 'text-align: center; padding: 16px;', | ||||
), | ), | ||||
phutil_tag( | phutil_tag( | ||||
'iframe', | 'iframe', | ||||
array( | array( | ||||
'style' => 'width: 100%; height: 600px; '. | 'style' => 'width: 100%; height: 800px; '. | ||||
'border: 1px solid #BFCFDA; '. | 'border: 1px solid #BFCFDA; '. | ||||
'background-color: #fff; '. | 'background-color: #fff; '. | ||||
'border-radius: 3px; ', | 'border-radius: 3px; ', | ||||
'src' => $this->getApplicationURI('/post/framed/'.$post->getID().'/'), | 'src' => $this->getApplicationURI('/post/framed/'.$post->getID().'/'), | ||||
), | ), | ||||
'')); | '')); | ||||
} | } | ||||
} | } |