Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/phame/application/PhabricatorPhameApplication.php b/src/applications/phame/application/PhabricatorPhameApplication.php
index f7643c6097..ec98087adf 100644
--- a/src/applications/phame/application/PhabricatorPhameApplication.php
+++ b/src/applications/phame/application/PhabricatorPhameApplication.php
@@ -1,103 +1,105 @@
<?php
final class PhabricatorPhameApplication extends PhabricatorApplication {
public function getName() {
return pht('Phame');
}
public function getBaseURI() {
return '/phame/';
}
public function getFontIcon() {
return 'fa-star';
}
public function getShortDescription() {
return pht('Blog');
}
public function getTitleGlyph() {
return "\xe2\x9c\xa9";
}
public function getHelpDocumentationArticles(PhabricatorUser $viewer) {
return array(
array(
'name' => pht('Phame User Guide'),
'href' => PhabricatorEnv::getDoclink('Phame User Guide'),
),
);
}
public function isPrototype() {
return true;
}
public function getRoutes() {
return array(
'/phame/' => array(
'' => 'PhamePostListController',
'live/(?P<id>[^/]+)/(?P<more>.*)' => 'PhameBlogLiveController',
'post/' => array(
'(?:(?P<filter>draft|all)/)?' => 'PhamePostListController',
+ '(?:query/(?P<queryKey>[^/]+)/)?' => 'PhamePostListController',
'blogger/(?P<bloggername>[\w\.-_]+)/' => 'PhamePostListController',
'delete/(?P<id>[^/]+)/' => 'PhamePostDeleteController',
'edit/(?:(?P<id>[^/]+)/)?' => 'PhamePostEditController',
'view/(?P<id>\d+)/' => 'PhamePostViewController',
'publish/(?P<id>\d+)/' => 'PhamePostPublishController',
'unpublish/(?P<id>\d+)/' => 'PhamePostUnpublishController',
'notlive/(?P<id>\d+)/' => 'PhamePostNotLiveController',
'preview/' => 'PhamePostPreviewController',
'framed/(?P<id>\d+)/' => 'PhamePostFramedController',
'new/' => 'PhamePostNewController',
'move/(?P<id>\d+)/' => 'PhamePostNewController',
),
'blog/' => array(
'(?:(?P<filter>user|all)/)?' => 'PhameBlogListController',
+ '(?:query/(?P<queryKey>[^/]+)/)?' => 'PhameBlogListController',
'delete/(?P<id>[^/]+)/' => 'PhameBlogDeleteController',
'edit/(?P<id>[^/]+)/' => 'PhameBlogEditController',
'view/(?P<id>[^/]+)/' => 'PhameBlogViewController',
'feed/(?P<id>[^/]+)/' => 'PhameBlogFeedController',
'new/' => 'PhameBlogEditController',
),
) + $this->getResourceSubroutes(),
);
}
public function getResourceRoutes() {
return array(
'/phame/' => $this->getResourceSubroutes(),
);
}
private function getResourceSubroutes() {
return array(
'r/(?P<id>\d+)/(?P<hash>[^/]+)/(?P<name>.*)' =>
'PhameResourceController',
);
}
public function getBlogRoutes() {
return array(
'/(?P<more>.*)' => 'PhameBlogLiveController',
);
}
public function getBlogCDNRoutes() {
return array(
'/phame/' => array(
'r/(?P<id>\d+)/(?P<hash>[^/]+)/(?P<name>.*)' =>
'PhameResourceController',
),
);
}
public function getQuicksandURIPatternBlacklist() {
return array(
'/phame/live/.*',
);
}
}
diff --git a/src/applications/phame/controller/blog/PhameBlogListController.php b/src/applications/phame/controller/blog/PhameBlogListController.php
index 9d0253d89c..965e1eec49 100644
--- a/src/applications/phame/controller/blog/PhameBlogListController.php
+++ b/src/applications/phame/controller/blog/PhameBlogListController.php
@@ -1,87 +1,34 @@
<?php
final class PhameBlogListController extends PhameController {
- public function handleRequest(AphrontRequest $request) {
- $user = $request->getUser();
-
- $nav = $this->renderSideNavFilterView(null);
- $filter = $request->getURIData('filter');
- $filter = $nav->selectFilter('blog/'.$filter, 'blog/user');
-
- $query = id(new PhameBlogQuery())
- ->setViewer($user);
-
- switch ($filter) {
- case 'blog/all':
- $title = pht('All Blogs');
- $nodata = pht('No blogs have been created.');
- break;
- case 'blog/user':
- $title = pht('Joinable Blogs');
- $nodata = pht('There are no blogs you can contribute to.');
- $query->requireCapabilities(
- array(
- PhabricatorPolicyCapability::CAN_JOIN,
- ));
- break;
- default:
- throw new Exception(pht("Unknown filter '%s'!", $filter));
- }
-
- $pager = id(new PHUIPagerView())
- ->setURI($request->getRequestURI(), 'offset')
- ->setOffset($request->getInt('offset'));
-
- $blogs = $query->executeWithOffsetPager($pager);
-
- $blog_list = $this->renderBlogList($blogs, $user, $nodata);
- $blog_list->setPager($pager);
-
- $box = id(new PHUIObjectBoxView())
- ->setHeaderText($title)
- ->setObjectList($blog_list);
-
- $crumbs = $this->buildApplicationCrumbs();
- $crumbs->addTextCrumb($title, $this->getApplicationURI());
+ public function shouldAllowPublic() {
+ return true;
+ }
- $nav->appendChild(
- array(
- $crumbs,
- $box,
- ));
+ public function handleRequest(AphrontRequest $request) {
+ $query_key = $request->getURIData('queryKey');
+ $controller = id(new PhabricatorApplicationSearchController())
+ ->setQueryKey($query_key)
+ ->setSearchEngine(new PhameBlogSearchEngine())
+ ->setNavigation($this->buildSideNavView());
- return $this->buildApplicationPage(
- $nav,
- array(
- 'title' => $title,
- ));
+ return $this->delegateToController($controller);
}
- private function renderBlogList(
- array $blogs,
- PhabricatorUser $viewer,
- $nodata) {
+ public function buildSideNavView() {
+ $viewer = $this->getRequest()->getUser();
- $view = new PHUIObjectItemListView();
- $view->setNoDataString($nodata);
- $view->setUser($viewer);
- foreach ($blogs as $blog) {
+ $nav = new AphrontSideNavFilterView();
+ $nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
- $id = $blog->getID();
- $item = id(new PHUIObjectItemView())
- ->setUser($viewer)
- ->setObject($blog)
- ->setHeader($blog->getName())
- ->setStatusIcon('fa-star')
- ->setHref($this->getApplicationURI("/blog/view/{$id}/"))
- ->addAttribute($blog->getSkin())
- ->addAttribute($blog->getDomain());
+ id(new PhameBlogSearchEngine())
+ ->setViewer($viewer)
+ ->addNavigationItems($nav->getMenu());
- $view->addItem($item);
- }
+ $nav->selectFilter(null);
- return $view;
+ return $nav;
}
}
diff --git a/src/applications/phame/controller/post/PhamePostListController.php b/src/applications/phame/controller/post/PhamePostListController.php
index b2b28bd4eb..fb38a830bb 100644
--- a/src/applications/phame/controller/post/PhamePostListController.php
+++ b/src/applications/phame/controller/post/PhamePostListController.php
@@ -1,79 +1,38 @@
<?php
final class PhamePostListController extends PhameController {
- public function handleRequest(AphrontRequest $request) {
- $viewer = $request->getViewer();
- $filter = $request->getURIData('filter');
- $bloggername = $request->getURIData('bloggername');
-
- $query = id(new PhamePostQuery())
- ->setViewer($viewer);
-
- $nav = $this->renderSideNavFilterView();
- $nodata = null;
+ public function shouldAllowPublic() {
+ return true;
+ }
- switch ($filter) {
- case 'draft':
- $query->withBloggerPHIDs(array($viewer->getPHID()));
- $query->withVisibility(PhamePost::VISIBILITY_DRAFT);
- $nodata = pht('You have no unpublished drafts.');
- $title = pht('Unpublished Drafts');
- $nav->selectFilter('post/draft');
- break;
- case 'blogger':
- if ($bloggername) {
- $blogger = id(new PhabricatorUser())->loadOneWhere(
- 'username = %s',
- $bloggername);
- if (!$blogger) {
- return new Aphront404Response();
- }
- } else {
- $blogger = $viewer;
- }
+ public function handleRequest(AphrontRequest $request) {
+ $query_key = $request->getURIData('queryKey');
+ $controller = id(new PhabricatorApplicationSearchController())
+ ->setQueryKey($query_key)
+ ->setSearchEngine(new PhamePostSearchEngine())
+ ->setNavigation($this->buildSideNavView());
- $query->withBloggerPHIDs(array($blogger->getPHID()));
- if ($blogger->getPHID() == $viewer->getPHID()) {
- $nav->selectFilter('post');
- $nodata = pht('You have not written any posts.');
- } else {
- $nodata = pht('%s has not written any posts.', $blogger);
- }
- $title = pht('Posts by %s', $blogger);
- break;
- default:
- case 'all':
- $nodata = pht('There are no visible posts.');
- $title = pht('Posts');
- $nav->selectFilter('post/all');
- break;
- }
+ return $this->delegateToController($controller);
+ }
- $pager = id(new AphrontCursorPagerView())
- ->readFromRequest($request);
+ public function buildSideNavView() {
+ $viewer = $this->getRequest()->getUser();
- $posts = $query->executeWithCursorPager($pager);
+ $nav = new AphrontSideNavFilterView();
+ $nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
- $post_list = $this->renderPostList($posts, $viewer, $nodata);
- $post_list = id(new PHUIObjectBoxView())
- ->setHeaderText($title)
- ->appendChild($post_list);
+ id(new PhamePostSearchEngine())
+ ->setViewer($viewer)
+ ->addNavigationItems($nav->getMenu());
- $crumbs = $this->buildApplicationCrumbs();
- $crumbs->addTextCrumb($title, $this->getApplicationURI());
+ $nav->addLabel(pht('Blogs'));
+ $nav->addFilter('blog/', pht('Manage Blogs'));
- $nav->appendChild(
- array(
- $crumbs,
- $post_list,
- ));
+ $nav->selectFilter(null);
- return $this->buildApplicationPage(
- $nav,
- array(
- 'title' => $title,
- ));
+ return $nav;
}
+
}
diff --git a/src/applications/phame/query/PhamePostSearchEngine.php b/src/applications/phame/query/PhamePostSearchEngine.php
index a5feb3d634..cedc02cc7a 100644
--- a/src/applications/phame/query/PhamePostSearchEngine.php
+++ b/src/applications/phame/query/PhamePostSearchEngine.php
@@ -1,110 +1,111 @@
<?php
final class PhamePostSearchEngine
extends PhabricatorApplicationSearchEngine {
public function getResultTypeDescription() {
return pht('Phame Posts');
}
public function getApplicationClassName() {
return 'PhabricatorPhameApplication';
}
public function newQuery() {
return new PhamePostQuery();
}
protected function buildQueryFromParameters(array $map) {
$query = $this->newQuery();
if (strlen($map['visibility'])) {
$query->withVisibility($map['visibility']);
}
return $query;
}
protected function buildCustomSearchFields() {
return array(
id(new PhabricatorSearchSelectField())
->setKey('visibility')
+ ->setLabel(pht('Visibility'))
->setOptions(array(
'' => pht('All'),
PhamePost::VISIBILITY_PUBLISHED => pht('Live'),
PhamePost::VISIBILITY_DRAFT => pht('Draft'),
)),
);
}
protected function getURI($path) {
return '/phame/post/'.$path;
}
protected function getBuiltinQueryNames() {
$names = array(
'all' => pht('All'),
'live' => pht('Live'),
'draft' => pht('Draft'),
);
return $names;
}
public function buildSavedQueryFromBuiltin($query_key) {
$query = $this->newSavedQuery();
$query->setQueryKey($query_key);
switch ($query_key) {
case 'all':
return $query;
case 'live':
return $query->setParameter(
'visibility', PhamePost::VISIBILITY_PUBLISHED);
case 'draft':
return $query->setParameter(
'visibility', PhamePost::VISIBILITY_DRAFT);
}
return parent::buildSavedQueryFromBuiltin($query_key);
}
protected function renderResultList(
array $posts,
PhabricatorSavedQuery $query,
array $handles) {
assert_instances_of($posts, 'PhamePost');
$viewer = $this->requireViewer();
$list = new PHUIObjectItemListView();
$list->setUser($viewer);
foreach ($posts as $post) {
$id = $post->getID();
$blog = $viewer->renderHandle($post->getBlogPHID())->render();
$item = id(new PHUIObjectItemView())
->setUser($viewer)
->setObject($post)
->setHeader($post->getTitle())
->setStatusIcon('fa-star')
->setHref($this->getApplicationURI("/post/view/{$id}/"))
->addAttribute(
pht('Blog: %s', $blog));
if ($post->isDraft()) {
$item->setStatusIcon('fa-star-o grey');
$item->setDisabled(true);
$item->addIcon('none', pht('Draft Post'));
} else {
$date = $post->getDatePublished();
$item->setEpoch($date);
}
$list->addItem($item);
}
$result = new PhabricatorApplicationSearchResultView();
$result->setObjectList($list);
$result->setNoDataString(pht('No blogs posts found.'));
return $result;
}
}

File Metadata

Mime Type
text/x-diff
Expires
Wed, Apr 30, 4:35 AM (1 d, 7 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
108554
Default Alt Text
(13 KB)

Event Timeline