1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-15 09:11:07 +01:00
phorge-phorge/src/applications/uiexample/controller/PhabricatorUIExampleRenderController.php

61 lines
1.5 KiB
PHP
Raw Normal View History

2011-04-01 02:06:33 +02:00
<?php
final class PhabricatorUIExampleRenderController extends PhabricatorController {
2011-04-01 02:06:33 +02:00
public function shouldAllowPublic() {
return true;
}
public function handleRequest(AphrontRequest $request) {
$id = $request->getURIData('class');
2011-04-01 02:06:33 +02:00
$classes = id(new PhutilClassMapQuery())
2011-04-01 02:06:33 +02:00
->setAncestorClass('PhabricatorUIExample')
->setSortMethod('getName')
->execute();
2011-04-01 02:06:33 +02:00
$nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI($this->getApplicationURI('view/')));
2011-04-01 02:06:33 +02:00
foreach ($classes as $class => $obj) {
$name = $obj->getName();
$nav->addFilter($class, $name);
2011-04-01 02:06:33 +02:00
}
$selected = $nav->selectFilter($id, head_key($classes));
2011-04-01 02:06:33 +02:00
$example = $classes[$selected];
$example->setRequest($this->getRequest());
$result = $example->renderExample();
if ($result instanceof AphrontResponse) {
// This allows examples to generate dialogs, etc., for demonstration.
return $result;
}
require_celerity_resource('phabricator-ui-example-css');
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb($example->getName());
$note = id(new PHUIInfoView())
->setTitle(pht('%s (%s)', $example->getName(), get_class($example)))
->appendChild($example->getDescription())
->setSeverity(PHUIInfoView::SEVERITY_NODATA);
2011-04-01 02:06:33 +02:00
$nav->appendChild(
array(
$crumbs,
$note,
$result,
));
2011-04-01 02:06:33 +02:00
return $this->buildApplicationPage(
2011-04-01 02:06:33 +02:00
$nav,
array(
'title' => $example->getName(),
2011-04-01 02:06:33 +02:00
));
}
}