mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +01:00
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
This commit is contained in:
parent
1fa307750d
commit
271d6605a9
14 changed files with 98 additions and 41 deletions
8
resources/sql/patches/20130502.countdownrevamp1.sql
Normal file
8
resources/sql/patches/20130502.countdownrevamp1.sql
Normal file
|
@ -0,0 +1,8 @@
|
|||
ALTER TABLE {$NAMESPACE}_countdown.countdown_timer
|
||||
RENAME TO {$NAMESPACE}_countdown.countdown;
|
||||
|
||||
ALTER TABLE {$NAMESPACE}_countdown.countdown
|
||||
change datepoint epoch INT UNSIGNED NOT NULL;
|
||||
|
||||
ALTER TABLE {$NAMESPACE}_countdown.countdown
|
||||
ADD COLUMN phid VARCHAR(64) NOT NULL COLLATE utf8_bin AFTER id;
|
23
resources/sql/patches/20130502.countdownrevamp2.php
Normal file
23
resources/sql/patches/20130502.countdownrevamp2.php
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
echo "Giving countdowns PHIDs";
|
||||
$table = new PhabricatorCountdown();
|
||||
$table->openTransaction();
|
||||
|
||||
foreach (new LiskMigrationIterator($table) as $countdown) {
|
||||
if ($countdown->getPHID()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
echo ".";
|
||||
|
||||
queryfx(
|
||||
$countdown->establishConnection('w'),
|
||||
'UPDATE %T SET phid = %s WHERE id = %d',
|
||||
$countdown->getTableName(),
|
||||
$countdown->generatePHID(),
|
||||
$countdown->getID());
|
||||
}
|
||||
|
||||
$table->saveTransaction();
|
||||
echo "\nDone.\n";
|
2
resources/sql/patches/20130502.countdownrevamp3.sql
Normal file
2
resources/sql/patches/20130502.countdownrevamp3.sql
Normal file
|
@ -0,0 +1,2 @@
|
|||
ALTER TABLE {$NAMESPACE}_countdown.countdown
|
||||
ADD UNIQUE KEY `key_phid` (phid);
|
|
@ -2271,7 +2271,7 @@ celerity_register_resource_map(array(
|
|||
),
|
||||
'javelin-behavior-slowvote-embed' =>
|
||||
array(
|
||||
'uri' => '/res/1315b118/rsrc/js/application/slowvote/behavior-slowvote-embed.js',
|
||||
'uri' => '/res/eef0818f/rsrc/js/application/slowvote/behavior-slowvote-embed.js',
|
||||
'type' => 'js',
|
||||
'requires' =>
|
||||
array(
|
||||
|
|
|
@ -867,6 +867,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorContentSourceView' => 'applications/metamta/contentsource/PhabricatorContentSourceView.php',
|
||||
'PhabricatorController' => 'applications/base/controller/PhabricatorController.php',
|
||||
'PhabricatorCoreConfigOptions' => 'applications/config/option/PhabricatorCoreConfigOptions.php',
|
||||
'PhabricatorCountdown' => 'applications/countdown/storage/PhabricatorCountdown.php',
|
||||
'PhabricatorCountdownController' => 'applications/countdown/controller/PhabricatorCountdownController.php',
|
||||
'PhabricatorCountdownDAO' => 'applications/countdown/storage/PhabricatorCountdownDAO.php',
|
||||
'PhabricatorCountdownDeleteController' => 'applications/countdown/controller/PhabricatorCountdownDeleteController.php',
|
||||
|
@ -1427,7 +1428,6 @@ phutil_register_library_map(array(
|
|||
'PhabricatorTimelineExample' => 'applications/uiexample/examples/PhabricatorTimelineExample.php',
|
||||
'PhabricatorTimelineIterator' => 'infrastructure/daemon/timeline/cursor/PhabricatorTimelineIterator.php',
|
||||
'PhabricatorTimelineView' => 'view/layout/PhabricatorTimelineView.php',
|
||||
'PhabricatorTimer' => 'applications/countdown/storage/PhabricatorTimer.php',
|
||||
'PhabricatorToken' => 'applications/tokens/storage/PhabricatorToken.php',
|
||||
'PhabricatorTokenController' => 'applications/tokens/controller/PhabricatorTokenController.php',
|
||||
'PhabricatorTokenCount' => 'applications/tokens/storage/PhabricatorTokenCount.php',
|
||||
|
@ -2352,6 +2352,7 @@ phutil_register_library_map(array(
|
|||
'ManiphestSavedQueryListController' => 'ManiphestController',
|
||||
'ManiphestSearchIndexer' => 'PhabricatorSearchDocumentIndexer',
|
||||
'ManiphestSubpriorityController' => 'ManiphestController',
|
||||
'ManiphestSubscribeController' => 'ManiphestController',
|
||||
'ManiphestTask' =>
|
||||
array(
|
||||
0 => 'ManiphestDAO',
|
||||
|
@ -2603,6 +2604,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorContentSourceView' => 'AphrontView',
|
||||
'PhabricatorController' => 'AphrontController',
|
||||
'PhabricatorCoreConfigOptions' => 'PhabricatorApplicationConfigOptions',
|
||||
'PhabricatorCountdown' => 'PhabricatorCountdownDAO',
|
||||
'PhabricatorCountdownController' => 'PhabricatorController',
|
||||
'PhabricatorCountdownDAO' => 'PhabricatorLiskDAO',
|
||||
'PhabricatorCountdownDeleteController' => 'PhabricatorCountdownController',
|
||||
|
@ -3121,7 +3123,6 @@ phutil_register_library_map(array(
|
|||
'PhabricatorTimelineExample' => 'PhabricatorUIExample',
|
||||
'PhabricatorTimelineIterator' => 'Iterator',
|
||||
'PhabricatorTimelineView' => 'AphrontView',
|
||||
'PhabricatorTimer' => 'PhabricatorCountdownDAO',
|
||||
'PhabricatorToken' =>
|
||||
array(
|
||||
0 => 'PhabricatorTokenDAO',
|
||||
|
|
|
@ -8,9 +8,9 @@ abstract class PhabricatorCountdownController extends PhabricatorController {
|
|||
$nav = new AphrontSideNavFilterView();
|
||||
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
|
||||
|
||||
$nav->addFilter('', pht('All Timers'),
|
||||
$nav->addFilter('', pht('All Countdowns'),
|
||||
$this->getApplicationURI(''));
|
||||
$nav->addFilter('', pht('Create Timer'),
|
||||
$nav->addFilter('', pht('Create Countdown'),
|
||||
$this->getApplicationURI('edit/'));
|
||||
|
||||
return $nav;
|
||||
|
@ -25,7 +25,7 @@ abstract class PhabricatorCountdownController extends PhabricatorController {
|
|||
|
||||
$crumbs->addAction(
|
||||
id(new PhabricatorMenuItemView())
|
||||
->setName(pht('Create Timer'))
|
||||
->setName(pht('Create Countdown'))
|
||||
->setHref($this->getApplicationURI('edit/'))
|
||||
->setIcon('create'));
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ final class PhabricatorCountdownDeleteController
|
|||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
|
||||
$timer = id(new PhabricatorTimer())->load($this->id);
|
||||
$timer = id(new PhabricatorCountdown())->load($this->id);
|
||||
if (!$timer) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
|
|
@ -12,10 +12,10 @@ final class PhabricatorCountdownEditController
|
|||
|
||||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
$action_label = pht('Create Timer');
|
||||
$action_label = pht('Create Countdown');
|
||||
|
||||
if ($this->id) {
|
||||
$timer = id(new PhabricatorTimer())->load($this->id);
|
||||
$timer = id(new PhabricatorCountdown())->load($this->id);
|
||||
// If no timer is found
|
||||
if (!$timer) {
|
||||
return new Aphront404Response();
|
||||
|
@ -26,10 +26,10 @@ final class PhabricatorCountdownEditController
|
|||
return new Aphront403Response();
|
||||
}
|
||||
|
||||
$action_label = pht('Update Timer');
|
||||
$action_label = pht('Update Countdown');
|
||||
} else {
|
||||
$timer = new PhabricatorTimer();
|
||||
$timer->setDatePoint(time());
|
||||
$timer = new PhabricatorCountdown();
|
||||
$timer->setEpoch(time());
|
||||
}
|
||||
|
||||
$error_view = null;
|
||||
|
@ -38,7 +38,7 @@ final class PhabricatorCountdownEditController
|
|||
if ($request->isFormPost()) {
|
||||
$errors = array();
|
||||
$title = $request->getStr('title');
|
||||
$datepoint = $request->getStr('datepoint');
|
||||
$epoch = $request->getStr('epoch');
|
||||
|
||||
$e_text = null;
|
||||
if (!strlen($title)) {
|
||||
|
@ -51,7 +51,7 @@ final class PhabricatorCountdownEditController
|
|||
$timezone = new DateTimeZone($user->getTimezoneIdentifier());
|
||||
|
||||
try {
|
||||
$date = new DateTime($datepoint, $timezone);
|
||||
$date = new DateTime($epoch, $timezone);
|
||||
$timestamp = $date->format('U');
|
||||
} catch (Exception $e) {
|
||||
$errors[] = pht('You entered an incorrect date. You can enter date'.
|
||||
|
@ -61,7 +61,7 @@ final class PhabricatorCountdownEditController
|
|||
}
|
||||
|
||||
$timer->setTitle($title);
|
||||
$timer->setDatePoint($timestamp);
|
||||
$timer->setEpoch($timestamp);
|
||||
|
||||
if (!count($errors)) {
|
||||
$timer->setAuthorPHID($user->getPHID());
|
||||
|
@ -76,12 +76,12 @@ final class PhabricatorCountdownEditController
|
|||
}
|
||||
}
|
||||
|
||||
if ($timer->getDatePoint()) {
|
||||
$display_datepoint = phabricator_datetime(
|
||||
$timer->getDatePoint(),
|
||||
if ($timer->getEpoch()) {
|
||||
$display_epoch = phabricator_datetime(
|
||||
$timer->getEpoch(),
|
||||
$user);
|
||||
} else {
|
||||
$display_datepoint = $request->getStr('datepoint');
|
||||
$display_epoch = $request->getStr('epoch');
|
||||
}
|
||||
|
||||
$form = id(new AphrontFormView())
|
||||
|
@ -95,8 +95,8 @@ final class PhabricatorCountdownEditController
|
|||
->appendChild(
|
||||
id(new AphrontFormTextControl())
|
||||
->setLabel(pht('End date'))
|
||||
->setValue($display_datepoint)
|
||||
->setName('datepoint')
|
||||
->setValue($display_epoch)
|
||||
->setName('epoch')
|
||||
->setCaption(pht('Examples: '.
|
||||
'2011-12-25 or 3 hours or '.
|
||||
'June 8 2011, 5 PM.')))
|
||||
|
|
|
@ -12,7 +12,7 @@ final class PhabricatorCountdownListController
|
|||
$pager->setOffset($request->getInt('page'));
|
||||
$pager->setURI($request->getRequestURI(), 'page');
|
||||
|
||||
$timers = id(new PhabricatorTimer())->loadAllWhere(
|
||||
$timers = id(new PhabricatorCountdown())->loadAllWhere(
|
||||
'1 = 1 ORDER BY id DESC LIMIT %d, %d',
|
||||
$pager->getOffset(),
|
||||
$pager->getPageSize() + 1);
|
||||
|
@ -54,7 +54,7 @@ final class PhabricatorCountdownListController
|
|||
'href' => '/countdown/'.$timer->getID().'/',
|
||||
),
|
||||
$timer->getTitle()),
|
||||
phabricator_datetime($timer->getDatepoint(), $user),
|
||||
phabricator_datetime($timer->getEpoch(), $user),
|
||||
$edit_button,
|
||||
$delete_button,
|
||||
);
|
||||
|
@ -83,7 +83,7 @@ final class PhabricatorCountdownListController
|
|||
|
||||
$panel = id(new AphrontPanelView())
|
||||
->appendChild($table)
|
||||
->setHeader(pht('Timers'))
|
||||
->setHeader(pht('Countdowns'))
|
||||
->setNoBackground()
|
||||
->appendChild($pager);
|
||||
|
||||
|
@ -91,7 +91,7 @@ final class PhabricatorCountdownListController
|
|||
->buildApplicationCrumbs()
|
||||
->addCrumb(
|
||||
id(new PhabricatorCrumbView())
|
||||
->setName(pht('All Timers'))
|
||||
->setName(pht('All Countdowns'))
|
||||
->setHref($this->getApplicationURI()));
|
||||
|
||||
return $this->buildApplicationPage(
|
||||
|
|
|
@ -14,7 +14,7 @@ final class PhabricatorCountdownViewController
|
|||
|
||||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
$timer = id(new PhabricatorTimer())->load($this->id);
|
||||
$timer = id(new PhabricatorCountdown())->load($this->id);
|
||||
if (!$timer) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ final class PhabricatorCountdownViewController
|
|||
</div>',
|
||||
$container,
|
||||
$timer->getTitle(),
|
||||
phabricator_datetime($timer->getDatePoint(), $user),
|
||||
phabricator_datetime($timer->getEpoch(), $user),
|
||||
pht('Days'),
|
||||
pht('Hours'),
|
||||
pht('Minutes'),
|
||||
|
@ -62,7 +62,7 @@ final class PhabricatorCountdownViewController
|
|||
$chrome_link);
|
||||
|
||||
Javelin::initBehavior('countdown-timer', array(
|
||||
'timestamp' => $timer->getDatepoint(),
|
||||
'timestamp' => $timer->getEpoch(),
|
||||
'container' => $container,
|
||||
));
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ final class PhabricatorCountdownRemarkupRule extends PhutilRemarkupRule {
|
|||
}
|
||||
|
||||
protected function markupCountdown($matches) {
|
||||
$countdown = id(new PhabricatorTimer())->load($matches[1]);
|
||||
$countdown = id(new PhabricatorCountdown())->load($matches[1]);
|
||||
if (!$countdown) {
|
||||
return $matches[0];
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ final class PhabricatorCountdownRemarkupRule extends PhutilRemarkupRule {
|
|||
$engine = $this->getEngine();
|
||||
|
||||
if ($engine->isTextMode()) {
|
||||
$date = $countdown->getDatepoint();
|
||||
$date = $countdown->getEpoch();
|
||||
$viewer = $engine->getConfig('viewer');
|
||||
if ($viewer) {
|
||||
$date = phabricator_datetime($date, $viewer);
|
||||
|
@ -36,7 +36,7 @@ final class PhabricatorCountdownRemarkupRule extends PhutilRemarkupRule {
|
|||
|
||||
$metadata_key = self::KEY_RULE_COUNTDOWN;
|
||||
$metadata = $engine->getTextMetadata($metadata_key, array());
|
||||
$metadata[$id] = array($countdown->getDatepoint(), $token);
|
||||
$metadata[$id] = array($countdown->getEpoch(), $token);
|
||||
$engine->setTextMetadata($metadata_key, $metadata);
|
||||
|
||||
return $token;
|
||||
|
|
21
src/applications/countdown/storage/PhabricatorCountdown.php
Normal file
21
src/applications/countdown/storage/PhabricatorCountdown.php
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorCountdown extends PhabricatorCountdownDAO {
|
||||
|
||||
protected $id;
|
||||
protected $phid;
|
||||
protected $title;
|
||||
protected $authorPHID;
|
||||
protected $epoch;
|
||||
|
||||
public function getConfiguration() {
|
||||
return array(
|
||||
self::CONFIG_AUX_PHID => true,
|
||||
) + parent::getConfiguration();
|
||||
}
|
||||
|
||||
public function generatePHID() {
|
||||
return PhabricatorPHID::generateNewPHID('CDWN');
|
||||
}
|
||||
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorTimer extends PhabricatorCountdownDAO {
|
||||
|
||||
protected $id;
|
||||
protected $title;
|
||||
protected $authorPHID;
|
||||
protected $datepoint;
|
||||
|
||||
}
|
|
@ -1258,6 +1258,18 @@ final class PhabricatorBuiltinPatchList extends PhabricatorSQLPatchList {
|
|||
'type' => 'sql',
|
||||
'name' => $this->getPatchPath('20130426.search_savedquery.sql'),
|
||||
),
|
||||
'20130502.countdownrevamp1.sql' => array(
|
||||
'type' => 'sql',
|
||||
'name' => $this->getPatchPath('20130502.countdownrevamp1.sql'),
|
||||
),
|
||||
'20130502.countdownrevamp2.php' => array(
|
||||
'type' => 'php',
|
||||
'name' => $this->getPatchPath('20130502.countdownrevamp2.php'),
|
||||
),
|
||||
'20130502.countdownrevamp3.sql' => array(
|
||||
'type' => 'sql',
|
||||
'name' => $this->getPatchPath('20130502.countdownrevamp3.sql'),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue