Exemplo n.º 1
0
 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;
 }
 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();
 }
 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'));
 }
 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'));
 }
 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();
 }
 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();
 }
 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();
 }
 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'));
 }
 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'));
 }
 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');
 }
 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;
 }
 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;
 }
Exemplo n.º 13
0
 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;
 }
Exemplo n.º 14
0
 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;
 }
 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'));
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $document = id(new PhrictionDocument())->loadOneWhere('slug = %s', PhabricatorSlug::normalize($this->slug));
     if (!$document) {
         return new Aphront404Response();
     }
     $current = id(new PhrictionContent())->load($document->getContentID());
     $pager = new AphrontPagerView();
     $pager->setOffset($request->getInt('page'));
     $pager->setURI($request->getRequestURI(), 'page');
     $history = id(new PhrictionContent())->loadAllWhere('documentID = %d ORDER BY version DESC LIMIT %d, %d', $document->getID(), $pager->getOffset(), $pager->getPageSize() + 1);
     $history = $pager->sliceResults($history);
     $author_phids = mpull($history, 'getAuthorPHID');
     $handles = id(new PhabricatorObjectHandleData($author_phids))->loadHandles();
     $rows = array();
     foreach ($history as $content) {
         $uri = PhrictionDocument::getSlugURI($document->getSlug());
         $version = $content->getVersion();
         $diff_uri = new PhutilURI('/phriction/diff/' . $document->getID() . '/');
         $vs_previous = '<em>Created</em>';
         if ($content->getVersion() != 1) {
             $uri = $diff_uri->alter('l', $content->getVersion() - 1)->alter('r', $content->getVersion());
             $vs_previous = phutil_render_tag('a', array('href' => $uri), 'Show Change');
         }
         $vs_head = '<em>Current</em>';
         if ($content->getID() != $document->getContentID()) {
             $uri = $diff_uri->alter('l', $content->getVersion())->alter('r', $current->getVersion());
             $vs_head = phutil_render_tag('a', array('href' => $uri), 'Show Later Changes');
         }
         $change_type = PhrictionChangeType::getChangeTypeLabel($content->getChangeType());
         $rows[] = array(phabricator_date($content->getDateCreated(), $user), phabricator_time($content->getDateCreated(), $user), phutil_render_tag('a', array('href' => $uri . '?v=' . $version), 'Version ' . $version), $handles[$content->getAuthorPHID()]->renderLink(), $change_type, phutil_escape_html($content->getDescription()), $vs_previous, $vs_head);
     }
     $crumbs = new AphrontCrumbsView();
     $crumbs->setCrumbs(array('Phriction', phutil_render_tag('a', array('href' => PhrictionDocument::getSlugURI($document->getSlug())), phutil_escape_html($current->getTitle())), 'History'));
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('Date', 'Time', 'Version', 'Author', 'Type', 'Description', 'Against Previous', 'Against Current'));
     $table->setColumnClasses(array('', 'right', 'pri', '', '', 'wide', '', ''));
     $panel = new AphrontPanelView();
     $panel->setHeader('Document History');
     $panel->appendChild($table);
     $panel->appendChild($pager);
     return $this->buildStandardPageResponse(array($crumbs, $panel), array('title' => 'Document History'));
 }
 /**
  * @param array $commit_phids phids of the commits to render
  * @param PhabricatorUser $user phabricator user
  * @return AphrontTableView
  */
 private static function createCommitTable(array $commit_phids, PhabricatorUser $user)
 {
     $loader = new PhabricatorObjectHandleData($commit_phids);
     $handles = $loader->loadHandles();
     $objects = $loader->loadObjects();
     $rows = array();
     foreach ($commit_phids as $phid) {
         $handle = $handles[$phid];
         $object = $objects[$phid];
         $commit_data = $object->getCommitData();
         $epoch = $handle->getTimeStamp();
         $date = phabricator_date($epoch, $user);
         $time = phabricator_time($epoch, $user);
         $link = phutil_render_tag('a', array('href' => $handle->getURI()), phutil_escape_html($handle->getName()));
         $rows[] = array($link, $date, $time, phutil_escape_html($commit_data->getSummary()));
     }
     $commit_table = new AphrontTableView($rows);
     $commit_table->setHeaders(array('Commit', 'Date', 'Time', 'Summary'));
     $commit_table->setColumnClasses(array('', '', 'right', 'wide'));
     return $commit_table;
 }
 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 PhabricatorUser())->loadAllWhere('1 = 1 ORDER BY id DESC LIMIT %d, %d', $pager->getOffset(), $pager->getPageSize());
     $rows = array();
     foreach ($users as $user) {
         $status = '';
         if ($user->getIsDisabled()) {
             $status = 'Disabled';
         } else {
             if ($user->getIsAdmin()) {
                 $status = 'Admin';
             } else {
                 $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, 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', 'Status', ''));
     $table->setColumnClasses(array(null, 'right', 'pri', 'wide', null, 'action'));
     $table->setColumnVisibility(array(true, true, true, true, $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'));
     }
     return $this->buildStandardPageResponse($panel, array('title' => 'People', 'tab' => 'directory'));
 }
 public function render()
 {
     $logs = $this->logs;
     $handles = $this->handles;
     $viewer = $this->getUser();
     $action_map = PhabricatorUserLog::getActionTypeMap();
     $base_uri = $this->searchBaseURI;
     $rows = array();
     foreach ($logs as $log) {
         $ip = $log->getRemoteAddr();
         $session = substr($log->getSession(), 0, 6);
         if ($base_uri) {
             $ip = phutil_tag('a', array('href' => $base_uri . '?ip=' . $log->getRemoteAddr() . '#R'), $ip);
             $session = phutil_tag('a', array('href' => $base_uri . '?sessions=' . $log->getSession() . '#R'), $session);
         }
         $action = $log->getAction();
         $action_name = idx($action_map, $action, $action);
         $rows[] = array(phabricator_date($log->getDateCreated(), $viewer), phabricator_time($log->getDateCreated(), $viewer), $action_name, $log->getActorPHID() ? $handles[$log->getActorPHID()]->getName() : null, $handles[$log->getUserPHID()]->getName(), $ip, $session);
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array(pht('Date'), pht('Time'), pht('Action'), pht('Actor'), pht('User'), pht('IP'), pht('Session')));
     $table->setColumnClasses(array('', 'right', 'wide', '', '', '', 'n'));
     return $table;
 }
Exemplo n.º 20
0
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $views = array('all' => 'All Documents', 'updates' => 'Recently Updated');
     if (empty($views[$this->view])) {
         $this->view = 'all';
     }
     $nav = new AphrontSideNavView();
     foreach ($views as $view => $name) {
         $nav->addNavItem(phutil_render_tag('a', array('href' => '/phriction/list/' . $view . '/', 'class' => $this->view == $view ? 'aphront-side-nav-selected' : null), phutil_escape_html($name)));
     }
     $pager = new AphrontPagerView();
     $pager->setURI($request->getRequestURI(), 'page');
     $pager->setOffset($request->getInt('page'));
     $documents = $this->loadDocuments($pager);
     $content = mpull($documents, 'getContent');
     $phids = mpull($content, 'getAuthorPHID');
     $handles = $this->loadViewerHandles($phids);
     $rows = array();
     foreach ($documents as $document) {
         $content = $document->getContent();
         $rows[] = array($handles[$content->getAuthorPHID()]->renderLink(), phutil_render_tag('a', array('href' => PhrictionDocument::getSlugURI($document->getSlug())), phutil_escape_html($content->getTitle())), phabricator_date($content->getDateCreated(), $user), phabricator_time($content->getDateCreated(), $user));
     }
     $document_table = new AphrontTableView($rows);
     $document_table->setHeaders(array('Last Editor', 'Title', 'Last Update', 'Time'));
     $document_table->setColumnClasses(array('', 'wide pri', 'right', 'right'));
     $view_headers = array('all' => 'All Documents', 'updates' => 'Recently Updated Documents');
     $view_header = $view_headers[$this->view];
     $panel = new AphrontPanelView();
     $panel->setHeader($view_header);
     $panel->appendChild($document_table);
     $panel->appendChild($pager);
     $nav->appendChild($panel);
     return $this->buildStandardPageResponse($nav, array('title' => 'Phriction Main'));
 }
Exemplo n.º 21
0
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $shortcuts = id(new PhabricatorRepositoryShortcut())->loadAll();
     if ($shortcuts) {
         $shortcuts = msort($shortcuts, 'getSequence');
         $rows = array();
         foreach ($shortcuts as $shortcut) {
             $rows[] = array(phutil_render_tag('a', array('href' => $shortcut->getHref()), phutil_escape_html($shortcut->getName())), phutil_escape_html($shortcut->getDescription()));
         }
         $shortcut_table = new AphrontTableView($rows);
         $shortcut_table->setHeaders(array('Link', ''));
         $shortcut_table->setColumnClasses(array('pri', 'wide'));
         $shortcut_panel = new AphrontPanelView();
         $shortcut_panel->setHeader('Shortcuts');
         $shortcut_panel->appendChild($shortcut_table);
     } else {
         $shortcut_panel = null;
     }
     $repository = new PhabricatorRepository();
     $repositories = $repository->loadAll();
     foreach ($repositories as $key => $repo) {
         if (!$repo->isTracked()) {
             unset($repositories[$key]);
         }
     }
     $repository_ids = mpull($repositories, 'getID');
     $summaries = array();
     $commits = array();
     if ($repository_ids) {
         $summaries = queryfx_all($repository->establishConnection('r'), 'SELECT * FROM %T WHERE repositoryID IN (%Ld)', PhabricatorRepository::TABLE_SUMMARY, $repository_ids);
         $summaries = ipull($summaries, null, 'repositoryID');
         $commit_ids = array_filter(ipull($summaries, 'lastCommitID'));
         if ($commit_ids) {
             $commit = new PhabricatorRepositoryCommit();
             $commits = $commit->loadAllWhere('id IN (%Ld)', $commit_ids);
             $commits = mpull($commits, null, 'getRepositoryID');
         }
     }
     $rows = array();
     foreach ($repositories as $repository) {
         $id = $repository->getID();
         $commit = idx($commits, $id);
         $size = idx(idx($summaries, $id, array()), 'size', 0);
         $date = '-';
         $time = '-';
         if ($commit) {
             $date = phabricator_date($commit->getEpoch(), $user);
             $time = phabricator_time($commit->getEpoch(), $user);
         }
         $rows[] = array(phutil_render_tag('a', array('href' => '/diffusion/' . $repository->getCallsign() . '/'), phutil_escape_html($repository->getName())), phutil_escape_html($repository->getDetail('description')), PhabricatorRepositoryType::getNameForRepositoryType($repository->getVersionControlSystem()), $size ? number_format($size) : '-', $commit ? DiffusionView::linkCommit($repository, $commit->getCommitIdentifier()) : '-', $date, $time);
     }
     $repository_tool_uri = PhabricatorEnv::getProductionURI('/repository/');
     $repository_tool = phutil_render_tag('a', array('href' => $repository_tool_uri), 'repository tool');
     $no_repositories_txt = 'This instance of Phabricator does not have any ' . 'configured repositories. ';
     if ($user->getIsAdmin()) {
         $no_repositories_txt .= 'To setup one or more repositories, visit the ' . $repository_tool . '.';
     } else {
         $no_repositories_txt .= 'Ask an administrator to setup one or more ' . 'repositories via the ' . $repository_tool . '.';
     }
     $table = new AphrontTableView($rows);
     $table->setNoDataString($no_repositories_txt);
     $table->setHeaders(array('Repository', 'Description', 'VCS', 'Commits', 'Last', 'Date', 'Time'));
     $table->setColumnClasses(array('pri', 'wide', '', 'n', 'n', '', 'right'));
     $panel = new AphrontPanelView();
     $panel->setHeader('Browse Repositories');
     $panel->appendChild($table);
     $crumbs = $this->buildCrumbs();
     return $this->buildStandardPageResponse(array($crumbs, $shortcut_panel, $panel), array('title' => 'Diffusion'));
 }
 public function renderEventDate(PhabricatorUser $viewer, $show_end)
 {
     $start = $this->newStartDateTime();
     $end = $this->newEndDateTime();
     $min_date = $start->newPHPDateTime();
     $max_date = $end->newPHPDateTime();
     if ($this->getIsAllDay()) {
         // Subtract one second since the stored date is exclusive.
         $max_date = $max_date->modify('-1 second');
     }
     if ($show_end) {
         $min_day = $min_date->format('Y m d');
         $max_day = $max_date->format('Y m d');
         $show_end_date = $min_day != $max_day;
     } else {
         $show_end_date = false;
     }
     $min_epoch = $min_date->format('U');
     $max_epoch = $max_date->format('U');
     if ($this->getIsAllDay()) {
         if ($show_end_date) {
             return pht('%s - %s, All Day', phabricator_date($min_epoch, $viewer), phabricator_date($max_epoch, $viewer));
         } else {
             return pht('%s, All Day', phabricator_date($min_epoch, $viewer));
         }
     } else {
         if ($show_end_date) {
             return pht('%s - %s', phabricator_datetime($min_epoch, $viewer), phabricator_datetime($max_epoch, $viewer));
         } else {
             if ($show_end) {
                 return pht('%s - %s', phabricator_datetime($min_epoch, $viewer), phabricator_time($max_epoch, $viewer));
             } else {
                 return pht('%s', phabricator_datetime($min_epoch, $viewer));
             }
         }
     }
 }
 public function render()
 {
     $drequest = $this->getDiffusionRequest();
     $handles = $this->handles;
     $graph = null;
     if ($this->parents) {
         $graph = $this->renderGraph();
     }
     $show_builds = PhabricatorApplication::isClassInstalledForViewer('PhabricatorHarbormasterApplication', $this->getUser());
     $rows = array();
     $ii = 0;
     foreach ($this->history as $history) {
         $epoch = $history->getEpoch();
         if ($epoch) {
             $date = phabricator_date($epoch, $this->user);
             $time = phabricator_time($epoch, $this->user);
         } else {
             $date = null;
             $time = null;
         }
         $data = $history->getCommitData();
         $author_phid = $committer = $committer_phid = null;
         if ($data) {
             $author_phid = $data->getCommitDetail('authorPHID');
             $committer_phid = $data->getCommitDetail('committerPHID');
             $committer = $data->getCommitDetail('committer');
         }
         if ($author_phid && isset($handles[$author_phid])) {
             $author = $handles[$author_phid]->renderLink();
         } else {
             $author = self::renderName($history->getAuthorName());
         }
         $different_committer = false;
         if ($committer_phid) {
             $different_committer = $committer_phid != $author_phid;
         } else {
             if ($committer != '') {
                 $different_committer = $committer != $history->getAuthorName();
             }
         }
         if ($different_committer) {
             if ($committer_phid && isset($handles[$committer_phid])) {
                 $committer = $handles[$committer_phid]->renderLink();
             } else {
                 $committer = self::renderName($committer);
             }
             $author = hsprintf('%s/%s', $author, $committer);
         }
         // We can show details once the message and change have been imported.
         $partial_import = PhabricatorRepositoryCommit::IMPORTED_MESSAGE | PhabricatorRepositoryCommit::IMPORTED_CHANGE;
         $commit = $history->getCommit();
         if ($commit && $commit->isPartiallyImported($partial_import) && $data) {
             $summary = AphrontTableView::renderSingleDisplayLine($history->getSummary());
         } else {
             $summary = phutil_tag('em', array(), "Importing…");
         }
         $build = null;
         if ($show_builds) {
             $buildable_lookup = $this->loadBuildablesOnDemand();
             $buildable = idx($buildable_lookup, $commit->getPHID());
             if ($buildable !== null) {
                 $icon = HarbormasterBuildable::getBuildableStatusIcon($buildable->getBuildableStatus());
                 $color = HarbormasterBuildable::getBuildableStatusColor($buildable->getBuildableStatus());
                 $name = HarbormasterBuildable::getBuildableStatusName($buildable->getBuildableStatus());
                 $icon_view = id(new PHUIIconView())->setIconFont($icon . ' ' . $color);
                 $tooltip_view = javelin_tag('span', array('sigil' => 'has-tooltip', 'meta' => array('tip' => $name)), $icon_view);
                 Javelin::initBehavior('phabricator-tooltips');
                 $href_view = phutil_tag('a', array('href' => '/' . $buildable->getMonogram()), $tooltip_view);
                 $build = $href_view;
                 $has_any_build = true;
             }
         }
         $rows[] = array($graph ? $graph[$ii++] : null, self::linkCommit($drequest->getRepository(), $history->getCommitIdentifier()), $build, $commit ? self::linkRevision(idx($this->revisions, $commit->getPHID())) : null, $author, $summary, $date, $time);
     }
     $view = new AphrontTableView($rows);
     $view->setHeaders(array('', pht('Commit'), '', pht('Revision'), pht('Author/Committer'), pht('Details'), pht('Date'), pht('Time')));
     $view->setColumnClasses(array('threads', 'n', 'icon', 'n', '', 'wide', '', 'right'));
     $view->setColumnVisibility(array($graph ? true : false));
     $view->setDeviceVisibility(array($graph ? true : false, true, true, true, false, true, false, false));
     return $view->render();
 }
 private function loadListData()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $pager = new AphrontPagerView();
     $pager->setOffset($this->getPagerOffset());
     if ($this->getPagerPageSize()) {
         $pager->setPageSize($this->getPagerPageSize());
     }
     $author = $this->getListAuthor();
     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');
     $this->setListPager($pager);
     $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->getViewURI()), 'View');
         } else {
             $view_button = null;
         }
         if (isset($highlighted[$file->getID()])) {
             $rowc[] = 'highlighted';
         } else {
             $rowc[] = '';
         }
         $name = $file->getName();
         $rows[] = array(phutil_escape_html('F' . $file->getID()), $file->getAuthorPHID() ? $handles[$file->getAuthorPHID()]->renderLink() : null, phutil_render_tag('a', array('href' => '/F' . $file->getID()), $name != '' ? phutil_escape_html($name) : '<em>no name</em>'), 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, phabricator_date($file->getDateCreated(), $user), phabricator_time($file->getDateCreated(), $user));
     }
     $this->setListRows($rows);
     $this->setListRowClasses($rowc);
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $filter_activity = $request->getStr('activity');
     $filter_ip = $request->getStr('ip');
     $filter_session = $request->getStr('session');
     $filter_user = $request->getArr('user', array());
     $filter_actor = $request->getArr('actor', array());
     $user_value = array();
     $actor_value = array();
     $phids = array_merge($filter_user, $filter_actor);
     if ($phids) {
         $handles = $this->loadViewerHandles($phids);
         if ($filter_user) {
             $filter_user = reset($filter_user);
             $user_value = array($filter_user => $handles[$filter_user]->getFullName());
         }
         if ($filter_actor) {
             $filter_actor = reset($filter_actor);
             $actor_value = array($filter_actor => $handles[$filter_actor]->getFullName());
         }
     }
     $form = new AphrontFormView();
     $form->setUser($user)->appendChild(id(new AphrontFormTokenizerControl())->setLabel('Filter Actor')->setName('actor')->setLimit(1)->setValue($actor_value)->setDatasource('/typeahead/common/accounts/'))->appendChild(id(new AphrontFormTokenizerControl())->setLabel('Filter User')->setName('user')->setLimit(1)->setValue($user_value)->setDatasource('/typeahead/common/accounts/'))->appendChild(id(new AphrontFormSelectControl())->setLabel('Show Activity')->setName('activity')->setValue($filter_activity)->setOptions(array('' => 'All Activity', 'admin' => 'Admin Activity')))->appendChild(id(new AphrontFormTextControl())->setLabel('Filter IP')->setName('ip')->setValue($filter_ip)->setCaption('Enter an IP (or IP prefix) to show only activity by that remote ' . 'address.'))->appendChild(id(new AphrontFormTextControl())->setLabel('Filter Session')->setName('session')->setValue($filter_session))->appendChild(id(new AphrontFormSubmitControl())->setValue('Filter Logs'));
     $log_table = new PhabricatorUserLog();
     $conn_r = $log_table->establishConnection('r');
     $where_clause = array();
     $where_clause[] = '1 = 1';
     if ($filter_user) {
         $where_clause[] = qsprintf($conn_r, 'userPHID = %s', $filter_user);
     }
     if ($filter_actor) {
         $where_clause[] = qsprintf($conn_r, 'actorPHID = %s', $filter_actor);
     }
     if ($filter_activity == 'admin') {
         $where_clause[] = qsprintf($conn_r, 'action NOT IN (%Ls)', array(PhabricatorUserLog::ACTION_LOGIN, PhabricatorUserLog::ACTION_LOGOUT, PhabricatorUserLog::ACTION_LOGIN_FAILURE));
     }
     if ($filter_ip) {
         $where_clause[] = qsprintf($conn_r, 'remoteAddr LIKE %>', $filter_ip);
     }
     if ($filter_session) {
         $where_clause[] = qsprintf($conn_r, 'session = %s', $filter_session);
     }
     $where_clause = '(' . implode(') AND (', $where_clause) . ')';
     $pager = new AphrontPagerView();
     $pager->setURI($request->getRequestURI(), 'page');
     $pager->setOffset($request->getInt('page'));
     $pager->setPageSize(500);
     $logs = $log_table->loadAllWhere('(%Q) ORDER BY dateCreated DESC LIMIT %d, %d', $where_clause, $pager->getOffset(), $pager->getPageSize() + 1);
     $logs = $pager->sliceResults($logs);
     $phids = array();
     foreach ($logs as $log) {
         $phids[$log->getActorPHID()] = true;
         $phids[$log->getUserPHID()] = true;
     }
     $phids = array_keys($phids);
     $handles = $this->loadViewerHandles($phids);
     $rows = array();
     foreach ($logs as $log) {
         $rows[] = array(phabricator_date($log->getDateCreated(), $user), phabricator_time($log->getDateCreated(), $user), $log->getAction(), $log->getActorPHID() ? phutil_escape_html($handles[$log->getActorPHID()]->getName()) : null, phutil_escape_html($handles[$log->getUserPHID()]->getName()), json_encode($log->getOldValue(), true), json_encode($log->getNewValue(), true), phutil_render_tag('a', array('href' => $request->getRequestURI()->alter('ip', $log->getRemoteAddr())), phutil_escape_html($log->getRemoteAddr())), phutil_render_tag('a', array('href' => $request->getRequestURI()->alter('session', $log->getSession())), phutil_escape_html($log->getSession())));
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('Date', 'Time', 'Action', 'Actor', 'User', 'Old', 'New', 'IP', 'Session'));
     $table->setColumnClasses(array('', 'right', '', '', '', 'wrap', 'wrap', '', 'wide'));
     $panel = new AphrontPanelView();
     $panel->setHeader('Activity Logs');
     $panel->appendChild($table);
     $panel->appendChild($pager);
     $filter = new AphrontListFilterView();
     $filter->appendChild($form);
     $nav = $this->buildSideNavView();
     $nav->selectFilter('logs');
     $nav->appendChild(array($filter, $panel));
     return $this->buildApplicationPage($nav, array('title' => 'Activity Logs'));
 }
 private function renderTransactionInfo()
 {
     $viewer = $this->getUser();
     $thread = $this->getConpherenceThread();
     $transaction = $this->getConpherenceTransaction();
     $info = array();
     Javelin::initBehavior('phabricator-tooltips');
     $tip = phabricator_datetime($transaction->getDateCreated(), $viewer);
     $label = phabricator_time($transaction->getDateCreated(), $viewer);
     $width = 360;
     if ($this->getFullDisplay()) {
         Javelin::initBehavior('phabricator-watch-anchor');
         $anchor = id(new PhabricatorAnchorView())->setAnchorName($transaction->getID())->render();
         $info[] = hsprintf('%s%s', $anchor, javelin_tag('a', array('href' => '#' . $transaction->getID(), 'class' => 'anchor-link', 'sigil' => 'has-tooltip', 'meta' => array('tip' => $tip, 'size' => $width)), $label));
     } else {
         $href = '/' . $thread->getMonogram() . '#' . $transaction->getID();
         $info[] = javelin_tag('a', array('href' => $href, 'class' => 'epoch-link', 'sigil' => 'has-tooltip', 'meta' => array('tip' => $tip, 'size' => $width)), $label);
     }
     return phutil_tag('span', array('class' => 'conpherence-transaction-info'), $info);
 }
 private function getEventDateLabel($event)
 {
     $viewer = $this->requireViewer();
     $from_datetime = PhabricatorTime::getDateTimeFromEpoch($event->getDateFrom(), $viewer);
     $to_datetime = PhabricatorTime::getDateTimeFromEpoch($event->getDateTo(), $viewer);
     $from_date_formatted = $from_datetime->format('Y m d');
     $to_date_formatted = $to_datetime->format('Y m d');
     if ($event->getIsAllDay()) {
         if ($from_date_formatted == $to_date_formatted) {
             return pht('%s, All Day', phabricator_date($event->getDateFrom(), $viewer));
         } else {
             return pht('%s - %s, All Day', phabricator_date($event->getDateFrom(), $viewer), phabricator_date($event->getDateTo(), $viewer));
         }
     } else {
         if ($from_date_formatted == $to_date_formatted) {
             return pht('%s - %s', phabricator_datetime($event->getDateFrom(), $viewer), phabricator_time($event->getDateTo(), $viewer));
         } else {
             return pht('%s - %s', phabricator_datetime($event->getDateFrom(), $viewer), phabricator_datetime($event->getDateTo(), $viewer));
         }
     }
 }
Exemplo n.º 28
0
 private function renderComparisonTable(array $content)
 {
     assert_instances_of($content, 'PhrictionContent');
     $user = $this->getRequest()->getUser();
     $phids = mpull($content, 'getAuthorPHID');
     $handles = $this->loadViewerHandles($phids);
     $rows = array();
     foreach ($content as $c) {
         $rows[] = array(phabricator_date($c->getDateCreated(), $user), phabricator_time($c->getDateCreated(), $user), phutil_escape_html('Version ' . $c->getVersion()), $handles[$c->getAuthorPHID()]->renderLink(), phutil_escape_html($c->getDescription()));
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('Date', 'Time', 'Version', 'Author', 'Description'));
     $table->setColumnClasses(array('', 'right', 'pri', '', 'wide'));
     return $table;
 }
Exemplo n.º 29
0
 private function renderComparisonTable(array $content)
 {
     assert_instances_of($content, 'PhrictionContent');
     $user = $this->getRequest()->getUser();
     $phids = mpull($content, 'getAuthorPHID');
     $handles = $this->loadViewerHandles($phids);
     $list = new PHUIObjectItemListView();
     $list->setFlush(true);
     $first = true;
     foreach ($content as $c) {
         $author = $handles[$c->getAuthorPHID()]->renderLink();
         $item = id(new PHUIObjectItemView())->setHeader(pht('%s by %s, %s', PhrictionChangeType::getChangeTypeLabel($c->getChangeType()), $author, pht('Version %s', $c->getVersion())))->addAttribute(pht('%s %s', phabricator_date($c->getDateCreated(), $user), phabricator_time($c->getDateCreated(), $user)));
         if ($c->getDescription()) {
             $item->addAttribute($c->getDescription());
         }
         if ($first == true) {
             $item->setBarColor('green');
             $first = false;
         } else {
             $item->setBarColor('red');
         }
         $list->addItem($item);
     }
     return $list;
 }
 private function renderKeyListView(AphrontRequest $request)
 {
     $user = $request->getUser();
     $keys = id(new PhabricatorUserSSHKey())->loadAllWhere('userPHID = %s', $user->getPHID());
     $rows = array();
     foreach ($keys as $key) {
         $rows[] = array(phutil_render_tag('a', array('href' => $this->getPanelURI('?edit=' . $key->getID())), phutil_escape_html($key->getName())), phutil_escape_html($key->getKeyComment()), phutil_escape_html($key->getKeyType()), phabricator_date($key->getDateCreated(), $user), phabricator_time($key->getDateCreated(), $user), javelin_render_tag('a', array('href' => $this->getPanelURI('?delete=' . $key->getID()), 'class' => 'small grey button', 'sigil' => 'workflow'), 'Delete'));
     }
     $table = new AphrontTableView($rows);
     $table->setNoDataString("You haven't added any SSH Public Keys.");
     $table->setHeaders(array('Name', 'Comment', 'Type', 'Created', 'Time', ''));
     $table->setColumnClasses(array('wide pri', '', '', '', 'right', 'action'));
     $panel = new AphrontPanelView();
     $panel->addButton(phutil_render_tag('a', array('href' => $this->getPanelURI('?edit=true'), 'class' => 'green button'), 'Add New Public Key'));
     $panel->setHeader('SSH Public Keys');
     $panel->appendChild($table);
     return $panel;
 }