Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / dashboard / controller / panel / PhabricatorDashboardPanelRenderController.php
blobfee7ef6de472445a7c9822b1c37b776e5a069738
1 <?php
3 final class PhabricatorDashboardPanelRenderController
4 extends PhabricatorDashboardController {
6 public function shouldAllowPublic() {
7 return true;
10 public function handleRequest(AphrontRequest $request) {
11 $viewer = $request->getViewer();
12 $id = $request->getURIData('id');
14 $panel = id(new PhabricatorDashboardPanelQuery())
15 ->setViewer($viewer)
16 ->withIDs(array($id))
17 ->executeOne();
18 if (!$panel) {
19 return new Aphront404Response();
22 if ($request->isAjax()) {
23 $parent_phids = $request->getStrList('parentPanelPHIDs', null);
24 if ($parent_phids === null) {
25 throw new Exception(
26 pht(
27 'Required parameter `parentPanelPHIDs` is not present in '.
28 'request.'));
30 } else {
31 $parent_phids = array();
34 $engine = id(new PhabricatorDashboardPanelRenderingEngine())
35 ->setViewer($viewer)
36 ->setPanel($panel)
37 ->setPanelPHID($panel->getPHID())
38 ->setParentPanelPHIDs($parent_phids)
39 ->setMovable($request->getBool('movable'))
40 ->setHeaderMode($request->getStr('headerMode'))
41 ->setPanelKey($request->getStr('panelKey'));
43 $context_phid = $request->getStr('contextPHID');
44 if ($context_phid) {
45 $context = id(new PhabricatorObjectQuery())
46 ->setViewer($viewer)
47 ->withPHIDs(array($context_phid))
48 ->executeOne();
49 if (!$context) {
50 return new Aphront404Response();
52 $engine->setContextObject($context);
55 $rendered_panel = $engine->renderPanel();
57 if ($request->isAjax()) {
58 return id(new AphrontAjaxResponse())
59 ->setContent(
60 array(
61 'panelMarkup' => hsprintf('%s', $rendered_panel),
62 ));
65 $crumbs = $this->buildApplicationCrumbs()
66 ->addTextCrumb(pht('Panels'), $this->getApplicationURI('panel/'))
67 ->addTextCrumb($panel->getMonogram(), '/'.$panel->getMonogram())
68 ->addTextCrumb(pht('Standalone View'))
69 ->setBorder(true);
71 $view = id(new PHUIBoxView())
72 ->addClass('dashboard-view')
73 ->appendChild($rendered_panel);
75 return $this->newPage()
76 ->setTitle(array(pht('Panel'), $panel->getName()))
77 ->setCrumbs($crumbs)
78 ->appendChild($view);