From d3cd9115f949b9662e288821fa3e9282666e80f7 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 10 Sep 2014 14:44:34 -0700 Subject: [PATCH] Add `ui.footer-items` to add a custom page footer Summary: Fixes T6052. Allow installs to link to legal documents, etc., in the page footer. Test Plan: - Configured a footer. - Viewed workboards (no footer). - Viewed Conpherence (no apparent disruption, I think everything z-indexes over the footer). - Viewed stuff on mobile (seems OK). - Viewed login page (saw footer). {F201718} Reviewers: btrahan, chad Reviewed By: chad Subscribers: epriestley Maniphest Tasks: T6052 Differential Revision: https://secure.phabricator.com/D10466 --- resources/celerity/map.php | 6 +- .../base/controller/PhabricatorController.php | 1 + .../option/PhabricatorUIConfigOptions.php | 32 +++++++ .../PhabricatorProjectBoardViewController.php | 1 + src/view/page/PhabricatorStandardPageView.php | 90 +++++++++++++++---- .../application/base/standard-page-view.css | 8 ++ 6 files changed, 118 insertions(+), 20 deletions(-) diff --git a/resources/celerity/map.php b/resources/celerity/map.php index e89c97bfbb..3ec7241b5a 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -7,7 +7,7 @@ */ return array( 'names' => array( - 'core.pkg.css' => '974635bb', + 'core.pkg.css' => 'f4235a32', 'core.pkg.js' => 'cbdbd552', 'darkconsole.pkg.js' => 'df001cab', 'differential.pkg.css' => '36884139', @@ -39,7 +39,7 @@ return array( 'rsrc/css/application/base/main-menu-view.css' => 'aceca0e9', 'rsrc/css/application/base/notification-menu.css' => '6aa0a74b', 'rsrc/css/application/base/phabricator-application-launch-view.css' => '8b7e271d', - 'rsrc/css/application/base/standard-page-view.css' => '517cdfb1', + 'rsrc/css/application/base/standard-page-view.css' => 'dd860661', 'rsrc/css/application/chatlog/chatlog.css' => '852140ff', 'rsrc/css/application/config/config-options.css' => '7fedf08b', 'rsrc/css/application/config/config-template.css' => '25d446d6', @@ -739,7 +739,7 @@ return array( 'phabricator-side-menu-view-css' => 'a2ccd7bd', 'phabricator-slowvote-css' => '266df6a1', 'phabricator-source-code-view-css' => '7d346aa4', - 'phabricator-standard-page-view' => '517cdfb1', + 'phabricator-standard-page-view' => 'dd860661', 'phabricator-textareautils' => '5c93c52c', 'phabricator-title' => '5c1c758c', 'phabricator-tooltip' => '3915d490', diff --git a/src/applications/base/controller/PhabricatorController.php b/src/applications/base/controller/PhabricatorController.php index 8b1db66769..df39349240 100644 --- a/src/applications/base/controller/PhabricatorController.php +++ b/src/applications/base/controller/PhabricatorController.php @@ -296,6 +296,7 @@ abstract class PhabricatorController extends AphrontController { $page->setDeviceReady(true); } + $page->setShowFooter(idx($options, 'showFooter', true)); $page->setShowChrome(idx($options, 'chrome', true)); $application_menu = $this->buildApplicationMenu(); diff --git a/src/applications/config/option/PhabricatorUIConfigOptions.php b/src/applications/config/option/PhabricatorUIConfigOptions.php index 01a55b7922..0b95fdfbc3 100644 --- a/src/applications/config/option/PhabricatorUIConfigOptions.php +++ b/src/applications/config/option/PhabricatorUIConfigOptions.php @@ -20,12 +20,44 @@ final class PhabricatorUIConfigOptions $options[$key] = $key; } + $example = <<newOption('ui.header-color', 'enum', 'dark') ->setDescription( pht( 'Sets the color of the main header.')) ->setEnumOptions($options), + $this->newOption('ui.footer-items', 'list', array()) + ->setSummary( + pht( + 'Allows you to add footer links on most pages.')) + ->setDescription( + pht( + "Allows you to add a footer with links in it to most ". + "pages. You might want to use these links to point at legal ". + "information or an about page.\n\n". + "Specify a list of dictionaries. Each dictionary describes ". + "a footer item. These keys are supported:\n\n". + " - `name` The name of the item.\n". + " - `href` Optionally, the link target of the item. You can ". + " omit this if you just want a piece of text, like a copyright ". + " notice.")) + ->addExample($example, pht('Basic Example')), ); } diff --git a/src/applications/project/controller/PhabricatorProjectBoardViewController.php b/src/applications/project/controller/PhabricatorProjectBoardViewController.php index 25519a368e..48c1d86b38 100644 --- a/src/applications/project/controller/PhabricatorProjectBoardViewController.php +++ b/src/applications/project/controller/PhabricatorProjectBoardViewController.php @@ -326,6 +326,7 @@ final class PhabricatorProjectBoardViewController ), array( 'title' => pht('%s Board', $project->getName()), + 'showFooter' => false, )); } diff --git a/src/view/page/PhabricatorStandardPageView.php b/src/view/page/PhabricatorStandardPageView.php index 6bfa86c74b..bcf274817b 100644 --- a/src/view/page/PhabricatorStandardPageView.php +++ b/src/view/page/PhabricatorStandardPageView.php @@ -15,6 +15,16 @@ final class PhabricatorStandardPageView extends PhabricatorBarePageView { private $disableConsole; private $pageObjects = array(); private $applicationMenu; + private $showFooter = true; + + public function setShowFooter($show_footer) { + $this->showFooter = $show_footer; + return $this; + } + + public function getShowFooter() { + return $this->showFooter; + } public function setApplicationMenu(PHUIListView $application_menu) { $this->applicationMenu = $application_menu; @@ -329,23 +339,23 @@ final class PhabricatorStandardPageView extends PhabricatorBarePageView { } } - return - phutil_tag( - 'div', - array( - 'id' => 'base-page', - 'class' => 'phabricator-standard-page', - ), - array( - $developer_warning, - $setup_warning, - $header_chrome, - phutil_tag_div('phabricator-standard-page-body', array( - ($console ? hsprintf('') : null), - parent::getBody(), - phutil_tag('div', array('style' => 'clear: both;')), - )), - )); + return phutil_tag( + 'div', + array( + 'id' => 'base-page', + 'class' => 'phabricator-standard-page', + ), + array( + $developer_warning, + $setup_warning, + $header_chrome, + phutil_tag_div('phabricator-standard-page-body', array( + ($console ? hsprintf('') : null), + parent::getBody(), + phutil_tag('div', array('style' => 'clear: both;')), + $this->renderFooter(), + )), + )); } protected function getTail() { @@ -457,4 +467,50 @@ final class PhabricatorStandardPageView extends PhabricatorBarePageView { return $this->getRequest()->getApplicationConfiguration()->getConsole(); } + private function renderFooter() { + if (!$this->getShowChrome()) { + return null; + } + + if (!$this->getShowFooter()) { + return null; + } + + $items = PhabricatorEnv::getEnvConfig('ui.footer-items'); + if (!$items) { + return null; + } + + $foot = array(); + foreach ($items as $item) { + $name = idx($item, 'name', pht('Unnamed Footer Item')); + + $href = idx($item, 'href'); + if (!PhabricatorEnv::isValidWebResource($href)) { + $href = null; + } + + if ($href !== null) { + $tag = 'a'; + } else { + $tag = 'span'; + } + + $foot[] = phutil_tag( + $tag, + array( + 'href' => $href, + ), + $name); + } + $foot = phutil_implode_html(" \xC2\xB7 ", $foot); + + return phutil_tag( + 'div', + array( + 'class' => 'phabricator-standard-page-footer', + ), + $foot); + } + } diff --git a/webroot/rsrc/css/application/base/standard-page-view.css b/webroot/rsrc/css/application/base/standard-page-view.css index 77ecefd1a7..301137c338 100644 --- a/webroot/rsrc/css/application/base/standard-page-view.css +++ b/webroot/rsrc/css/application/base/standard-page-view.css @@ -13,6 +13,14 @@ border-width: 0px; } +.phabricator-standard-page-footer { + text-align: right; + margin: 0 16px; + padding: 8px 0; + border-top: 1px solid {$lightgreyborder}; + color: {$lightgreytext}; +} + .keyboard-shortcut-help td, .keyboard-shortcut-help th { padding: 8px;