2012-08-02 14:07:21 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorApplicationLaunchView extends AphrontView {
|
|
|
|
|
|
|
|
private $application;
|
|
|
|
private $status;
|
2013-01-15 15:41:37 -08:00
|
|
|
private $fullWidth;
|
|
|
|
|
|
|
|
public function setFullWidth($full_width) {
|
|
|
|
$this->fullWidth = $full_width;
|
|
|
|
return $this;
|
|
|
|
}
|
2012-08-02 14:07:21 -07:00
|
|
|
|
|
|
|
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');
|
2013-01-15 15:41:22 -08:00
|
|
|
require_celerity_resource('sprite-apps-large-css');
|
2012-08-02 14:07:21 -07:00
|
|
|
|
|
|
|
$content = array();
|
2013-01-15 15:41:22 -08:00
|
|
|
$icon = null;
|
2013-01-22 09:06:57 -08:00
|
|
|
$create_button = null;
|
2013-01-15 15:41:22 -08:00
|
|
|
if ($application) {
|
2013-01-17 18:43:35 -08:00
|
|
|
$content[] = phutil_tag(
|
2013-01-15 15:41:22 -08:00
|
|
|
'span',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-application-launch-name',
|
|
|
|
),
|
2013-01-17 18:43:35 -08:00
|
|
|
$application->getName());
|
2012-10-03 15:16:26 -07:00
|
|
|
|
2013-01-19 10:12:44 -08:00
|
|
|
if ($application->isBeta()) {
|
2013-01-25 05:50:50 -08:00
|
|
|
$content[] = phutil_tag(
|
2013-01-19 10:12:44 -08:00
|
|
|
'span',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-application-beta',
|
|
|
|
),
|
|
|
|
"\xCE\xB2");
|
|
|
|
}
|
|
|
|
|
2013-01-15 15:41:37 -08:00
|
|
|
if ($this->fullWidth) {
|
2013-01-17 18:43:35 -08:00
|
|
|
$content[] = phutil_tag(
|
2013-01-15 15:41:37 -08:00
|
|
|
'span',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-application-launch-description',
|
|
|
|
),
|
2013-01-17 18:43:35 -08:00
|
|
|
$application->getShortDescription());
|
2013-01-15 15:41:37 -08:00
|
|
|
}
|
|
|
|
|
2013-02-22 14:13:26 -08:00
|
|
|
$counts = array();
|
2013-02-21 10:42:19 -08:00
|
|
|
$text = array();
|
2013-01-15 15:41:22 -08:00
|
|
|
if ($this->status) {
|
|
|
|
foreach ($this->status as $status) {
|
2013-02-22 14:13:26 -08:00
|
|
|
$type = $status->getType();
|
|
|
|
$counts[$type] = idx($counts, $type, 0) + $status->getCount();
|
2013-02-21 10:42:19 -08:00
|
|
|
if ($status->getCount()) {
|
|
|
|
$text[] = $status->getText();
|
|
|
|
}
|
2013-01-15 15:41:22 -08:00
|
|
|
}
|
2012-08-02 14:07:21 -07:00
|
|
|
}
|
2013-01-15 15:41:22 -08:00
|
|
|
|
2013-02-22 14:13:26 -08:00
|
|
|
$attention = PhabricatorApplicationStatusView::TYPE_NEEDS_ATTENTION;
|
|
|
|
$warning = PhabricatorApplicationStatusView::TYPE_WARNING;
|
|
|
|
if (!empty($counts[$attention]) || !empty($counts[$warning])) {
|
|
|
|
$count = idx($counts, $attention, 0);
|
2013-02-22 15:46:29 -08:00
|
|
|
$count1 = $count2 = '';
|
|
|
|
if ($count > 0) {
|
|
|
|
$count1 = phutil_tag(
|
|
|
|
'span',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-application-attention-count',
|
|
|
|
),
|
|
|
|
$count);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-22 14:13:26 -08:00
|
|
|
if (!empty($counts[$warning])) {
|
2013-02-22 15:46:29 -08:00
|
|
|
$count2 = phutil_tag(
|
|
|
|
'span',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-application-warning-count',
|
|
|
|
),
|
|
|
|
$counts[$warning]);
|
2013-02-22 14:13:26 -08:00
|
|
|
}
|
|
|
|
|
2013-02-21 10:42:19 -08:00
|
|
|
Javelin::initBehavior('phabricator-tooltips');
|
|
|
|
$content[] = javelin_tag(
|
2012-10-03 15:16:26 -07:00
|
|
|
'span',
|
|
|
|
array(
|
2013-02-21 10:42:19 -08:00
|
|
|
'sigil' => 'has-tooltip',
|
|
|
|
'meta' => array(
|
|
|
|
'tip' => implode("\n", $text),
|
|
|
|
'size' => 240,
|
|
|
|
),
|
2013-01-15 15:41:22 -08:00
|
|
|
'class' => 'phabricator-application-launch-attention',
|
2012-10-03 15:16:26 -07:00
|
|
|
),
|
2013-02-22 15:46:29 -08:00
|
|
|
array($count1, $count2));
|
2012-10-03 15:16:26 -07:00
|
|
|
}
|
2012-08-02 14:07:21 -07:00
|
|
|
|
2013-01-15 15:41:22 -08:00
|
|
|
$classes = array();
|
|
|
|
$classes[] = 'phabricator-application-launch-icon';
|
|
|
|
$styles = array();
|
2012-10-03 15:16:26 -07:00
|
|
|
|
2013-01-15 15:41:22 -08:00
|
|
|
if ($application->getIconURI()) {
|
|
|
|
$styles[] = 'background-image: url('.$application->getIconURI().')';
|
|
|
|
} else {
|
|
|
|
$icon = $application->getIconName();
|
|
|
|
$classes[] = 'sprite-apps-large';
|
2013-04-13 09:09:42 -07:00
|
|
|
$classes[] = 'apps-'.$icon.'-light-large';
|
2013-01-15 15:41:22 -08:00
|
|
|
}
|
|
|
|
|
2013-01-17 18:57:09 -08:00
|
|
|
$icon = phutil_tag(
|
2012-08-02 14:07:21 -07:00
|
|
|
'span',
|
|
|
|
array(
|
2013-01-15 15:41:22 -08:00
|
|
|
'class' => implode(' ', $classes),
|
|
|
|
'style' => nonempty(implode('; ', $styles), null),
|
2012-08-02 14:07:21 -07:00
|
|
|
),
|
2013-01-15 15:41:22 -08:00
|
|
|
'');
|
2012-08-14 14:23:55 -07:00
|
|
|
}
|
|
|
|
|
2014-01-29 17:23:50 -08:00
|
|
|
$classes = array();
|
2013-01-15 15:41:37 -08:00
|
|
|
$classes[] = 'phabricator-application-launch-container';
|
|
|
|
if ($this->fullWidth) {
|
|
|
|
$classes[] = 'application-tile-full';
|
|
|
|
}
|
|
|
|
|
2013-02-22 14:13:26 -08:00
|
|
|
$title = null;
|
|
|
|
if ($application && !$this->fullWidth) {
|
|
|
|
$title = $application->getShortDescription();
|
|
|
|
}
|
|
|
|
|
2013-01-28 18:46:48 -08:00
|
|
|
$app_button = phutil_tag(
|
2013-01-15 15:41:22 -08:00
|
|
|
$application ? 'a' : 'div',
|
2012-08-02 14:07:21 -07:00
|
|
|
array(
|
2013-01-15 15:41:37 -08:00
|
|
|
'class' => implode(' ', $classes),
|
2013-01-15 15:41:22 -08:00
|
|
|
'href' => $application ? $application->getBaseURI() : null,
|
2013-02-22 14:13:26 -08:00
|
|
|
'title' => $title,
|
2012-08-02 14:07:21 -07:00
|
|
|
),
|
2013-01-28 18:46:48 -08:00
|
|
|
array(
|
2013-03-09 13:52:41 -08:00
|
|
|
$icon,
|
|
|
|
$content,
|
2013-01-28 18:46:48 -08:00
|
|
|
));
|
2013-03-09 13:52:41 -08:00
|
|
|
|
|
|
|
return array($app_button, $create_button);
|
2012-08-02 14:07:21 -07:00
|
|
|
}
|
|
|
|
}
|