mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 00:42:41 +01:00
Hard-code and unify "more applications" in Phabricator
Summary: This is mostly intended to simplify D2323. We currently allow users to edit and customize the links on the homepage, but as far as I know no one actually does this (no one complained when we redid the homepage earlier this year) and it creates a lot of mess in the database patches and quickstart dump. After D2331, this is the only data we load in the patch files. The patch files are also a mess with respect to this data and have various different versions of it. Also the current UI is just kind of bad, it stretches stuff across too many screens and is generally ungood. Nuking this lets us nuke a lot of code in general. (In the long term, I think we'll move toward an "application" model anyway, and this stuff will go away sooner or later.) I'll add a drop-database patch some time later, just in case anyone does actually use this, so they can get their data out of MySQL. Test Plan: Looked at home page, clicked "More Stuff", got a single list of other apps/things. Reviewers: btrahan, vrana, edward, jungejason Reviewed By: jungejason CC: aran Maniphest Tasks: T345 Differential Revision: https://secure.phabricator.com/D2332
This commit is contained in:
parent
8ed48a89f4
commit
bf505ef51c
23 changed files with 168 additions and 887 deletions
|
@ -568,16 +568,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorDefaultFileStorageEngineSelector' => 'applications/files/engineselector/default',
|
||||
'PhabricatorDefaultSearchEngineSelector' => 'applications/search/selector/default',
|
||||
'PhabricatorDifferenceEngine' => 'infrastructure/diff/engine',
|
||||
'PhabricatorDirectoryCategory' => 'applications/directory/storage/category',
|
||||
'PhabricatorDirectoryCategoryDeleteController' => 'applications/directory/controller/categorydelete',
|
||||
'PhabricatorDirectoryCategoryEditController' => 'applications/directory/controller/categoryedit',
|
||||
'PhabricatorDirectoryCategoryViewController' => 'applications/directory/controller/categoryview',
|
||||
'PhabricatorDirectoryController' => 'applications/directory/controller/base',
|
||||
'PhabricatorDirectoryDAO' => 'applications/directory/storage/base',
|
||||
'PhabricatorDirectoryEditController' => 'applications/directory/controller/edit',
|
||||
'PhabricatorDirectoryItem' => 'applications/directory/storage/item',
|
||||
'PhabricatorDirectoryItemDeleteController' => 'applications/directory/controller/itemdelete',
|
||||
'PhabricatorDirectoryItemEditController' => 'applications/directory/controller/itemedit',
|
||||
'PhabricatorDirectoryMainController' => 'applications/directory/controller/main',
|
||||
'PhabricatorDisabledUserController' => 'applications/auth/controller/disabled',
|
||||
'PhabricatorDraft' => 'applications/draft/storage/draft',
|
||||
|
@ -1487,17 +1478,8 @@ phutil_register_library_map(array(
|
|||
'PhabricatorDaemonTimelineEventController' => 'PhabricatorDaemonController',
|
||||
'PhabricatorDefaultFileStorageEngineSelector' => 'PhabricatorFileStorageEngineSelector',
|
||||
'PhabricatorDefaultSearchEngineSelector' => 'PhabricatorSearchEngineSelector',
|
||||
'PhabricatorDirectoryCategory' => 'PhabricatorDirectoryDAO',
|
||||
'PhabricatorDirectoryCategoryDeleteController' => 'PhabricatorDirectoryController',
|
||||
'PhabricatorDirectoryCategoryEditController' => 'PhabricatorDirectoryController',
|
||||
'PhabricatorDirectoryCategoryViewController' => 'PhabricatorDirectoryController',
|
||||
'PhabricatorDirectoryController' => 'PhabricatorController',
|
||||
'PhabricatorDirectoryDAO' => 'PhabricatorLiskDAO',
|
||||
'PhabricatorDirectoryEditController' => 'PhabricatorDirectoryController',
|
||||
'PhabricatorDirectoryItem' => 'PhabricatorDirectoryDAO',
|
||||
'PhabricatorDirectoryItemDeleteController' => 'PhabricatorDirectoryController',
|
||||
'PhabricatorDirectoryItemEditController' => 'PhabricatorDirectoryController',
|
||||
'PhabricatorDirectoryMainController' => 'PhabricatorDirectoryController',
|
||||
'PhabricatorDirectoryMainController' => 'PhabricatorController',
|
||||
'PhabricatorDisabledUserController' => 'PhabricatorAuthController',
|
||||
'PhabricatorDraft' => 'PhabricatorDraftDAO',
|
||||
'PhabricatorDraftDAO' => 'PhabricatorLiskDAO',
|
||||
|
|
|
@ -32,27 +32,13 @@ class AphrontDefaultApplicationConfiguration
|
|||
|
||||
public function getURIMap() {
|
||||
return $this->getResourceURIMapRules() + array(
|
||||
'/(?:(?P<filter>jump)/)?' =>
|
||||
'/(?:(?P<filter>(?:jump|apps))/)?' =>
|
||||
'PhabricatorDirectoryMainController',
|
||||
'/(?:(?P<filter>feed)/)' => array(
|
||||
'public/' => 'PhabricatorFeedPublicStreamController',
|
||||
'(?:(?P<subfilter>[^/]+)/)?' =>
|
||||
'PhabricatorDirectoryMainController',
|
||||
),
|
||||
'/directory/' => array(
|
||||
'(?P<id>\d+)/'
|
||||
=> 'PhabricatorDirectoryCategoryViewController',
|
||||
'edit/'
|
||||
=> 'PhabricatorDirectoryEditController',
|
||||
'item/edit/(?:(?P<id>\d+)/)?'
|
||||
=> 'PhabricatorDirectoryItemEditController',
|
||||
'item/delete/(?P<id>\d+)/'
|
||||
=> 'PhabricatorDirectoryItemDeleteController',
|
||||
'category/edit/(?:(?P<id>\d+)/)?'
|
||||
=> 'PhabricatorDirectoryCategoryEditController',
|
||||
'category/delete/(?P<id>\d+)/'
|
||||
=> 'PhabricatorDirectoryCategoryDeleteController',
|
||||
),
|
||||
'/file/' => array(
|
||||
'' => 'PhabricatorFileListController',
|
||||
'filter/(?P<filter>\w+)/' => 'PhabricatorFileListController',
|
||||
|
|
|
@ -18,11 +18,6 @@
|
|||
|
||||
abstract class PhabricatorDirectoryController extends PhabricatorController {
|
||||
|
||||
public function shouldRequireAdmin() {
|
||||
// Most controllers here are admin-only, so default to locking them down.
|
||||
return true;
|
||||
}
|
||||
|
||||
public function buildStandardPageResponse($view, array $data) {
|
||||
$page = $this->buildStandardPageView();
|
||||
|
||||
|
@ -47,28 +42,9 @@ abstract class PhabricatorDirectoryController extends PhabricatorController {
|
|||
$nav->addFilter('jump', 'Jump Nav');
|
||||
$nav->addFilter('feed', 'Feed');
|
||||
$nav->addSpacer();
|
||||
$nav->addLabel('Applications');
|
||||
|
||||
$categories = $this->loadDirectoryCategories();
|
||||
|
||||
foreach ($categories as $category) {
|
||||
$nav->addFilter(
|
||||
'directory/'.$category->getID(),
|
||||
$category->getName());
|
||||
}
|
||||
|
||||
if ($user->getIsAdmin()) {
|
||||
$nav->addSpacer();
|
||||
$nav->addFilter('directory/edit', 'Edit Applications...');
|
||||
}
|
||||
$nav->addFilter('apps', 'More Stuff');
|
||||
|
||||
return $nav;
|
||||
}
|
||||
|
||||
protected function loadDirectoryCategories() {
|
||||
$categories = id(new PhabricatorDirectoryCategory())->loadAll();
|
||||
$categories = msort($categories, 'getSequence');
|
||||
return $categories;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
phutil_require_module('phabricator', 'aphront/response/webpage');
|
||||
phutil_require_module('phabricator', 'applications/base/controller/base');
|
||||
phutil_require_module('phabricator', 'applications/directory/storage/category');
|
||||
phutil_require_module('phabricator', 'view/layout/sidenavfilter');
|
||||
|
||||
phutil_require_module('phutil', 'parser/uri');
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
final class PhabricatorDirectoryCategoryDeleteController
|
||||
extends PhabricatorDirectoryController {
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$this->id = $data['id'];
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
|
||||
$category = id(new PhabricatorDirectoryCategory())->load($this->id);
|
||||
if (!$category) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
$request = $this->getRequest();
|
||||
|
||||
if ($request->isFormPost()) {
|
||||
$category->delete();
|
||||
return id(new AphrontRedirectResponse())
|
||||
->setURI('/directory/edit/');
|
||||
}
|
||||
|
||||
$dialog = new AphrontDialogView();
|
||||
$dialog->setUser($request->getUser());
|
||||
$dialog->setTitle('Really delete this category?');
|
||||
$dialog->appendChild("Are you sure you want to delete this category?");
|
||||
$dialog->addSubmitButton('Delete');
|
||||
$dialog->addCancelButton('/directory/edit/');
|
||||
$dialog->setSubmitURI($request->getPath());
|
||||
|
||||
return id(new AphrontDialogResponse())->setDialog($dialog);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'aphront/response/404');
|
||||
phutil_require_module('phabricator', 'aphront/response/dialog');
|
||||
phutil_require_module('phabricator', 'aphront/response/redirect');
|
||||
phutil_require_module('phabricator', 'applications/directory/controller/base');
|
||||
phutil_require_module('phabricator', 'applications/directory/storage/category');
|
||||
phutil_require_module('phabricator', 'view/dialog');
|
||||
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('PhabricatorDirectoryCategoryDeleteController.php');
|
|
@ -1,111 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
final class PhabricatorDirectoryCategoryEditController
|
||||
extends PhabricatorDirectoryController {
|
||||
|
||||
private $id;
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$this->id = idx($data, 'id');
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
|
||||
if ($this->id) {
|
||||
$category = id(new PhabricatorDirectoryCategory())->load($this->id);
|
||||
if (!$category) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
} else {
|
||||
$category = new PhabricatorDirectoryCategory();
|
||||
}
|
||||
|
||||
$e_name = true;
|
||||
$errors = array();
|
||||
|
||||
$request = $this->getRequest();
|
||||
if ($request->isFormPost()) {
|
||||
$category->setName($request->getStr('name'));
|
||||
$category->setSequence($request->getStr('sequence'));
|
||||
|
||||
if (!strlen($category->getName())) {
|
||||
$errors[] = 'Category name is required.';
|
||||
$e_name = 'Required';
|
||||
}
|
||||
|
||||
if (!$errors) {
|
||||
$category->save();
|
||||
return id(new AphrontRedirectResponse())
|
||||
->setURI('/directory/edit/');
|
||||
}
|
||||
}
|
||||
|
||||
$error_view = null;
|
||||
if ($errors) {
|
||||
$error_view = id(new AphrontErrorView())
|
||||
->setTitle('Form Errors')
|
||||
->setErrors($errors);
|
||||
}
|
||||
|
||||
$form = new AphrontFormView();
|
||||
$form->setUser($request->getUser());
|
||||
if ($category->getID()) {
|
||||
$form->setAction('/directory/category/edit/'.$category->getID().'/');
|
||||
} else {
|
||||
$form->setAction('/directory/category/edit/');
|
||||
}
|
||||
|
||||
$categories = id(new PhabricatorDirectoryCategory())->loadAll();
|
||||
$category_map = mpull($categories, 'getName', 'getID');
|
||||
|
||||
$form
|
||||
->appendChild(
|
||||
id(new AphrontFormTextControl())
|
||||
->setLabel('Name')
|
||||
->setName('name')
|
||||
->setValue($category->getName())
|
||||
->setError($e_name))
|
||||
->appendChild(
|
||||
id(new AphrontFormTextControl())
|
||||
->setLabel('Order')
|
||||
->setName('sequence')
|
||||
->setValue((int)$category->getSequence()))
|
||||
->appendChild(
|
||||
id(new AphrontFormSubmitControl())
|
||||
->setValue('Save')
|
||||
->addCancelButton('/directory/edit/'));
|
||||
|
||||
$panel = new AphrontPanelView();
|
||||
if ($category->getID()) {
|
||||
$panel->setHeader('Edit Directory Category');
|
||||
} else {
|
||||
$panel->setHeader('Create New Directory Category');
|
||||
}
|
||||
|
||||
$panel->appendChild($form);
|
||||
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
|
||||
|
||||
return $this->buildStandardPageResponse(
|
||||
array($error_view, $panel),
|
||||
array(
|
||||
'title' => 'Edit Directory Category',
|
||||
));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'aphront/response/404');
|
||||
phutil_require_module('phabricator', 'aphront/response/redirect');
|
||||
phutil_require_module('phabricator', 'applications/directory/controller/base');
|
||||
phutil_require_module('phabricator', 'applications/directory/storage/category');
|
||||
phutil_require_module('phabricator', 'view/form/base');
|
||||
phutil_require_module('phabricator', 'view/form/control/submit');
|
||||
phutil_require_module('phabricator', 'view/form/control/text');
|
||||
phutil_require_module('phabricator', 'view/form/error');
|
||||
phutil_require_module('phabricator', 'view/layout/panel');
|
||||
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('PhabricatorDirectoryCategoryEditController.php');
|
|
@ -1,78 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
final class PhabricatorDirectoryCategoryViewController
|
||||
extends PhabricatorDirectoryController {
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$this->id = $data['id'];
|
||||
}
|
||||
|
||||
public function shouldRequireAdmin() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
$category = id(new PhabricatorDirectoryCategory())->load($this->id);
|
||||
if (!$category) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
$items = id(new PhabricatorDirectoryItem())->loadAllWhere(
|
||||
'categoryID = %d',
|
||||
$category->getID());
|
||||
$items = msort($items, 'getSortKey');
|
||||
|
||||
$nav = $this->buildNav();
|
||||
$nav->selectFilter('directory/'.$this->id, 'directory/'.$this->id);
|
||||
|
||||
require_celerity_resource('phabricator-directory-css');
|
||||
|
||||
$item_markup = array();
|
||||
foreach ($items as $item) {
|
||||
$item_markup[] =
|
||||
'<div class="aphront-directory-item">'.
|
||||
'<h1>'.
|
||||
phutil_render_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => $item->getHref(),
|
||||
),
|
||||
phutil_escape_html($item->getName())).
|
||||
'</h1>'.
|
||||
'<p>'.phutil_escape_html($item->getDescription()).'</p>'.
|
||||
'</div>';
|
||||
}
|
||||
|
||||
$content =
|
||||
'<div class="aphront-directory-list">'.
|
||||
implode("\n", $item_markup).
|
||||
'</div>';
|
||||
|
||||
|
||||
$nav->appendChild($content);
|
||||
|
||||
return $this->buildStandardPageResponse(
|
||||
$nav,
|
||||
array(
|
||||
'title' => 'Directory Category List',
|
||||
'tab' => 'categories',
|
||||
));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'aphront/response/404');
|
||||
phutil_require_module('phabricator', 'applications/directory/controller/base');
|
||||
phutil_require_module('phabricator', 'applications/directory/storage/category');
|
||||
phutil_require_module('phabricator', 'applications/directory/storage/item');
|
||||
phutil_require_module('phabricator', 'infrastructure/celerity/api');
|
||||
|
||||
phutil_require_module('phutil', 'markup');
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('PhabricatorDirectoryCategoryViewController.php');
|
|
@ -1,136 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
final class PhabricatorDirectoryEditController
|
||||
extends PhabricatorDirectoryController {
|
||||
|
||||
public function processRequest() {
|
||||
$nav = $this->buildNav();
|
||||
$nav->selectFilter('directory/edit', 'directory/edit');
|
||||
|
||||
$nav->appendChild($this->buildCategoryList());
|
||||
$nav->appendChild($this->buildItemList());
|
||||
|
||||
return $this->buildStandardPageResponse(
|
||||
$nav,
|
||||
array(
|
||||
'title' => 'Edit Applications',
|
||||
));
|
||||
}
|
||||
|
||||
private function buildCategoryList() {
|
||||
$categories = id(new PhabricatorDirectoryCategory())->loadAll();
|
||||
$categories = msort($categories, 'getSequence');
|
||||
|
||||
$rows = array();
|
||||
foreach ($categories as $category) {
|
||||
$rows[] = array(
|
||||
$category->getID(),
|
||||
phutil_render_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => '/directory/category/edit/'.$category->getID().'/',
|
||||
),
|
||||
phutil_escape_html($category->getName())),
|
||||
javelin_render_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => '/directory/category/delete/'.$category->getID().'/',
|
||||
'class' => 'button grey small',
|
||||
'sigil' => 'workflow',
|
||||
),
|
||||
'Delete'),
|
||||
);
|
||||
}
|
||||
|
||||
$table = new AphrontTableView($rows);
|
||||
$table->setHeaders(
|
||||
array(
|
||||
'ID',
|
||||
'Name',
|
||||
'',
|
||||
));
|
||||
$table->setColumnClasses(
|
||||
array(
|
||||
null,
|
||||
'wide',
|
||||
'action',
|
||||
));
|
||||
|
||||
$panel = new AphrontPanelView();
|
||||
$panel->appendChild($table);
|
||||
$panel->setHeader('Directory Categories');
|
||||
$panel->setCreateButton('New Category', '/directory/category/edit/');
|
||||
|
||||
return $panel;
|
||||
}
|
||||
|
||||
private function buildItemList() {
|
||||
$items = id(new PhabricatorDirectoryItem())->loadAll();
|
||||
$items = msort($items, 'getSortKey');
|
||||
|
||||
$categories = id(new PhabricatorDirectoryCategory())->loadAll();
|
||||
$category_names = mpull($categories, 'getName', 'getID');
|
||||
|
||||
$rows = array();
|
||||
foreach ($items as $item) {
|
||||
$rows[] = array(
|
||||
$item->getID(),
|
||||
phutil_escape_html(idx($category_names, $item->getCategoryID())),
|
||||
phutil_render_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => '/directory/item/edit/'.$item->getID().'/',
|
||||
),
|
||||
phutil_escape_html($item->getName())),
|
||||
javelin_render_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => '/directory/item/delete/'.$item->getID().'/',
|
||||
'class' => 'button grey small',
|
||||
'sigil' => 'workflow',
|
||||
),
|
||||
'Delete'),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$table = new AphrontTableView($rows);
|
||||
$table->setHeaders(
|
||||
array(
|
||||
'ID',
|
||||
'Category',
|
||||
'Name',
|
||||
'',
|
||||
));
|
||||
$table->setColumnClasses(
|
||||
array(
|
||||
null,
|
||||
null,
|
||||
'wide',
|
||||
'action',
|
||||
));
|
||||
|
||||
$panel = new AphrontPanelView();
|
||||
$panel->appendChild($table);
|
||||
$panel->setHeader('Directory Items');
|
||||
$panel->setCreateButton('New Item', '/directory/item/edit/');
|
||||
|
||||
return $panel;
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/directory/controller/base');
|
||||
phutil_require_module('phabricator', 'applications/directory/storage/category');
|
||||
phutil_require_module('phabricator', 'applications/directory/storage/item');
|
||||
phutil_require_module('phabricator', 'infrastructure/javelin/markup');
|
||||
phutil_require_module('phabricator', 'view/control/table');
|
||||
phutil_require_module('phabricator', 'view/layout/panel');
|
||||
|
||||
phutil_require_module('phutil', 'markup');
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('PhabricatorDirectoryEditController.php');
|
|
@ -1,52 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
final class PhabricatorDirectoryItemDeleteController
|
||||
extends PhabricatorDirectoryController {
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$this->id = $data['id'];
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
|
||||
$item = id(new PhabricatorDirectoryItem())->load($this->id);
|
||||
if (!$item) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
$request = $this->getRequest();
|
||||
|
||||
if ($request->isFormPost()) {
|
||||
$item->delete();
|
||||
return id(new AphrontRedirectResponse())
|
||||
->setURI('/directory/edit/');
|
||||
}
|
||||
|
||||
$dialog = new AphrontDialogView();
|
||||
$dialog->setUser($request->getUser());
|
||||
$dialog->setTitle('Really delete this item?');
|
||||
$dialog->appendChild("Are you sure you want to delete this item?");
|
||||
$dialog->addSubmitButton('Delete');
|
||||
$dialog->addCancelButton('/directory/edit/');
|
||||
$dialog->setSubmitURI($request->getPath());
|
||||
|
||||
return id(new AphrontDialogResponse())->setDialog($dialog);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'aphront/response/404');
|
||||
phutil_require_module('phabricator', 'aphront/response/dialog');
|
||||
phutil_require_module('phabricator', 'aphront/response/redirect');
|
||||
phutil_require_module('phabricator', 'applications/directory/controller/base');
|
||||
phutil_require_module('phabricator', 'applications/directory/storage/item');
|
||||
phutil_require_module('phabricator', 'view/dialog');
|
||||
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('PhabricatorDirectoryItemDeleteController.php');
|
|
@ -1,146 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
final class PhabricatorDirectoryItemEditController
|
||||
extends PhabricatorDirectoryController {
|
||||
|
||||
private $id;
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$this->id = idx($data, 'id');
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
|
||||
if ($this->id) {
|
||||
$item = id(new PhabricatorDirectoryItem())->load($this->id);
|
||||
if (!$item) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
} else {
|
||||
$item = new PhabricatorDirectoryItem();
|
||||
}
|
||||
|
||||
$e_name = true;
|
||||
$e_href = true;
|
||||
$errors = array();
|
||||
|
||||
$request = $this->getRequest();
|
||||
if ($request->isFormPost()) {
|
||||
$item->setName($request->getStr('name'));
|
||||
$item->setHref($request->getStr('href'));
|
||||
$item->setDescription($request->getStr('description'));
|
||||
$item->setCategoryID($request->getStr('categoryID'));
|
||||
$item->setSequence($request->getStr('sequence'));
|
||||
|
||||
if (!strlen($item->getName())) {
|
||||
$errors[] = 'Item name is required.';
|
||||
$e_name = 'Required';
|
||||
}
|
||||
|
||||
if (!strlen($item->getHref())) {
|
||||
$errors[] = 'Item link is required.';
|
||||
$e_href = 'Required';
|
||||
} else {
|
||||
$href = $item->getHref();
|
||||
if (!PhabricatorEnv::isValidWebResource($href)) {
|
||||
$e_href = 'Invalid';
|
||||
$errors[] = 'Item link must point to a valid web page.';
|
||||
}
|
||||
}
|
||||
|
||||
if (!$errors) {
|
||||
$item->save();
|
||||
return id(new AphrontRedirectResponse())
|
||||
->setURI('/directory/edit/');
|
||||
}
|
||||
}
|
||||
|
||||
$error_view = null;
|
||||
if ($errors) {
|
||||
$error_view = id(new AphrontErrorView())
|
||||
->setTitle('Form Errors')
|
||||
->setErrors($errors);
|
||||
}
|
||||
|
||||
$form = new AphrontFormView();
|
||||
$form->setUser($request->getUser());
|
||||
|
||||
if ($item->getID()) {
|
||||
$form->setAction('/directory/item/edit/'.$item->getID().'/');
|
||||
} else {
|
||||
$form->setAction('/directory/item/edit/');
|
||||
}
|
||||
|
||||
$categories = id(new PhabricatorDirectoryCategory())->loadAll();
|
||||
$category_map = mpull($categories, 'getName', 'getID');
|
||||
|
||||
$form
|
||||
->appendChild(
|
||||
id(new AphrontFormTextControl())
|
||||
->setLabel('Name')
|
||||
->setName('name')
|
||||
->setValue($item->getName())
|
||||
->setError($e_name))
|
||||
->appendChild(
|
||||
id(new AphrontFormSelectControl())
|
||||
->setLabel('Category')
|
||||
->setName('categoryID')
|
||||
->setOptions($category_map)
|
||||
->setValue($item->getCategoryID()))
|
||||
->appendChild(
|
||||
id(new AphrontFormTextControl())
|
||||
->setLabel('Link')
|
||||
->setName('href')
|
||||
->setValue($item->getHref())
|
||||
->setError($e_href))
|
||||
->appendChild(
|
||||
id(new AphrontFormTextAreaControl())
|
||||
->setLabel('Description')
|
||||
->setName('description')
|
||||
->setValue($item->getDescription()))
|
||||
->appendChild(
|
||||
id(new AphrontFormTextControl())
|
||||
->setLabel('Order')
|
||||
->setName('sequence')
|
||||
->setCaption(
|
||||
'Items in a category are sorted by "order", then by name.')
|
||||
->setValue((int)$item->getSequence()))
|
||||
->appendChild(
|
||||
id(new AphrontFormSubmitControl())
|
||||
->setValue('Save')
|
||||
->addCancelButton('/directory/edit/'));
|
||||
|
||||
$panel = new AphrontPanelView();
|
||||
if ($item->getID()) {
|
||||
$panel->setHeader('Edit Directory Item');
|
||||
} else {
|
||||
$panel->setHeader('Create New Directory Item');
|
||||
}
|
||||
|
||||
$panel->appendChild($form);
|
||||
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
|
||||
|
||||
return $this->buildStandardPageResponse(
|
||||
array($error_view, $panel),
|
||||
array(
|
||||
'title' => 'Edit Directory Item',
|
||||
));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'aphront/response/404');
|
||||
phutil_require_module('phabricator', 'aphront/response/redirect');
|
||||
phutil_require_module('phabricator', 'applications/directory/controller/base');
|
||||
phutil_require_module('phabricator', 'applications/directory/storage/category');
|
||||
phutil_require_module('phabricator', 'applications/directory/storage/item');
|
||||
phutil_require_module('phabricator', 'infrastructure/env');
|
||||
phutil_require_module('phabricator', 'view/form/base');
|
||||
phutil_require_module('phabricator', 'view/form/control/select');
|
||||
phutil_require_module('phabricator', 'view/form/control/submit');
|
||||
phutil_require_module('phabricator', 'view/form/control/text');
|
||||
phutil_require_module('phabricator', 'view/form/control/textarea');
|
||||
phutil_require_module('phabricator', 'view/form/error');
|
||||
phutil_require_module('phabricator', 'view/layout/panel');
|
||||
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('PhabricatorDirectoryItemEditController.php');
|
|
@ -27,12 +27,6 @@ final class PhabricatorDirectoryMainController
|
|||
$this->subfilter = idx($data, 'subfilter');
|
||||
}
|
||||
|
||||
public function shouldRequireAdmin() {
|
||||
// These controllers are admin-only by default, but this one is public,
|
||||
// so allow non-admin users to view it.
|
||||
return false;
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
$user = $this->getRequest()->getUser();
|
||||
|
||||
|
@ -41,6 +35,7 @@ final class PhabricatorDirectoryMainController
|
|||
|
||||
switch ($this->filter) {
|
||||
case 'jump':
|
||||
case 'apps':
|
||||
break;
|
||||
case 'home':
|
||||
case 'feed':
|
||||
|
@ -57,6 +52,8 @@ final class PhabricatorDirectoryMainController
|
|||
return $this->buildFeedResponse($nav, $projects);
|
||||
case 'jump':
|
||||
return $this->buildJumpResponse($nav);
|
||||
case 'apps':
|
||||
return $this->buildAppsResponse($nav);
|
||||
default:
|
||||
return $this->buildMainResponse($nav, $projects);
|
||||
}
|
||||
|
@ -727,4 +724,166 @@ final class PhabricatorDirectoryMainController
|
|||
return $panel;
|
||||
}
|
||||
|
||||
public function buildAppsResponse(AphrontSideNavFilterView $nav) {
|
||||
$user = $this->getRequest()->getUser();
|
||||
|
||||
$apps = array(
|
||||
array(
|
||||
'/repository/',
|
||||
'Repositories',
|
||||
'Configure tracked source code repositories.',
|
||||
),
|
||||
array(
|
||||
'/herald/',
|
||||
'Herald',
|
||||
'Create notification rules. Watch for danger!',
|
||||
),
|
||||
array(
|
||||
'/file/',
|
||||
'Files',
|
||||
'Upload and download files. Blob store for Pokemon pictures.',
|
||||
),
|
||||
array(
|
||||
'/project/',
|
||||
'Projects',
|
||||
'Group stuff into big piles.',
|
||||
),
|
||||
array(
|
||||
'/vote/',
|
||||
'Slowvote',
|
||||
'Create polls. Design by committee.',
|
||||
),
|
||||
array(
|
||||
'/countdown/',
|
||||
'Countdown',
|
||||
'Count down to events. Utilize the full capabilities of your ALU.',
|
||||
),
|
||||
array(
|
||||
'/people/',
|
||||
'People',
|
||||
'User directory. Sort of a social utility.',
|
||||
),
|
||||
array(
|
||||
'/owners/',
|
||||
'Owners',
|
||||
'Keep track of who owns code. Adopt today!',
|
||||
),
|
||||
array(
|
||||
'/conduit/',
|
||||
'Conduit API Console',
|
||||
'Web console for Conduit API.',
|
||||
),
|
||||
array(
|
||||
'/daemon/',
|
||||
'Daemon Console',
|
||||
'Offline process management.',
|
||||
),
|
||||
array(
|
||||
'/mail/',
|
||||
'MetaMTA',
|
||||
'Manage mail delivery. Yo dawg, we heard you like MTAs.',
|
||||
array(
|
||||
'admin' => true,
|
||||
),
|
||||
),
|
||||
array(
|
||||
'/phid/',
|
||||
'PHID Manager',
|
||||
'Debugging tool for PHIDs.',
|
||||
),
|
||||
array(
|
||||
'/xhpast/',
|
||||
'XHPAST',
|
||||
'Web interface to PHP AST tool. Lex XHP AST & CTS FYI, LOL.',
|
||||
),
|
||||
array(
|
||||
'http://www.phabricator.com/docs/phabricator/',
|
||||
'Phabricator Ducks',
|
||||
'Oops, that should say "Docs".',
|
||||
array(
|
||||
'new' => true,
|
||||
),
|
||||
),
|
||||
array(
|
||||
'http://www.phabricator.com/docs/arcanist/',
|
||||
'Arcanist Docs',
|
||||
'Words have never been so finely crafted.',
|
||||
array(
|
||||
'new' => true,
|
||||
),
|
||||
),
|
||||
array(
|
||||
'http://www.phabricator.com/docs/libphutil/',
|
||||
'libphutil Docs',
|
||||
'Soothing prose; seductive poetry.',
|
||||
array(
|
||||
'new' => true,
|
||||
),
|
||||
),
|
||||
array(
|
||||
'http://www.phabricator.com/docs/javelin/',
|
||||
'Javelin Docs',
|
||||
'O, what noble scribe hath penned these words?',
|
||||
array(
|
||||
'new' => true,
|
||||
),
|
||||
),
|
||||
array(
|
||||
'/uiexample/',
|
||||
'UI Examples',
|
||||
'Phabricator UI elements. A gallery of modern art.',
|
||||
array(
|
||||
'new' => true,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$out = array();
|
||||
foreach ($apps as $app) {
|
||||
if (empty($app[3])) {
|
||||
$app[3] = array();
|
||||
}
|
||||
$app[3] += array(
|
||||
'admin' => false,
|
||||
'new' => false,
|
||||
);
|
||||
list($href, $name, $desc, $options) = $app;
|
||||
|
||||
if ($options['admin'] && !$user->getIsAdmin()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$link = phutil_render_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => $href,
|
||||
'target' => $options['new'] ? '_blank' : null,
|
||||
),
|
||||
phutil_escape_html($name));
|
||||
|
||||
|
||||
|
||||
$out[] =
|
||||
'<div class="aphront-directory-item">'.
|
||||
'<h1>'.$link.'</h1>'.
|
||||
'<p>'.phutil_escape_html($desc).'</p>'.
|
||||
'</div>';
|
||||
}
|
||||
|
||||
require_celerity_resource('phabricator-directory-css');
|
||||
|
||||
$out =
|
||||
'<div class="aphront-directory-list">'.
|
||||
implode("\n", $out).
|
||||
'</div>';
|
||||
|
||||
$nav->appendChild($out);
|
||||
|
||||
return $this->buildStandardPageResponse(
|
||||
$nav,
|
||||
array(
|
||||
'title' => 'More Stuff',
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
abstract class PhabricatorDirectoryDAO extends PhabricatorLiskDAO {
|
||||
|
||||
public function getApplicationName() {
|
||||
return 'directory';
|
||||
}
|
||||
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/base/storage/lisk');
|
||||
|
||||
|
||||
phutil_require_source('PhabricatorDirectoryDAO.php');
|
|
@ -1,24 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
final class PhabricatorDirectoryCategory extends PhabricatorDirectoryDAO {
|
||||
|
||||
protected $name;
|
||||
protected $sequence;
|
||||
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/directory/storage/base');
|
||||
|
||||
|
||||
phutil_require_source('PhabricatorDirectoryCategory.php');
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
final class PhabricatorDirectoryItem extends PhabricatorDirectoryDAO {
|
||||
|
||||
protected $name;
|
||||
protected $description;
|
||||
protected $href;
|
||||
protected $categoryID;
|
||||
protected $sequence;
|
||||
protected $imagePHID;
|
||||
|
||||
public function getSortKey() {
|
||||
return sprintf(
|
||||
'%08d:%08d:%s',
|
||||
$this->getCategoryID(),
|
||||
$this->getSequence(),
|
||||
$this->getName());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/directory/storage/base');
|
||||
|
||||
|
||||
phutil_require_source('PhabricatorDirectoryItem.php');
|
Loading…
Reference in a new issue