1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-18 21:02:41 +01:00

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
This commit is contained in:
epriestley 2014-09-10 14:44:34 -07:00
parent 13834f1406
commit d3cd9115f9
6 changed files with 118 additions and 20 deletions

View file

@ -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',

View file

@ -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();

View file

@ -20,12 +20,44 @@ final class PhabricatorUIConfigOptions
$options[$key] = $key;
}
$example = <<<EOJSON
[
{
"name" : "Copyright 2199 Examplecorp"
},
{
"name" : "Privacy Policy",
"href" : "http://www.example.org/privacy/"
},
{
"name" : "Terms and Conditions",
"href" : "http://www.example.org/terms/"
}
]
EOJSON;
return array(
$this->newOption('ui.header-color', 'enum', 'dark')
->setDescription(
pht(
'Sets the color of the main header.'))
->setEnumOptions($options),
$this->newOption('ui.footer-items', 'list<wild>', 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')),
);
}

View file

@ -326,6 +326,7 @@ final class PhabricatorProjectBoardViewController
),
array(
'title' => pht('%s Board', $project->getName()),
'showFooter' => false,
));
}

View file

@ -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('<darkconsole />') : 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('<darkconsole />') : 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);
}
}

View file

@ -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;