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-01-15 15:41:22 -08:00
|
|
|
$count = 0;
|
|
|
|
if ($this->status) {
|
|
|
|
foreach ($this->status as $status) {
|
|
|
|
$count += $status->getCount();
|
|
|
|
}
|
2012-08-02 14:07:21 -07:00
|
|
|
}
|
2013-01-15 15:41:22 -08:00
|
|
|
|
|
|
|
if ($count) {
|
2013-01-17 18:43:35 -08:00
|
|
|
$content[] = phutil_tag(
|
2012-10-03 15:16:26 -07:00
|
|
|
'span',
|
|
|
|
array(
|
2013-01-15 15:41:22 -08:00
|
|
|
'class' => 'phabricator-application-launch-attention',
|
2012-10-03 15:16:26 -07:00
|
|
|
),
|
2013-01-17 18:43:35 -08:00
|
|
|
$count);
|
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';
|
|
|
|
$classes[] = 'app-'.$icon.'-light-large';
|
|
|
|
}
|
|
|
|
|
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
|
|
|
'');
|
2013-01-22 09:06:57 -08:00
|
|
|
|
|
|
|
$classes = array();
|
|
|
|
if ($application->getQuickCreateURI()) {
|
|
|
|
$classes[] = 'phabricator-application-create-icon';
|
|
|
|
$classes[] = 'sprite-icon';
|
|
|
|
$classes[] = 'action-new-grey';
|
2013-01-25 05:50:50 -08:00
|
|
|
$plus_icon = phutil_tag(
|
2013-01-22 09:06:57 -08:00
|
|
|
'span',
|
|
|
|
array(
|
|
|
|
'class' => implode(' ', $classes),
|
|
|
|
));
|
|
|
|
|
2013-01-25 05:50:50 -08:00
|
|
|
$create_button = phutil_tag(
|
2013-01-22 09:06:57 -08:00
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => $application->getQuickCreateURI(),
|
|
|
|
'class' => 'phabricator-application-launch-create',
|
|
|
|
),
|
|
|
|
$plus_icon);
|
|
|
|
$classes = array();
|
|
|
|
$classes[] = 'application-tile-create';
|
|
|
|
}
|
2012-08-14 14:23:55 -07:00
|
|
|
}
|
|
|
|
|
2013-01-15 15:41:37 -08:00
|
|
|
$classes[] = 'phabricator-application-launch-container';
|
|
|
|
if ($this->fullWidth) {
|
|
|
|
$classes[] = 'application-tile-full';
|
|
|
|
}
|
|
|
|
|
2013-01-22 09:06:57 -08:00
|
|
|
$app_button = phutil_render_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-01-24 17:02:21 -08:00
|
|
|
'title' => $application ? $application->getShortDescription() : null,
|
2012-08-02 14:07:21 -07:00
|
|
|
),
|
2012-08-14 14:23:55 -07:00
|
|
|
$icon.
|
2012-08-02 14:07:21 -07:00
|
|
|
$this->renderSingleView($content));
|
2013-01-22 09:06:57 -08:00
|
|
|
|
|
|
|
return $app_button.$create_button;
|
2012-08-02 14:07:21 -07:00
|
|
|
}
|
|
|
|
}
|