当前位置: 首页>>代码示例>>PHP>>正文


PHP phabricator_time函数代码示例

本文整理汇总了PHP中phabricator_time函数的典型用法代码示例。如果您正苦于以下问题:PHP phabricator_time函数的具体用法?PHP phabricator_time怎么用?PHP phabricator_time使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了phabricator_time函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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

示例2: render

 public function render()
 {
     $rows = array();
     if (!$this->user) {
         throw new Exception("Call setUser() before rendering!");
     }
     foreach ($this->daemonLogs as $log) {
         $epoch = $log->getDateCreated();
         if ($log->getHost() == php_uname('n')) {
             $pid = $log->getPID();
             $is_running = PhabricatorDaemonReference::isProcessRunning($pid);
             if ($is_running) {
                 $running = phutil_render_tag('span', array('style' => 'color: #00cc00', 'title' => 'Running'), '&bull;');
             } else {
                 $running = phutil_render_tag('span', array('style' => 'color: #cc0000', 'title' => 'Not running'), '&bull;');
             }
         } else {
             $running = phutil_render_tag('span', array('style' => 'color: #888888', 'title' => 'Not on this host'), '?');
         }
         $rows[] = array($running, phutil_escape_html($log->getDaemon()), phutil_escape_html($log->getHost()), $log->getPID(), phabricator_date($epoch, $this->user), phabricator_time($epoch, $this->user), phutil_render_tag('a', array('href' => '/daemon/log/' . $log->getID() . '/', 'class' => 'button small grey'), 'View Log'));
     }
     $daemon_table = new AphrontTableView($rows);
     $daemon_table->setHeaders(array('', 'Daemon', 'Host', 'PID', 'Date', 'Time', 'View'));
     $daemon_table->setColumnClasses(array('', 'wide wrap', '', '', '', 'right', 'action'));
     return $daemon_table->render();
 }
开发者ID:nguyennamtien,项目名称:phabricator,代码行数:26,代码来源:PhabricatorDaemonLogListView.php

示例3: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $pager = new AphrontPagerView();
     $pager->setOffset($request->getInt('page'));
     $pager->setURI($request->getRequestURI(), 'page');
     $mails = id(new PhabricatorMetaMTAReceivedMail())->loadAllWhere('1 = 1 ORDER BY id DESC LIMIT %d, %d', $pager->getOffset(), $pager->getPageSize() + 1);
     $mails = $pager->sliceResults($mails);
     $phids = array_merge(mpull($mails, 'getAuthorPHID'), mpull($mails, 'getRelatedPHID'));
     $phids = array_unique(array_filter($phids));
     $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
     $rows = array();
     foreach ($mails as $mail) {
         $rows[] = array($mail->getID(), phabricator_date($mail->getDateCreated(), $user), phabricator_time($mail->getDateCreated(), $user), $mail->getAuthorPHID() ? $handles[$mail->getAuthorPHID()]->renderLink() : '-', $mail->getRelatedPHID() ? $handles[$mail->getRelatedPHID()]->renderLink() : '-', phutil_escape_html($mail->getMessage()));
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('ID', 'Date', 'Time', 'Author', 'Object', 'Message'));
     $table->setColumnClasses(array(null, null, 'right', null, null, 'wide'));
     $panel = new AphrontPanelView();
     $panel->setHeader('Received Mail');
     $panel->appendChild($table);
     $panel->appendChild($pager);
     $nav = $this->buildSideNavView();
     $nav->selectFilter('received');
     $nav->appendChild($panel);
     return $this->buildApplicationPage($nav, array('title' => 'Received Mail'));
 }
开发者ID:neoxen,项目名称:phabricator,代码行数:28,代码来源:PhabricatorMetaMTAReceivedListController.php

示例4: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $views = array(self::VIEW_ALL => 'All Slowvotes', self::VIEW_CREATED => 'Created', self::VIEW_VOTED => 'Voted In');
     $view = isset($views[$this->view]) ? $this->view : self::VIEW_ALL;
     $side_nav = $this->renderSideNav($views, $view);
     $pager = new AphrontPagerView();
     $pager->setOffset($request->getInt('page'));
     $pager->setURI($request->getRequestURI(), 'page');
     $polls = $this->loadPolls($pager, $view);
     $phids = mpull($polls, 'getAuthorPHID');
     $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
     $rows = array();
     foreach ($polls as $poll) {
         $rows[] = array('V' . $poll->getID(), phutil_render_tag('a', array('href' => '/V' . $poll->getID()), phutil_escape_html($poll->getQuestion())), $handles[$poll->getAuthorPHID()]->renderLink(), phabricator_date($poll->getDateCreated(), $user), phabricator_time($poll->getDateCreated(), $user));
     }
     $table = new AphrontTableView($rows);
     $table->setColumnClasses(array('', 'pri wide', '', '', 'right'));
     $table->setHeaders(array('ID', 'Poll', 'Author', 'Date', 'Time'));
     $panel = new AphrontPanelView();
     $panel->setHeader($this->getTableHeader($view));
     $panel->setCreateButton('Create Slowvote', '/vote/create/');
     $panel->appendChild($table);
     $panel->appendChild($pager);
     $side_nav->appendChild($panel);
     return $this->buildStandardPageResponse($side_nav, array('title' => 'Slowvotes'));
 }
开发者ID:netcomtec,项目名称:phabricator,代码行数:28,代码来源:PhabricatorSlowvoteListController.php

示例5: render

 public function render()
 {
     $viewer = $this->getViewer();
     $rows = array();
     foreach ($this->events as $event) {
         // Limit display log size. If a daemon gets stuck in an output loop this
         // page can be like >100MB if we don't truncate stuff. Try to do cheap
         // line-based truncation first, and fall back to expensive UTF-8 character
         // truncation if that doesn't get things short enough.
         $message = $event->getMessage();
         $more = null;
         if (!$this->showFullMessage) {
             $more_lines = null;
             $more_chars = null;
             $line_limit = 12;
             if (substr_count($message, "\n") > $line_limit) {
                 $message = explode("\n", $message);
                 $more_lines = count($message) - $line_limit;
                 $message = array_slice($message, 0, $line_limit);
                 $message = implode("\n", $message);
             }
             $char_limit = 8192;
             if (strlen($message) > $char_limit) {
                 $message = phutil_utf8v($message);
                 $more_chars = count($message) - $char_limit;
                 $message = array_slice($message, 0, $char_limit);
                 $message = implode('', $message);
             }
             if ($more_chars) {
                 $more = new PhutilNumber($more_chars);
                 $more = pht('Show %d more character(s)...', $more);
             } else {
                 if ($more_lines) {
                     $more = new PhutilNumber($more_lines);
                     $more = pht('Show %d more line(s)...', $more);
                 }
             }
             if ($more) {
                 $id = $event->getID();
                 $more = array("\n...\n", phutil_tag('a', array('href' => "/daemon/event/{$id}/"), $more));
             }
         }
         $row = array($event->getLogType(), phabricator_date($event->getEpoch(), $viewer), phabricator_time($event->getEpoch(), $viewer), array($message, $more));
         if ($this->combinedLog) {
             array_unshift($row, phutil_tag('a', array('href' => '/daemon/log/' . $event->getLogID() . '/'), pht('Daemon %s', $event->getLogID())));
         }
         $rows[] = $row;
     }
     $classes = array('', '', 'right', 'wide prewrap');
     $headers = array('Type', 'Date', 'Time', 'Message');
     if ($this->combinedLog) {
         array_unshift($classes, 'pri');
         array_unshift($headers, 'Daemon');
     }
     $log_table = new AphrontTableView($rows);
     $log_table->setHeaders($headers);
     $log_table->setColumnClasses($classes);
     return $log_table->render();
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:59,代码来源:PhabricatorDaemonLogEventsView.php

示例6: render

 public function render()
 {
     $rows = array();
     if (!$this->user) {
         throw new Exception("Call setUser() before rendering!");
     }
     foreach ($this->daemonLogs as $log) {
         $epoch = $log->getDateCreated();
         $status = $log->getStatus();
         if ($log->getHost() == php_uname('n') && $status != PhabricatorDaemonLog::STATUS_EXITED && $status != PhabricatorDaemonLog::STATUS_DEAD) {
             $pid = $log->getPID();
             $is_running = PhabricatorDaemonReference::isProcessRunning($pid);
             if (!$is_running) {
                 $guard = AphrontWriteGuard::beginScopedUnguardedWrites();
                 $log->setStatus(PhabricatorDaemonLog::STATUS_DEAD);
                 $log->save();
                 unset($guard);
                 $status = PhabricatorDaemonLog::STATUS_DEAD;
             }
         }
         $heartbeat_timeout = $log->getDateModified() + 3 * PhutilDaemonOverseer::HEARTBEAT_WAIT;
         if ($status == PhabricatorDaemonLog::STATUS_RUNNING && $heartbeat_timeout < time()) {
             $status = PhabricatorDaemonLog::STATUS_UNKNOWN;
         }
         switch ($status) {
             case PhabricatorDaemonLog::STATUS_RUNNING:
                 $style = 'color: #00cc00';
                 $title = 'Running';
                 $symbol = '&bull;';
                 break;
             case PhabricatorDaemonLog::STATUS_DEAD:
                 $style = 'color: #cc0000';
                 $title = 'Died';
                 $symbol = '&bull;';
                 break;
             case PhabricatorDaemonLog::STATUS_EXITED:
                 $style = 'color: #000000';
                 $title = 'Exited';
                 $symbol = '&bull;';
                 break;
             case PhabricatorDaemonLog::STATUS_UNKNOWN:
             default:
                 // fallthrough
                 $style = 'color: #888888';
                 $title = 'Unknown';
                 $symbol = '?';
         }
         $running = phutil_render_tag('span', array('style' => $style, 'title' => $title), $symbol);
         $rows[] = array($running, phutil_escape_html($log->getDaemon()), phutil_escape_html($log->getHost()), $log->getPID(), phabricator_date($epoch, $this->user), phabricator_time($epoch, $this->user), phutil_render_tag('a', array('href' => '/daemon/log/' . $log->getID() . '/', 'class' => 'button small grey'), 'View Log'));
     }
     $daemon_table = new AphrontTableView($rows);
     $daemon_table->setHeaders(array('', 'Daemon', 'Host', 'PID', 'Date', 'Time', 'View'));
     $daemon_table->setColumnClasses(array('', 'wide wrap', '', '', '', 'right', 'action'));
     return $daemon_table->render();
 }
开发者ID:nexeck,项目名称:phabricator,代码行数:55,代码来源:PhabricatorDaemonLogListView.php

示例7: render

 public function render()
 {
     $rows = array();
     if (!$this->user) {
         throw new Exception("Call setUser() before rendering!");
     }
     foreach ($this->events as $event) {
         // Limit display log size. If a daemon gets stuck in an output loop this
         // page can be like >100MB if we don't truncate stuff. Try to do cheap
         // line-based truncation first, and fall back to expensive UTF-8 character
         // truncation if that doesn't get things short enough.
         $message = $event->getMessage();
         $more_lines = null;
         $more_chars = null;
         $line_limit = 12;
         if (substr_count($message, "\n") > $line_limit) {
             $message = explode("\n", $message);
             $more_lines = count($message) - $line_limit;
             $message = array_slice($message, 0, $line_limit);
             $message = implode("\n", $message);
         }
         $char_limit = 8192;
         if (strlen($message) > $char_limit) {
             $message = phutil_utf8v($message);
             $more_chars = count($message) - $char_limit;
             $message = array_slice($message, 0, $char_limit);
             $message = implode('', $message);
         }
         $more = null;
         if ($more_chars) {
             $more = number_format($more_chars);
             $more = "\n<... {$more} more characters ...>";
         } else {
             if ($more_lines) {
                 $more = number_format($more_lines);
                 $more = "\n<... {$more} more lines ...>";
             }
         }
         $row = array(phutil_escape_html($event->getLogType()), phabricator_date($event->getEpoch(), $this->user), phabricator_time($event->getEpoch(), $this->user), str_replace("\n", '<br />', phutil_escape_html($message . $more)));
         if ($this->combinedLog) {
             array_unshift($row, phutil_render_tag('a', array('href' => '/daemon/log/' . $event->getLogID() . '/'), phutil_escape_html('Daemon ' . $event->getLogID())));
         }
         $rows[] = $row;
     }
     $classes = array('', '', 'right', 'wide wrap');
     $headers = array('Type', 'Date', 'Time', 'Message');
     if ($this->combinedLog) {
         array_unshift($classes, 'pri');
         array_unshift($headers, 'Daemon');
     }
     $log_table = new AphrontTableView($rows);
     $log_table->setHeaders($headers);
     $log_table->setColumnClasses($classes);
     return $log_table->render();
 }
开发者ID:nguyennamtien,项目名称:phabricator,代码行数:55,代码来源:PhabricatorDaemonLogEventsView.php

示例8: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $upload_panel = $this->renderUploadPanel();
     $author = null;
     $author_username = $request->getStr('author');
     if ($author_username) {
         $author = id(new PhabricatorUser())->loadOneWhere('userName = %s', $author_username);
         if (!$author) {
             return id(new Aphront404Response());
         }
         $title = 'Files Uploaded by ' . phutil_escape_html($author->getUsername());
     } else {
         $title = 'Files';
     }
     $pager = new AphrontPagerView();
     $pager->setOffset($request->getInt('page'));
     if ($author) {
         $files = id(new PhabricatorFile())->loadAllWhere('authorPHID = %s ORDER BY id DESC LIMIT %d, %d', $author->getPHID(), $pager->getOffset(), $pager->getPageSize() + 1);
     } else {
         $files = id(new PhabricatorFile())->loadAllWhere('1 = 1 ORDER BY id DESC LIMIT %d, %d', $pager->getOffset(), $pager->getPageSize() + 1);
     }
     $files = $pager->sliceResults($files);
     $pager->setURI($request->getRequestURI(), 'page');
     $phids = mpull($files, 'getAuthorPHID');
     $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
     $highlighted = $request->getStr('h');
     $highlighted = explode('-', $highlighted);
     $highlighted = array_fill_keys($highlighted, true);
     $rows = array();
     $rowc = array();
     foreach ($files as $file) {
         if ($file->isViewableInBrowser()) {
             $view_button = phutil_render_tag('a', array('class' => 'small button grey', 'href' => '/file/view/' . $file->getPHID() . '/'), 'View');
         } else {
             $view_button = null;
         }
         if (isset($highlighted[$file->getID()])) {
             $rowc[] = 'highlighted';
         } else {
             $rowc[] = '';
         }
         $rows[] = array(phutil_escape_html('F' . $file->getID()), $file->getAuthorPHID() ? $handles[$file->getAuthorPHID()]->renderLink() : null, phutil_render_tag('a', array('href' => $file->getViewURI()), phutil_escape_html($file->getName())), phutil_escape_html(number_format($file->getByteSize()) . ' bytes'), phutil_render_tag('a', array('class' => 'small button grey', 'href' => '/file/info/' . $file->getPHID() . '/'), 'Info'), $view_button, phutil_render_tag('a', array('class' => 'small button grey', 'href' => '/file/download/' . $file->getPHID() . '/'), 'Download'), phabricator_date($file->getDateCreated(), $user), phabricator_time($file->getDateCreated(), $user));
     }
     $table = new AphrontTableView($rows);
     $table->setRowClasses($rowc);
     $table->setHeaders(array('File ID', 'Author', 'Name', 'Size', '', '', '', 'Created', ''));
     $table->setColumnClasses(array(null, '', 'wide pri', 'right', 'action', 'action', 'action', '', 'right'));
     $panel = new AphrontPanelView();
     $panel->appendChild($table);
     $panel->setHeader($title);
     $panel->appendChild($pager);
     return $this->buildStandardPageResponse(array($upload_panel, $panel), array('title' => 'Files', 'tab' => 'files'));
 }
开发者ID:nguyennamtien,项目名称:phabricator,代码行数:55,代码来源:PhabricatorFileListController.php

示例9: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $viewer = $request->getUser();
     $is_admin = $viewer->getIsAdmin();
     $user = new PhabricatorUser();
     $count = queryfx_one($user->establishConnection('r'), 'SELECT COUNT(*) N FROM %T', $user->getTableName());
     $count = idx($count, 'N', 0);
     $pager = new AphrontPagerView();
     $pager->setOffset($request->getInt('page', 0));
     $pager->setCount($count);
     $pager->setURI($request->getRequestURI(), 'page');
     $users = id(new PhabricatorPeopleQuery())->needPrimaryEmail(true)->executeWithOffsetPager($pager);
     $rows = array();
     foreach ($users as $user) {
         $primary_email = $user->loadPrimaryEmail();
         if ($primary_email && $primary_email->getIsVerified()) {
             $email = 'Verified';
         } else {
             $email = 'Unverified';
         }
         $status = array();
         if ($user->getIsDisabled()) {
             $status[] = 'Disabled';
         }
         if ($user->getIsAdmin()) {
             $status[] = 'Admin';
         }
         if ($user->getIsSystemAgent()) {
             $status[] = 'System Agent';
         }
         $status = implode(', ', $status);
         $rows[] = array(phabricator_date($user->getDateCreated(), $viewer), phabricator_time($user->getDateCreated(), $viewer), phutil_render_tag('a', array('href' => '/p/' . $user->getUsername() . '/'), phutil_escape_html($user->getUserName())), phutil_escape_html($user->getRealName()), $status, $email, phutil_render_tag('a', array('class' => 'button grey small', 'href' => '/people/edit/' . $user->getID() . '/'), 'Administrate User'));
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('Join Date', 'Time', 'Username', 'Real Name', 'Roles', 'Email', ''));
     $table->setColumnClasses(array(null, 'right', 'pri', 'wide', null, null, 'action'));
     $table->setColumnVisibility(array(true, true, true, true, $is_admin, $is_admin, $is_admin));
     $panel = new AphrontPanelView();
     $panel->setHeader('People (' . number_format($count) . ')');
     $panel->appendChild($table);
     $panel->appendChild($pager);
     if ($is_admin) {
         $panel->addButton(phutil_render_tag('a', array('href' => '/people/edit/', 'class' => 'button green'), 'Create New Account'));
         if (PhabricatorEnv::getEnvConfig('ldap.auth-enabled')) {
             $panel->addButton(phutil_render_tag('a', array('href' => '/people/ldap/', 'class' => 'button green'), 'Import from LDAP'));
         }
     }
     $nav = $this->buildSideNavView();
     $nav->selectFilter('people');
     $nav->appendChild($panel);
     return $this->buildApplicationPage($nav, array('title' => 'People'));
 }
开发者ID:neoxen,项目名称:phabricator,代码行数:53,代码来源:PhabricatorPeopleListController.php

示例10: testLocalTimeFormatting

 public function testLocalTimeFormatting()
 {
     $user = new PhabricatorUser();
     $user->setTimezoneIdentifier('America/Los_Angeles');
     $utc = new PhabricatorUser();
     $utc->setTimezoneIdentifier('UTC');
     $this->assertEqual('Jan 1 2000, 12:00 AM', phabricator_datetime(946684800, $utc), 'Datetime formatting');
     $this->assertEqual('Jan 1 2000', phabricator_date(946684800, $utc), 'Date formatting');
     $this->assertEqual('12:00 AM', phabricator_time(946684800, $utc), 'Time formatting');
     $this->assertEqual('Dec 31 1999, 4:00 PM', phabricator_datetime(946684800, $user), 'Localization');
     $this->assertEqual('', phabricator_datetime(0, $user), 'Missing epoch should fail gracefully');
 }
开发者ID:nexeck,项目名称:phabricator,代码行数:12,代码来源:PhabricatorLocalTimeTestCase.php

示例11: getTagContent

 protected function getTagContent()
 {
     if (!$this->blankState && empty($this->events)) {
         return '';
     }
     Javelin::initBehavior('phabricator-tooltips');
     $singletons = array();
     $allday = false;
     foreach ($this->events as $event) {
         $start_epoch = $event->getEpochStart();
         if ($event->getIsAllDay()) {
             $timelabel = pht('All Day');
         } else {
             $timelabel = phabricator_time($event->getEpochStart(), $this->getUser());
         }
         $icon_icon = $event->getIcon();
         $icon_color = $event->getIconColor();
         $icon = id(new PHUIIconView())->setIcon($icon_icon, $icon_color)->addClass('phui-calendar-list-item-icon');
         $title = phutil_tag('span', array('class' => 'phui-calendar-list-title'), $this->getEventTitle($event, $allday));
         $time = phutil_tag('span', array('class' => 'phui-calendar-list-time'), $timelabel);
         $event_classes = array();
         $event_classes[] = 'phui-calendar-list-item';
         if ($event->getIsAllDay()) {
             $event_classes[] = 'all-day';
         }
         if ($event->getIsCancelled()) {
             $event_classes[] = 'event-cancelled';
         }
         $tip = $event->getDateTimeSummary();
         if ($this->getView() == 'day') {
             $tip_align = 'E';
         } else {
             if ($this->getView() == 'month') {
                 $tip_align = 'N';
             } else {
                 $tip_align = 'W';
             }
         }
         $content = javelin_tag('a', array('href' => $event->getURI(), 'sigil' => 'has-tooltip', 'meta' => array('tip' => $tip, 'size' => 200, 'align' => $tip_align)), array($icon, $time, $title));
         $singletons[] = phutil_tag('li', array('class' => implode(' ', $event_classes)), $content);
     }
     if ($this->moreLink) {
         $singletons[] = phutil_tag('li', array('class' => 'phui-calendar-list-item'), phutil_tag('a', array('href' => $this->moreLink, 'class' => 'phui-calendar-list-more'), array(id(new PHUIIconView())->setIcon('fa-ellipsis-h grey'), phutil_tag('span', array('class' => 'phui-calendar-list-title'), pht('View More...')))));
     }
     if (empty($singletons)) {
         $singletons[] = phutil_tag('li', array('class' => 'phui-calendar-list-item-empty'), pht('Clear sailing ahead.'));
     }
     $list = phutil_tag('ul', array('class' => 'phui-calendar-list'), $singletons);
     return $list;
 }
开发者ID:NeoArmageddon,项目名称:phabricator,代码行数:50,代码来源:PHUICalendarListView.php

示例12: renderColumns

 private function renderColumns(DiffusionRequest $drequest, array $handles, PhabricatorRepositoryCommit $commit = null, $lint = null)
 {
     assert_instances_of($handles, 'PhabricatorObjectHandle');
     $viewer = $this->getRequest()->getUser();
     if ($commit) {
         $epoch = $commit->getEpoch();
         $modified = DiffusionView::linkCommit($drequest->getRepository(), $commit->getCommitIdentifier());
         $date = phabricator_date($epoch, $viewer);
         $time = phabricator_time($epoch, $viewer);
     } else {
         $modified = '';
         $date = '';
         $time = '';
     }
     $data = $commit->getCommitData();
     if ($data) {
         $author_phid = $data->getCommitDetail('authorPHID');
         if ($author_phid && isset($handles[$author_phid])) {
             $author = $handles[$author_phid]->renderLink();
         } else {
             $author = DiffusionView::renderName($data->getAuthorName());
         }
         $committer = $data->getCommitDetail('committer');
         if ($committer) {
             $committer_phid = $data->getCommitDetail('committerPHID');
             if ($committer_phid && isset($handles[$committer_phid])) {
                 $committer = $handles[$committer_phid]->renderLink();
             } else {
                 $committer = DiffusionView::renderName($committer);
             }
             if ($author != $committer) {
                 $author = hsprintf('%s/%s', $author, $committer);
             }
         }
         $details = AphrontTableView::renderSingleDisplayLine($data->getSummary());
     } else {
         $author = '';
         $details = '';
     }
     $return = array('commit' => $modified, 'date' => $date, 'time' => $time, 'author' => $author, 'details' => $details);
     if ($lint !== null) {
         $return['lint'] = phutil_tag('a', array('href' => $drequest->generateURI(array('action' => 'lint', 'lint' => null))), number_format($lint));
     }
     // The client treats these results as markup, so make sure they have been
     // escaped correctly.
     foreach ($return as $key => $value) {
         $return[$key] = hsprintf('%s', $value);
     }
     return $return;
 }
开发者ID:fengshao0907,项目名称:phabricator,代码行数:50,代码来源:DiffusionLastModifiedController.php

示例13: renderEventLink

 private function renderEventLink($event)
 {
     Javelin::initBehavior('phabricator-tooltips');
     if ($event->getMultiDay()) {
         $tip = pht('%s, Until: %s', $event->getName(), phabricator_date($event->getEpochEnd(), $this->getUser()));
     } else {
         $tip = pht('%s, Until: %s', $event->getName(), phabricator_time($event->getEpochEnd(), $this->getUser()));
     }
     $description = $event->getDescription();
     if (strlen($description) == 0) {
         $description = pht('(%s)', $event->getName());
     }
     $anchor = javelin_tag('a', array('sigil' => 'has-tooltip', 'class' => 'phui-calendar-item-link', 'href' => '/calendar/event/view/' . $event->getEventID() . '/', 'meta' => array('tip' => $tip, 'size' => 200)), $description);
     return $anchor;
 }
开发者ID:denghp,项目名称:phabricator,代码行数:15,代码来源:PHUICalendarListView.php

示例14: getTagContent

 protected function getTagContent()
 {
     if (!$this->blankState && empty($this->events)) {
         return '';
     }
     $singletons = array();
     $allday = false;
     foreach ($this->events as $event) {
         $start_epoch = $event->getEpochStart();
         if ($event->getIsAllDay()) {
             $timelabel = pht('All Day');
         } else {
             $timelabel = phabricator_time($event->getEpochStart(), $this->getUser());
         }
         if ($event->getViewerIsInvited()) {
             $icon_color = 'green';
         } else {
             $icon_color = null;
         }
         $dot = id(new PHUIIconView())->setIcon($event->getIcon(), $icon_color)->addClass('phui-calendar-list-item-icon');
         $title = phutil_tag('span', array('class' => 'phui-calendar-list-title'), $this->getEventTitle($event, $allday));
         $time = phutil_tag('span', array('class' => 'phui-calendar-list-time'), $timelabel);
         $class = 'phui-calendar-list-item';
         if ($event->getViewerIsInvited()) {
             $class = $class . ' phui-calendar-viewer-invited';
         }
         if ($event->getIsAllDay()) {
             $class = $class . ' all-day';
         }
         $tip = $this->getEventTooltip($event);
         if ($this->getView() == 'day') {
             $tip_align = 'E';
         } else {
             if ($this->getView() == 'month') {
                 $tip_align = 'N';
             } else {
                 $tip_align = 'W';
             }
         }
         $content = javelin_tag('a', array('href' => $event->getURI(), 'sigil' => 'has-tooltip', 'meta' => array('tip' => $tip, 'size' => 200, 'align' => $tip_align)), array($dot, $time, $title));
         $singletons[] = phutil_tag('li', array('class' => $class), $content);
     }
     if (empty($singletons)) {
         $singletons[] = phutil_tag('li', array('class' => 'phui-calendar-list-item-empty'), pht('Clear sailing ahead.'));
     }
     $list = phutil_tag('ul', array('class' => 'phui-calendar-list'), $singletons);
     return $list;
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:48,代码来源:PHUICalendarListView.php

示例15: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     // Get one page of data together with the pager.
     // Pull these objects manually since the serialized fields are gigantic.
     $transcript = new HeraldTranscript();
     $conn_r = $transcript->establishConnection('r');
     $phid = $request->getStr('phid');
     $where_clause = '';
     if ($phid) {
         $where_clause = qsprintf($conn_r, 'WHERE objectPHID = %s', $phid);
     }
     $pager = new AphrontPagerView();
     $pager->setOffset($request->getInt('offset'));
     $pager->setURI($request->getRequestURI(), 'offset');
     $limit_clause = qsprintf($conn_r, 'LIMIT %d, %d', $pager->getOffset(), $pager->getPageSize() + 1);
     $data = queryfx_all($conn_r, 'SELECT id, objectPHID, time, duration, dryRun FROM %T
     %Q
     ORDER BY id DESC
     %Q', $transcript->getTableName(), $where_clause, $limit_clause);
     $data = $pager->sliceResults($data);
     // Render the table.
     $handles = array();
     if ($data) {
         $phids = ipull($data, 'objectPHID', 'objectPHID');
         $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
     }
     $rows = array();
     foreach ($data as $xscript) {
         $rows[] = array(phabricator_date($xscript['time'], $user), phabricator_time($xscript['time'], $user), $handles[$xscript['objectPHID']]->renderLink(), $xscript['dryRun'] ? 'Yes' : '', number_format((int) (1000 * $xscript['duration'])) . ' ms', phutil_render_tag('a', array('href' => '/herald/transcript/' . $xscript['id'] . '/', 'class' => 'button small grey'), 'View Transcript'));
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('Date', 'Time', 'Object', 'Dry Run', 'Duration', 'View'));
     $table->setColumnClasses(array('', 'right', 'wide wrap', '', '', 'action'));
     // Render the whole page.
     $panel = new AphrontPanelView();
     $panel->setHeader('Herald Transcripts');
     $panel->appendChild($table);
     $panel->appendChild($pager);
     $nav = $this->renderNav();
     $nav->selectFilter('transcript');
     $nav->appendChild($panel);
     return $this->buildStandardPageResponse($nav, array('title' => 'Herald Transcripts', 'tab' => 'transcripts'));
 }
开发者ID:nexeck,项目名称:phabricator,代码行数:45,代码来源:HeraldTranscriptListController.php


注:本文中的phabricator_time函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。