Changeset View
Changeset View
Standalone View
Standalone View
src/applications/people/view/PhabricatorUserCardView.php
<?php | <?php | ||||
final class PhabricatorUserCardView extends AphrontTagView { | final class PhabricatorUserCardView extends AphrontTagView { | ||||
private $profile; | private $profile; | ||||
private $viewer; | private $viewer; | ||||
private $tag; | private $tag; | ||||
private $isExiled; | |||||
public function setProfile(PhabricatorUser $profile) { | public function setProfile(PhabricatorUser $profile) { | ||||
$this->profile = $profile; | $this->profile = $profile; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function setViewer(PhabricatorUser $viewer) { | public function setViewer(PhabricatorUser $viewer) { | ||||
$this->viewer = $viewer; | $this->viewer = $viewer; | ||||
Show All 21 Lines | if ($this->profile->getIsDisabled()) { | ||||
$classes[] = 'project-card-disabled'; | $classes[] = 'project-card-disabled'; | ||||
} | } | ||||
return array( | return array( | ||||
'class' => implode(' ', $classes), | 'class' => implode(' ', $classes), | ||||
); | ); | ||||
} | } | ||||
public function setIsExiled($is_exiled) { | |||||
$this->isExiled = $is_exiled; | |||||
return $this; | |||||
} | |||||
public function getIsExiled() { | |||||
return $this->isExiled; | |||||
} | |||||
protected function getTagContent() { | protected function getTagContent() { | ||||
$user = $this->profile; | $user = $this->profile; | ||||
$profile = $user->loadUserProfile(); | $profile = $user->loadUserProfile(); | ||||
$picture = $user->getProfileImageURI(); | $picture = $user->getProfileImageURI(); | ||||
$viewer = $this->viewer; | $viewer = $this->viewer; | ||||
require_celerity_resource('project-card-view-css'); | require_celerity_resource('project-card-view-css'); | ||||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | if ($has_calendar) { | ||||
$body[] = $this->addItem( | $body[] = $this->addItem( | ||||
'fa-calendar-o', | 'fa-calendar-o', | ||||
id(new PHUIUserAvailabilityView()) | id(new PHUIUserAvailabilityView()) | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->setAvailableUser($user)); | ->setAvailableUser($user)); | ||||
} | } | ||||
} | } | ||||
if ($this->getIsExiled()) { | |||||
$body[] = $this->addItem( | |||||
'fa-eye-slash red', | |||||
pht('This user can not see this object.'), | |||||
array( | |||||
'project-card-item-exiled', | |||||
)); | |||||
} | |||||
$classes[] = 'project-card-image'; | $classes[] = 'project-card-image'; | ||||
$image = phutil_tag( | $image = phutil_tag( | ||||
'img', | 'img', | ||||
array( | array( | ||||
'src' => $picture, | 'src' => $picture, | ||||
'class' => implode(' ', $classes), | 'class' => implode(' ', $classes), | ||||
)); | )); | ||||
Show All 36 Lines | $card = phutil_tag( | ||||
array( | array( | ||||
$header, | $header, | ||||
$image, | $image, | ||||
)); | )); | ||||
return $card; | return $card; | ||||
} | } | ||||
private function addItem($icon, $value) { | private function addItem($icon, $value, $classes = array()) { | ||||
$classes[] = 'project-card-item'; | |||||
$icon = id(new PHUIIconView()) | $icon = id(new PHUIIconView()) | ||||
->addClass('project-card-item-icon') | ->addClass('project-card-item-icon') | ||||
->setIcon($icon); | ->setIcon($icon); | ||||
$text = phutil_tag( | $text = phutil_tag( | ||||
'span', | 'span', | ||||
array( | array( | ||||
'class' => 'project-card-item-text', | 'class' => 'project-card-item-text', | ||||
), | ), | ||||
$value); | $value); | ||||
return phutil_tag_div('project-card-item', array($icon, $text)); | |||||
return phutil_tag( | |||||
'div', | |||||
array( | |||||
'class' => implode(' ', $classes), | |||||
), | |||||
array($icon, $text)); | |||||
} | } | ||||
} | } |