本文整理汇总了PHP中PhabricatorTime类的典型用法代码示例。如果您正苦于以下问题:PHP PhabricatorTime类的具体用法?PHP PhabricatorTime怎么用?PHP PhabricatorTime使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PhabricatorTime类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: renderResultList
protected function renderResultList(array $countdowns, PhabricatorSavedQuery $query, array $handles)
{
assert_instances_of($countdowns, 'PhabricatorCountdown');
$viewer = $this->requireViewer();
$list = new PHUIObjectItemListView();
$list->setUser($viewer);
foreach ($countdowns as $countdown) {
$id = $countdown->getID();
$ended = false;
$epoch = $countdown->getEpoch();
if ($epoch <= PhabricatorTime::getNow()) {
$ended = true;
}
$item = id(new PHUIObjectItemView())->setUser($viewer)->setObject($countdown)->setObjectName("C{$id}")->setHeader($countdown->getTitle())->setHref($this->getApplicationURI("{$id}/"))->addByline(pht('Created by %s', $handles[$countdown->getAuthorPHID()]->renderLink()));
if ($ended) {
$item->addAttribute(pht('Launched on %s', phabricator_datetime($epoch, $viewer)));
$item->setDisabled(true);
} else {
$time_left = $epoch - PhabricatorTime::getNow();
$num = round($time_left / (60 * 60 * 24));
$noun = pht('Days');
if ($num < 1) {
$num = round($time_left / (60 * 60), 1);
$noun = pht('Hours');
}
$item->setCountdown($num, $noun);
$item->addAttribute(phabricator_datetime($epoch, $viewer));
}
$list->addItem($item);
}
$result = new PhabricatorApplicationSearchResultView();
$result->setObjectList($list);
$result->setNoDataString(pht('No countdowns found.'));
return $result;
}
开发者ID:rchicoli,项目名称:phabricator,代码行数:35,代码来源:PhabricatorCountdownSearchEngine.php
示例2: buildAbstractDocument
protected function buildAbstractDocument(PhabricatorSearchAbstractDocument $document, $object)
{
$project = $object;
$project->updateDatasourceTokens();
$document->setDocumentTitle($project->getName());
$document->addRelationship($project->isArchived() ? PhabricatorSearchRelationship::RELATIONSHIP_CLOSED : PhabricatorSearchRelationship::RELATIONSHIP_OPEN, $project->getPHID(), PhabricatorProjectProjectPHIDType::TYPECONST, PhabricatorTime::getNow());
}
开发者ID:phpengineer,项目名称:phabricator,代码行数:7,代码来源:PhabricatorProjectFulltextEngine.php
示例3: parseDateTime
protected function parseDateTime($value)
{
if (!strlen($value)) {
return null;
}
return PhabricatorTime::parseLocalTime($value, $this->getViewer());
}
开发者ID:pugong,项目名称:phabricator,代码行数:7,代码来源:PhabricatorSearchDateField.php
示例4: loadTasks
protected function loadTasks(PhutilArgumentParser $args)
{
$ids = $args->getArg('id');
$class = $args->getArg('class');
$min_failures = $args->getArg('min-failure-count');
if (!$ids && !$class && !$min_failures) {
throw new PhutilArgumentUsageException(pht('Use --id, --class, or --min-failure-count to select tasks.'));
}
$active_query = new PhabricatorWorkerActiveTaskQuery();
$archive_query = new PhabricatorWorkerArchiveTaskQuery();
if ($ids) {
$active_query = $active_query->withIDs($ids);
$archive_query = $archive_query->withIDs($ids);
}
if ($class) {
$class_array = array($class);
$active_query = $active_query->withClassNames($class_array);
$archive_query = $archive_query->withClassNames($class_array);
}
if ($min_failures) {
$active_query = $active_query->withFailureCountBetween($min_failures, null);
$archive_query = $archive_query->withFailureCountBetween($min_failures, null);
}
$active_tasks = $active_query->execute();
$archive_tasks = $archive_query->execute();
$tasks = mpull($active_tasks, null, 'getID') + mpull($archive_tasks, null, 'getID');
if ($ids) {
foreach ($ids as $id) {
if (empty($tasks[$id])) {
throw new PhutilArgumentUsageException(pht('No task exists with id "%s"!', $id));
}
}
}
if ($class && $min_failures) {
if (!$tasks) {
throw new PhutilArgumentUsageException(pht('No task exists with class "%s" and at least %d failures!', $class, $min_failures));
}
} else {
if ($class) {
if (!$tasks) {
throw new PhutilArgumentUsageException(pht('No task exists with class "%s"!', $class));
}
} else {
if ($min_failures) {
if (!$tasks) {
throw new PhutilArgumentUsageException(pht('No tasks exist with at least %d failures!', $min_failures));
}
}
}
}
// When we lock tasks properly, this gets populated as a side effect. Just
// fake it when doing manual CLI stuff. This makes sure CLI yields have
// their expires times set properly.
foreach ($tasks as $task) {
if ($task instanceof PhabricatorWorkerActiveTask) {
$task->setServerTime(PhabricatorTime::getNow());
}
}
return $tasks;
}
开发者ID:NeoArmageddon,项目名称:phabricator,代码行数:60,代码来源:PhabricatorWorkerManagementWorkflow.php
示例5: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$countdown = id(new PhabricatorCountdownQuery())->setViewer($viewer)->withIDs(array($id))->executeOne();
if (!$countdown) {
return new Aphront404Response();
}
$countdown_view = id(new PhabricatorCountdownView())->setUser($viewer)->setCountdown($countdown)->setHeadless(true);
$id = $countdown->getID();
$title = $countdown->getTitle();
$crumbs = $this->buildApplicationCrumbs()->addTextCrumb("C{$id}");
$epoch = $countdown->getEpoch();
if ($epoch >= PhabricatorTime::getNow()) {
$icon = 'fa-clock-o';
$color = '';
$status = pht('Running');
} else {
$icon = 'fa-check-square-o';
$color = 'dark';
$status = pht('Launched');
}
$header = id(new PHUIHeaderView())->setHeader($title)->setUser($viewer)->setPolicyObject($countdown)->setStatus($icon, $color, $status);
$actions = $this->buildActionListView($countdown);
$properties = $this->buildPropertyListView($countdown, $actions);
$object_box = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties);
$timeline = $this->buildTransactionTimeline($countdown, new PhabricatorCountdownTransactionQuery());
$add_comment = $this->buildCommentForm($countdown);
$content = array($crumbs, $object_box, $countdown_view, $timeline, $add_comment);
return $this->buildApplicationPage($content, array('title' => $title, 'pageObjects' => array($countdown->getPHID())));
}
开发者ID:fengshao0907,项目名称:phabricator,代码行数:31,代码来源:PhabricatorCountdownViewController.php
示例6: execute
public function execute(PhutilArgumentParser $args)
{
$console = PhutilConsole::getConsole();
$tasks = $this->loadTasks($args);
foreach ($tasks as $task) {
$can_execute = !$task->isArchived();
if (!$can_execute) {
$console->writeOut("**<bg:yellow> %s </bg>** %s\n", pht('ARCHIVED'), pht('%s is already archived, and can not be executed.', $this->describeTask($task)));
continue;
}
// NOTE: This ignores leases, maybe it should respect them without
// a parameter like --force?
$task->setLeaseOwner(null);
$task->setLeaseExpires(PhabricatorTime::getNow());
$task->save();
$task_data = id(new PhabricatorWorkerTaskData())->loadOneWhere('id = %d', $task->getDataID());
$task->setData($task_data->getData());
$console->writeOut(pht('Executing task %d (%s)...', $task->getID(), $task->getTaskClass()));
$task = $task->executeTask();
$ex = $task->getExecutionException();
if ($ex) {
throw $ex;
}
}
return 0;
}
开发者ID:fengshao0907,项目名称:phabricator,代码行数:26,代码来源:PhabricatorWorkerManagementExecuteWorkflow.php
示例7: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$countdown = id(new PhabricatorCountdownQuery())->setViewer($viewer)->withIDs(array($id))->executeOne();
if (!$countdown) {
return new Aphront404Response();
}
$countdown_view = id(new PhabricatorCountdownView())->setUser($viewer)->setCountdown($countdown);
$id = $countdown->getID();
$title = $countdown->getTitle();
$crumbs = $this->buildApplicationCrumbs()->addTextCrumb("C{$id}")->setBorder(true);
$epoch = $countdown->getEpoch();
if ($epoch >= PhabricatorTime::getNow()) {
$icon = 'fa-clock-o';
$color = '';
$status = pht('Running');
} else {
$icon = 'fa-check-square-o';
$color = 'dark';
$status = pht('Launched');
}
$header = id(new PHUIHeaderView())->setHeader($title)->setUser($viewer)->setPolicyObject($countdown)->setStatus($icon, $color, $status)->setHeaderIcon('fa-rocket');
$curtain = $this->buildCurtain($countdown);
$subheader = $this->buildSubheaderView($countdown);
$timeline = $this->buildTransactionTimeline($countdown, new PhabricatorCountdownTransactionQuery());
$comment_view = id(new PhabricatorCountdownEditEngine())->setViewer($viewer)->buildEditEngineCommentView($countdown);
$content = array($countdown_view, $timeline, $comment_view);
$view = id(new PHUITwoColumnView())->setHeader($header)->setSubheader($subheader)->setCurtain($curtain)->setMainColumn($content);
return $this->newPage()->setTitle($title)->setCrumbs($crumbs)->setPageObjectPHIDs(array($countdown->getPHID()))->appendChild($view);
}
开发者ID:rchicoli,项目名称:phabricator,代码行数:31,代码来源:PhabricatorCountdownViewController.php
示例8: revokeToken
public function revokeToken()
{
if ($this->isRevocable()) {
$this->setTokenExpires(PhabricatorTime::getNow() - 1)->save();
}
return $this;
}
开发者ID:pugong,项目名称:phabricator,代码行数:7,代码来源:PhabricatorAuthTemporaryToken.php
示例9: execute
public function execute(PhutilArgumentParser $args)
{
$console = PhutilConsole::getConsole();
$viewer = $this->getViewer();
$since = PhabricatorTime::getNow() - phutil_units('30 days in seconds');
$until = PhabricatorTime::getNow();
$mails = id(new PhabricatorMetaMTAMailQuery())->setViewer($viewer)->withDateCreatedBetween($since, $until)->execute();
$unfiltered = array();
foreach ($mails as $mail) {
$unfiltered_actors = mpull($mail->loadAllActors(), 'getPHID');
foreach ($unfiltered_actors as $phid) {
if (empty($unfiltered[$phid])) {
$unfiltered[$phid] = 0;
}
$unfiltered[$phid]++;
}
}
arsort($unfiltered);
$table = id(new PhutilConsoleTable())->setBorders(true)->addColumn('user', array('title' => pht('User')))->addColumn('unfiltered', array('title' => pht('Unfiltered')));
$handles = $viewer->loadHandles(array_keys($unfiltered));
$names = mpull(iterator_to_array($handles), 'getName', 'getPHID');
foreach ($unfiltered as $phid => $count) {
$table->addRow(array('user' => idx($names, $phid), 'unfiltered' => $count));
}
$table->draw();
echo "\n";
echo pht('Mail sent in the last 30 days.') . "\n";
echo pht('"Unfiltered" is raw volume before preferences were applied.') . "\n";
echo "\n";
return 0;
}
开发者ID:JohnnyEstilles,项目名称:phabricator,代码行数:31,代码来源:PhabricatorMailManagementVolumeWorkflow.php
示例10: updateLease
private function updateLease(DrydockLease $lease)
{
if ($lease->getStatus() != DrydockLeaseStatus::STATUS_ACTIVE) {
return;
}
$viewer = $this->getViewer();
$drydock_phid = id(new PhabricatorDrydockApplication())->getPHID();
// Check if the lease has expired. If it is, we're going to send it a
// release command. This command will be handled immediately below, it
// just generates a command log and improves consistency.
$now = PhabricatorTime::getNow();
$expires = $lease->getUntil();
if ($expires && $expires <= $now) {
$command = DrydockCommand::initializeNewCommand($viewer)->setTargetPHID($lease->getPHID())->setAuthorPHID($drydock_phid)->setCommand(DrydockCommand::COMMAND_RELEASE)->save();
}
$commands = $this->loadCommands($lease->getPHID());
foreach ($commands as $command) {
if ($lease->getStatus() != DrydockLeaseStatus::STATUS_ACTIVE) {
// Leases can't receive commands before they activate or after they
// release.
break;
}
$this->processCommand($lease, $command);
$command->setIsConsumed(true)->save();
}
// If this is the task which will eventually release the lease after it
// expires but it is still active, reschedule the task to run after the
// lease expires. This can happen if the lease's expiration was pushed
// forward.
if ($lease->getStatus() == DrydockLeaseStatus::STATUS_ACTIVE) {
if ($this->getTaskDataValue('isExpireTask') && $expires) {
throw new PhabricatorWorkerYieldException($expires - $now);
}
}
}
开发者ID:Robert-Xie,项目名称:phabricator,代码行数:35,代码来源:DrydockLeaseUpdateWorker.php
示例11: buildWhereClause
protected function buildWhereClause(AphrontDatabaseConnection $conn_r)
{
$where = array();
if ($this->ids !== null) {
$where[] = qsprintf($conn_r, 'id IN (%Ld)', $this->ids);
}
if ($this->objectPHIDs !== null) {
$where[] = qsprintf($conn_r, 'objectPHID IN (%Ls)', $this->objectPHIDs);
}
if ($this->tokens !== null) {
$where[] = qsprintf($conn_r, 'token IN (%Ls)', $this->tokens);
}
if ($this->tokenTypes !== null) {
$where[] = qsprintf($conn_r, 'tokenType IN (%Ls)', $this->tokenTypes);
}
if ($this->expired !== null) {
if ($this->expired) {
$where[] = qsprintf($conn_r, 'expires <= %d', PhabricatorTime::getNow());
} else {
$where[] = qsprintf($conn_r, 'expires IS NULL OR expires > %d', PhabricatorTime::getNow());
}
}
$where[] = $this->buildPagingClause($conn_r);
return $this->formatWhereClause($where);
}
开发者ID:barcelonascience,项目名称:phabricator,代码行数:25,代码来源:PhabricatorConduitTokenQuery.php
示例12: testParseLocalTime
public function testParseLocalTime()
{
$u = new PhabricatorUser();
$u->setTimezoneIdentifier('UTC');
$v = new PhabricatorUser();
$v->setTimezoneIdentifier('America/Los_Angeles');
$t = 1370202281;
// 2013-06-02 12:44:41 -0700
$time = PhabricatorTime::pushTime($t, 'America/Los_Angeles');
$this->assertEqual($t, PhabricatorTime::parseLocalTime('now', $u));
$this->assertEqual($t, PhabricatorTime::parseLocalTime('now', $v));
$this->assertEqual($t, PhabricatorTime::parseLocalTime('2013-06-02 12:44:41 -0700', $u));
$this->assertEqual($t, PhabricatorTime::parseLocalTime('2013-06-02 12:44:41 -0700', $v));
$this->assertEqual($t, PhabricatorTime::parseLocalTime('2013-06-02 12:44:41 PDT', $u));
$this->assertEqual($t, PhabricatorTime::parseLocalTime('2013-06-02 12:44:41 PDT', $v));
$this->assertEqual($t, PhabricatorTime::parseLocalTime('2013-06-02 19:44:41', $u));
$this->assertEqual($t, PhabricatorTime::parseLocalTime('2013-06-02 12:44:41', $v));
$this->assertEqual($t + 3600, PhabricatorTime::parseLocalTime('+1 hour', $u));
$this->assertEqual($t + 3600, PhabricatorTime::parseLocalTime('+1 hour', $v));
unset($time);
$t = 1370239200;
// 2013-06-02 23:00:00 -0700
$time = PhabricatorTime::pushTime($t, 'America/Los_Angeles');
// For the UTC user, midnight was 6 hours ago because it's early in the
// morning for htem. For the PDT user, midnight was 23 hours ago.
$this->assertEqual($t + -6 * 3600 + 60, PhabricatorTime::parseLocalTime('12:01:00 AM', $u));
$this->assertEqual($t + -23 * 3600 + 60, PhabricatorTime::parseLocalTime('12:01:00 AM', $v));
unset($time);
}
开发者ID:pugong,项目名称:phabricator,代码行数:29,代码来源:PhabricatorTimeTestCase.php
示例13: buildAbstractDocument
protected function buildAbstractDocument(PhabricatorSearchAbstractDocument $document, $object)
{
$revision = id(new DifferentialRevisionQuery())->setViewer($this->getViewer())->withPHIDs(array($object->getPHID()))->needReviewerStatus(true)->executeOne();
// TODO: This isn't very clean, but custom fields currently rely on it.
$object->attachReviewerStatus($revision->getReviewerStatus());
$document->setDocumentTitle($revision->getTitle());
$document->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR, $revision->getAuthorPHID(), PhabricatorPeopleUserPHIDType::TYPECONST, $revision->getDateCreated());
$document->addRelationship($revision->isClosed() ? PhabricatorSearchRelationship::RELATIONSHIP_CLOSED : PhabricatorSearchRelationship::RELATIONSHIP_OPEN, $revision->getPHID(), DifferentialRevisionPHIDType::TYPECONST, PhabricatorTime::getNow());
// If a revision needs review, the owners are the reviewers. Otherwise, the
// owner is the author (e.g., accepted, rejected, closed).
$status_review = ArcanistDifferentialRevisionStatus::NEEDS_REVIEW;
if ($revision->getStatus() == $status_review) {
$reviewers = $revision->getReviewerStatus();
$reviewers = mpull($reviewers, 'getReviewerPHID', 'getReviewerPHID');
if ($reviewers) {
foreach ($reviewers as $phid) {
$document->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_OWNER, $phid, PhabricatorPeopleUserPHIDType::TYPECONST, $revision->getDateModified());
// Bogus timestamp.
}
} else {
$document->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_UNOWNED, $revision->getPHID(), PhabricatorPeopleUserPHIDType::TYPECONST, $revision->getDateModified());
// Bogus timestamp.
}
} else {
$document->addRelationship(PhabricatorSearchRelationship::RELATIONSHIP_OWNER, $revision->getAuthorPHID(), PhabricatorPHIDConstants::PHID_TYPE_VOID, $revision->getDateCreated());
}
}
开发者ID:truSense,项目名称:phabricator,代码行数:27,代码来源:DifferentialRevisionFulltextEngine.php
示例14: buildAbstractDocument
protected function buildAbstractDocument(PhabricatorSearchAbstractDocument $document, $object)
{
$credential = $object;
$document->setDocumentTitle($credential->getName());
$document->addField(PhabricatorSearchDocumentFieldType::FIELD_BODY, $credential->getDescription());
$document->addRelationship($credential->getIsDestroyed() ? PhabricatorSearchRelationship::RELATIONSHIP_CLOSED : PhabricatorSearchRelationship::RELATIONSHIP_OPEN, $credential->getPHID(), PassphraseCredentialPHIDType::TYPECONST, PhabricatorTime::getNow());
}
开发者ID:phpengineer,项目名称:phabricator,代码行数:7,代码来源:PassphraseCredentialFulltextEngine.php
示例15: buildAbstractDocument
protected function buildAbstractDocument(PhabricatorSearchAbstractDocument $document, $object)
{
$blog = $object;
$document->setDocumentTitle($blog->getName());
$document->addField(PhabricatorSearchDocumentFieldType::FIELD_BODY, $blog->getDescription());
$document->addRelationship($blog->isArchived() ? PhabricatorSearchRelationship::RELATIONSHIP_CLOSED : PhabricatorSearchRelationship::RELATIONSHIP_OPEN, $blog->getPHID(), PhabricatorPhameBlogPHIDType::TYPECONST, PhabricatorTime::getNow());
}
开发者ID:rchicoli,项目名称:phabricator,代码行数:7,代码来源:PhameBlogFulltextEngine.php
示例16: getDisplayMinutes
public function getDisplayMinutes()
{
$epoch = $this->getEpoch();
$now = PhabricatorTime::getNow();
$minutes = (int) ceil(($epoch - $now) / 60);
return new PhutilNumber($minutes);
}
开发者ID:NeoArmageddon,项目名称:phabricator,代码行数:7,代码来源:PhabricatorCalendarEventNotificationView.php
示例17: applyCustomInternalTransaction
protected function applyCustomInternalTransaction(PhabricatorLiskDAO $object, PhabricatorApplicationTransaction $xaction)
{
switch ($xaction->getTransactionType()) {
case PhamePostTransaction::TYPE_TITLE:
return $object->setTitle($xaction->getNewValue());
case PhamePostTransaction::TYPE_SUBTITLE:
return $object->setSubtitle($xaction->getNewValue());
case PhamePostTransaction::TYPE_BODY:
return $object->setBody($xaction->getNewValue());
case PhamePostTransaction::TYPE_BLOG:
return $object->setBlogPHID($xaction->getNewValue());
case PhamePostTransaction::TYPE_HEADERIMAGE:
return $object->setHeaderImagePHID($xaction->getNewValue());
case PhamePostTransaction::TYPE_VISIBILITY:
if ($xaction->getNewValue() == PhameConstants::VISIBILITY_DRAFT) {
$object->setDatePublished(0);
} else {
if ($xaction->getNewValue() == PhameConstants::VISIBILITY_ARCHIVED) {
$object->setDatePublished(0);
} else {
$object->setDatePublished(PhabricatorTime::getNow());
}
}
return $object->setVisibility($xaction->getNewValue());
}
return parent::applyCustomInternalTransaction($object, $xaction);
}
开发者ID:NeoArmageddon,项目名称:phabricator,代码行数:27,代码来源:PhamePostEditor.php
示例18: executeQuery
protected final function executeQuery()
{
$future = $this->newQueryFuture();
$drequest = $this->getRequest();
$name = basename($drequest->getPath());
$ttl = PhabricatorTime::getNow() + phutil_units('48 hours in seconds');
try {
$threshold = PhabricatorFileStorageEngine::getChunkThreshold();
$future->setReadBufferSize($threshold);
$source = id(new PhabricatorExecFutureFileUploadSource())->setName($name)->setTTL($ttl)->setViewPolicy(PhabricatorPolicies::POLICY_NOONE)->setExecFuture($future);
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
$file = $source->uploadFile();
unset($unguarded);
} catch (CommandException $ex) {
if (!$future->getWasKilledByTimeout()) {
throw $ex;
}
$this->didHitTimeLimit = true;
$file = null;
}
$byte_limit = $this->getByteLimit();
if ($byte_limit && $file->getByteSize() > $byte_limit) {
$this->didHitByteLimit = true;
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
id(new PhabricatorDestructionEngine())->destroyObject($file);
unset($unguarded);
$file = null;
}
return $file;
}
开发者ID:endlessm,项目名称:phabricator,代码行数:30,代码来源:DiffusionFileFutureQuery.php
示例19: render
public function render()
{
require_celerity_resource('phui-calendar-day-css');
$viewer = $this->getUser();
$hours = $this->getHoursOfDay();
$js_hours = array();
$js_today_events = array();
foreach ($hours as $hour) {
$js_hours[] = array('hour' => $hour->format('G'), 'displayTime' => phabricator_time($hour->format('U'), $viewer));
}
$first_event_hour = null;
$js_today_all_day_events = array();
$all_day_events = $this->getAllDayEvents();
$day_start = $this->getDateTime();
$day_end = id(clone $day_start)->modify('+1 day');
$day_start_epoch = $day_start->format('U');
$day_end_epoch = $day_end->format('U') - 1;
foreach ($all_day_events as $all_day_event) {
$all_day_start = $all_day_event->getEpochStart();
$all_day_end = $all_day_event->getEpochEnd();
if ($all_day_start < $day_end_epoch && $all_day_end > $day_start_epoch) {
$js_today_all_day_events[] = array('name' => $all_day_event->getName(), 'id' => $all_day_event->getEventID(), 'viewerIsInvited' => $all_day_event->getViewerIsInvited(), 'uri' => $all_day_event->getURI(), 'displayIcon' => $all_day_event->getIcon(), 'displayIconColor' => $all_day_event->getIconColor());
}
}
$this->events = msort($this->events, 'getEpochStart');
$first_event_hour = $this->getDateTime()->setTime(8, 0, 0);
$midnight = $this->getDateTime()->setTime(0, 0, 0);
foreach ($this->events as $event) {
if ($event->getIsAllDay()) {
continue;
}
if ($event->getEpochStart() <= $day_end_epoch && $event->getEpochEnd() > $day_start_epoch) {
if ($event->getEpochStart() < $midnight->format('U') && $event->getEpochEnd() > $midnight->format('U')) {
$first_event_hour = clone $midnight;
}
if ($event->getEpochStart() < $first_event_hour->format('U') && $event->getEpochStart() > $midnight->format('U')) {
$first_event_hour = PhabricatorTime::getDateTimeFromEpoch($event->getEpochStart(), $viewer);
$first_event_hour->setTime($first_event_hour->format('h'), 0, 0);
}
$event_start = max($event->getEpochStart(), $day_start_epoch);
$event_end = min($event->getEpochEnd(), $day_end_epoch);
$day_duration = ($day_end_epoch - $first_event_hour->format('U')) / 60;
$top = ($event_start - $first_event_hour->format('U')) / ($day_end_epoch - $first_event_hour->format('U')) * $day_duration;
$top = max(0, $top);
$height = ($event_end - $event_start) / ($day_end_epoch - $first_event_hour->format('U')) * $day_duration;
$height = min($day_duration, $height);
$js_today_events[] = array('eventStartEpoch' => $event->getEpochStart(), 'eventEndEpoch' => $event->getEpochEnd(), 'eventName' => $event->getName(), 'eventID' => $event->getEventID(), 'viewerIsInvited' => $event->getViewerIsInvited(), 'uri' => $event->getURI(), 'offset' => '0', 'width' => '100%', 'top' => $top . 'px', 'height' => $height . 'px', 'canEdit' => $event->getCanEdit(), 'displayIcon' => $event->getIcon(), 'displayIconColor' => $event->getIconColor());
}
}
$header = $this->renderDayViewHeader();
$sidebar = id(new PHUICalendarWeekView())->setViewer($this->getViewer())->setEvents($this->events)->setDateTime($this->getDateTime())->render();
$warnings = $this->getQueryRangeWarning();
$table_id = celerity_generate_unique_node_id();
$table_wrapper = phutil_tag('div', array('id' => $table_id), '');
Javelin::initBehavior('day-view', array('year' => $first_event_hour->format('Y'), 'month' => $first_event_hour->format('m'), 'day' => $first_event_hour->format('d'), 'query' => $this->getQuery(), 'allDayEvents' => $js_today_all_day_events, 'todayEvents' => $js_today_events, 'hours' => $js_hours, 'firstEventHour' => $first_event_hour->format('G'), 'firstEventHourEpoch' => $first_event_hour->format('U'), 'tableID' => $table_id));
$table_box = id(new PHUIObjectBoxView())->setHeader($header)->appendChild($table_wrapper)->setFormErrors($warnings)->setFlush(true);
$layout = id(new AphrontMultiColumnView())->addColumn($sidebar, 'third phui-day-view-upcoming')->addColumn($table_box, 'thirds phui-day-view-column')->setFluidLayout(true);
$layout = id(new PHUIBoxView())->appendChild($layout)->addClass('phui-calendar-box');
return $layout;
}
开发者ID:endlessm,项目名称:phabricator,代码行数:60,代码来源:PHUICalendarDayView.php
示例20: buildCalendarDayView
private function buildCalendarDayView(PhabricatorUser $user)
{
$viewer = $this->getViewer();
$class = 'PhabricatorCalendarApplication';
if (!PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
return null;
}
$midnight = PhabricatorTime::getTodayMidnightDateTime($viewer);
$week_end = clone $midnight;
$week_end = $week_end->modify('+3 days');
$range_start = $midnight->format('U');
$range_end = $week_end->format('U');
$events = id(new PhabricatorCalendarEventQuery())->setViewer($viewer)->withDateRange($range_start, $range_end)->withInvitedPHIDs(array($user->getPHID()))->withIsCancelled(false)->needRSVPs(array($viewer->getPHID()))->execute();
$event_views = array();
foreach ($events as $event) {
$viewer_is_invited = $event->isRSVPInvited($viewer->getPHID());
$can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $event, PhabricatorPolicyCapability::CAN_EDIT);
$epoch_min = $event->getStartDateTimeEpoch();
$epoch_max = $event->getEndDateTimeEpoch();
$event_view = id(new AphrontCalendarEventView())->setCanEdit($can_edit)->setEventID($event->getID())->setEpochRange($epoch_min, $epoch_max)->setIsAllDay($event->getIsAllDay())->setIcon($event->getIcon())->setViewerIsInvited($viewer_is_invited)->setName($event->getName())->setDatetimeSummary($event->renderEventDate($viewer, true))->setURI($event->getURI());
$event_views[] = $event_view;
}
$event_views = msort($event_views, 'getEpochStart');
$day_view = id(new PHUICalendarWeekView())->setViewer($viewer)->setView('week')->setEvents($event_views)->setWeekLength(3)->render();
$header = id(new PHUIHeaderView())->setHeader(pht('Calendar'))->setHref(urisprintf('/calendar/?invited=%s#R', $user->getUsername()));
$box = id(new PHUIObjectBoxView())->setHeader($header)->appendChild($day_view)->addClass('calendar-profile-box')->setBackground(PHUIObjectBoxView::GREY);
return $box;
}
开发者ID:NeoArmageddon,项目名称:phabricator,代码行数:28,代码来源:PhabricatorPeopleProfileViewController.php
注:本文中的PhabricatorTime类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论