Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2891362
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
10 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/applications/countdown/controller/edit/PhabricatorCountdownEditController.php b/src/applications/countdown/controller/edit/PhabricatorCountdownEditController.php
index 21b9fcc505..5af29d93e6 100644
--- a/src/applications/countdown/controller/edit/PhabricatorCountdownEditController.php
+++ b/src/applications/countdown/controller/edit/PhabricatorCountdownEditController.php
@@ -1,122 +1,140 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class PhabricatorCountdownEditController
extends PhabricatorCountdownController {
private $id;
public function willProcessRequest(array $data) {
$this->id = idx($data, 'id');
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$action_label = 'Create Timer';
if ($this->id) {
$timer = id(new PhabricatorTimer())->load($this->id);
// If no timer is found
if (!$timer) {
return new Aphront404Response();
}
if (($timer->getAuthorPHID() != $user->getPHID())
&& $user->getIsAdmin() == false) {
return new Aphront404Response();
}
$action_label = 'Update Timer';
} else {
$timer = new PhabricatorTimer();
$timer->setDatePoint(time());
}
$error_view = null;
$e_text = null;
if ($request->isFormPost()) {
$errors = array();
$title = $request->getStr('title');
$datepoint = $request->getStr('datepoint');
- $timestamp = strtotime($datepoint);
$e_text = null;
if (!strlen($title)) {
$e_text = 'Required';
- $errors[] = 'You must give it a name';
+ $errors[] = 'You must give it a name.';
}
- if ($timestamp === false) {
+ // If the user types something like "5 PM", convert it to a timestamp
+ // using their local time, not the server time.
+ $timezone = new DateTimeZone($user->getTimezoneIdentifier());
+
+ try {
+ $date = new DateTime($datepoint, $timezone);
+ $timestamp = $date->format('U');
+ } catch (Exception $e) {
$errors[] = 'You entered an incorrect date. You can enter date like'.
' \'2011-06-26 13:33:37\' to create an event at'.
- ' 13:33:37 on the 26th of June 2011';
+ ' 13:33:37 on the 26th of June 2011.';
+ $timestamp = null;
}
$timer->setTitle($title);
$timer->setDatePoint($timestamp);
if (!count($errors)) {
$timer->setAuthorPHID($user->getPHID());
$timer->save();
return id(new AphrontRedirectResponse())
->setURI('/countdown/'.$timer->getID().'/');
- }
- else {
+ } else {
$error_view = id(new AphrontErrorView())
->setErrors($errors)
->setTitle('It\'s not The Final Countdown (du nu nuuu nun)' .
' until you fix these problem');
}
}
+ if ($timer->getDatePoint()) {
+ $display_datepoint = phabricator_datetime(
+ $timer->getDatePoint(),
+ $user);
+ } else {
+ $display_datepoint = $request->getStr('datepoint');
+ }
+
$form = id(new AphrontFormView())
->setUser($user)
->setAction($request->getRequestURI()->getPath())
->appendChild(
id(new AphrontFormTextControl())
->setLabel('Title')
->setValue($timer->getTitle())
->setName('title'))
->appendChild(
id(new AphrontFormTextControl())
->setLabel('End date')
- ->setValue(strftime("%F %H:%M:%S", $timer->getDatePoint()))
+ ->setValue($display_datepoint)
->setName('datepoint')
- ->setCaption('Post any date that is parsable by strtotime'))
+ ->setCaption(
+ 'Examples: '.
+ '<tt>2011-12-25</tt> or '.
+ '<tt>3 hours</tt> or '.
+ '<tt>June 8 2011, 5 PM</tt>.'))
->appendChild(
id(new AphrontFormSubmitControl())
->addCancelButton('/countdown/')
->setValue($action_label));
$panel = id(new AphrontPanelView())
->setWidth(AphrontPanelView::WIDTH_FORM)
->setHeader($action_label)
->appendChild($form);
return $this->buildStandardPageResponse(
array(
$error_view,
$panel,
),
array(
'title' => 'Edit Countdown',
));
}
}
diff --git a/src/applications/countdown/controller/edit/__init__.php b/src/applications/countdown/controller/edit/__init__.php
index d7534b78c0..4f2100659c 100644
--- a/src/applications/countdown/controller/edit/__init__.php
+++ b/src/applications/countdown/controller/edit/__init__.php
@@ -1,22 +1,23 @@
<?php
/**
* This file is automatically generated. Lint this module to rebuild it.
* @generated
*/
phutil_require_module('phabricator', 'aphront/response/404');
phutil_require_module('phabricator', 'aphront/response/redirect');
phutil_require_module('phabricator', 'applications/countdown/controller/base');
phutil_require_module('phabricator', 'applications/countdown/storage/timer');
phutil_require_module('phabricator', 'view/form/base');
phutil_require_module('phabricator', 'view/form/control/submit');
phutil_require_module('phabricator', 'view/form/control/text');
phutil_require_module('phabricator', 'view/form/error');
phutil_require_module('phabricator', 'view/layout/panel');
+phutil_require_module('phabricator', 'view/utils');
phutil_require_module('phutil', 'utils');
phutil_require_source('PhabricatorCountdownEditController.php');
diff --git a/src/applications/countdown/controller/view/PhabricatorCountdownViewController.php b/src/applications/countdown/controller/view/PhabricatorCountdownViewController.php
index 7ee31bb5c2..964ec885b7 100644
--- a/src/applications/countdown/controller/view/PhabricatorCountdownViewController.php
+++ b/src/applications/countdown/controller/view/PhabricatorCountdownViewController.php
@@ -1,87 +1,88 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class PhabricatorCountdownViewController
extends PhabricatorCountdownController {
private $id;
public function willProcessRequest(array $data) {
$this->id = $data['id'];
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$timer = id(new PhabricatorTimer())->load($this->id);
if (!$timer) {
return new Aphront404Response();
}
require_celerity_resource('phabricator-countdown-css');
$chrome_visible = $request->getBool('chrome', true);
$chrome_link = phutil_render_tag(
'a',
array(
'href' => $request->getRequestURI()->alter('chrome', !$chrome_visible),
'class' => 'phabricator-timer-chrome-link',
),
$chrome_visible ? 'Disable Chrome' : 'Enable Chrome');
$content =
'<div class="phabricator-timer">
<h1 class="phabricator-timer-header">'.
- phutil_escape_html($timer->getTitle()).'
- </h1>
+ phutil_escape_html($timer->getTitle()).' · '.
+ phabricator_datetime($timer->getDatePoint(), $user).
+ '</h1>
<div class="phabricator-timer-pane">
<table class="phabricator-timer-table">
<tr>
<th>Days</th>
<th>Hours</th>
<th>Minutes</th>
<th>Seconds</th>
</tr>
<tr>
<td id="phabricator-timer-days"></td>
<td id="phabricator-timer-hours"></td>
<td id="phabricator-timer-minutes"></td>
<td id="phabricator-timer-seconds"></td>
</table>
</div>'.
$chrome_link.
'</div>';
Javelin::initBehavior('countdown-timer', array(
'timestamp' => $timer->getDatepoint()
));
$panel = $content;
return $this->buildStandardPageResponse(
$panel,
array(
'title' => 'Countdown: '.$timer->getTitle(),
'tab' => 'view',
'chrome' => $chrome_visible
));
}
}
diff --git a/src/applications/countdown/controller/view/__init__.php b/src/applications/countdown/controller/view/__init__.php
index 7689aa507d..8edea94a87 100644
--- a/src/applications/countdown/controller/view/__init__.php
+++ b/src/applications/countdown/controller/view/__init__.php
@@ -1,19 +1,20 @@
<?php
/**
* This file is automatically generated. Lint this module to rebuild it.
* @generated
*/
phutil_require_module('phabricator', 'aphront/response/404');
phutil_require_module('phabricator', 'applications/countdown/controller/base');
phutil_require_module('phabricator', 'applications/countdown/storage/timer');
phutil_require_module('phabricator', 'infrastructure/celerity/api');
phutil_require_module('phabricator', 'infrastructure/javelin/api');
+phutil_require_module('phabricator', 'view/utils');
phutil_require_module('phutil', 'markup');
phutil_require_module('phutil', 'utils');
phutil_require_source('PhabricatorCountdownViewController.php');
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sun, Jan 19, 15:06 (3 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1125792
Default Alt Text
(10 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment