2011-03-31 17:06:33 -07:00
|
|
|
<?php
|
|
|
|
|
2012-09-11 09:56:40 -07:00
|
|
|
final class PhabricatorUIExampleRenderController extends PhabricatorController {
|
2011-03-31 17:06:33 -07:00
|
|
|
|
2014-04-21 15:32:03 -07:00
|
|
|
public function shouldAllowPublic() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-08-01 15:40:26 -07:00
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
|
|
$id = $request->getURIData('class');
|
2011-03-31 17:06:33 -07:00
|
|
|
|
|
|
|
$classes = id(new PhutilSymbolLoader())
|
|
|
|
->setAncestorClass('PhabricatorUIExample')
|
2014-04-21 15:32:03 -07:00
|
|
|
->loadObjects();
|
2012-09-11 09:56:40 -07:00
|
|
|
$classes = msort($classes, 'getName');
|
2011-03-31 17:06:33 -07:00
|
|
|
|
2012-09-11 09:56:40 -07:00
|
|
|
$nav = new AphrontSideNavFilterView();
|
|
|
|
$nav->setBaseURI(new PhutilURI($this->getApplicationURI('view/')));
|
2011-03-31 17:06:33 -07:00
|
|
|
|
|
|
|
foreach ($classes as $class => $obj) {
|
|
|
|
$name = $obj->getName();
|
2012-09-11 09:56:40 -07:00
|
|
|
$nav->addFilter($class, $name);
|
2011-03-31 17:06:33 -07:00
|
|
|
}
|
|
|
|
|
2015-08-01 15:40:26 -07:00
|
|
|
$selected = $nav->selectFilter($id, head_key($classes));
|
2012-09-11 09:56:40 -07:00
|
|
|
|
2011-03-31 17:06:33 -07:00
|
|
|
$example = $classes[$selected];
|
|
|
|
$example->setRequest($this->getRequest());
|
|
|
|
|
2012-10-03 10:21:39 -07:00
|
|
|
$result = $example->renderExample();
|
|
|
|
if ($result instanceof AphrontResponse) {
|
|
|
|
// This allows examples to generate dialogs, etc., for demonstration.
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
2012-10-16 10:33:47 -07:00
|
|
|
require_celerity_resource('phabricator-ui-example-css');
|
|
|
|
|
2014-04-21 15:32:03 -07:00
|
|
|
$crumbs = $this->buildApplicationCrumbs();
|
|
|
|
$crumbs->addTextCrumb($example->getName());
|
|
|
|
|
2015-05-22 12:50:01 -07:00
|
|
|
$note = id(new PHUIInfoView())
|
|
|
|
->setTitle(pht('%s (%s)', $example->getName(), get_class($example)))
|
|
|
|
->appendChild($example->getDescription())
|
|
|
|
->setSeverity(PHUIInfoView::SEVERITY_NODATA);
|
2011-03-31 17:06:33 -07:00
|
|
|
|
2014-04-21 15:32:03 -07:00
|
|
|
$nav->appendChild(
|
|
|
|
array(
|
|
|
|
$crumbs,
|
2015-05-22 12:50:01 -07:00
|
|
|
$note,
|
2014-04-21 15:32:03 -07:00
|
|
|
$result,
|
|
|
|
));
|
2011-03-31 17:06:33 -07:00
|
|
|
|
2012-09-11 09:56:40 -07:00
|
|
|
return $this->buildApplicationPage(
|
2011-03-31 17:06:33 -07:00
|
|
|
$nav,
|
|
|
|
array(
|
2014-04-21 15:32:03 -07:00
|
|
|
'title' => $example->getName(),
|
2011-03-31 17:06:33 -07:00
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|