@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+168 -887
+1 -19
src/__phutil_library_map__.php
··· 568 568 'PhabricatorDefaultFileStorageEngineSelector' => 'applications/files/engineselector/default', 569 569 'PhabricatorDefaultSearchEngineSelector' => 'applications/search/selector/default', 570 570 'PhabricatorDifferenceEngine' => 'infrastructure/diff/engine', 571 - 'PhabricatorDirectoryCategory' => 'applications/directory/storage/category', 572 - 'PhabricatorDirectoryCategoryDeleteController' => 'applications/directory/controller/categorydelete', 573 - 'PhabricatorDirectoryCategoryEditController' => 'applications/directory/controller/categoryedit', 574 - 'PhabricatorDirectoryCategoryViewController' => 'applications/directory/controller/categoryview', 575 571 'PhabricatorDirectoryController' => 'applications/directory/controller/base', 576 - 'PhabricatorDirectoryDAO' => 'applications/directory/storage/base', 577 - 'PhabricatorDirectoryEditController' => 'applications/directory/controller/edit', 578 - 'PhabricatorDirectoryItem' => 'applications/directory/storage/item', 579 - 'PhabricatorDirectoryItemDeleteController' => 'applications/directory/controller/itemdelete', 580 - 'PhabricatorDirectoryItemEditController' => 'applications/directory/controller/itemedit', 581 572 'PhabricatorDirectoryMainController' => 'applications/directory/controller/main', 582 573 'PhabricatorDisabledUserController' => 'applications/auth/controller/disabled', 583 574 'PhabricatorDraft' => 'applications/draft/storage/draft', ··· 1487 1478 'PhabricatorDaemonTimelineEventController' => 'PhabricatorDaemonController', 1488 1479 'PhabricatorDefaultFileStorageEngineSelector' => 'PhabricatorFileStorageEngineSelector', 1489 1480 'PhabricatorDefaultSearchEngineSelector' => 'PhabricatorSearchEngineSelector', 1490 - 'PhabricatorDirectoryCategory' => 'PhabricatorDirectoryDAO', 1491 - 'PhabricatorDirectoryCategoryDeleteController' => 'PhabricatorDirectoryController', 1492 - 'PhabricatorDirectoryCategoryEditController' => 'PhabricatorDirectoryController', 1493 - 'PhabricatorDirectoryCategoryViewController' => 'PhabricatorDirectoryController', 1494 1481 'PhabricatorDirectoryController' => 'PhabricatorController', 1495 - 'PhabricatorDirectoryDAO' => 'PhabricatorLiskDAO', 1496 - 'PhabricatorDirectoryEditController' => 'PhabricatorDirectoryController', 1497 - 'PhabricatorDirectoryItem' => 'PhabricatorDirectoryDAO', 1498 - 'PhabricatorDirectoryItemDeleteController' => 'PhabricatorDirectoryController', 1499 - 'PhabricatorDirectoryItemEditController' => 'PhabricatorDirectoryController', 1500 - 'PhabricatorDirectoryMainController' => 'PhabricatorDirectoryController', 1482 + 'PhabricatorDirectoryMainController' => 'PhabricatorController', 1501 1483 'PhabricatorDisabledUserController' => 'PhabricatorAuthController', 1502 1484 'PhabricatorDraft' => 'PhabricatorDraftDAO', 1503 1485 'PhabricatorDraftDAO' => 'PhabricatorLiskDAO',
+1 -15
src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php
··· 32 32 33 33 public function getURIMap() { 34 34 return $this->getResourceURIMapRules() + array( 35 - '/(?:(?P<filter>jump)/)?' => 35 + '/(?:(?P<filter>(?:jump|apps))/)?' => 36 36 'PhabricatorDirectoryMainController', 37 37 '/(?:(?P<filter>feed)/)' => array( 38 38 'public/' => 'PhabricatorFeedPublicStreamController', 39 39 '(?:(?P<subfilter>[^/]+)/)?' => 40 40 'PhabricatorDirectoryMainController', 41 - ), 42 - '/directory/' => array( 43 - '(?P<id>\d+)/' 44 - => 'PhabricatorDirectoryCategoryViewController', 45 - 'edit/' 46 - => 'PhabricatorDirectoryEditController', 47 - 'item/edit/(?:(?P<id>\d+)/)?' 48 - => 'PhabricatorDirectoryItemEditController', 49 - 'item/delete/(?P<id>\d+)/' 50 - => 'PhabricatorDirectoryItemDeleteController', 51 - 'category/edit/(?:(?P<id>\d+)/)?' 52 - => 'PhabricatorDirectoryCategoryEditController', 53 - 'category/delete/(?P<id>\d+)/' 54 - => 'PhabricatorDirectoryCategoryDeleteController', 55 41 ), 56 42 '/file/' => array( 57 43 '' => 'PhabricatorFileListController',
+1 -25
src/applications/directory/controller/base/PhabricatorDirectoryController.php
··· 18 18 19 19 abstract class PhabricatorDirectoryController extends PhabricatorController { 20 20 21 - public function shouldRequireAdmin() { 22 - // Most controllers here are admin-only, so default to locking them down. 23 - return true; 24 - } 25 - 26 21 public function buildStandardPageResponse($view, array $data) { 27 22 $page = $this->buildStandardPageView(); 28 23 ··· 47 42 $nav->addFilter('jump', 'Jump Nav'); 48 43 $nav->addFilter('feed', 'Feed'); 49 44 $nav->addSpacer(); 50 - $nav->addLabel('Applications'); 51 - 52 - $categories = $this->loadDirectoryCategories(); 53 - 54 - foreach ($categories as $category) { 55 - $nav->addFilter( 56 - 'directory/'.$category->getID(), 57 - $category->getName()); 58 - } 59 - 60 - if ($user->getIsAdmin()) { 61 - $nav->addSpacer(); 62 - $nav->addFilter('directory/edit', 'Edit Applications...'); 63 - } 45 + $nav->addFilter('apps', 'More Stuff'); 64 46 65 47 return $nav; 66 - } 67 - 68 - protected function loadDirectoryCategories() { 69 - $categories = id(new PhabricatorDirectoryCategory())->loadAll(); 70 - $categories = msort($categories, 'getSequence'); 71 - return $categories; 72 48 } 73 49 74 50 }
-1
src/applications/directory/controller/base/__init__.php
··· 8 8 9 9 phutil_require_module('phabricator', 'aphront/response/webpage'); 10 10 phutil_require_module('phabricator', 'applications/base/controller/base'); 11 - phutil_require_module('phabricator', 'applications/directory/storage/category'); 12 11 phutil_require_module('phabricator', 'view/layout/sidenavfilter'); 13 12 14 13 phutil_require_module('phutil', 'parser/uri');
-52
src/applications/directory/controller/categorydelete/PhabricatorDirectoryCategoryDeleteController.php
··· 1 - <?php 2 - 3 - /* 4 - * Copyright 2012 Facebook, Inc. 5 - * 6 - * Licensed under the Apache License, Version 2.0 (the "License"); 7 - * you may not use this file except in compliance with the License. 8 - * You may obtain a copy of the License at 9 - * 10 - * http://www.apache.org/licenses/LICENSE-2.0 11 - * 12 - * Unless required by applicable law or agreed to in writing, software 13 - * distributed under the License is distributed on an "AS IS" BASIS, 14 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 - * See the License for the specific language governing permissions and 16 - * limitations under the License. 17 - */ 18 - 19 - final class PhabricatorDirectoryCategoryDeleteController 20 - extends PhabricatorDirectoryController { 21 - 22 - public function willProcessRequest(array $data) { 23 - $this->id = $data['id']; 24 - } 25 - 26 - public function processRequest() { 27 - 28 - $category = id(new PhabricatorDirectoryCategory())->load($this->id); 29 - if (!$category) { 30 - return new Aphront404Response(); 31 - } 32 - 33 - $request = $this->getRequest(); 34 - 35 - if ($request->isFormPost()) { 36 - $category->delete(); 37 - return id(new AphrontRedirectResponse()) 38 - ->setURI('/directory/edit/'); 39 - } 40 - 41 - $dialog = new AphrontDialogView(); 42 - $dialog->setUser($request->getUser()); 43 - $dialog->setTitle('Really delete this category?'); 44 - $dialog->appendChild("Are you sure you want to delete this category?"); 45 - $dialog->addSubmitButton('Delete'); 46 - $dialog->addCancelButton('/directory/edit/'); 47 - $dialog->setSubmitURI($request->getPath()); 48 - 49 - return id(new AphrontDialogResponse())->setDialog($dialog); 50 - } 51 - 52 - }
-19
src/applications/directory/controller/categorydelete/__init__.php
··· 1 - <?php 2 - /** 3 - * This file is automatically generated. Lint this module to rebuild it. 4 - * @generated 5 - */ 6 - 7 - 8 - 9 - phutil_require_module('phabricator', 'aphront/response/404'); 10 - phutil_require_module('phabricator', 'aphront/response/dialog'); 11 - phutil_require_module('phabricator', 'aphront/response/redirect'); 12 - phutil_require_module('phabricator', 'applications/directory/controller/base'); 13 - phutil_require_module('phabricator', 'applications/directory/storage/category'); 14 - phutil_require_module('phabricator', 'view/dialog'); 15 - 16 - phutil_require_module('phutil', 'utils'); 17 - 18 - 19 - phutil_require_source('PhabricatorDirectoryCategoryDeleteController.php');
-111
src/applications/directory/controller/categoryedit/PhabricatorDirectoryCategoryEditController.php
··· 1 - <?php 2 - 3 - /* 4 - * Copyright 2012 Facebook, Inc. 5 - * 6 - * Licensed under the Apache License, Version 2.0 (the "License"); 7 - * you may not use this file except in compliance with the License. 8 - * You may obtain a copy of the License at 9 - * 10 - * http://www.apache.org/licenses/LICENSE-2.0 11 - * 12 - * Unless required by applicable law or agreed to in writing, software 13 - * distributed under the License is distributed on an "AS IS" BASIS, 14 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 - * See the License for the specific language governing permissions and 16 - * limitations under the License. 17 - */ 18 - 19 - final class PhabricatorDirectoryCategoryEditController 20 - extends PhabricatorDirectoryController { 21 - 22 - private $id; 23 - 24 - public function willProcessRequest(array $data) { 25 - $this->id = idx($data, 'id'); 26 - } 27 - 28 - public function processRequest() { 29 - 30 - if ($this->id) { 31 - $category = id(new PhabricatorDirectoryCategory())->load($this->id); 32 - if (!$category) { 33 - return new Aphront404Response(); 34 - } 35 - } else { 36 - $category = new PhabricatorDirectoryCategory(); 37 - } 38 - 39 - $e_name = true; 40 - $errors = array(); 41 - 42 - $request = $this->getRequest(); 43 - if ($request->isFormPost()) { 44 - $category->setName($request->getStr('name')); 45 - $category->setSequence($request->getStr('sequence')); 46 - 47 - if (!strlen($category->getName())) { 48 - $errors[] = 'Category name is required.'; 49 - $e_name = 'Required'; 50 - } 51 - 52 - if (!$errors) { 53 - $category->save(); 54 - return id(new AphrontRedirectResponse()) 55 - ->setURI('/directory/edit/'); 56 - } 57 - } 58 - 59 - $error_view = null; 60 - if ($errors) { 61 - $error_view = id(new AphrontErrorView()) 62 - ->setTitle('Form Errors') 63 - ->setErrors($errors); 64 - } 65 - 66 - $form = new AphrontFormView(); 67 - $form->setUser($request->getUser()); 68 - if ($category->getID()) { 69 - $form->setAction('/directory/category/edit/'.$category->getID().'/'); 70 - } else { 71 - $form->setAction('/directory/category/edit/'); 72 - } 73 - 74 - $categories = id(new PhabricatorDirectoryCategory())->loadAll(); 75 - $category_map = mpull($categories, 'getName', 'getID'); 76 - 77 - $form 78 - ->appendChild( 79 - id(new AphrontFormTextControl()) 80 - ->setLabel('Name') 81 - ->setName('name') 82 - ->setValue($category->getName()) 83 - ->setError($e_name)) 84 - ->appendChild( 85 - id(new AphrontFormTextControl()) 86 - ->setLabel('Order') 87 - ->setName('sequence') 88 - ->setValue((int)$category->getSequence())) 89 - ->appendChild( 90 - id(new AphrontFormSubmitControl()) 91 - ->setValue('Save') 92 - ->addCancelButton('/directory/edit/')); 93 - 94 - $panel = new AphrontPanelView(); 95 - if ($category->getID()) { 96 - $panel->setHeader('Edit Directory Category'); 97 - } else { 98 - $panel->setHeader('Create New Directory Category'); 99 - } 100 - 101 - $panel->appendChild($form); 102 - $panel->setWidth(AphrontPanelView::WIDTH_FORM); 103 - 104 - return $this->buildStandardPageResponse( 105 - array($error_view, $panel), 106 - array( 107 - 'title' => 'Edit Directory Category', 108 - )); 109 - } 110 - 111 - }
-22
src/applications/directory/controller/categoryedit/__init__.php
··· 1 - <?php 2 - /** 3 - * This file is automatically generated. Lint this module to rebuild it. 4 - * @generated 5 - */ 6 - 7 - 8 - 9 - phutil_require_module('phabricator', 'aphront/response/404'); 10 - phutil_require_module('phabricator', 'aphront/response/redirect'); 11 - phutil_require_module('phabricator', 'applications/directory/controller/base'); 12 - phutil_require_module('phabricator', 'applications/directory/storage/category'); 13 - phutil_require_module('phabricator', 'view/form/base'); 14 - phutil_require_module('phabricator', 'view/form/control/submit'); 15 - phutil_require_module('phabricator', 'view/form/control/text'); 16 - phutil_require_module('phabricator', 'view/form/error'); 17 - phutil_require_module('phabricator', 'view/layout/panel'); 18 - 19 - phutil_require_module('phutil', 'utils'); 20 - 21 - 22 - phutil_require_source('PhabricatorDirectoryCategoryEditController.php');
-78
src/applications/directory/controller/categoryview/PhabricatorDirectoryCategoryViewController.php
··· 1 - <?php 2 - 3 - /* 4 - * Copyright 2012 Facebook, Inc. 5 - * 6 - * Licensed under the Apache License, Version 2.0 (the "License"); 7 - * you may not use this file except in compliance with the License. 8 - * You may obtain a copy of the License at 9 - * 10 - * http://www.apache.org/licenses/LICENSE-2.0 11 - * 12 - * Unless required by applicable law or agreed to in writing, software 13 - * distributed under the License is distributed on an "AS IS" BASIS, 14 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 - * See the License for the specific language governing permissions and 16 - * limitations under the License. 17 - */ 18 - 19 - final class PhabricatorDirectoryCategoryViewController 20 - extends PhabricatorDirectoryController { 21 - 22 - public function willProcessRequest(array $data) { 23 - $this->id = $data['id']; 24 - } 25 - 26 - public function shouldRequireAdmin() { 27 - return false; 28 - } 29 - 30 - public function processRequest() { 31 - $category = id(new PhabricatorDirectoryCategory())->load($this->id); 32 - if (!$category) { 33 - return new Aphront404Response(); 34 - } 35 - 36 - $items = id(new PhabricatorDirectoryItem())->loadAllWhere( 37 - 'categoryID = %d', 38 - $category->getID()); 39 - $items = msort($items, 'getSortKey'); 40 - 41 - $nav = $this->buildNav(); 42 - $nav->selectFilter('directory/'.$this->id, 'directory/'.$this->id); 43 - 44 - require_celerity_resource('phabricator-directory-css'); 45 - 46 - $item_markup = array(); 47 - foreach ($items as $item) { 48 - $item_markup[] = 49 - '<div class="aphront-directory-item">'. 50 - '<h1>'. 51 - phutil_render_tag( 52 - 'a', 53 - array( 54 - 'href' => $item->getHref(), 55 - ), 56 - phutil_escape_html($item->getName())). 57 - '</h1>'. 58 - '<p>'.phutil_escape_html($item->getDescription()).'</p>'. 59 - '</div>'; 60 - } 61 - 62 - $content = 63 - '<div class="aphront-directory-list">'. 64 - implode("\n", $item_markup). 65 - '</div>'; 66 - 67 - 68 - $nav->appendChild($content); 69 - 70 - return $this->buildStandardPageResponse( 71 - $nav, 72 - array( 73 - 'title' => 'Directory Category List', 74 - 'tab' => 'categories', 75 - )); 76 - } 77 - 78 - }
-19
src/applications/directory/controller/categoryview/__init__.php
··· 1 - <?php 2 - /** 3 - * This file is automatically generated. Lint this module to rebuild it. 4 - * @generated 5 - */ 6 - 7 - 8 - 9 - phutil_require_module('phabricator', 'aphront/response/404'); 10 - phutil_require_module('phabricator', 'applications/directory/controller/base'); 11 - phutil_require_module('phabricator', 'applications/directory/storage/category'); 12 - phutil_require_module('phabricator', 'applications/directory/storage/item'); 13 - phutil_require_module('phabricator', 'infrastructure/celerity/api'); 14 - 15 - phutil_require_module('phutil', 'markup'); 16 - phutil_require_module('phutil', 'utils'); 17 - 18 - 19 - phutil_require_source('PhabricatorDirectoryCategoryViewController.php');
-136
src/applications/directory/controller/edit/PhabricatorDirectoryEditController.php
··· 1 - <?php 2 - 3 - /* 4 - * Copyright 2012 Facebook, Inc. 5 - * 6 - * Licensed under the Apache License, Version 2.0 (the "License"); 7 - * you may not use this file except in compliance with the License. 8 - * You may obtain a copy of the License at 9 - * 10 - * http://www.apache.org/licenses/LICENSE-2.0 11 - * 12 - * Unless required by applicable law or agreed to in writing, software 13 - * distributed under the License is distributed on an "AS IS" BASIS, 14 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 - * See the License for the specific language governing permissions and 16 - * limitations under the License. 17 - */ 18 - 19 - final class PhabricatorDirectoryEditController 20 - extends PhabricatorDirectoryController { 21 - 22 - public function processRequest() { 23 - $nav = $this->buildNav(); 24 - $nav->selectFilter('directory/edit', 'directory/edit'); 25 - 26 - $nav->appendChild($this->buildCategoryList()); 27 - $nav->appendChild($this->buildItemList()); 28 - 29 - return $this->buildStandardPageResponse( 30 - $nav, 31 - array( 32 - 'title' => 'Edit Applications', 33 - )); 34 - } 35 - 36 - private function buildCategoryList() { 37 - $categories = id(new PhabricatorDirectoryCategory())->loadAll(); 38 - $categories = msort($categories, 'getSequence'); 39 - 40 - $rows = array(); 41 - foreach ($categories as $category) { 42 - $rows[] = array( 43 - $category->getID(), 44 - phutil_render_tag( 45 - 'a', 46 - array( 47 - 'href' => '/directory/category/edit/'.$category->getID().'/', 48 - ), 49 - phutil_escape_html($category->getName())), 50 - javelin_render_tag( 51 - 'a', 52 - array( 53 - 'href' => '/directory/category/delete/'.$category->getID().'/', 54 - 'class' => 'button grey small', 55 - 'sigil' => 'workflow', 56 - ), 57 - 'Delete'), 58 - ); 59 - } 60 - 61 - $table = new AphrontTableView($rows); 62 - $table->setHeaders( 63 - array( 64 - 'ID', 65 - 'Name', 66 - '', 67 - )); 68 - $table->setColumnClasses( 69 - array( 70 - null, 71 - 'wide', 72 - 'action', 73 - )); 74 - 75 - $panel = new AphrontPanelView(); 76 - $panel->appendChild($table); 77 - $panel->setHeader('Directory Categories'); 78 - $panel->setCreateButton('New Category', '/directory/category/edit/'); 79 - 80 - return $panel; 81 - } 82 - 83 - private function buildItemList() { 84 - $items = id(new PhabricatorDirectoryItem())->loadAll(); 85 - $items = msort($items, 'getSortKey'); 86 - 87 - $categories = id(new PhabricatorDirectoryCategory())->loadAll(); 88 - $category_names = mpull($categories, 'getName', 'getID'); 89 - 90 - $rows = array(); 91 - foreach ($items as $item) { 92 - $rows[] = array( 93 - $item->getID(), 94 - phutil_escape_html(idx($category_names, $item->getCategoryID())), 95 - phutil_render_tag( 96 - 'a', 97 - array( 98 - 'href' => '/directory/item/edit/'.$item->getID().'/', 99 - ), 100 - phutil_escape_html($item->getName())), 101 - javelin_render_tag( 102 - 'a', 103 - array( 104 - 'href' => '/directory/item/delete/'.$item->getID().'/', 105 - 'class' => 'button grey small', 106 - 'sigil' => 'workflow', 107 - ), 108 - 'Delete'), 109 - ); 110 - } 111 - 112 - 113 - $table = new AphrontTableView($rows); 114 - $table->setHeaders( 115 - array( 116 - 'ID', 117 - 'Category', 118 - 'Name', 119 - '', 120 - )); 121 - $table->setColumnClasses( 122 - array( 123 - null, 124 - null, 125 - 'wide', 126 - 'action', 127 - )); 128 - 129 - $panel = new AphrontPanelView(); 130 - $panel->appendChild($table); 131 - $panel->setHeader('Directory Items'); 132 - $panel->setCreateButton('New Item', '/directory/item/edit/'); 133 - 134 - return $panel; 135 - } 136 - }
-20
src/applications/directory/controller/edit/__init__.php
··· 1 - <?php 2 - /** 3 - * This file is automatically generated. Lint this module to rebuild it. 4 - * @generated 5 - */ 6 - 7 - 8 - 9 - phutil_require_module('phabricator', 'applications/directory/controller/base'); 10 - phutil_require_module('phabricator', 'applications/directory/storage/category'); 11 - phutil_require_module('phabricator', 'applications/directory/storage/item'); 12 - phutil_require_module('phabricator', 'infrastructure/javelin/markup'); 13 - phutil_require_module('phabricator', 'view/control/table'); 14 - phutil_require_module('phabricator', 'view/layout/panel'); 15 - 16 - phutil_require_module('phutil', 'markup'); 17 - phutil_require_module('phutil', 'utils'); 18 - 19 - 20 - phutil_require_source('PhabricatorDirectoryEditController.php');
-52
src/applications/directory/controller/itemdelete/PhabricatorDirectoryItemDeleteController.php
··· 1 - <?php 2 - 3 - /* 4 - * Copyright 2012 Facebook, Inc. 5 - * 6 - * Licensed under the Apache License, Version 2.0 (the "License"); 7 - * you may not use this file except in compliance with the License. 8 - * You may obtain a copy of the License at 9 - * 10 - * http://www.apache.org/licenses/LICENSE-2.0 11 - * 12 - * Unless required by applicable law or agreed to in writing, software 13 - * distributed under the License is distributed on an "AS IS" BASIS, 14 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 - * See the License for the specific language governing permissions and 16 - * limitations under the License. 17 - */ 18 - 19 - final class PhabricatorDirectoryItemDeleteController 20 - extends PhabricatorDirectoryController { 21 - 22 - public function willProcessRequest(array $data) { 23 - $this->id = $data['id']; 24 - } 25 - 26 - public function processRequest() { 27 - 28 - $item = id(new PhabricatorDirectoryItem())->load($this->id); 29 - if (!$item) { 30 - return new Aphront404Response(); 31 - } 32 - 33 - $request = $this->getRequest(); 34 - 35 - if ($request->isFormPost()) { 36 - $item->delete(); 37 - return id(new AphrontRedirectResponse()) 38 - ->setURI('/directory/edit/'); 39 - } 40 - 41 - $dialog = new AphrontDialogView(); 42 - $dialog->setUser($request->getUser()); 43 - $dialog->setTitle('Really delete this item?'); 44 - $dialog->appendChild("Are you sure you want to delete this item?"); 45 - $dialog->addSubmitButton('Delete'); 46 - $dialog->addCancelButton('/directory/edit/'); 47 - $dialog->setSubmitURI($request->getPath()); 48 - 49 - return id(new AphrontDialogResponse())->setDialog($dialog); 50 - } 51 - 52 - }
-19
src/applications/directory/controller/itemdelete/__init__.php
··· 1 - <?php 2 - /** 3 - * This file is automatically generated. Lint this module to rebuild it. 4 - * @generated 5 - */ 6 - 7 - 8 - 9 - phutil_require_module('phabricator', 'aphront/response/404'); 10 - phutil_require_module('phabricator', 'aphront/response/dialog'); 11 - phutil_require_module('phabricator', 'aphront/response/redirect'); 12 - phutil_require_module('phabricator', 'applications/directory/controller/base'); 13 - phutil_require_module('phabricator', 'applications/directory/storage/item'); 14 - phutil_require_module('phabricator', 'view/dialog'); 15 - 16 - phutil_require_module('phutil', 'utils'); 17 - 18 - 19 - phutil_require_source('PhabricatorDirectoryItemDeleteController.php');
-146
src/applications/directory/controller/itemedit/PhabricatorDirectoryItemEditController.php
··· 1 - <?php 2 - 3 - /* 4 - * Copyright 2012 Facebook, Inc. 5 - * 6 - * Licensed under the Apache License, Version 2.0 (the "License"); 7 - * you may not use this file except in compliance with the License. 8 - * You may obtain a copy of the License at 9 - * 10 - * http://www.apache.org/licenses/LICENSE-2.0 11 - * 12 - * Unless required by applicable law or agreed to in writing, software 13 - * distributed under the License is distributed on an "AS IS" BASIS, 14 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 - * See the License for the specific language governing permissions and 16 - * limitations under the License. 17 - */ 18 - 19 - final class PhabricatorDirectoryItemEditController 20 - extends PhabricatorDirectoryController { 21 - 22 - private $id; 23 - 24 - public function willProcessRequest(array $data) { 25 - $this->id = idx($data, 'id'); 26 - } 27 - 28 - public function processRequest() { 29 - 30 - if ($this->id) { 31 - $item = id(new PhabricatorDirectoryItem())->load($this->id); 32 - if (!$item) { 33 - return new Aphront404Response(); 34 - } 35 - } else { 36 - $item = new PhabricatorDirectoryItem(); 37 - } 38 - 39 - $e_name = true; 40 - $e_href = true; 41 - $errors = array(); 42 - 43 - $request = $this->getRequest(); 44 - if ($request->isFormPost()) { 45 - $item->setName($request->getStr('name')); 46 - $item->setHref($request->getStr('href')); 47 - $item->setDescription($request->getStr('description')); 48 - $item->setCategoryID($request->getStr('categoryID')); 49 - $item->setSequence($request->getStr('sequence')); 50 - 51 - if (!strlen($item->getName())) { 52 - $errors[] = 'Item name is required.'; 53 - $e_name = 'Required'; 54 - } 55 - 56 - if (!strlen($item->getHref())) { 57 - $errors[] = 'Item link is required.'; 58 - $e_href = 'Required'; 59 - } else { 60 - $href = $item->getHref(); 61 - if (!PhabricatorEnv::isValidWebResource($href)) { 62 - $e_href = 'Invalid'; 63 - $errors[] = 'Item link must point to a valid web page.'; 64 - } 65 - } 66 - 67 - if (!$errors) { 68 - $item->save(); 69 - return id(new AphrontRedirectResponse()) 70 - ->setURI('/directory/edit/'); 71 - } 72 - } 73 - 74 - $error_view = null; 75 - if ($errors) { 76 - $error_view = id(new AphrontErrorView()) 77 - ->setTitle('Form Errors') 78 - ->setErrors($errors); 79 - } 80 - 81 - $form = new AphrontFormView(); 82 - $form->setUser($request->getUser()); 83 - 84 - if ($item->getID()) { 85 - $form->setAction('/directory/item/edit/'.$item->getID().'/'); 86 - } else { 87 - $form->setAction('/directory/item/edit/'); 88 - } 89 - 90 - $categories = id(new PhabricatorDirectoryCategory())->loadAll(); 91 - $category_map = mpull($categories, 'getName', 'getID'); 92 - 93 - $form 94 - ->appendChild( 95 - id(new AphrontFormTextControl()) 96 - ->setLabel('Name') 97 - ->setName('name') 98 - ->setValue($item->getName()) 99 - ->setError($e_name)) 100 - ->appendChild( 101 - id(new AphrontFormSelectControl()) 102 - ->setLabel('Category') 103 - ->setName('categoryID') 104 - ->setOptions($category_map) 105 - ->setValue($item->getCategoryID())) 106 - ->appendChild( 107 - id(new AphrontFormTextControl()) 108 - ->setLabel('Link') 109 - ->setName('href') 110 - ->setValue($item->getHref()) 111 - ->setError($e_href)) 112 - ->appendChild( 113 - id(new AphrontFormTextAreaControl()) 114 - ->setLabel('Description') 115 - ->setName('description') 116 - ->setValue($item->getDescription())) 117 - ->appendChild( 118 - id(new AphrontFormTextControl()) 119 - ->setLabel('Order') 120 - ->setName('sequence') 121 - ->setCaption( 122 - 'Items in a category are sorted by "order", then by name.') 123 - ->setValue((int)$item->getSequence())) 124 - ->appendChild( 125 - id(new AphrontFormSubmitControl()) 126 - ->setValue('Save') 127 - ->addCancelButton('/directory/edit/')); 128 - 129 - $panel = new AphrontPanelView(); 130 - if ($item->getID()) { 131 - $panel->setHeader('Edit Directory Item'); 132 - } else { 133 - $panel->setHeader('Create New Directory Item'); 134 - } 135 - 136 - $panel->appendChild($form); 137 - $panel->setWidth(AphrontPanelView::WIDTH_FORM); 138 - 139 - return $this->buildStandardPageResponse( 140 - array($error_view, $panel), 141 - array( 142 - 'title' => 'Edit Directory Item', 143 - )); 144 - } 145 - 146 - }
-26
src/applications/directory/controller/itemedit/__init__.php
··· 1 - <?php 2 - /** 3 - * This file is automatically generated. Lint this module to rebuild it. 4 - * @generated 5 - */ 6 - 7 - 8 - 9 - phutil_require_module('phabricator', 'aphront/response/404'); 10 - phutil_require_module('phabricator', 'aphront/response/redirect'); 11 - phutil_require_module('phabricator', 'applications/directory/controller/base'); 12 - phutil_require_module('phabricator', 'applications/directory/storage/category'); 13 - phutil_require_module('phabricator', 'applications/directory/storage/item'); 14 - phutil_require_module('phabricator', 'infrastructure/env'); 15 - phutil_require_module('phabricator', 'view/form/base'); 16 - phutil_require_module('phabricator', 'view/form/control/select'); 17 - phutil_require_module('phabricator', 'view/form/control/submit'); 18 - phutil_require_module('phabricator', 'view/form/control/text'); 19 - phutil_require_module('phabricator', 'view/form/control/textarea'); 20 - phutil_require_module('phabricator', 'view/form/error'); 21 - phutil_require_module('phabricator', 'view/layout/panel'); 22 - 23 - phutil_require_module('phutil', 'utils'); 24 - 25 - 26 - phutil_require_source('PhabricatorDirectoryItemEditController.php');
+165 -6
src/applications/directory/controller/main/PhabricatorDirectoryMainController.php
··· 27 27 $this->subfilter = idx($data, 'subfilter'); 28 28 } 29 29 30 - public function shouldRequireAdmin() { 31 - // These controllers are admin-only by default, but this one is public, 32 - // so allow non-admin users to view it. 33 - return false; 34 - } 35 - 36 30 public function processRequest() { 37 31 $user = $this->getRequest()->getUser(); 38 32 ··· 41 35 42 36 switch ($this->filter) { 43 37 case 'jump': 38 + case 'apps': 44 39 break; 45 40 case 'home': 46 41 case 'feed': ··· 57 52 return $this->buildFeedResponse($nav, $projects); 58 53 case 'jump': 59 54 return $this->buildJumpResponse($nav); 55 + case 'apps': 56 + return $this->buildAppsResponse($nav); 60 57 default: 61 58 return $this->buildMainResponse($nav, $projects); 62 59 } ··· 725 722 "View Problem Commits \xC2\xBB")); 726 723 727 724 return $panel; 725 + } 726 + 727 + public function buildAppsResponse(AphrontSideNavFilterView $nav) { 728 + $user = $this->getRequest()->getUser(); 729 + 730 + $apps = array( 731 + array( 732 + '/repository/', 733 + 'Repositories', 734 + 'Configure tracked source code repositories.', 735 + ), 736 + array( 737 + '/herald/', 738 + 'Herald', 739 + 'Create notification rules. Watch for danger!', 740 + ), 741 + array( 742 + '/file/', 743 + 'Files', 744 + 'Upload and download files. Blob store for Pokemon pictures.', 745 + ), 746 + array( 747 + '/project/', 748 + 'Projects', 749 + 'Group stuff into big piles.', 750 + ), 751 + array( 752 + '/vote/', 753 + 'Slowvote', 754 + 'Create polls. Design by committee.', 755 + ), 756 + array( 757 + '/countdown/', 758 + 'Countdown', 759 + 'Count down to events. Utilize the full capabilities of your ALU.', 760 + ), 761 + array( 762 + '/people/', 763 + 'People', 764 + 'User directory. Sort of a social utility.', 765 + ), 766 + array( 767 + '/owners/', 768 + 'Owners', 769 + 'Keep track of who owns code. Adopt today!', 770 + ), 771 + array( 772 + '/conduit/', 773 + 'Conduit API Console', 774 + 'Web console for Conduit API.', 775 + ), 776 + array( 777 + '/daemon/', 778 + 'Daemon Console', 779 + 'Offline process management.', 780 + ), 781 + array( 782 + '/mail/', 783 + 'MetaMTA', 784 + 'Manage mail delivery. Yo dawg, we heard you like MTAs.', 785 + array( 786 + 'admin' => true, 787 + ), 788 + ), 789 + array( 790 + '/phid/', 791 + 'PHID Manager', 792 + 'Debugging tool for PHIDs.', 793 + ), 794 + array( 795 + '/xhpast/', 796 + 'XHPAST', 797 + 'Web interface to PHP AST tool. Lex XHP AST & CTS FYI, LOL.', 798 + ), 799 + array( 800 + 'http://www.phabricator.com/docs/phabricator/', 801 + 'Phabricator Ducks', 802 + 'Oops, that should say "Docs".', 803 + array( 804 + 'new' => true, 805 + ), 806 + ), 807 + array( 808 + 'http://www.phabricator.com/docs/arcanist/', 809 + 'Arcanist Docs', 810 + 'Words have never been so finely crafted.', 811 + array( 812 + 'new' => true, 813 + ), 814 + ), 815 + array( 816 + 'http://www.phabricator.com/docs/libphutil/', 817 + 'libphutil Docs', 818 + 'Soothing prose; seductive poetry.', 819 + array( 820 + 'new' => true, 821 + ), 822 + ), 823 + array( 824 + 'http://www.phabricator.com/docs/javelin/', 825 + 'Javelin Docs', 826 + 'O, what noble scribe hath penned these words?', 827 + array( 828 + 'new' => true, 829 + ), 830 + ), 831 + array( 832 + '/uiexample/', 833 + 'UI Examples', 834 + 'Phabricator UI elements. A gallery of modern art.', 835 + array( 836 + 'new' => true, 837 + ), 838 + ), 839 + ); 840 + 841 + $out = array(); 842 + foreach ($apps as $app) { 843 + if (empty($app[3])) { 844 + $app[3] = array(); 845 + } 846 + $app[3] += array( 847 + 'admin' => false, 848 + 'new' => false, 849 + ); 850 + list($href, $name, $desc, $options) = $app; 851 + 852 + if ($options['admin'] && !$user->getIsAdmin()) { 853 + continue; 854 + } 855 + 856 + $link = phutil_render_tag( 857 + 'a', 858 + array( 859 + 'href' => $href, 860 + 'target' => $options['new'] ? '_blank' : null, 861 + ), 862 + phutil_escape_html($name)); 863 + 864 + 865 + 866 + $out[] = 867 + '<div class="aphront-directory-item">'. 868 + '<h1>'.$link.'</h1>'. 869 + '<p>'.phutil_escape_html($desc).'</p>'. 870 + '</div>'; 871 + } 872 + 873 + require_celerity_resource('phabricator-directory-css'); 874 + 875 + $out = 876 + '<div class="aphront-directory-list">'. 877 + implode("\n", $out). 878 + '</div>'; 879 + 880 + $nav->appendChild($out); 881 + 882 + return $this->buildStandardPageResponse( 883 + $nav, 884 + array( 885 + 'title' => 'More Stuff', 886 + )); 728 887 } 729 888 730 889 }
-25
src/applications/directory/storage/base/PhabricatorDirectoryDAO.php
··· 1 - <?php 2 - 3 - /* 4 - * Copyright 2011 Facebook, Inc. 5 - * 6 - * Licensed under the Apache License, Version 2.0 (the "License"); 7 - * you may not use this file except in compliance with the License. 8 - * You may obtain a copy of the License at 9 - * 10 - * http://www.apache.org/licenses/LICENSE-2.0 11 - * 12 - * Unless required by applicable law or agreed to in writing, software 13 - * distributed under the License is distributed on an "AS IS" BASIS, 14 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 - * See the License for the specific language governing permissions and 16 - * limitations under the License. 17 - */ 18 - 19 - abstract class PhabricatorDirectoryDAO extends PhabricatorLiskDAO { 20 - 21 - public function getApplicationName() { 22 - return 'directory'; 23 - } 24 - 25 - }
-12
src/applications/directory/storage/base/__init__.php
··· 1 - <?php 2 - /** 3 - * This file is automatically generated. Lint this module to rebuild it. 4 - * @generated 5 - */ 6 - 7 - 8 - 9 - phutil_require_module('phabricator', 'applications/base/storage/lisk'); 10 - 11 - 12 - phutil_require_source('PhabricatorDirectoryDAO.php');
-24
src/applications/directory/storage/category/PhabricatorDirectoryCategory.php
··· 1 - <?php 2 - 3 - /* 4 - * Copyright 2012 Facebook, Inc. 5 - * 6 - * Licensed under the Apache License, Version 2.0 (the "License"); 7 - * you may not use this file except in compliance with the License. 8 - * You may obtain a copy of the License at 9 - * 10 - * http://www.apache.org/licenses/LICENSE-2.0 11 - * 12 - * Unless required by applicable law or agreed to in writing, software 13 - * distributed under the License is distributed on an "AS IS" BASIS, 14 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 - * See the License for the specific language governing permissions and 16 - * limitations under the License. 17 - */ 18 - 19 - final class PhabricatorDirectoryCategory extends PhabricatorDirectoryDAO { 20 - 21 - protected $name; 22 - protected $sequence; 23 - 24 - }
-12
src/applications/directory/storage/category/__init__.php
··· 1 - <?php 2 - /** 3 - * This file is automatically generated. Lint this module to rebuild it. 4 - * @generated 5 - */ 6 - 7 - 8 - 9 - phutil_require_module('phabricator', 'applications/directory/storage/base'); 10 - 11 - 12 - phutil_require_source('PhabricatorDirectoryCategory.php');
-36
src/applications/directory/storage/item/PhabricatorDirectoryItem.php
··· 1 - <?php 2 - 3 - /* 4 - * Copyright 2012 Facebook, Inc. 5 - * 6 - * Licensed under the Apache License, Version 2.0 (the "License"); 7 - * you may not use this file except in compliance with the License. 8 - * You may obtain a copy of the License at 9 - * 10 - * http://www.apache.org/licenses/LICENSE-2.0 11 - * 12 - * Unless required by applicable law or agreed to in writing, software 13 - * distributed under the License is distributed on an "AS IS" BASIS, 14 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 - * See the License for the specific language governing permissions and 16 - * limitations under the License. 17 - */ 18 - 19 - final class PhabricatorDirectoryItem extends PhabricatorDirectoryDAO { 20 - 21 - protected $name; 22 - protected $description; 23 - protected $href; 24 - protected $categoryID; 25 - protected $sequence; 26 - protected $imagePHID; 27 - 28 - public function getSortKey() { 29 - return sprintf( 30 - '%08d:%08d:%s', 31 - $this->getCategoryID(), 32 - $this->getSequence(), 33 - $this->getName()); 34 - } 35 - 36 - }
-12
src/applications/directory/storage/item/__init__.php
··· 1 - <?php 2 - /** 3 - * This file is automatically generated. Lint this module to rebuild it. 4 - * @generated 5 - */ 6 - 7 - 8 - 9 - phutil_require_module('phabricator', 'applications/directory/storage/base'); 10 - 11 - 12 - phutil_require_source('PhabricatorDirectoryItem.php');