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

Display holidays

Summary:
We will need it for two purposes:

- Status tool.
- Nagging tool - @aran suggested using "3 business days" and I don't want it to fall on New Year's Eve or such.

I don't plan working on any interface for editing this as this kind of data should be always imported.

Test Plan:
`bin/storage upgrade`
`scripts/calendar/import_us_holidays.php`
/calendar/

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Koolvin

Differential Revision: https://secure.phabricator.com/D2375

vrana 73c82e5a 826e5405

+211 -4
+7
resources/sql/patches/holidays.sql
··· 1 + CREATE TABLE {$NAMESPACE}_calendar.calendar_holiday ( 2 + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, 3 + `day` date NOT NULL, 4 + `name` varchar(50) NOT NULL, 5 + PRIMARY KEY (`id`), 6 + UNIQUE `day` (`day`) 7 + ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+78
scripts/calendar/import_us_holidays.php
··· 1 + #!/usr/bin/env php 2 + <?php 3 + 4 + /* 5 + * Copyright 2012 Facebook, Inc. 6 + * 7 + * Licensed under the Apache License, Version 2.0 (the "License"); 8 + * you may not use this file except in compliance with the License. 9 + * You may obtain a copy of the License at 10 + * 11 + * http://www.apache.org/licenses/LICENSE-2.0 12 + * 13 + * Unless required by applicable law or agreed to in writing, software 14 + * distributed under the License is distributed on an "AS IS" BASIS, 15 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 + * See the License for the specific language governing permissions and 17 + * limitations under the License. 18 + */ 19 + 20 + $root = dirname(dirname(dirname(__FILE__))); 21 + require_once $root.'/scripts/__init_script__.php'; 22 + 23 + // http://www.opm.gov/operating_status_schedules/fedhol/ 24 + $holidays = array( 25 + '2012-01-02' => "New Year's Day", 26 + '2012-01-16' => "Birthday of Martin Luther King, Jr.", 27 + '2012-02-20' => "Washington's Birthday", 28 + '2012-05-28' => "Memorial Day", 29 + '2012-07-04' => "Independence Day", 30 + '2012-09-03' => "Labor Day", 31 + '2012-10-08' => "Columbus Day", 32 + '2012-11-12' => "Veterans Day", 33 + '2012-11-22' => "Thanksgiving Day", 34 + '2012-12-25' => "Christmas Day", 35 + '2013-01-01' => "New Year's Day", 36 + '2013-01-21' => "Birthday of Martin Luther King, Jr.", 37 + '2013-02-18' => "Washington's Birthday", 38 + '2013-05-27' => "Memorial Day", 39 + '2013-07-04' => "Independence Day", 40 + '2013-09-02' => "Labor Day", 41 + '2013-10-14' => "Columbus Day", 42 + '2013-11-11' => "Veterans Day", 43 + '2013-11-28' => "Thanksgiving Day", 44 + '2013-12-25' => "Christmas Day", 45 + '2014-01-01' => "New Year's Day", 46 + '2014-01-20' => "Birthday of Martin Luther King, Jr.", 47 + '2014-02-17' => "Washington's Birthday", 48 + '2014-05-26' => "Memorial Day", 49 + '2014-07-04' => "Independence Day", 50 + '2014-09-01' => "Labor Day", 51 + '2014-10-13' => "Columbus Day", 52 + '2014-11-11' => "Veterans Day", 53 + '2014-11-27' => "Thanksgiving Day", 54 + '2014-12-25' => "Christmas Day", 55 + '2015-01-01' => "New Year's Day", 56 + '2015-01-19' => "Birthday of Martin Luther King, Jr.", 57 + '2015-02-16' => "Washington's Birthday", 58 + '2015-05-25' => "Memorial Day", 59 + '2015-07-03' => "Independence Day", 60 + '2015-09-07' => "Labor Day", 61 + '2015-10-12' => "Columbus Day", 62 + '2015-11-11' => "Veterans Day", 63 + '2015-11-26' => "Thanksgiving Day", 64 + '2015-12-25' => "Christmas Day", 65 + ); 66 + 67 + $table = new PhabricatorCalendarHoliday(); 68 + $conn_w = $table->establishConnection('w'); 69 + $table_name = $table->getTableName(); 70 + 71 + foreach ($holidays as $day => $name) { 72 + queryfx( 73 + $conn_w, 74 + 'INSERT IGNORE INTO %T (day, name) VALUES (%s, %s)', 75 + $table_name, 76 + $day, 77 + $name); 78 + }
+1 -1
src/__celerity_resource_map__.php
··· 375 375 ), 376 376 'aphront-calendar-view-css' => 377 377 array( 378 - 'uri' => '/res/c86d9a4b/rsrc/css/aphront/calendar-view.css', 378 + 'uri' => '/res/57b017ec/rsrc/css/aphront/calendar-view.css', 379 379 'type' => 'css', 380 380 'requires' => 381 381 array(
+4
src/__phutil_library_map__.php
··· 529 529 'PhabricatorBuiltinPatchList' => 'infrastructure/setup/sql/phabricator', 530 530 'PhabricatorCalendarBrowseController' => 'applications/calendar/controller/browse', 531 531 'PhabricatorCalendarController' => 'applications/calendar/controller/base', 532 + 'PhabricatorCalendarDAO' => 'applications/calendar/storage/base', 533 + 'PhabricatorCalendarHoliday' => 'applications/calendar/storage/holiday', 532 534 'PhabricatorChangesetResponse' => 'infrastructure/diff/response', 533 535 'PhabricatorChatLogChannelListController' => 'applications/chatlog/controller/channellist', 534 536 'PhabricatorChatLogChannelLogController' => 'applications/chatlog/controller/channellog', ··· 1461 1463 'PhabricatorBuiltinPatchList' => 'PhabricatorSQLPatchList', 1462 1464 'PhabricatorCalendarBrowseController' => 'PhabricatorCalendarController', 1463 1465 'PhabricatorCalendarController' => 'PhabricatorController', 1466 + 'PhabricatorCalendarDAO' => 'PhabricatorLiskDAO', 1467 + 'PhabricatorCalendarHoliday' => 'PhabricatorCalendarDAO', 1464 1468 'PhabricatorChangesetResponse' => 'AphrontProxyResponse', 1465 1469 'PhabricatorChatLogChannelListController' => 'PhabricatorChatLogController', 1466 1470 'PhabricatorChatLogChannelLogController' => 'PhabricatorChatLogController',
+8 -1
src/applications/calendar/controller/browse/PhabricatorCalendarBrowseController.php
··· 22 22 public function processRequest() { 23 23 $request = $this->getRequest(); 24 24 $user = $request->getUser(); 25 + $year = idate('Y'); 26 + 27 + $holidays = id(new PhabricatorCalendarHoliday())->loadAllWhere( 28 + 'day BETWEEN %s AND %s', 29 + "{$year}-01-01", 30 + "{$year}-12-31"); 25 31 26 32 $months = array(); 27 33 for ($ii = 1; $ii <= 12; $ii++) { 28 - $month_view = new AphrontCalendarMonthView($ii, 2011); 34 + $month_view = new AphrontCalendarMonthView($ii, $year); 29 35 $month_view->setUser($user); 36 + $month_view->setHolidays($holidays); 30 37 $months[] = '<div style="padding: 2em;">'; 31 38 $months[] = $month_view; 32 39 $months[] = '</div>';
+3
src/applications/calendar/controller/browse/__init__.php
··· 7 7 8 8 9 9 phutil_require_module('phabricator', 'applications/calendar/controller/base'); 10 + phutil_require_module('phabricator', 'applications/calendar/storage/holiday'); 10 11 phutil_require_module('phabricator', 'applications/calendar/view/month'); 12 + 13 + phutil_require_module('phutil', 'utils'); 11 14 12 15 13 16 phutil_require_source('PhabricatorCalendarBrowseController.php');
+25
src/applications/calendar/storage/base/PhabricatorCalendarDAO.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 + abstract class PhabricatorCalendarDAO extends PhabricatorLiskDAO { 20 + 21 + public function getApplicationName() { 22 + return 'calendar'; 23 + } 24 + 25 + }
+12
src/applications/calendar/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('PhabricatorCalendarDAO.php');
+30
src/applications/calendar/storage/holiday/PhabricatorCalendarHoliday.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 PhabricatorCalendarHoliday extends PhabricatorCalendarDAO { 20 + 21 + protected $day; 22 + protected $name; 23 + 24 + public function getConfiguration() { 25 + return array( 26 + self::CONFIG_TIMESTAMPS => false, 27 + ) + parent::getConfiguration(); 28 + } 29 + 30 + }
+12
src/applications/calendar/storage/holiday/__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/calendar/storage/base'); 10 + 11 + 12 + phutil_require_source('PhabricatorCalendarHoliday.php');
+16 -2
src/applications/calendar/view/month/AphrontCalendarMonthView.php
··· 1 1 <?php 2 2 3 3 /* 4 - * Copyright 2011 Facebook, Inc. 4 + * Copyright 2012 Facebook, Inc. 5 5 * 6 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 7 * you may not use this file except in compliance with the License. ··· 21 21 private $user; 22 22 private $month; 23 23 private $year; 24 + private $holidays = array(); 24 25 25 26 public function setUser(PhabricatorUser $user) { 26 27 $this->user = $user; 28 + return $this; 29 + } 30 + 31 + public function setHolidays(array $holidays) { 32 + assert_instances_of($holidays, 'PhabricatorCalendarHoliday'); 33 + $this->holidays = mpull($holidays, null, 'getDay'); 27 34 return $this; 28 35 } 29 36 ··· 51 58 } 52 59 53 60 foreach ($days as $day) { 61 + $holiday = idx($this->holidays, $day->format('Y-m-d')); 62 + $class = 'aphront-calendar-day-of-month'; 63 + $weekday = $day->format('w'); 64 + if ($holiday || $weekday == 0 || $weekday == 6) { 65 + $class .= ' aphront-calendar-not-work-day'; 66 + } 54 67 $markup[] = 55 - '<div class="aphront-calendar-day-of-month">'. 68 + '<div class="'.$class.'">'. 56 69 $day->format('j'). 70 + ($holiday ? '<br />'.phutil_escape_html($holiday->getName()) : ''). 57 71 '</div>'; 58 72 } 59 73
+3
src/applications/calendar/view/month/__init__.php
··· 9 9 phutil_require_module('phabricator', 'infrastructure/celerity/api'); 10 10 phutil_require_module('phabricator', 'view/base'); 11 11 12 + phutil_require_module('phutil', 'markup'); 13 + phutil_require_module('phutil', 'utils'); 14 + 12 15 13 16 phutil_require_source('AphrontCalendarMonthView.php');
+8
src/infrastructure/setup/sql/phabricator/PhabricatorBuiltinPatchList.php
··· 39 39 'name' => 'audit', 40 40 'after' => array( /* First Patch */ ), 41 41 ), 42 + 'db.calendar' => array( 43 + 'type' => 'db', 44 + 'name' => 'calendar', 45 + ), 42 46 'db.chatlog' => array( 43 47 'type' => 'db', 44 48 'name' => 'chatlog', ··· 846 850 'type' => 'sql', 847 851 'name' => $this->getPatchPath('137.auditmetadata.sql'), 848 852 'legacy' => 137, 853 + ), 854 + 'holidays.sql' => array( 855 + 'type' => 'sql', 856 + 'name' => $this->getPatchPath('holidays.sql'), 849 857 ), 850 858 ); 851 859 }
+4
webroot/rsrc/css/aphront/calendar-view.css
··· 39 39 text-align: right; 40 40 color: #666666; 41 41 } 42 + 43 + .aphront-calendar-not-work-day { 44 + background-color: #fdfae7; 45 + }