1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-23 05:01:13 +01:00
phorge-phorge/src/applications/meta/view/PhabricatorApplicationLaunchView.php

144 lines
3.7 KiB
PHP
Raw Normal View History

<?php
final class PhabricatorApplicationLaunchView extends AphrontView {
private $application;
private $status;
public function setApplication(PhabricatorApplication $application) {
$this->application = $application;
return $this;
}
public function setApplicationStatus(array $status) {
$this->status = $status;
return $this;
}
public function render() {
$application = $this->application;
require_celerity_resource('phabricator-application-launch-view-css');
require_celerity_resource('sprite-apps-large-css');
$content = array();
$icon = null;
if ($application) {
$content[] = phutil_tag(
'span',
array(
'class' => 'phabricator-application-launch-name',
),
$application->getName());
if ($application->isBeta()) {
$content[] = javelin_tag(
'span',
array(
'aural' => false,
'class' => 'phabricator-application-beta',
),
"\xCE\xB2");
}
2014-05-24 21:56:45 -07:00
$content[] = phutil_tag(
'span',
array(
'class' => 'phabricator-application-launch-description',
),
$application->getShortDescription());
$counts = array();
$text = array();
if ($this->status) {
foreach ($this->status as $status) {
$type = $status->getType();
$counts[$type] = idx($counts, $type, 0) + $status->getCount();
if ($status->getCount()) {
$text[] = $status->getText();
}
}
}
$attention = PhabricatorApplicationStatusView::TYPE_NEEDS_ATTENTION;
$warning = PhabricatorApplicationStatusView::TYPE_WARNING;
if (!empty($counts[$attention]) || !empty($counts[$warning])) {
$count = idx($counts, $attention, 0);
$count1 = $count2 = '';
if ($count > 0) {
$count1 = phutil_tag(
'span',
array(
'class' => 'phabricator-application-attention-count',
),
$count);
}
if (!empty($counts[$warning])) {
$count2 = phutil_tag(
'span',
array(
'class' => 'phabricator-application-warning-count',
),
$counts[$warning]);
}
2014-05-25 13:18:51 -07:00
if (nonempty($count1)) {
$numbers = array($count1, ' / ', $count2);
} else {
$numbers = array($count1, $count2);
}
Javelin::initBehavior('phabricator-tooltips');
$content[] = javelin_tag(
'span',
array(
'sigil' => 'has-tooltip',
'meta' => array(
'tip' => implode("\n", $text),
'size' => 240,
),
'class' => 'phabricator-application-launch-attention',
),
2014-05-25 13:18:51 -07:00
$numbers);
}
$classes = array();
$classes[] = 'phabricator-application-launch-icon';
$styles = array();
if ($application->getIconURI()) {
$styles[] = 'background-image: url('.$application->getIconURI().')';
} else {
$icon = $application->getIconName();
$classes[] = 'sprite-apps-large';
2014-05-24 21:56:45 -07:00
$classes[] = 'apps-'.$icon.'-dark-large';
}
$icon = phutil_tag(
'span',
array(
'class' => implode(' ', $classes),
'style' => nonempty(implode('; ', $styles), null),
),
'');
}
$classes = array();
$classes[] = 'phabricator-application-launch-container';
$app_button = phutil_tag(
$application ? 'a' : 'div',
array(
'class' => implode(' ', $classes),
'href' => $application ? $application->getBaseURI() : null,
),
array(
$icon,
$content,
));
2014-05-25 16:30:32 -07:00
return $app_button;
}
}