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

Countdown revamp

Summary:
countdown_timer table named to countdown.
datepoint and related stuff renamed to epoch.
Countdowns now have phids.
Various UI items changed from timer to countdown.

Test Plan: Did run storage upgrade and added some countdowns.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin, AnhNhan

Maniphest Tasks: T2624

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

authored by

Lauri-Henrik Jalonen and committed by
epriestley
271d6605 1fa30775

+98 -41
+8
resources/sql/patches/20130502.countdownrevamp1.sql
··· 1 + ALTER TABLE {$NAMESPACE}_countdown.countdown_timer 2 + RENAME TO {$NAMESPACE}_countdown.countdown; 3 + 4 + ALTER TABLE {$NAMESPACE}_countdown.countdown 5 + change datepoint epoch INT UNSIGNED NOT NULL; 6 + 7 + ALTER TABLE {$NAMESPACE}_countdown.countdown 8 + ADD COLUMN phid VARCHAR(64) NOT NULL COLLATE utf8_bin AFTER id;
+23
resources/sql/patches/20130502.countdownrevamp2.php
··· 1 + <?php 2 + 3 + echo "Giving countdowns PHIDs"; 4 + $table = new PhabricatorCountdown(); 5 + $table->openTransaction(); 6 + 7 + foreach (new LiskMigrationIterator($table) as $countdown) { 8 + if ($countdown->getPHID()) { 9 + continue; 10 + } 11 + 12 + echo "."; 13 + 14 + queryfx( 15 + $countdown->establishConnection('w'), 16 + 'UPDATE %T SET phid = %s WHERE id = %d', 17 + $countdown->getTableName(), 18 + $countdown->generatePHID(), 19 + $countdown->getID()); 20 + } 21 + 22 + $table->saveTransaction(); 23 + echo "\nDone.\n";
+2
resources/sql/patches/20130502.countdownrevamp3.sql
··· 1 + ALTER TABLE {$NAMESPACE}_countdown.countdown 2 + ADD UNIQUE KEY `key_phid` (phid);
+1 -1
src/__celerity_resource_map__.php
··· 2271 2271 ), 2272 2272 'javelin-behavior-slowvote-embed' => 2273 2273 array( 2274 - 'uri' => '/res/1315b118/rsrc/js/application/slowvote/behavior-slowvote-embed.js', 2274 + 'uri' => '/res/eef0818f/rsrc/js/application/slowvote/behavior-slowvote-embed.js', 2275 2275 'type' => 'js', 2276 2276 'requires' => 2277 2277 array(
+3 -2
src/__phutil_library_map__.php
··· 867 867 'PhabricatorContentSourceView' => 'applications/metamta/contentsource/PhabricatorContentSourceView.php', 868 868 'PhabricatorController' => 'applications/base/controller/PhabricatorController.php', 869 869 'PhabricatorCoreConfigOptions' => 'applications/config/option/PhabricatorCoreConfigOptions.php', 870 + 'PhabricatorCountdown' => 'applications/countdown/storage/PhabricatorCountdown.php', 870 871 'PhabricatorCountdownController' => 'applications/countdown/controller/PhabricatorCountdownController.php', 871 872 'PhabricatorCountdownDAO' => 'applications/countdown/storage/PhabricatorCountdownDAO.php', 872 873 'PhabricatorCountdownDeleteController' => 'applications/countdown/controller/PhabricatorCountdownDeleteController.php', ··· 1427 1428 'PhabricatorTimelineExample' => 'applications/uiexample/examples/PhabricatorTimelineExample.php', 1428 1429 'PhabricatorTimelineIterator' => 'infrastructure/daemon/timeline/cursor/PhabricatorTimelineIterator.php', 1429 1430 'PhabricatorTimelineView' => 'view/layout/PhabricatorTimelineView.php', 1430 - 'PhabricatorTimer' => 'applications/countdown/storage/PhabricatorTimer.php', 1431 1431 'PhabricatorToken' => 'applications/tokens/storage/PhabricatorToken.php', 1432 1432 'PhabricatorTokenController' => 'applications/tokens/controller/PhabricatorTokenController.php', 1433 1433 'PhabricatorTokenCount' => 'applications/tokens/storage/PhabricatorTokenCount.php', ··· 2352 2352 'ManiphestSavedQueryListController' => 'ManiphestController', 2353 2353 'ManiphestSearchIndexer' => 'PhabricatorSearchDocumentIndexer', 2354 2354 'ManiphestSubpriorityController' => 'ManiphestController', 2355 + 'ManiphestSubscribeController' => 'ManiphestController', 2355 2356 'ManiphestTask' => 2356 2357 array( 2357 2358 0 => 'ManiphestDAO', ··· 2603 2604 'PhabricatorContentSourceView' => 'AphrontView', 2604 2605 'PhabricatorController' => 'AphrontController', 2605 2606 'PhabricatorCoreConfigOptions' => 'PhabricatorApplicationConfigOptions', 2607 + 'PhabricatorCountdown' => 'PhabricatorCountdownDAO', 2606 2608 'PhabricatorCountdownController' => 'PhabricatorController', 2607 2609 'PhabricatorCountdownDAO' => 'PhabricatorLiskDAO', 2608 2610 'PhabricatorCountdownDeleteController' => 'PhabricatorCountdownController', ··· 3121 3123 'PhabricatorTimelineExample' => 'PhabricatorUIExample', 3122 3124 'PhabricatorTimelineIterator' => 'Iterator', 3123 3125 'PhabricatorTimelineView' => 'AphrontView', 3124 - 'PhabricatorTimer' => 'PhabricatorCountdownDAO', 3125 3126 'PhabricatorToken' => 3126 3127 array( 3127 3128 0 => 'PhabricatorTokenDAO',
+3 -3
src/applications/countdown/controller/PhabricatorCountdownController.php
··· 8 8 $nav = new AphrontSideNavFilterView(); 9 9 $nav->setBaseURI(new PhutilURI($this->getApplicationURI())); 10 10 11 - $nav->addFilter('', pht('All Timers'), 11 + $nav->addFilter('', pht('All Countdowns'), 12 12 $this->getApplicationURI('')); 13 - $nav->addFilter('', pht('Create Timer'), 13 + $nav->addFilter('', pht('Create Countdown'), 14 14 $this->getApplicationURI('edit/')); 15 15 16 16 return $nav; ··· 25 25 26 26 $crumbs->addAction( 27 27 id(new PhabricatorMenuItemView()) 28 - ->setName(pht('Create Timer')) 28 + ->setName(pht('Create Countdown')) 29 29 ->setHref($this->getApplicationURI('edit/')) 30 30 ->setIcon('create')); 31 31
+1 -1
src/applications/countdown/controller/PhabricatorCountdownDeleteController.php
··· 14 14 $request = $this->getRequest(); 15 15 $user = $request->getUser(); 16 16 17 - $timer = id(new PhabricatorTimer())->load($this->id); 17 + $timer = id(new PhabricatorCountdown())->load($this->id); 18 18 if (!$timer) { 19 19 return new Aphront404Response(); 20 20 }
+14 -14
src/applications/countdown/controller/PhabricatorCountdownEditController.php
··· 12 12 13 13 $request = $this->getRequest(); 14 14 $user = $request->getUser(); 15 - $action_label = pht('Create Timer'); 15 + $action_label = pht('Create Countdown'); 16 16 17 17 if ($this->id) { 18 - $timer = id(new PhabricatorTimer())->load($this->id); 18 + $timer = id(new PhabricatorCountdown())->load($this->id); 19 19 // If no timer is found 20 20 if (!$timer) { 21 21 return new Aphront404Response(); ··· 26 26 return new Aphront403Response(); 27 27 } 28 28 29 - $action_label = pht('Update Timer'); 29 + $action_label = pht('Update Countdown'); 30 30 } else { 31 - $timer = new PhabricatorTimer(); 32 - $timer->setDatePoint(time()); 31 + $timer = new PhabricatorCountdown(); 32 + $timer->setEpoch(time()); 33 33 } 34 34 35 35 $error_view = null; ··· 38 38 if ($request->isFormPost()) { 39 39 $errors = array(); 40 40 $title = $request->getStr('title'); 41 - $datepoint = $request->getStr('datepoint'); 41 + $epoch = $request->getStr('epoch'); 42 42 43 43 $e_text = null; 44 44 if (!strlen($title)) { ··· 51 51 $timezone = new DateTimeZone($user->getTimezoneIdentifier()); 52 52 53 53 try { 54 - $date = new DateTime($datepoint, $timezone); 54 + $date = new DateTime($epoch, $timezone); 55 55 $timestamp = $date->format('U'); 56 56 } catch (Exception $e) { 57 57 $errors[] = pht('You entered an incorrect date. You can enter date'. ··· 61 61 } 62 62 63 63 $timer->setTitle($title); 64 - $timer->setDatePoint($timestamp); 64 + $timer->setEpoch($timestamp); 65 65 66 66 if (!count($errors)) { 67 67 $timer->setAuthorPHID($user->getPHID()); ··· 76 76 } 77 77 } 78 78 79 - if ($timer->getDatePoint()) { 80 - $display_datepoint = phabricator_datetime( 81 - $timer->getDatePoint(), 79 + if ($timer->getEpoch()) { 80 + $display_epoch = phabricator_datetime( 81 + $timer->getEpoch(), 82 82 $user); 83 83 } else { 84 - $display_datepoint = $request->getStr('datepoint'); 84 + $display_epoch = $request->getStr('epoch'); 85 85 } 86 86 87 87 $form = id(new AphrontFormView()) ··· 95 95 ->appendChild( 96 96 id(new AphrontFormTextControl()) 97 97 ->setLabel(pht('End date')) 98 - ->setValue($display_datepoint) 99 - ->setName('datepoint') 98 + ->setValue($display_epoch) 99 + ->setName('epoch') 100 100 ->setCaption(pht('Examples: '. 101 101 '2011-12-25 or 3 hours or '. 102 102 'June 8 2011, 5 PM.')))
+4 -4
src/applications/countdown/controller/PhabricatorCountdownListController.php
··· 12 12 $pager->setOffset($request->getInt('page')); 13 13 $pager->setURI($request->getRequestURI(), 'page'); 14 14 15 - $timers = id(new PhabricatorTimer())->loadAllWhere( 15 + $timers = id(new PhabricatorCountdown())->loadAllWhere( 16 16 '1 = 1 ORDER BY id DESC LIMIT %d, %d', 17 17 $pager->getOffset(), 18 18 $pager->getPageSize() + 1); ··· 54 54 'href' => '/countdown/'.$timer->getID().'/', 55 55 ), 56 56 $timer->getTitle()), 57 - phabricator_datetime($timer->getDatepoint(), $user), 57 + phabricator_datetime($timer->getEpoch(), $user), 58 58 $edit_button, 59 59 $delete_button, 60 60 ); ··· 83 83 84 84 $panel = id(new AphrontPanelView()) 85 85 ->appendChild($table) 86 - ->setHeader(pht('Timers')) 86 + ->setHeader(pht('Countdowns')) 87 87 ->setNoBackground() 88 88 ->appendChild($pager); 89 89 ··· 91 91 ->buildApplicationCrumbs() 92 92 ->addCrumb( 93 93 id(new PhabricatorCrumbView()) 94 - ->setName(pht('All Timers')) 94 + ->setName(pht('All Countdowns')) 95 95 ->setHref($this->getApplicationURI())); 96 96 97 97 return $this->buildApplicationPage(
+3 -3
src/applications/countdown/controller/PhabricatorCountdownViewController.php
··· 14 14 15 15 $request = $this->getRequest(); 16 16 $user = $request->getUser(); 17 - $timer = id(new PhabricatorTimer())->load($this->id); 17 + $timer = id(new PhabricatorCountdown())->load($this->id); 18 18 if (!$timer) { 19 19 return new Aphront404Response(); 20 20 } ··· 50 50 </div>', 51 51 $container, 52 52 $timer->getTitle(), 53 - phabricator_datetime($timer->getDatePoint(), $user), 53 + phabricator_datetime($timer->getEpoch(), $user), 54 54 pht('Days'), 55 55 pht('Hours'), 56 56 pht('Minutes'), ··· 62 62 $chrome_link); 63 63 64 64 Javelin::initBehavior('countdown-timer', array( 65 - 'timestamp' => $timer->getDatepoint(), 65 + 'timestamp' => $timer->getEpoch(), 66 66 'container' => $container, 67 67 )); 68 68
+3 -3
src/applications/countdown/remarkup/PhabricatorCountdownRemarkupRule.php
··· 15 15 } 16 16 17 17 protected function markupCountdown($matches) { 18 - $countdown = id(new PhabricatorTimer())->load($matches[1]); 18 + $countdown = id(new PhabricatorCountdown())->load($matches[1]); 19 19 if (!$countdown) { 20 20 return $matches[0]; 21 21 } ··· 23 23 $engine = $this->getEngine(); 24 24 25 25 if ($engine->isTextMode()) { 26 - $date = $countdown->getDatepoint(); 26 + $date = $countdown->getEpoch(); 27 27 $viewer = $engine->getConfig('viewer'); 28 28 if ($viewer) { 29 29 $date = phabricator_datetime($date, $viewer); ··· 36 36 37 37 $metadata_key = self::KEY_RULE_COUNTDOWN; 38 38 $metadata = $engine->getTextMetadata($metadata_key, array()); 39 - $metadata[$id] = array($countdown->getDatepoint(), $token); 39 + $metadata[$id] = array($countdown->getEpoch(), $token); 40 40 $engine->setTextMetadata($metadata_key, $metadata); 41 41 42 42 return $token;
+21
src/applications/countdown/storage/PhabricatorCountdown.php
··· 1 + <?php 2 + 3 + final class PhabricatorCountdown extends PhabricatorCountdownDAO { 4 + 5 + protected $id; 6 + protected $phid; 7 + protected $title; 8 + protected $authorPHID; 9 + protected $epoch; 10 + 11 + public function getConfiguration() { 12 + return array( 13 + self::CONFIG_AUX_PHID => true, 14 + ) + parent::getConfiguration(); 15 + } 16 + 17 + public function generatePHID() { 18 + return PhabricatorPHID::generateNewPHID('CDWN'); 19 + } 20 + 21 + }
-10
src/applications/countdown/storage/PhabricatorTimer.php
··· 1 - <?php 2 - 3 - final class PhabricatorTimer extends PhabricatorCountdownDAO { 4 - 5 - protected $id; 6 - protected $title; 7 - protected $authorPHID; 8 - protected $datepoint; 9 - 10 - }
+12
src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php
··· 1258 1258 'type' => 'sql', 1259 1259 'name' => $this->getPatchPath('20130426.search_savedquery.sql'), 1260 1260 ), 1261 + '20130502.countdownrevamp1.sql' => array( 1262 + 'type' => 'sql', 1263 + 'name' => $this->getPatchPath('20130502.countdownrevamp1.sql'), 1264 + ), 1265 + '20130502.countdownrevamp2.php' => array( 1266 + 'type' => 'php', 1267 + 'name' => $this->getPatchPath('20130502.countdownrevamp2.php'), 1268 + ), 1269 + '20130502.countdownrevamp3.sql' => array( 1270 + 'type' => 'sql', 1271 + 'name' => $this->getPatchPath('20130502.countdownrevamp3.sql'), 1272 + ), 1261 1273 ); 1262 1274 } 1263 1275 }