Select the types of activity you want to include in your feed.
@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
···11+<?php
22+33+final class PhabricatorMotivatorProfilePanel
44+ extends PhabricatorProfilePanel {
55+66+ const PANELKEY = 'motivator';
77+88+ public function getPanelTypeIcon() {
99+ return 'fa-coffee';
1010+ }
1111+1212+ public function getPanelTypeName() {
1313+ return pht('Motivator');
1414+ }
1515+1616+ public function canAddToObject($object) {
1717+ return true;
1818+ }
1919+2020+ public function getDisplayName(
2121+ PhabricatorProfilePanelConfiguration $config) {
2222+2323+ $options = $this->getOptions();
2424+ $name = idx($options, $config->getPanelProperty('source'));
2525+ if ($name !== null) {
2626+ return pht('Motivator: %s', $name);
2727+ } else {
2828+ return pht('Motivator');
2929+ }
3030+ }
3131+3232+ public function buildEditEngineFields(
3333+ PhabricatorProfilePanelConfiguration $config) {
3434+ return array(
3535+ id(new PhabricatorInstructionsEditField())
3636+ ->setValue(
3737+ pht(
3838+ 'Motivate your team with inspirational quotes from great minds. '.
3939+ 'This panel shows a new quote every day.')),
4040+ id(new PhabricatorSelectEditField())
4141+ ->setKey('source')
4242+ ->setLabel(pht('Source'))
4343+ ->setOptions($this->getOptions()),
4444+ );
4545+ }
4646+4747+ private function getOptions() {
4848+ return array(
4949+ 'catfacts' => pht('Cat Facts'),
5050+ );
5151+ }
5252+5353+ protected function newNavigationMenuItems(
5454+ PhabricatorProfilePanelConfiguration $config) {
5555+5656+ $source = $config->getPanelProperty('source');
5757+5858+ switch ($source) {
5959+ case 'catfacts':
6060+ default:
6161+ $facts = $this->getCatFacts();
6262+ break;
6363+ }
6464+6565+ $fact = $this->selectFact($facts);
6666+6767+ switch ($source) {
6868+ case 'catfacts':
6969+ default:
7070+ $fact = array(
7171+ id(new PHUIIconView())->setIconFont('fa-paw'),
7272+ ' ',
7373+ $fact,
7474+ );
7575+ break;
7676+ }
7777+7878+ $fact = phutil_tag(
7979+ 'div',
8080+ array(
8181+ 'class' => 'phui-motivator',
8282+ ),
8383+ $fact);
8484+8585+ $item = $this->newItem()
8686+ ->appendChild($fact);
8787+8888+ return array(
8989+ $item,
9090+ );
9191+ }
9292+9393+ private function getCatFacts() {
9494+ return array(
9595+ pht('Cats purr when they are happy, upset, or asleep.'),
9696+ pht('The first cats evolved on the savanah about 8,000 years ago.'),
9797+ pht(
9898+ 'Cats have a tail, two feet, between one and three ears, and two '.
9999+ 'other feet.'),
100100+ pht('Cats use their keen sense of smell to avoid feeling empathy.'),
101101+ pht('The first cats evolved in swamps about 65 years ago.'),
102102+ pht(
103103+ 'You can tell how warm a cat is by examining the coloration: cooler '.
104104+ 'areas are darker.'),
105105+ pht(
106106+ 'Cat tails are flexible because they contain thousands of tiny '.
107107+ 'bones.'),
108108+ pht(
109109+ 'A cattail is a wetland plant with an appearance that resembles '.
110110+ 'the tail of a cat.'),
111111+ pht(
112112+ 'Cats must eat a diet rich in fish to replace the tiny bones in '.
113113+ 'their tails.'),
114114+ pht('Cats are stealthy predators and nearly invisible to radar.'),
115115+ pht(
116116+ 'Cats use a special type of magnetism to help them land on their '.
117117+ 'feet.'),
118118+ pht(
119119+ 'A cat can run seven times faster than a human, but only for a '.
120120+ 'short distance.'),
121121+ pht(
122122+ 'The largest recorded cat was nearly 11 inches long from nose to '.
123123+ 'tail.'),
124124+ pht(
125125+ 'Not all cats can retract their claws, but most of them can.'),
126126+ pht(
127127+ 'In the wild, cats and racooons sometimes hunt together in packs.'),
128128+ pht(
129129+ 'The Spanish word for cat is "cato". The biggest cat is called '.
130130+ '"el cato".'),
131131+ pht(
132132+ 'The Japanese word for cat is "kome", which is also the word for '.
133133+ 'rice. Japanese cats love to eat rice, so the two are synonymous.'),
134134+ );
135135+ }
136136+137137+ private function selectFact(array $facts) {
138138+ // This is a simple pseudorandom number generator that avoids touching
139139+ // srand(), because it would seed it to a highly predictable value. It
140140+ // selects a new fact every day.
141141+142142+ $seed = ((int)date('Y') * 366) + (int)date('z');
143143+ for ($ii = 0; $ii < 32; $ii++) {
144144+ $seed = ((1664525 * $seed) + 1013904223) % (1 << 31);
145145+ }
146146+147147+ return $facts[$seed % count($facts)];
148148+ }
149149+150150+151151+}