本文整理汇总了PHP中phabricator_datetime函数的典型用法代码示例。如果您正苦于以下问题:PHP phabricator_datetime函数的具体用法?PHP phabricator_datetime怎么用?PHP phabricator_datetime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了phabricator_datetime函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
public function render()
{
$user = $this->user;
if (!$user) {
throw new Exception("Call setUser() before render()!");
}
$rows = array();
foreach ($this->revisions as $revision) {
$status = $revision->getStatus();
$status = DifferentialRevisionStatus::getNameForRevisionStatus($status);
$reviewer_phids = $revision->getReviewers();
if ($reviewer_phids) {
$first = reset($reviewer_phids);
if (count($reviewer_phids) > 1) {
$suffix = ' (+' . (count($reviewer_phids) - 1) . ')';
} else {
$suffix = null;
}
$reviewers = $this->handles[$first]->renderLink() . $suffix;
} else {
$reviewers = '<em>None</em>';
}
$link = phutil_render_tag('a', array('href' => '/D' . $revision->getID()), phutil_escape_html($revision->getTitle()));
$rows[] = array('D' . $revision->getID(), $link, phutil_escape_html($status), number_format($revision->getLineCount()), $this->handles[$revision->getAuthorPHID()]->renderLink(), $reviewers, phabricator_datetime($revision->getDateModified(), $user), phabricator_date($revision->getDateCreated(), $user));
}
$table = new AphrontTableView($rows);
$table->setHeaders(array('ID', 'Revision', 'Status', 'Lines', 'Author', 'Reviewers', 'Updated', 'Created'));
$table->setColumnClasses(array(null, 'wide pri', null, 'n', null, null, 'right', 'right'));
if ($this->noDataString) {
$table->setNoDataString($this->noDataString);
}
return $table->render();
}
示例2: render
public function render()
{
$drequest = $this->getDiffusionRequest();
$current_branch = $drequest->getBranch();
$rows = array();
$rowc = array();
foreach ($this->branches as $branch) {
$commit = idx($this->commits, $branch->getHeadCommitIdentifier());
if ($commit) {
$details = $commit->getCommitData()->getCommitMessage();
$details = idx(explode("\n", $details), 0);
$details = substr($details, 0, 80);
$datetime = phabricator_datetime($commit->getEpoch(), $this->user);
} else {
$datetime = null;
$details = null;
}
$rows[] = array(phutil_render_tag('a', array('href' => $drequest->generateURI(array('action' => 'history', 'branch' => $branch->getName()))), 'History'), phutil_render_tag('a', array('href' => $drequest->generateURI(array('action' => 'browse', 'branch' => $branch->getName()))), phutil_escape_html($branch->getName())), self::linkCommit($drequest->getRepository(), $branch->getHeadCommitIdentifier()), $datetime, AphrontTableView::renderSingleDisplayLine(phutil_escape_html($details)));
if ($branch->getName() == $current_branch) {
$rowc[] = 'highlighted';
} else {
$rowc[] = null;
}
}
$view = new AphrontTableView($rows);
$view->setHeaders(array('History', 'Branch', 'Head', 'Modified', 'Details'));
$view->setColumnClasses(array('', 'pri', '', '', 'wide'));
$view->setRowClasses($rowc);
return $view->render();
}
示例3: renderTransactionInfo
private function renderTransactionInfo()
{
$info = array();
if ($this->contentSource) {
$content_source = new PhabricatorContentSourceView();
$content_source->setContentSource($this->contentSource);
$content_source->setUser($this->user);
$source = $content_source->render();
if ($source) {
$info[] = $source;
}
}
if ($this->isPreview) {
$info[] = 'PREVIEW';
} else {
if ($this->epoch) {
$info[] = phabricator_datetime($this->epoch, $this->user);
}
}
if ($this->anchorName) {
Javelin::initBehavior('phabricator-watch-anchor');
$anchor = id(new PhabricatorAnchorView())->setAnchorName($this->anchorName)->render();
$info[] = hsprintf('%s%s', $anchor, phutil_tag('a', array('href' => '#' . $this->anchorName), $this->anchorText));
}
$info = phutil_implode_html(" · ", $info);
return phutil_tag('span', array('class' => 'phabricator-transaction-info'), $info);
}
示例4: buildPropertyList
private function buildPropertyList(HarbormasterBuildStep $step, PhabricatorCustomFieldList $field_list)
{
$viewer = $this->getViewer();
$view = id(new PHUIPropertyListView())->setUser($viewer)->setObject($step);
try {
$implementation = $step->getStepImplementation();
} catch (Exception $ex) {
$implementation = null;
}
if ($implementation) {
$type = $implementation->getName();
} else {
$type = phutil_tag('em', array(), pht('Invalid Implementation ("%s")!', $step->getClassName()));
}
$view->addProperty(pht('Step Type'), $type);
$view->addProperty(pht('Created'), phabricator_datetime($step->getDateCreated(), $viewer));
$field_list->appendFieldsToPropertyList($step, $viewer, $view);
$view->invokeWillRenderEvent();
$description = $step->getDescription();
if (strlen($description)) {
$view->addSectionHeader(pht('Description'), PHUIPropertyListView::ICON_SUMMARY);
$view->addTextContent(new PHUIRemarkupView($viewer, $description));
}
return $view;
}
示例5: processRequest
public function processRequest()
{
$request = $this->getRequest();
$user = $request->getUser();
$nav = $this->buildSideNav('resource');
$pager = new AphrontPagerView();
$pager->setURI(new PhutilURI('/drydock/resource/'), 'page');
$data = id(new DrydockResource())->loadAllWhere('1 = 1 ORDER BY id DESC LIMIT %d, %d', $pager->getOffset(), $pager->getPageSize() + 1);
$data = $pager->sliceResults($data);
$phids = mpull($data, 'getOwnerPHID');
$handles = $this->loadViewerHandles($phids);
$rows = array();
foreach ($data as $resource) {
$rows[] = array($resource->getID(), $resource->getOwnerPHID() ? $handles[$resource->getOwnerPHID()]->renderLink() : null, phutil_escape_html($resource->getType()), DrydockResourceStatus::getNameForStatus($resource->getStatus()), phutil_escape_html(nonempty($resource->getName(), 'Unnamed')), phabricator_datetime($resource->getDateCreated(), $user));
}
$table = new AphrontTableView($rows);
$table->setHeaders(array('ID', 'Owner', 'Type', 'Status', 'Resource', 'Created'));
$table->setColumnClasses(array('', '', '', '', 'pri wide', 'right'));
$panel = new AphrontPanelView();
$panel->setHeader('Drydock Resources');
$panel->addButton(phutil_render_tag('a', array('href' => '/drydock/resource/allocate/', 'class' => 'green button'), 'Allocate Resource'));
$panel->appendChild($table);
$panel->appendChild($pager);
$nav->appendChild($panel);
return $this->buildStandardPageResponse($nav, array('title' => 'Resources'));
}
示例6: buildMessageProperties
private function buildMessageProperties(PhabricatorMetaMTAMail $mail)
{
$viewer = $this->getViewer();
$properties = id(new PHUIPropertyListView())->setUser($viewer)->setObject($mail);
if ($mail->getFrom()) {
$from_str = $viewer->renderHandle($mail->getFrom());
} else {
$from_str = pht('Sent by Phabricator');
}
$properties->addProperty(pht('From'), $from_str);
if ($mail->getToPHIDs()) {
$to_list = $viewer->renderHandleList($mail->getToPHIDs());
} else {
$to_list = pht('None');
}
$properties->addProperty(pht('To'), $to_list);
if ($mail->getCcPHIDs()) {
$cc_list = $viewer->renderHandleList($mail->getCcPHIDs());
} else {
$cc_list = pht('None');
}
$properties->addProperty(pht('Cc'), $cc_list);
$properties->addProperty(pht('Sent'), phabricator_datetime($mail->getDateCreated(), $viewer));
$properties->addSectionHeader(pht('Message'), PHUIPropertyListView::ICON_SUMMARY);
if ($mail->hasSensitiveContent()) {
$body = phutil_tag('em', array(), pht('The content of this mail is sensitive and it can not be ' . 'viewed from the web UI.'));
} else {
$body = phutil_tag('div', array('style' => 'white-space: pre-wrap'), $mail->getBody());
}
$properties->addTextContent($body);
return $properties;
}
示例7: renderResultList
protected function renderResultList(array $pastes, PhabricatorSavedQuery $query, array $handles)
{
assert_instances_of($pastes, 'PhabricatorPaste');
$viewer = $this->requireViewer();
$lang_map = PhabricatorEnv::getEnvConfig('pygments.dropdown-choices');
$list = new PHUIObjectItemListView();
$list->setUser($viewer);
foreach ($pastes as $paste) {
$created = phabricator_date($paste->getDateCreated(), $viewer);
$author = $handles[$paste->getAuthorPHID()]->renderLink();
$lines = phutil_split_lines($paste->getContent());
$preview = id(new PhabricatorSourceCodeView())->setLimit(5)->setLines($lines)->setURI(new PhutilURI($paste->getURI()));
$source_code = phutil_tag('div', array('class' => 'phabricator-source-code-summary'), $preview);
$created = phabricator_datetime($paste->getDateCreated(), $viewer);
$line_count = count($lines);
$line_count = pht('%s Line(s)', new PhutilNumber($line_count));
$title = nonempty($paste->getTitle(), pht('(An Untitled Masterwork)'));
$item = id(new PHUIObjectItemView())->setObjectName('P' . $paste->getID())->setHeader($title)->setHref('/P' . $paste->getID())->setObject($paste)->addByline(pht('Author: %s', $author))->addIcon('none', $created)->addIcon('none', $line_count)->appendChild($source_code);
$lang_name = $paste->getLanguage();
if ($lang_name) {
$lang_name = idx($lang_map, $lang_name, $lang_name);
$item->addIcon('none', $lang_name);
}
$list->addItem($item);
}
$result = new PhabricatorApplicationSearchResultView();
$result->setObjectList($list);
$result->setNoDataString(pht('No pastes found.'));
return $result;
}
示例8: render
public function render()
{
$logs = $this->logs;
$viewer = $this->getUser();
$handles = $this->handles;
// Figure out which repositories are editable. We only let you see remote
// IPs if you have edit capability on a repository.
$editable_repos = array();
if ($logs) {
$editable_repos = id(new PhabricatorRepositoryQuery())->setViewer($viewer)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->withPHIDs(mpull($logs, 'getRepositoryPHID'))->execute();
$editable_repos = mpull($editable_repos, null, 'getPHID');
}
$rows = array();
foreach ($logs as $log) {
$repository = $log->getRepository();
// Reveal this if it's valid and the user can edit the repository.
$remote_addr = '-';
if (isset($editable_repos[$log->getRepositoryPHID()])) {
$remote_long = $log->getPushEvent()->getRemoteAddress();
if ($remote_long) {
$remote_addr = long2ip($remote_long);
}
}
$event_id = $log->getPushEvent()->getID();
$old_ref_link = null;
if ($log->getRefOld() != DiffusionCommitHookEngine::EMPTY_HASH) {
$old_ref_link = phutil_tag('a', array('href' => $repository->getCommitURI($log->getRefOld())), $log->getRefOldShort());
}
$rows[] = array(phutil_tag('a', array('href' => '/diffusion/pushlog/view/' . $event_id . '/'), $event_id), phutil_tag('a', array('href' => $repository->getURI()), $repository->getDisplayName()), $handles[$log->getPusherPHID()]->renderLink(), $remote_addr, $log->getPushEvent()->getRemoteProtocol(), $log->getRefType(), $log->getRefName(), $old_ref_link, phutil_tag('a', array('href' => $repository->getCommitURI($log->getRefNew())), $log->getRefNewShort()), $log->getChangeFlags(), $log->getPushEvent()->getRejectCode(), phabricator_datetime($log->getEpoch(), $viewer));
}
$table = id(new AphrontTableView($rows))->setHeaders(array(pht('Push'), pht('Repository'), pht('Pusher'), pht('From'), pht('Via'), pht('Type'), pht('Name'), pht('Old'), pht('New'), pht('Flags'), pht('Code'), pht('Date')))->setColumnClasses(array('', '', '', '', '', '', 'wide', 'n', 'n', 'date'));
return $table;
}
示例9: processRequest
public function processRequest()
{
$request = $this->getRequest();
$user = $request->getUser();
$nav = $this->buildSideNav('lease');
$pager = new AphrontPagerView();
$pager->setURI(new PhutilURI('/drydock/lease/'), 'page');
$data = id(new DrydockLease())->loadAllWhere('1 = 1 ORDER BY id DESC LIMIT %d, %d', $pager->getOffset(), $pager->getPageSize() + 1);
$data = $pager->sliceResults($data);
$phids = mpull($data, 'getOwnerPHID');
$handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
$resource_ids = mpull($data, 'getResourceID');
$resources = array();
if ($resource_ids) {
$resources = id(new DrydockResource())->loadAllWhere('id IN (%Ld)', $resource_ids);
}
$rows = array();
foreach ($data as $lease) {
$resource = idx($resources, $lease->getResourceID());
$rows[] = array($lease->getID(), DrydockLeaseStatus::getNameForStatus($lease->getStatus()), $lease->getOwnerPHID() ? $handles[$lease->getOwnerPHID()]->renderLink() : null, $lease->getResourceID(), $resource ? phutil_escape_html($resource->getName()) : null, phabricator_datetime($lease->getDateCreated(), $user));
}
$table = new AphrontTableView($rows);
$table->setHeaders(array('ID', 'Status', 'Owner', 'Resource ID', 'Resource', 'Created'));
$table->setColumnClasses(array('', '', '', '', 'wide pri', 'right'));
$panel = new AphrontPanelView();
$panel->setHeader('Drydock Leases');
$panel->appendChild($table);
$panel->appendChild($pager);
$nav->appendChild($panel);
return $this->buildStandardPageResponse($nav, array('title' => 'Leases'));
}
示例10: render
public function render()
{
$list = new PHUIObjectItemListView();
$list->setFlush(true);
foreach ($this->edits as $edit) {
$name = nonempty($edit->getRuleName(), 'Unknown Rule');
$rule_name = phutil_tag('strong', array(), $name);
switch ($edit->getAction()) {
case 'create':
$details = pht("Created rule '%s'.", $rule_name);
break;
case 'delete':
$details = pht("Deleted rule '%s'.", $rule_name);
break;
case 'edit':
default:
$details = pht("Edited rule '%s'.", $rule_name);
break;
}
$editor = $this->handles[$edit->getEditorPHID()]->renderLink();
$date = phabricator_datetime($edit->getDateCreated(), $this->user);
$item = id(new PHUIObjectItemView())->setObjectName(pht('Rule %d', $edit->getRuleID()))->setSubHead($details)->addIcon('none', $date)->addByLine(pht('Editor: %s', $editor));
$list->addItem($item);
}
$list->setNoDataString(pht('No edits for rule.'));
return $list;
}
示例11: processRequest
public function processRequest()
{
$request = $this->getRequest();
$current_user = $request->getUser();
$error = null;
$phid = $this->getClientPHID();
$client = id(new PhabricatorOAuthServerClient())->loadOneWhere('phid = %s', $phid);
$title = 'View OAuth Client';
// validate the client
if (empty($client)) {
$message = 'No client found with id ' . $phid . '.';
return $this->buildStandardPageResponse($this->buildErrorView($message), array('title' => $title));
}
$panel = new AphrontPanelView();
$panel->setHeader($title);
$form = id(new AphrontFormView())->setUser($current_user)->appendChild(id(new AphrontFormStaticControl())->setLabel('Name')->setValue($client->getName()))->appendChild(id(new AphrontFormStaticControl())->setLabel('ID')->setValue($phid));
if ($current_user->getPHID() == $client->getCreatorPHID()) {
$form->appendChild(id(new AphrontFormStaticControl())->setLabel('Secret')->setValue($client->getSecret()));
}
$form->appendChild(id(new AphrontFormStaticControl())->setLabel('Redirect URI')->setValue($client->getRedirectURI()));
$created = phabricator_datetime($client->getDateCreated(), $current_user);
$updated = phabricator_datetime($client->getDateModified(), $current_user);
$form->appendChild(id(new AphrontFormStaticControl())->setLabel('Created')->setValue($created))->appendChild(id(new AphrontFormStaticControl())->setLabel('Last Updated')->setValue($updated));
$panel->appendChild($form);
$admin_panel = null;
if ($client->getCreatorPHID() == $current_user->getPHID()) {
$edit_button = phutil_render_tag('a', array('href' => $client->getEditURI(), 'class' => 'grey button'), 'Edit OAuth Client');
$panel->addButton($edit_button);
$create_authorization_form = id(new AphrontFormView())->setUser($current_user)->addHiddenInput('action', 'testclientauthorization')->addHiddenInput('client_phid', $phid)->setAction('/oauthserver/test/')->appendChild(id(new AphrontFormSubmitControl())->setValue('Create Scopeless Test Authorization'));
$admin_panel = id(new AphrontPanelView())->setHeader('Admin Tools')->appendChild($create_authorization_form);
}
return $this->buildStandardPageResponse(array($error, $panel, $admin_panel), array('title' => $title));
}
示例12: render
public function render()
{
$rows = array();
foreach ($this->edits as $edit) {
$name = nonempty($edit->getRuleName(), 'Unknown Rule');
$rule_name = phutil_render_tag('strong', array(), phutil_escape_html($name));
switch ($edit->getAction()) {
case 'create':
$details = "Created rule '{$rule_name}'.";
break;
case 'delete':
$details = "Deleted rule '{$rule_name}'.";
break;
case 'edit':
default:
$details = "Edited rule '{$rule_name}'.";
break;
}
$rows[] = array($edit->getRuleID(), $this->handles[$edit->getEditorPHID()]->renderLink(), $details, phabricator_datetime($edit->getDateCreated(), $this->user));
}
$table = new AphrontTableView($rows);
$table->setNoDataString("No edits for rule.");
$table->setHeaders(array('Rule ID', 'Editor', 'Details', 'Edit Date'));
$table->setColumnClasses(array('', '', 'wide', ''));
return $table->render();
}
示例13: handleHovercardEvent
private function handleHovercardEvent($event)
{
$viewer = $event->getUser();
$hovercard = $event->getValue('hovercard');
$object_handle = $event->getValue('handle');
$phid = $object_handle->getPHID();
$rev = $event->getValue('object');
if (!$rev instanceof DifferentialRevision) {
return;
}
$rev->loadRelationships();
$reviewer_phids = $rev->getReviewers();
$e_task = DifferentialRevisionHasTaskEdgeType::EDGECONST;
$edge_query = id(new PhabricatorEdgeQuery())->withSourcePHIDs(array($phid))->withEdgeTypes(array($e_task));
$edge_query->execute();
$tasks = $edge_query->getDestinationPHIDs();
$phids = array_merge(array($rev->getAuthorPHID()), $reviewer_phids, $tasks);
$handles = id(new PhabricatorHandleQuery())->setViewer($viewer)->withPHIDs($phids)->execute();
$hovercard->setTitle('D' . $rev->getID());
$hovercard->setDetail($rev->getTitle());
$hovercard->addField(pht('Author'), $handles[$rev->getAuthorPHID()]->renderLink());
$hovercard->addField(pht('Date'), phabricator_datetime($rev->getDateModified(), $viewer));
$hovercard->addField(pht('Reviewers'), implode_selected_handle_links(', ', $handles, $reviewer_phids));
if ($tasks) {
$hovercard->addField(pht('Task(s)', count($tasks)), implode_selected_handle_links(', ', $handles, $tasks));
}
if ($rev->getSummary()) {
$hovercard->addField(pht('Summary'), id(new PhutilUTF8StringTruncator())->setMaximumGlyphs(120)->truncateString($rev->getSummary()));
}
$hovercard->addTag(DifferentialRevisionDetailView::renderTagForRevision($rev));
$event->setValue('hovercard', $hovercard);
}
示例14: handleRequest
public function handleRequest(AphrontRequest $request)
{
$viewer = $this->getViewer();
$pager = new AphrontCursorPagerView();
$pager->readFromRequest($request);
$query = id(new PhluxVariableQuery())->setViewer($viewer);
$vars = $query->executeWithCursorPager($pager);
$view = new PHUIObjectItemListView();
$view->setFlush(true);
foreach ($vars as $var) {
$key = $var->getVariableKey();
$item = new PHUIObjectItemView();
$item->setHeader($key);
$item->setHref($this->getApplicationURI('/view/' . $key . '/'));
$item->addIcon('none', phabricator_datetime($var->getDateModified(), $viewer));
$view->addItem($item);
}
$crumbs = $this->buildApplicationCrumbs();
$box = id(new PHUIObjectBoxView())->setHeaderText('Variables')->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->appendChild($view);
$title = pht('Variable List');
$header = id(new PHUIHeaderView())->setHeader($title)->setHeaderIcon('fa-copy');
$crumbs->addTextCrumb($title, $this->getApplicationURI());
$crumbs->setBorder(true);
$view = id(new PHUITwoColumnView())->setHeader($header)->setFooter(array($box, $pager));
return $this->newPage()->setTitle($title)->setCrumbs($crumbs)->appendChild($view);
}
示例15: processRequest
public function processRequest()
{
$phid = $this->getAuthorizationPHID();
$title = 'Edit OAuth Client Authorization';
$request = $this->getRequest();
$current_user = $request->getUser();
$authorization = id(new PhabricatorOAuthClientAuthorization())->loadOneWhere('phid = %s', $phid);
if (empty($authorization)) {
return new Aphront404Response();
}
if ($authorization->getUserPHID() != $current_user->getPHID()) {
$message = 'Access denied to client authorization with phid ' . $phid . '. ' . 'Only the user who authorized the client has permission to ' . 'edit the authorization.';
return id(new Aphront403Response())->setForbiddenText($message);
}
if ($request->isFormPost()) {
$scopes = PhabricatorOAuthServerScope::getScopesFromRequest($request);
$authorization->setScope($scopes);
$authorization->save();
return id(new AphrontRedirectResponse())->setURI('/oauthserver/clientauthorization/?edited=' . $phid);
}
$client_phid = $authorization->getClientPHID();
$client = id(new PhabricatorOAuthServerClient())->loadOneWhere('phid = %s', $client_phid);
$created = phabricator_datetime($authorization->getDateCreated(), $current_user);
$updated = phabricator_datetime($authorization->getDateModified(), $current_user);
$panel = new AphrontPanelView();
$delete_button = phutil_render_tag('a', array('href' => $authorization->getDeleteURI(), 'class' => 'grey button'), 'Delete OAuth Client Authorization');
$panel->addButton($delete_button);
$panel->setHeader($title);
$form = id(new AphrontFormView())->setUser($current_user)->appendChild(id(new AphrontFormMarkupControl())->setLabel('Client')->setValue(phutil_render_tag('a', array('href' => $client->getViewURI()), phutil_escape_html($client->getName()))))->appendChild(id(new AphrontFormStaticControl())->setLabel('Created')->setValue($created))->appendChild(id(new AphrontFormStaticControl())->setLabel('Last Updated')->setValue($updated))->appendChild(PhabricatorOAuthServerScope::getCheckboxControl($authorization->getScope()))->appendChild(id(new AphrontFormSubmitControl())->setValue('Save OAuth Client Authorization')->addCancelButton('/oauthserver/clientauthorization/'));
$panel->appendChild($form);
return $this->buildStandardPageResponse($panel, array('title' => $title));
}