2015-01-27 23:50:20 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhortuneSubscriptionTableView extends AphrontView {
|
|
|
|
|
|
|
|
private $subscriptions;
|
|
|
|
private $handles;
|
2015-01-30 20:28:49 +01:00
|
|
|
private $isMerchantView;
|
2015-01-27 23:50:20 +01:00
|
|
|
|
|
|
|
public function setHandles(array $handles) {
|
|
|
|
$this->handles = $handles;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getHandles() {
|
|
|
|
return $this->handles;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setSubscriptions(array $subscriptions) {
|
|
|
|
$this->subscriptions = $subscriptions;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getSubscriptions() {
|
|
|
|
return $this->subscriptions;
|
|
|
|
}
|
|
|
|
|
2015-01-30 20:28:49 +01:00
|
|
|
public function setIsMerchantView($is_merchant_view) {
|
|
|
|
$this->isMerchantView = $is_merchant_view;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getIsMerchantView() {
|
|
|
|
return $this->isMerchantView;
|
|
|
|
}
|
|
|
|
|
2015-01-27 23:50:20 +01:00
|
|
|
public function render() {
|
|
|
|
$subscriptions = $this->getSubscriptions();
|
|
|
|
$handles = $this->getHandles();
|
|
|
|
$viewer = $this->getUser();
|
|
|
|
|
|
|
|
$rows = array();
|
|
|
|
$rowc = array();
|
|
|
|
foreach ($subscriptions as $subscription) {
|
2015-01-30 20:28:49 +01:00
|
|
|
if ($this->getIsMerchantView()) {
|
|
|
|
$uri = $subscription->getMerchantURI();
|
|
|
|
} else {
|
|
|
|
$uri = $subscription->getURI();
|
|
|
|
}
|
|
|
|
|
2015-01-27 23:50:20 +01:00
|
|
|
$subscription_link = $handles[$subscription->getPHID()]->renderLink();
|
|
|
|
$rows[] = array(
|
|
|
|
$subscription->getID(),
|
2015-01-30 20:28:49 +01:00
|
|
|
phutil_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => $uri,
|
|
|
|
),
|
|
|
|
$subscription->getSubscriptionName()),
|
2015-01-27 23:50:20 +01:00
|
|
|
phabricator_datetime($subscription->getDateCreated(), $viewer),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$table = id(new AphrontTableView($rows))
|
|
|
|
->setHeaders(
|
|
|
|
array(
|
|
|
|
pht('ID'),
|
2015-01-30 20:28:49 +01:00
|
|
|
pht('Name'),
|
2015-01-27 23:50:20 +01:00
|
|
|
pht('Created'),
|
|
|
|
))
|
|
|
|
->setColumnClasses(
|
|
|
|
array(
|
|
|
|
'',
|
2015-01-30 20:28:49 +01:00
|
|
|
'wide',
|
2015-01-27 23:50:20 +01:00
|
|
|
'right',
|
|
|
|
));
|
|
|
|
|
|
|
|
return $table;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|