Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2896328
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
153 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/applications/config/view/PhabricatorSetupIssueView.php b/src/applications/config/view/PhabricatorSetupIssueView.php
index 19922ed10b..c5a0932e3e 100644
--- a/src/applications/config/view/PhabricatorSetupIssueView.php
+++ b/src/applications/config/view/PhabricatorSetupIssueView.php
@@ -1,331 +1,328 @@
<?php
final class PhabricatorSetupIssueView extends AphrontView {
private $issue;
public function setIssue(PhabricatorSetupIssue $issue) {
$this->issue = $issue;
return $this;
}
public function getIssue() {
return $this->issue;
}
public function render() {
$issue = $this->getIssue();
$description = array();
$description[] = phutil_tag(
'div',
array(
'class' => 'setup-issue-instructions',
),
phutil_escape_html_newlines($issue->getMessage()));
$configs = $issue->getPHPConfig();
if ($configs) {
$description[] = $this->renderPHPConfig($configs);
}
$configs = $issue->getPhabricatorConfig();
if ($configs) {
$description[] = $this->renderPhabricatorConfig($configs);
}
$commands = $issue->getCommands();
if ($commands) {
$run_these = pht("Run these %d command(s):", count($commands));
$description[] = phutil_tag(
'div',
array(
'class' => 'setup-issue-config',
),
array(
phutil_tag('p', array(), $run_these),
phutil_tag('pre', array(), phutil_implode_html("\n", $commands)),
));
}
$extensions = $issue->getPHPExtensions();
if ($extensions) {
$install_these = pht(
"Install these %d PHP extension(s):", count($extensions));
$install_info = pht(
"You can usually install a PHP extension using %s or %s. Common ".
"package names are %s or %s. Try commands like these:",
phutil_tag('tt', array(), 'apt-get'),
phutil_tag('tt', array(), 'yum'),
hsprintf('<tt>php-<em>%s</em></tt>', pht('extname')),
hsprintf('<tt>php5-<em>%s</em></tt>', pht('extname')));
// TODO: We should do a better job of detecting how to install extensions
// on the current system.
$install_commands = hsprintf(
"\$ sudo apt-get install php5-<em>extname</em> ".
"# Debian / Ubuntu\n".
"\$ sudo yum install php-<em>extname</em> ".
"# Red Hat / Derivatives");
$fallback_info = pht(
"If those commands don't work, try Google. The process of installing ".
"PHP extensions is not specific to Phabricator, and any instructions ".
"you can find for installing them on your system should work. On Mac ".
"OS X, you might want to try Homebrew.");
$restart_info = pht(
"After installing new PHP extensions, <strong>restart your webserver ".
"for the changes to take effect</strong>.",
hsprintf(''));
$description[] = phutil_tag(
'div',
array(
'class' => 'setup-issue-config',
),
array(
phutil_tag('p', array(), $install_these),
phutil_tag('pre', array(), implode("\n", $extensions)),
phutil_tag('p', array(), $install_info),
phutil_tag('pre', array(), $install_commands),
phutil_tag('p', array(), $fallback_info),
phutil_tag('p', array(), $restart_info),
));
}
$next = phutil_tag(
'div',
array(
'class' => 'setup-issue-next',
),
pht('To continue, resolve this problem and reload the page.'));
$name = phutil_tag(
'div',
array(
'class' => 'setup-issue-name',
),
$issue->getName());
return phutil_tag(
'div',
array(
'class' => 'setup-issue',
),
- $this->renderSingleView(
- array(
- $name,
- $description,
- $next,
- )));
+ array(
+ $name,
+ $description,
+ $next,
+ ));
}
private function renderPhabricatorConfig(array $configs) {
$issue = $this->getIssue();
$table_info = phutil_tag(
'p',
array(),
pht(
"The current Phabricator configuration has these %d value(s):",
count($configs)));
$dict = array();
foreach ($configs as $key) {
$dict[$key] = PhabricatorEnv::getUnrepairedEnvConfig($key);
}
$table = $this->renderValueTable($dict);
$options = PhabricatorApplicationConfigOptions::loadAllOptions();
if ($this->getIssue()->getIsFatal()) {
$update_info = phutil_tag(
'p',
array(),
pht(
"To update these %d value(s), run these command(s) from the command ".
"line:",
count($configs)));
$update = array();
foreach ($configs as $key) {
$update[] = hsprintf(
'<tt>phabricator/ $</tt> ./bin/config set %s <em>value</em>',
$key);
}
$update = phutil_tag('pre', array(), phutil_implode_html("\n", $update));
} else {
$update = array();
foreach ($configs as $config) {
if (!idx($options, $config) || $options[$config]->getLocked()) {
continue;
}
$link = phutil_tag(
'a',
array(
'href' => '/config/edit/'.$config.'/?issue='.$issue->getIssueKey(),
),
pht('Edit %s', $config));
$update[] = phutil_tag('li', array(), $link);
}
if ($update) {
$update = phutil_tag('ul', array(), $update);
$update_info = phutil_tag(
'p',
array(),
pht("You can update these %d value(s) here:", count($configs)));
} else {
$update = null;
$update_info = null;
}
}
return phutil_tag(
'div',
array(
'class' => 'setup-issue-config',
),
- self::renderSingleView(
- array(
- $table_info,
- $table,
- $update_info,
- $update,
- )));
+ array(
+ $table_info,
+ $table,
+ $update_info,
+ $update,
+ ));
}
private function renderPHPConfig(array $configs) {
$table_info = phutil_tag(
'p',
array(),
pht(
"The current PHP configuration has these %d value(s):",
count($configs)));
$dict = array();
foreach ($configs as $key) {
$dict[$key] = ini_get($key);
}
$table = $this->renderValueTable($dict);
ob_start();
phpinfo();
$phpinfo = ob_get_clean();
$rex = '@Loaded Configuration File\s*</td><td class="v">(.*?)</td>@i';
$matches = null;
$ini_loc = null;
if (preg_match($rex, $phpinfo, $matches)) {
$ini_loc = trim($matches[1]);
}
$rex = '@Additional \.ini files parsed\s*</td><td class="v">(.*?)</td>@i';
$more_loc = array();
if (preg_match($rex, $phpinfo, $matches)) {
$more_loc = trim($matches[1]);
if ($more_loc == '(none)') {
$more_loc = array();
} else {
$more_loc = preg_split('/\s*,\s*/', $more_loc);
}
}
$info = array();
if (!$ini_loc) {
$info[] = phutil_tag(
'p',
array(),
pht(
"To update these %d value(s), edit your PHP configuration file.",
count($configs)));
} else {
$info[] = phutil_tag(
'p',
array(),
pht(
"To update these %d value(s), edit your PHP configuration file, ".
"located here:",
count($configs)));
$info[] = phutil_tag(
'pre',
array(),
$ini_loc);
}
if ($more_loc) {
$info[] = phutil_tag(
'p',
array(),
pht(
"PHP also loaded these configuration file(s):",
count($more_loc)));
$info[] = phutil_tag(
'pre',
array(),
implode("\n", $more_loc));
}
$info[] = phutil_tag(
'p',
array(),
pht(
'You can find more information about PHP configuration values in the '.
'<a href="%s">PHP Documentation</a>.',
'http://php.net/manual/ini.list.php',
hsprintf('')));
$info[] = phutil_tag(
'p',
array(),
pht(
"After editing the PHP configuration, <strong>restart your ".
"webserver for the changes to take effect</strong>.",
hsprintf('')));
return phutil_tag(
'div',
array(
'class' => 'setup-issue-config',
),
- $this->renderSingleView(
- array(
- $table_info,
- $table,
- $info,
- )));
+ array(
+ $table_info,
+ $table,
+ $info,
+ ));
}
private function renderValueTable(array $dict) {
$rows = array();
foreach ($dict as $key => $value) {
$cols = array(
phutil_tag('th', array(), $key),
phutil_tag('td', array(), $this->renderValueForDisplay($value)),
);
$rows[] = phutil_tag('tr', array(), $cols);
}
return phutil_tag('table', array(), $rows);
}
private function renderValueForDisplay($value) {
if ($value === null) {
return phutil_tag('em', array(), 'null');
} else if ($value === false) {
return phutil_tag('em', array(), 'false');
} else if ($value === true) {
return phutil_tag('em', array(), 'true');
} else if ($value === '') {
return phutil_tag('em', array(), 'empty string');
} else {
return PhabricatorConfigJSON::prettyPrintJSON($value);
}
}
}
diff --git a/src/applications/conpherence/view/ConpherenceFileWidgetView.php b/src/applications/conpherence/view/ConpherenceFileWidgetView.php
index d85ec2020b..6cf746300b 100644
--- a/src/applications/conpherence/view/ConpherenceFileWidgetView.php
+++ b/src/applications/conpherence/view/ConpherenceFileWidgetView.php
@@ -1,65 +1,65 @@
<?php
final class ConpherenceFileWidgetView extends AphrontView {
private $conpherence;
private $updateURI;
public function setUpdateURI($update_uri) {
$this->updateURI = $update_uri;
return $this;
}
public function getUpdateURI() {
return $this->updateURI;
}
public function setConpherence(ConpherenceThread $conpherence) {
$this->conpherence = $conpherence;
return $this;
}
public function getConpherence() {
return $this->conpherence;
}
public function render() {
$conpherence = $this->getConpherence();
$widget_data = $conpherence->getWidgetData();
$files = $widget_data['files'];
$table_data = array();
foreach ($files as $file) {
$file_view = id(new PhabricatorFileLinkView())
->setFilePHID($file->getPHID())
->setFileName($file->getName())
->setFileViewable(true)
->setFileViewURI($file->getBestURI());
$meta = $file_view->getMetadata();
$table_data[] = array(
javelin_tag(
'a',
array(
'sigil' => 'lightboxable',
'meta' => $meta
),
phutil_tag(
'img',
array(
'src' => $file->getThumb60x45URI()
),
'')),
$file_view->render()
);
}
$header = id(new PhabricatorHeaderView())
->setHeader(pht('Attached Files'));
$table = id(new AphrontTableView($table_data))
->setNoDataString(pht('No files attached to conpherence.'))
->setHeaders(array('', pht('Name')))
->setColumnClasses(array('', 'wide wrap'));
- return $this->renderSingleView(array($header, $table));
+ return array($header, $table);
}
}
diff --git a/src/applications/conpherence/view/ConpherenceMenuItemView.php b/src/applications/conpherence/view/ConpherenceMenuItemView.php
index 539a107122..50284abfa0 100644
--- a/src/applications/conpherence/view/ConpherenceMenuItemView.php
+++ b/src/applications/conpherence/view/ConpherenceMenuItemView.php
@@ -1,152 +1,151 @@
<?php
/**
* @group conpherence
*/
final class ConpherenceMenuItemView extends AphrontTagView {
private $title;
private $subtitle;
private $imageURI;
private $href;
private $messageText;
private $epoch;
private $unreadCount;
public function setUnreadCount($unread_count) {
$this->unreadCount = $unread_count;
return $this;
}
public function getUnreadCount() {
return $this->unreadCount;
}
public function setMessageText($message_text) {
$this->messageText = $message_text;
return $this;
}
public function getMessageText() {
return $this->messageText;
}
public function setEpoch($epoch) {
$this->epoch = $epoch;
return $this;
}
public function getEpoch() {
return $this->epoch;
}
public function setHref($href) {
$this->href = $href;
return $this;
}
public function getHref() {
return $this->href;
}
public function setImageURI($image_uri) {
$this->imageURI = $image_uri;
return $this;
}
public function getImageURI() {
return $this->imageURI;
}
public function setSubtitle($subtitle) {
$this->subtitle = $subtitle;
return $this;
}
public function getSubtitle() {
return $this->subtitle;
}
public function setTitle($title) {
$this->title = $title;
return $this;
}
public function getTitle() {
return $this->title;
}
protected function getTagName() {
return 'a';
}
protected function getTagAttributes() {
$classes = array('conpherence-menu-item-view');
return array(
'class' => $classes,
'href' => $this->href,
);
}
protected function getTagContent() {
$image = null;
if ($this->imageURI) {
$image = phutil_tag(
'span',
array(
'class' => 'conpherence-menu-item-image',
'style' => 'background-image: url('.$this->imageURI.');'
),
'');
}
$title = null;
if ($this->title) {
$title = phutil_tag(
'span',
array(
'class' => 'conpherence-menu-item-title',
),
$this->title);
}
$subtitle = null;
if ($this->subtitle) {
$subtitle = phutil_tag(
'span',
array(
'class' => 'conpherence-menu-item-subtitle',
),
$this->subtitle);
}
$message = null;
if ($this->messageText) {
$message = phutil_tag(
'span',
array(
'class' => 'conpherence-menu-item-message-text'
),
$this->messageText);
}
$epoch = null;
if ($this->epoch) {
$epoch = phutil_tag(
'span',
array(
'class' => 'conpherence-menu-item-date',
),
phabricator_relative_date($this->epoch, $this->user));
}
$unread_count = null;
if ($this->unreadCount) {
$unread_count = phutil_tag(
'span',
array(
'class' => 'conpherence-menu-item-unread-count'
),
(int)$this->unreadCount);
}
- return $this->renderSingleView(
- array(
- $image,
- $title,
- $subtitle,
- $message,
- $epoch,
- $unread_count,
- ));
+ return array(
+ $image,
+ $title,
+ $subtitle,
+ $message,
+ $epoch,
+ $unread_count,
+ );
}
}
diff --git a/src/applications/conpherence/view/ConpherenceTransactionView.php b/src/applications/conpherence/view/ConpherenceTransactionView.php
index 0a1b307bf6..2d3780fcd2 100644
--- a/src/applications/conpherence/view/ConpherenceTransactionView.php
+++ b/src/applications/conpherence/view/ConpherenceTransactionView.php
@@ -1,94 +1,94 @@
<?php
/**
* @group conpherence
*/
final class ConpherenceTransactionView extends AphrontView {
private $conpherenceTransaction;
private $handles;
private $markupEngine;
public function setMarkupEngine(PhabricatorMarkupEngine $markup_engine) {
$this->markupEngine = $markup_engine;
return $this;
}
public function setHandles(array $handles) {
assert_instances_of($handles, 'PhabricatorObjectHandle');
$this->handles = $handles;
return $this;
}
public function getHandles() {
return $this->handles;
}
public function setConpherenceTransaction(ConpherenceTransaction $tx) {
$this->conpherenceTransaction = $tx;
return $this;
}
private function getConpherenceTransaction() {
return $this->conpherenceTransaction;
}
public function render() {
$transaction = $this->getConpherenceTransaction();
$handles = $this->getHandles();
$transaction->setHandles($handles);
$author = $handles[$transaction->getAuthorPHID()];
$transaction_view = id(new PhabricatorTransactionView())
->setUser($this->getUser())
->setEpoch($transaction->getDateCreated())
->setContentSource($transaction->getContentSource());
$content = null;
$content_class = null;
$content = null;
switch ($transaction->getTransactionType()) {
case ConpherenceTransactionType::TYPE_TITLE:
case ConpherenceTransactionType::TYPE_PICTURE:
case ConpherenceTransactionType::TYPE_PICTURE_CROP:
$content = $transaction->getTitle();
$transaction_view->addClass('conpherence-edited');
break;
case ConpherenceTransactionType::TYPE_FILES:
$content = $transaction->getTitle();
break;
case ConpherenceTransactionType::TYPE_PICTURE:
$img = $transaction->getHandle($transaction->getNewValue());
$content = array(
$transaction->getTitle(),
phutil_tag(
'img',
array(
'src' => $img->getImageURI()
)));
$transaction_view->addClass('conpherence-edited');
break;
case ConpherenceTransactionType::TYPE_PARTICIPANTS:
$content = $transaction->getTitle();
$transaction_view->addClass('conpherence-edited');
break;
case PhabricatorTransactions::TYPE_COMMENT:
$comment = $transaction->getComment();
$content = $this->markupEngine->getOutput(
$comment,
PhabricatorApplicationTransactionComment::MARKUP_FIELD_COMMENT);
$content_class = 'conpherence-message phabricator-remarkup';
$transaction_view
->setImageURI($author->getImageURI())
->setActions(array($author->renderLink()));
break;
}
- $transaction_view
- ->appendChild(phutil_tag(
+ $transaction_view->appendChild(
+ phutil_tag(
'div',
array(
'class' => $content_class
),
- $this->renderSingleView($content)));
+ $content));
return $transaction_view->render();
}
}
diff --git a/src/applications/differential/view/DifferentialChangesetDetailView.php b/src/applications/differential/view/DifferentialChangesetDetailView.php
index e010d4e539..308f2705a0 100644
--- a/src/applications/differential/view/DifferentialChangesetDetailView.php
+++ b/src/applications/differential/view/DifferentialChangesetDetailView.php
@@ -1,108 +1,107 @@
<?php
final class DifferentialChangesetDetailView extends AphrontView {
private $changeset;
private $buttons = array();
private $editable;
private $symbolIndex;
private $id;
private $vsChangesetID;
public function setChangeset($changeset) {
$this->changeset = $changeset;
return $this;
}
public function addButton($button) {
$this->buttons[] = $button;
return $this;
}
public function setEditable($editable) {
$this->editable = $editable;
return $this;
}
public function setSymbolIndex($symbol_index) {
$this->symbolIndex = $symbol_index;
return $this;
}
public function getID() {
if (!$this->id) {
$this->id = celerity_generate_unique_node_id();
}
return $this->id;
}
public function setVsChangesetID($vs_changeset_id) {
$this->vsChangesetID = $vs_changeset_id;
return $this;
}
public function getVsChangesetID() {
return $this->vsChangesetID;
}
public function render() {
require_celerity_resource('differential-changeset-view-css');
require_celerity_resource('syntax-highlighting-css');
Javelin::initBehavior('phabricator-oncopy', array());
$changeset = $this->changeset;
$class = 'differential-changeset';
if (!$this->editable) {
$class .= ' differential-changeset-immutable';
}
$buttons = null;
if ($this->buttons) {
$buttons = phutil_tag(
'div',
array(
'class' => 'differential-changeset-buttons',
),
$this->buttons);
}
$id = $this->getID();
if ($this->symbolIndex) {
Javelin::initBehavior(
'repository-crossreference',
array(
'container' => $id,
) + $this->symbolIndex);
}
$display_filename = $changeset->getDisplayFilename();
return javelin_tag(
'div',
array(
'sigil' => 'differential-changeset',
'meta' => array(
'left' => nonempty(
$this->getVsChangesetID(),
$this->changeset->getID()),
'right' => $this->changeset->getID(),
),
'class' => $class,
'id' => $id,
),
- $this->renderSingleView(
- array(
- id(new PhabricatorAnchorView())
- ->setAnchorName($changeset->getAnchorName())
- ->setNavigationMarker(true)
- ->render(),
- $buttons,
- phutil_tag('h1', array(), $display_filename),
- phutil_tag('div', array('style' => 'clear: both'), ''),
- $this->renderChildren(),
- )));
+ array(
+ id(new PhabricatorAnchorView())
+ ->setAnchorName($changeset->getAnchorName())
+ ->setNavigationMarker(true)
+ ->render(),
+ $buttons,
+ phutil_tag('h1', array(), $display_filename),
+ phutil_tag('div', array('style' => 'clear: both'), ''),
+ $this->renderChildren(),
+ ));
}
}
diff --git a/src/applications/differential/view/DifferentialChangesetListView.php b/src/applications/differential/view/DifferentialChangesetListView.php
index 422e8fd9ab..f72733b769 100644
--- a/src/applications/differential/view/DifferentialChangesetListView.php
+++ b/src/applications/differential/view/DifferentialChangesetListView.php
@@ -1,324 +1,323 @@
<?php
final class DifferentialChangesetListView extends AphrontView {
private $changesets = array();
private $visibleChangesets = array();
private $references = array();
private $inlineURI;
private $renderURI = '/differential/changeset/';
private $whitespace;
private $standaloneURI;
private $leftRawFileURI;
private $rightRawFileURI;
private $symbolIndexes = array();
private $repository;
private $branch;
private $diff;
private $vsMap = array();
private $title;
public function setTitle($title) {
$this->title = $title;
return $this;
}
private function getTitle() {
return $this->title;
}
public function setBranch($branch) {
$this->branch = $branch;
return $this;
}
private function getBranch() {
return $this->branch;
}
public function setChangesets($changesets) {
$this->changesets = $changesets;
return $this;
}
public function setVisibleChangesets($visible_changesets) {
$this->visibleChangesets = $visible_changesets;
return $this;
}
public function setInlineCommentControllerURI($uri) {
$this->inlineURI = $uri;
return $this;
}
public function setRepository(PhabricatorRepository $repository) {
$this->repository = $repository;
return $this;
}
public function setDiff(DifferentialDiff $diff) {
$this->diff = $diff;
return $this;
}
public function setRenderingReferences(array $references) {
$this->references = $references;
return $this;
}
public function setSymbolIndexes(array $indexes) {
$this->symbolIndexes = $indexes;
return $this;
}
public function setRenderURI($render_uri) {
$this->renderURI = $render_uri;
return $this;
}
public function setWhitespace($whitespace) {
$this->whitespace = $whitespace;
return $this;
}
public function setVsMap(array $vs_map) {
$this->vsMap = $vs_map;
return $this;
}
public function getVsMap() {
return $this->vsMap;
}
public function setStandaloneURI($uri) {
$this->standaloneURI = $uri;
return $this;
}
public function setRawFileURIs($l, $r) {
$this->leftRawFileURI = $l;
$this->rightRawFileURI = $r;
return $this;
}
public function render() {
require_celerity_resource('differential-changeset-view-css');
$changesets = $this->changesets;
Javelin::initBehavior('differential-toggle-files', array());
$output = array();
$mapping = array();
foreach ($changesets as $key => $changeset) {
$file = $changeset->getFilename();
$class = 'differential-changeset';
if (!$this->inlineURI) {
$class .= ' differential-changeset-noneditable';
}
$ref = $this->references[$key];
$detail = new DifferentialChangesetDetailView();
$view_options = $this->renderViewOptionsDropdown(
$detail,
$ref,
$changeset);
$detail->setChangeset($changeset);
$detail->addButton($view_options);
$detail->setSymbolIndex(idx($this->symbolIndexes, $key));
$detail->setVsChangesetID(idx($this->vsMap, $changeset->getID()));
$detail->setEditable(true);
$uniq_id = 'diff-'.$changeset->getAnchorName();
if (isset($this->visibleChangesets[$key])) {
$load = 'Loading...';
$mapping[$uniq_id] = $ref;
} else {
$load = javelin_tag(
'a',
array(
'href' => '#'.$uniq_id,
'meta' => array(
'id' => $uniq_id,
'ref' => $ref,
'kill' => true,
),
'sigil' => 'differential-load',
'mustcapture' => true,
),
pht('Load'));
}
$detail->appendChild(
phutil_tag(
'div',
array(
'id' => $uniq_id,
),
phutil_tag('div', array('class' => 'differential-loading'), $load)));
$output[] = $detail->render();
}
require_celerity_resource('aphront-tooltip-css');
Javelin::initBehavior('differential-populate', array(
'registry' => $mapping,
'whitespace' => $this->whitespace,
'uri' => $this->renderURI,
));
Javelin::initBehavior('differential-show-more', array(
'uri' => $this->renderURI,
'whitespace' => $this->whitespace,
));
Javelin::initBehavior('differential-comment-jump', array());
if ($this->inlineURI) {
$undo_templates = $this->renderUndoTemplates();
Javelin::initBehavior('differential-edit-inline-comments', array(
'uri' => $this->inlineURI,
'undo_templates' => $undo_templates,
'stage' => 'differential-review-stage',
));
}
- return $this->renderSingleView(
- array(
- id(new PhabricatorHeaderView())
- ->setHeader($this->getTitle())
- ->render(),
- phutil_tag(
- 'div',
- array(
- 'class' => 'differential-review-stage',
- 'id' => 'differential-review-stage',
- ),
- $output),
- ));
+ return array(
+ id(new PhabricatorHeaderView())
+ ->setHeader($this->getTitle())
+ ->render(),
+ phutil_tag(
+ 'div',
+ array(
+ 'class' => 'differential-review-stage',
+ 'id' => 'differential-review-stage',
+ ),
+ $output),
+ );
}
/**
* Render the "Undo" markup for the inline comment undo feature.
*/
private function renderUndoTemplates() {
$link = javelin_tag(
'a',
array(
'href' => '#',
'sigil' => 'differential-inline-comment-undo',
),
pht('Undo'));
$div = phutil_tag(
'div',
array(
'class' => 'differential-inline-undo',
),
array('Changes discarded. ', $link));
return array(
'l' => hsprintf(
'<table><tr>'.
'<th></th><td>%s</td>'.
'<th></th><td colspan="3"></td>'.
'</tr></table>',
$div),
'r' => hsprintf(
'<table><tr>'.
'<th></th><td></td>'.
'<th></th><td colspan="3">%s</td>'.
'</tr></table>',
$div),
);
}
private function renderViewOptionsDropdown(
DifferentialChangesetDetailView $detail,
$ref,
DifferentialChangeset $changeset) {
$meta = array();
$qparams = array(
'ref' => $ref,
'whitespace' => $this->whitespace,
);
if ($this->standaloneURI) {
$uri = new PhutilURI($this->standaloneURI);
$uri->setQueryParams($uri->getQueryParams() + $qparams);
$meta['standaloneURI'] = (string)$uri;
}
$repository = $this->repository;
if ($repository) {
try {
$meta['diffusionURI'] =
(string)$repository->getDiffusionBrowseURIForPath(
$changeset->getAbsoluteRepositoryPath($repository, $this->diff),
idx($changeset->getMetadata(), 'line:first'),
$this->getBranch());
} catch (DiffusionSetupException $e) {
// Ignore
}
}
$change = $changeset->getChangeType();
if ($this->leftRawFileURI) {
if ($change != DifferentialChangeType::TYPE_ADD) {
$uri = new PhutilURI($this->leftRawFileURI);
$uri->setQueryParams($uri->getQueryParams() + $qparams);
$meta['leftURI'] = (string)$uri;
}
}
if ($this->rightRawFileURI) {
if ($change != DifferentialChangeType::TYPE_DELETE &&
$change != DifferentialChangeType::TYPE_MULTICOPY) {
$uri = new PhutilURI($this->rightRawFileURI);
$uri->setQueryParams($uri->getQueryParams() + $qparams);
$meta['rightURI'] = (string)$uri;
}
}
$user = $this->user;
if ($user && $repository) {
$path = ltrim(
$changeset->getAbsoluteRepositoryPath($repository, $this->diff),
'/');
$line = idx($changeset->getMetadata(), 'line:first', 1);
$callsign = $repository->getCallsign();
$editor_link = $user->loadEditorLink($path, $line, $callsign);
if ($editor_link) {
$meta['editor'] = $editor_link;
} else {
$meta['editorConfigure'] = '/settings/panel/display/';
}
}
$meta['containerID'] = $detail->getID();
Javelin::initBehavior(
'differential-dropdown-menus',
array());
return javelin_tag(
'a',
array(
'class' => 'button small grey',
'meta' => $meta,
'href' => idx($meta, 'detailURI', '#'),
'target' => '_blank',
'sigil' => 'differential-view-options',
),
pht("View Options \xE2\x96\xBC"));
}
}
diff --git a/src/applications/differential/view/DifferentialRevisionCommentView.php b/src/applications/differential/view/DifferentialRevisionCommentView.php
index 226e9a9e82..c7499ddcca 100644
--- a/src/applications/differential/view/DifferentialRevisionCommentView.php
+++ b/src/applications/differential/view/DifferentialRevisionCommentView.php
@@ -1,305 +1,305 @@
<?php
final class DifferentialRevisionCommentView extends AphrontView {
private $comment;
private $handles;
private $markupEngine;
private $preview;
private $inlines;
private $changesets;
private $target;
private $anchorName;
private $versusDiffID;
public function setComment($comment) {
$this->comment = $comment;
return $this;
}
public function setHandles(array $handles) {
assert_instances_of($handles, 'PhabricatorObjectHandle');
$this->handles = $handles;
return $this;
}
public function setMarkupEngine(PhabricatorMarkupEngine $markup_engine) {
$this->markupEngine = $markup_engine;
return $this;
}
public function setPreview($preview) {
$this->preview = $preview;
return $this;
}
public function setInlineComments(array $inline_comments) {
assert_instances_of($inline_comments, 'PhabricatorInlineCommentInterface');
$this->inlines = $inline_comments;
return $this;
}
public function setChangesets(array $changesets) {
assert_instances_of($changesets, 'DifferentialChangeset');
// Ship these in sorted by getSortKey() and keyed by ID... or else!
$this->changesets = $changesets;
return $this;
}
public function setTargetDiff($target) {
$this->target = $target;
return $this;
}
public function setVersusDiffID($diff_vs) {
$this->versusDiffID = $diff_vs;
return $this;
}
public function setAnchorName($anchor_name) {
$this->anchorName = $anchor_name;
return $this;
}
public function render() {
if (!$this->user) {
throw new Exception("Call setUser() before rendering!");
}
require_celerity_resource('phabricator-remarkup-css');
require_celerity_resource('differential-revision-comment-css');
$comment = $this->comment;
$action = $comment->getAction();
$action_class = 'differential-comment-action-'.$action;
$info = array();
$content = $comment->getContent();
$hide_comments = true;
if (strlen(rtrim($content))) {
$hide_comments = false;
$content = $this->markupEngine->getOutput(
$comment,
PhabricatorInlineCommentInterface::MARKUP_FIELD_BODY);
$content = hsprintf(
'<div class="phabricator-remarkup">%s</div>',
$content);
}
$inline_render = $this->renderInlineComments();
if ($inline_render) {
$hide_comments = false;
}
$author = $this->handles[$comment->getAuthorPHID()];
$author_link = $author->renderLink();
$metadata = $comment->getMetadata();
$added_reviewers = idx(
$metadata,
DifferentialComment::METADATA_ADDED_REVIEWERS,
array());
$removed_reviewers = idx(
$metadata,
DifferentialComment::METADATA_REMOVED_REVIEWERS,
array());
$added_ccs = idx(
$metadata,
DifferentialComment::METADATA_ADDED_CCS,
array());
$verb = DifferentialAction::getActionPastTenseVerb($comment->getAction());
$actions = array();
// TODO: i18n
switch ($comment->getAction()) {
case DifferentialAction::ACTION_ADDCCS:
$actions[] = hsprintf(
"%s added CCs: %s.",
$author_link,
$this->renderHandleList($added_ccs));
$added_ccs = null;
break;
case DifferentialAction::ACTION_ADDREVIEWERS:
$actions[] = hsprintf(
"%s added reviewers: %s.",
$author_link,
$this->renderHandleList($added_reviewers));
$added_reviewers = null;
break;
case DifferentialAction::ACTION_UPDATE:
$diff_id = idx($metadata, DifferentialComment::METADATA_DIFF_ID);
if ($diff_id) {
$diff_link = phutil_tag(
'a',
array(
'href' => '/D'.$comment->getRevisionID().'?id='.$diff_id,
),
'Diff #'.$diff_id);
$actions[] = hsprintf(
"%s updated this revision to %s.",
$author_link,
$diff_link);
} else {
$actions[] = hsprintf(
"%s %s this revision.",
$author_link,
$verb);
}
break;
default:
$actions[] = hsprintf(
"%s %s this revision.",
$author_link,
$verb);
break;
}
if ($added_reviewers) {
$actions[] = hsprintf(
"%s added reviewers: %s.",
$author_link,
$this->renderHandleList($added_reviewers));
}
if ($removed_reviewers) {
$actions[] = hsprintf(
"%s removed reviewers: %s.",
$author_link,
$this->renderHandleList($removed_reviewers));
}
if ($added_ccs) {
$actions[] = hsprintf(
"%s added CCs: %s.",
$author_link,
$this->renderHandleList($added_ccs));
}
foreach ($actions as $key => $action) {
$actions[$key] = phutil_tag('div', array(), $action);
}
$xaction_view = id(new PhabricatorTransactionView())
->setUser($this->user)
->setImageURI($author->getImageURI())
->setContentSource($comment->getContentSource())
->addClass($action_class)
->setActions($actions);
if ($this->preview) {
$xaction_view->setIsPreview($this->preview);
} else {
$xaction_view->setEpoch($comment->getDateCreated());
if ($this->anchorName) {
$anchor_text =
'D'.$comment->getRevisionID().
'#'.preg_replace('/^comment-/', '', $this->anchorName);
$xaction_view->setAnchor($this->anchorName, $anchor_text);
}
}
if (!$hide_comments) {
$xaction_view->appendChild(hsprintf(
'<div class="differential-comment-core">%s%s</div>',
$content,
- $this->renderSingleView($inline_render)));
+ $inline_render));
}
return $xaction_view->render();
}
private function renderHandleList(array $phids) {
$result = array();
foreach ($phids as $phid) {
$result[] = $this->handles[$phid]->renderLink();
}
return phutil_implode_html(', ', $result);
}
private function renderInlineComments() {
if (!$this->inlines) {
return null;
}
$inlines = $this->inlines;
$changesets = $this->changesets;
$inlines_by_changeset = mgroup($inlines, 'getChangesetID');
$inlines_by_changeset = array_select_keys(
$inlines_by_changeset,
array_keys($this->changesets));
$view = new PhabricatorInlineSummaryView();
foreach ($inlines_by_changeset as $changeset_id => $inlines) {
$changeset = $changesets[$changeset_id];
$items = array();
foreach ($inlines as $inline) {
$on_target = ($this->target) &&
($this->target->getID() == $changeset->getDiffID());
$is_visible = false;
if ($inline->getIsNewFile()) {
// This comment is on the right side of the versus diff, and visible
// on the left side of the page.
if ($this->versusDiffID) {
if ($changeset->getDiffID() == $this->versusDiffID) {
$is_visible = true;
}
}
// This comment is on the right side of the target diff, and visible
// on the right side of the page.
if ($on_target) {
$is_visible = true;
}
} else {
// Ths comment is on the left side of the target diff, and visible
// on the left side of the page.
if (!$this->versusDiffID) {
if ($on_target) {
$is_visible = true;
}
}
// TODO: We still get one edge case wrong here, when we have a
// versus diff and the file didn't exist in the old version. The
// comment is visible because we show the left side of the target
// diff when there's no corresponding file in the versus diff, but
// we incorrectly link it off-page.
}
$item = array(
'id' => $inline->getID(),
'line' => $inline->getLineNumber(),
'length' => $inline->getLineLength(),
'content' => $this->markupEngine->getOutput(
$inline,
DifferentialInlineComment::MARKUP_FIELD_BODY),
);
if (!$is_visible) {
$diff_id = $changeset->getDiffID();
$item['where'] = '(On Diff #'.$diff_id.')';
$item['href'] =
'D'.$this->comment->getRevisionID().
'?id='.$diff_id.
'#inline-'.$inline->getID();
}
$items[] = $item;
}
$view->addCommentGroup($changeset->getFilename(), $items);
}
return $view;
}
}
diff --git a/src/applications/diffusion/view/DiffusionCommentView.php b/src/applications/diffusion/view/DiffusionCommentView.php
index 890052e667..94a743d97f 100644
--- a/src/applications/diffusion/view/DiffusionCommentView.php
+++ b/src/applications/diffusion/view/DiffusionCommentView.php
@@ -1,209 +1,209 @@
<?php
final class DiffusionCommentView extends AphrontView {
private $comment;
private $commentNumber;
private $handles;
private $isPreview;
private $pathMap;
private $inlineComments;
private $markupEngine;
public function setComment(PhabricatorAuditComment $comment) {
$this->comment = $comment;
return $this;
}
public function setCommentNumber($comment_number) {
$this->commentNumber = $comment_number;
return $this;
}
public function setHandles(array $handles) {
assert_instances_of($handles, 'PhabricatorObjectHandle');
$this->handles = $handles;
return $this;
}
public function setIsPreview($is_preview) {
$this->isPreview = $is_preview;
return $this;
}
public function setInlineComments(array $inline_comments) {
assert_instances_of($inline_comments, 'PhabricatorInlineCommentInterface');
$this->inlineComments = $inline_comments;
return $this;
}
public function setPathMap(array $path_map) {
$this->pathMap = $path_map;
return $this;
}
public function setMarkupEngine(PhabricatorMarkupEngine $markup_engine) {
$this->markupEngine = $markup_engine;
return $this;
}
public function getMarkupEngine() {
return $this->markupEngine;
}
public function getRequiredHandlePHIDs() {
return array($this->comment->getActorPHID());
}
private function getHandle($phid) {
if (empty($this->handles[$phid])) {
throw new Exception("Unloaded handle '{$phid}'!");
}
return $this->handles[$phid];
}
public function render() {
$comment = $this->comment;
$author = $this->getHandle($comment->getActorPHID());
$author_link = $author->renderLink();
$actions = $this->renderActions();
$content = $this->renderContent();
$classes = $this->renderClasses();
$xaction_view = id(new PhabricatorTransactionView())
->setUser($this->user)
->setImageURI($author->getImageURI())
->setActions($actions)
->appendChild($content);
if ($this->isPreview) {
$xaction_view->setIsPreview(true);
} else {
$xaction_view
->setAnchor('comment-'.$this->commentNumber, '#'.$this->commentNumber)
->setEpoch($comment->getDateCreated());
}
foreach ($classes as $class) {
$xaction_view->addClass($class);
}
return $xaction_view->render();
}
private function renderActions() {
$comment = $this->comment;
$author = $this->getHandle($comment->getActorPHID());
$author_link = $author->renderLink();
$action = $comment->getAction();
$verb = PhabricatorAuditActionConstants::getActionPastTenseVerb($action);
$metadata = $comment->getMetadata();
$added_auditors = idx(
$metadata,
PhabricatorAuditComment::METADATA_ADDED_AUDITORS,
array());
$added_ccs = idx(
$metadata,
PhabricatorAuditComment::METADATA_ADDED_CCS,
array());
$actions = array();
if ($action == PhabricatorAuditActionConstants::ADD_CCS) {
$rendered_ccs = $this->renderHandleList($added_ccs);
$actions[] = hsprintf("%s added CCs: %s.", $author_link, $rendered_ccs);
} else if ($action == PhabricatorAuditActionConstants::ADD_AUDITORS) {
$rendered_auditors = $this->renderHandleList($added_auditors);
$actions[] = hsprintf(
"%s added auditors: %s.",
$author_link,
$rendered_auditors);
} else {
$actions[] = hsprintf("%s %s this commit.", $author_link, $verb);
}
foreach ($actions as $key => $action) {
$actions[$key] = phutil_tag('div', array(), $action);
}
return $actions;
}
private function renderContent() {
$comment = $this->comment;
$engine = $this->getMarkupEngine();
if (!strlen($comment->getContent()) && empty($this->inlineComments)) {
return null;
} else {
return hsprintf(
'<div class="phabricator-remarkup">%s%s</div>',
$engine->getOutput(
$comment,
PhabricatorAuditComment::MARKUP_FIELD_BODY),
- $this->renderSingleView($this->renderInlines()));
+ $this->renderInlines());
}
}
private function renderInlines() {
if (!$this->inlineComments) {
return null;
}
$engine = $this->getMarkupEngine();
$inlines_by_path = mgroup($this->inlineComments, 'getPathID');
$view = new PhabricatorInlineSummaryView();
foreach ($inlines_by_path as $path_id => $inlines) {
$path = idx($this->pathMap, $path_id);
if ($path === null) {
continue;
}
$items = array();
foreach ($inlines as $inline) {
$items[] = array(
'id' => $inline->getID(),
'line' => $inline->getLineNumber(),
'length' => $inline->getLineLength(),
'content' => $engine->getOutput(
$inline,
PhabricatorInlineCommentInterface::MARKUP_FIELD_BODY),
);
}
$view->addCommentGroup($path, $items);
}
return $view;
}
private function renderHandleList(array $phids) {
$result = array();
foreach ($phids as $phid) {
$result[] = $this->handles[$phid]->renderLink();
}
return phutil_implode_html(', ', $result);
}
private function renderClasses() {
$comment = $this->comment;
$classes = array();
switch ($comment->getAction()) {
case PhabricatorAuditActionConstants::ACCEPT:
$classes[] = 'audit-accept';
break;
case PhabricatorAuditActionConstants::CONCERN:
$classes[] = 'audit-concern';
break;
}
return $classes;
}
}
diff --git a/src/applications/feed/view/PhabricatorFeedStoryView.php b/src/applications/feed/view/PhabricatorFeedStoryView.php
index fb2d8df8f1..20c8fe0155 100644
--- a/src/applications/feed/view/PhabricatorFeedStoryView.php
+++ b/src/applications/feed/view/PhabricatorFeedStoryView.php
@@ -1,125 +1,125 @@
<?php
final class PhabricatorFeedStoryView extends PhabricatorFeedView {
private $title;
private $image;
private $phid;
private $epoch;
private $viewed;
private $href;
private $oneLine;
public function setTitle($title) {
$this->title = $title;
return $this;
}
public function setEpoch($epoch) {
$this->epoch = $epoch;
return $this;
}
public function setImage($image) {
$this->image = $image;
return $this;
}
public function setOneLineStory($one_line) {
$this->oneLine = $one_line;
return $this;
}
public function setViewed($viewed) {
$this->viewed = $viewed;
return $this;
}
public function getViewed() {
return $this->viewed;
}
public function setHref($href) {
$this->href = $href;
return $this;
}
public function getHref() {
return $this->href;
}
public function renderNotification() {
$classes = array(
'phabricator-notification',
);
if (!$this->viewed) {
$classes[] = 'phabricator-notification-unread';
}
return javelin_tag(
'div',
array(
'class' => implode(' ', $classes),
'sigil' => 'notification',
'meta' => array(
'href' => $this->getHref(),
),
),
$this->title);
}
public function render() {
$head = phutil_tag(
'div',
array(
'class' => 'phabricator-feed-story-head',
),
nonempty($this->title, 'Untitled Story'));
$body = null;
$foot = null;
$image_style = null;
if (!$this->oneLine) {
$body = phutil_tag(
'div',
array(
'class' => 'phabricator-feed-story-body',
),
$this->renderChildren());
if ($this->epoch) {
$foot = phabricator_datetime($this->epoch, $this->user);
} else {
$foot = '';
}
$foot = phutil_tag(
'div',
array(
'class' => 'phabricator-feed-story-foot',
),
$foot);
if ($this->image) {
$image_style = 'background-image: url('.$this->image.')';
}
}
require_celerity_resource('phabricator-feed-css');
return phutil_tag(
'div',
array(
'class' => $this->oneLine
? 'phabricator-feed-story phabricator-feed-story-one-line'
: 'phabricator-feed-story',
'style' => $image_style,
),
- $this->renderSingleView(array($head, $body, $foot)));
+ array($head, $body, $foot));
}
}
diff --git a/src/applications/maniphest/view/ManiphestTaskListView.php b/src/applications/maniphest/view/ManiphestTaskListView.php
index aa8baac074..556d460753 100644
--- a/src/applications/maniphest/view/ManiphestTaskListView.php
+++ b/src/applications/maniphest/view/ManiphestTaskListView.php
@@ -1,51 +1,51 @@
<?php
/**
* @group maniphest
*/
final class ManiphestTaskListView extends ManiphestView {
private $tasks;
private $handles;
private $showBatchControls;
private $showSubpriorityControls;
public function setTasks(array $tasks) {
assert_instances_of($tasks, 'ManiphestTask');
$this->tasks = $tasks;
return $this;
}
public function setHandles(array $handles) {
assert_instances_of($handles, 'PhabricatorObjectHandle');
$this->handles = $handles;
return $this;
}
public function setShowBatchControls($show_batch_controls) {
$this->showBatchControls = $show_batch_controls;
return $this;
}
public function setShowSubpriorityControls($show_subpriority_controls) {
$this->showSubpriorityControls = $show_subpriority_controls;
return $this;
}
public function render() {
$views = array();
foreach ($this->tasks as $task) {
$view = new ManiphestTaskSummaryView();
$view->setTask($task);
$view->setShowBatchControls($this->showBatchControls);
$view->setShowSubpriorityControls($this->showSubpriorityControls);
$view->setUser($this->user);
$view->setHandles($this->handles);
$views[] = $view->render();
}
- return $this->renderSingleView($views);
+ return $views;
}
}
diff --git a/src/applications/maniphest/view/ManiphestTaskProjectsView.php b/src/applications/maniphest/view/ManiphestTaskProjectsView.php
index f292157a91..db9d4959db 100644
--- a/src/applications/maniphest/view/ManiphestTaskProjectsView.php
+++ b/src/applications/maniphest/view/ManiphestTaskProjectsView.php
@@ -1,58 +1,58 @@
<?php
/**
* @group maniphest
*/
final class ManiphestTaskProjectsView extends ManiphestView {
private $handles;
public function setHandles(array $handles) {
assert_instances_of($handles, 'PhabricatorObjectHandle');
$this->handles = $handles;
return $this;
}
public function render() {
require_celerity_resource('phabricator-project-tag-css');
$show = array_slice($this->handles, 0, 2);
$tags = array();
foreach ($show as $handle) {
$tags[] = phutil_tag(
'a',
array(
'href' => $handle->getURI(),
'class' => 'phabricator-project-tag',
),
phutil_utf8_shorten($handle->getName(), 24));
}
if (count($this->handles) > 2) {
require_celerity_resource('aphront-tooltip-css');
Javelin::initBehavior('phabricator-tooltips');
$all = array();
foreach ($this->handles as $handle) {
$all[] = $handle->getName();
}
$tags[] = javelin_tag(
'span',
array(
'class' => 'phabricator-project-tag',
'sigil' => 'has-tooltip',
'meta' => array(
'tip' => implode(', ', $all),
'size' => 200,
),
),
"\xE2\x80\xA6");
}
- return $this->renderSingleView($tags);
+ return $tags;
}
}
diff --git a/src/applications/meta/view/PhabricatorApplicationLaunchView.php b/src/applications/meta/view/PhabricatorApplicationLaunchView.php
index 261944bfe4..0a6e2e46ef 100644
--- a/src/applications/meta/view/PhabricatorApplicationLaunchView.php
+++ b/src/applications/meta/view/PhabricatorApplicationLaunchView.php
@@ -1,182 +1,177 @@
<?php
final class PhabricatorApplicationLaunchView extends AphrontView {
private $application;
private $status;
private $fullWidth;
public function setFullWidth($full_width) {
$this->fullWidth = $full_width;
return $this;
}
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;
$create_button = null;
if ($application) {
$content[] = phutil_tag(
'span',
array(
'class' => 'phabricator-application-launch-name',
),
$application->getName());
if ($application->isBeta()) {
$content[] = phutil_tag(
'span',
array(
'class' => 'phabricator-application-beta',
),
"\xCE\xB2");
}
if ($this->fullWidth) {
$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]);
}
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',
),
array($count1, $count2));
}
$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';
$classes[] = 'app-'.$icon.'-light-large';
}
$icon = phutil_tag(
'span',
array(
'class' => implode(' ', $classes),
'style' => nonempty(implode('; ', $styles), null),
),
'');
$classes = array();
if ($application->getQuickCreateURI()) {
$classes[] = 'phabricator-application-create-icon';
$classes[] = 'sprite-icon';
$classes[] = 'action-new-grey';
$plus_icon = phutil_tag(
'span',
array(
'class' => implode(' ', $classes),
),
'');
$create_button = phutil_tag(
'a',
array(
'href' => $application->getQuickCreateURI(),
'class' => 'phabricator-application-launch-create',
),
$plus_icon);
$classes = array();
$classes[] = 'application-tile-create';
}
}
$classes[] = 'phabricator-application-launch-container';
if ($this->fullWidth) {
$classes[] = 'application-tile-full';
}
$title = null;
if ($application && !$this->fullWidth) {
$title = $application->getShortDescription();
}
$app_button = phutil_tag(
$application ? 'a' : 'div',
array(
'class' => implode(' ', $classes),
'href' => $application ? $application->getBaseURI() : null,
'title' => $title,
),
- $this->renderSingleView(
- array(
- $icon,
- $content,
- )));
-
- return $this->renderSingleView(
array(
- $app_button,
- $create_button,
+ $icon,
+ $content,
));
+
+ return array($app_button, $create_button);
}
}
diff --git a/src/applications/pholio/view/PholioInlineCommentEditView.php b/src/applications/pholio/view/PholioInlineCommentEditView.php
index 228888be58..862e72aebe 100644
--- a/src/applications/pholio/view/PholioInlineCommentEditView.php
+++ b/src/applications/pholio/view/PholioInlineCommentEditView.php
@@ -1,144 +1,141 @@
<?php
/**
* @group pholio
*/
final class PholioInlineCommentEditView extends AphrontView {
private $inputs = array();
private $uri;
private $title;
private $inlineComment;
public function addHiddenInput($key, $value) {
$this->inputs[] = array($key, $value);
return $this;
}
public function setSubmitURI($uri) {
$this->uri = $uri;
return $this;
}
public function setTitle($title) {
$this->title = $title;
return $this;
}
public function setInlineComment($inline_comment) {
$this->inlineComment = $inline_comment;
return $this;
}
public function render() {
if (!$this->uri) {
throw new Exception("Call setSubmitURI() before render()!");
}
if (!$this->user) {
throw new Exception("Call setUser() before render()!");
}
$content = phabricator_form(
$this->user,
array(
'action' => $this->uri,
'method' => 'POST',
'sigil' => 'inline-edit-form',
),
- $this->renderSingleView(
- array(
- $this->renderInputs(),
- $this->renderBody(),
- )));
+ array(
+ $this->renderInputs(),
+ $this->renderBody(),
+ ));
return $content;
}
private function renderInputs() {
$out = array();
foreach ($this->inputs as $input) {
list($name, $value) = $input;
$out[] = phutil_tag(
'input',
array(
'type' => 'hidden',
'name' => $name,
'value' => $value,
));
}
return $out;
}
private function renderBody() {
$buttons = array();
$buttons[] = javelin_tag(
'button',
array(
'sigil' => 'inline-edit-submit',
'meta' => array(
'id' => $this->inlineComment->getID(),
'phid' => $this->inlineComment->getPHID()
)
),
pht('Ready'));
$buttons[] = javelin_tag(
'button',
array(
'sigil' => 'inline-edit-cancel',
'meta' => array(
'id' => $this->inlineComment->getID()
),
'class' => 'grey',
),
pht('Cancel'));
$formatting = phutil_tag(
'a',
array(
'href' => PhabricatorEnv::getDoclink(
'article/Remarkup_Reference.html'),
'tabindex' => '-1',
'target' => '_blank',
),
pht('Formatting Reference'));
$title = phutil_tag(
'div',
array(
'class' => 'pholio-inline-comment-dialog-title',
),
$this->title);
$body = phutil_tag(
'div',
array(),
$this->renderChildren());
$edit = phutil_tag(
'edit',
array(
'class' => 'pholio-inline-comment-dialog-buttons',
),
- $this->renderSingleView(
- array(
- $formatting,
- $buttons,
- phutil_tag('div', array('style' => 'clear: both'), ''),
- )));
+ array(
+ $formatting,
+ $buttons,
+ phutil_tag('div', array('style' => 'clear: both'), ''),
+ ));
return javelin_tag(
'div',
array(
'class' => 'pholio-inline-comment-dialog',
),
- $this->renderSingleView(
- array(
- $title,
- $body,
- $edit,
- )));
+ array(
+ $title,
+ $body,
+ $edit,
+ ));
}
}
diff --git a/src/applications/pholio/view/PholioInlineCommentSaveView.php b/src/applications/pholio/view/PholioInlineCommentSaveView.php
index c5f0897748..da5b361523 100644
--- a/src/applications/pholio/view/PholioInlineCommentSaveView.php
+++ b/src/applications/pholio/view/PholioInlineCommentSaveView.php
@@ -1,131 +1,128 @@
<?php
/**
* @group pholio
*/
final class PholioInlineCommentSaveView extends AphrontView {
private $inputs = array();
private $uri;
private $title;
public function addHiddenInput($key, $value) {
$this->inputs[] = array($key, $value);
return $this;
}
public function setSubmitURI($uri) {
$this->uri = $uri;
return $this;
}
public function setTitle($title) {
$this->title = $title;
return $this;
}
public function render() {
if (!$this->uri) {
throw new Exception("Call setSubmitURI() before render()!");
}
if (!$this->user) {
throw new Exception("Call setUser() before render()!");
}
$content = phabricator_form(
$this->user,
array(
'action' => $this->uri,
'method' => 'POST',
'sigil' => 'inline-save-form',
'class' => 'pholio-new-inline-comment',
'id' => 'pholio-new-inline-comment-dialog'
),
- $this->renderSingleView(
- array(
- $this->renderInputs(),
- $this->renderBody(),
- )));
+ array(
+ $this->renderInputs(),
+ $this->renderBody(),
+ ));
return $content;
}
private function renderInputs() {
$out = array();
foreach ($this->inputs as $input) {
list($name, $value) = $input;
$out[] = phutil_tag(
'input',
array(
'type' => 'hidden',
'name' => $name,
'value' => $value,
));
}
return $out;
}
private function renderBody() {
$buttons = array();
$buttons[] = javelin_tag(
'button',
array(
'sigil' => 'inline-save-submit',
),
pht('Done'));
$buttons[] = javelin_tag(
'button',
array(
'sigil' => 'inline-save-cancel',
'class' => 'grey',
),
pht('Cancel'));
$formatting = phutil_tag(
'a',
array(
'href' => PhabricatorEnv::getDoclink(
'article/Remarkup_Reference.html'),
'tabindex' => '-1',
'target' => '_blank',
),
pht('Formatting Reference'));
$title = phutil_tag(
'div',
array(
'class' => 'pholio-inline-comment-dialog-title',
),
$this->title);
$body = phutil_tag(
'div',
array(),
$this->renderChildren());
$edit = phutil_tag(
'edit',
array(
'class' => 'pholio-inline-comment-dialog-buttons',
),
- $this->renderSingleView(
- array(
- $formatting,
- $buttons,
- phutil_tag('div', array('style' => 'clear: both'), ''),
- )));
+ array(
+ $formatting,
+ $buttons,
+ phutil_tag('div', array('style' => 'clear: both'), ''),
+ ));
return javelin_tag(
'div',
array(
),
- $this->renderSingleView(
- array(
- $title,
- $body,
- $edit,
- )));
+ array(
+ $title,
+ $body,
+ $edit,
+ ));
}
}
diff --git a/src/applications/pholio/view/PholioInlineCommentView.php b/src/applications/pholio/view/PholioInlineCommentView.php
index 1ac2018659..2993be226b 100644
--- a/src/applications/pholio/view/PholioInlineCommentView.php
+++ b/src/applications/pholio/view/PholioInlineCommentView.php
@@ -1,136 +1,133 @@
<?php
final class PholioInlineCommentView extends AphrontView {
private $engine;
private $handle;
private $inlineComment;
public function setEngine(PhabricatorMarkupEngine $engine) {
$this->engine = $engine;
return $this;
}
public function setHandle(PhabricatorObjectHandle $handle) {
$this->handle = $handle;
return $this;
}
public function setInlineComment(PholioTransactionComment $inline_comment) {
if ($inline_comment->getImageID() === null) {
throw new Exception("Comment provided is not inline comment");
}
$this->inlineComment = $inline_comment;
return $this;
}
public function render() {
if (!$this->inlineComment) {
throw new Exception("Call setInlineComment() before render()!");
}
if ($this->user === null) {
throw new Exception("Call setUser() before render()!");
}
if ($this->engine === null) {
throw new Exception("Call setEngine() before render()!");
}
if ($this->handle === null) {
throw new Exception("Call setHandle() before render()!");
}
$actions = null;
$inline = $this->inlineComment;
$phid = $inline->getPHID();
$id = $inline->getID();
$user = $this->user;
$is_draft = ($inline->getTransactionPHID() === null);
$can_edit = PhabricatorPolicyFilter::hasCapability(
$user,
$inline,
PhabricatorPolicyCapability::CAN_EDIT);
if ($is_draft && $can_edit) {
$draft = phutil_tag(
'span',
array(
'class' => 'pholio-inline-status',
),
pht('Not Submitted Yet'));
$edit_action = javelin_tag(
'a',
array(
'href' => '/pholio/inline/edit/'.$id.'/',
'sigil' => 'inline-edit',
'meta' => array(
'phid' => $phid,
'id' => $id,
)
),
pht('Edit'));
$delete_action = javelin_tag(
'a',
array(
'href' => '/pholio/inline/delete/'.$id.'/',
'sigil' => 'inline-delete',
'meta' => array(
'phid' => $phid,
'id' => $id,
)
),
pht('Delete'));
$actions = phutil_tag(
'span',
array(
'class' => 'pholio-inline-head-links'
),
phutil_implode_html(
" \xC2\xB7 ",
array($draft, $edit_action, $delete_action)));
}
$comment_header = phutil_tag(
'div',
array(
'class' => 'pholio-inline-comment-header'
),
array($this->handle->getName(), $actions));
$comment = $this->engine->renderOneObject(
$inline,
PholioTransactionComment::MARKUP_FIELD_COMMENT,
$this->user);
$comment_body = phutil_tag(
'div',
array(),
$comment);
$classes = array();
$classes[] = 'pholio-inline-comment';
if ($is_draft) {
$classes[] = 'pholio-inline-comment-draft';
}
- $comment_block = javelin_tag(
+ return javelin_tag(
'div',
array(
'id' => "{$phid}_comment",
'class' => implode(' ', $classes),
'sigil' => 'inline_comment',
'meta' => array(
'phid' => $phid,
)
),
array($comment_header, $comment_body));
-
-
- return $this->renderSingleView($comment_block);
}
}
diff --git a/src/applications/pholio/view/PholioMockEmbedView.php b/src/applications/pholio/view/PholioMockEmbedView.php
index 27f7674725..8cdc1d7ffe 100644
--- a/src/applications/pholio/view/PholioMockEmbedView.php
+++ b/src/applications/pholio/view/PholioMockEmbedView.php
@@ -1,106 +1,104 @@
<?php
final class PholioMockEmbedView extends AphrontView {
private $mock;
public function setMock(PholioMock $mock) {
$this->mock = $mock;
return $this;
}
public function render() {
if (!$this->mock) {
throw new Exception("Call setMock() before render()!");
}
require_celerity_resource('pholio-css');
$mock_link = phutil_tag(
'a',
array(
'href' => '/M'.$this->mock->getID(),
),
'M'.$this->mock->getID().' '.$this->mock->getName());
$mock_header = phutil_tag(
'div',
array(
'class' => 'pholio-mock-embed-head',
),
$mock_link);
$thumbnails = array();
foreach (array_slice($this->mock->getImages(), 0, 4) as $image) {
$thumbfile = $image->getFile();
$dimensions = PhabricatorImageTransformer::getPreviewDimensions(
$thumbfile,
140);
$tag = phutil_tag(
'img',
array(
'width' => $dimensions['sdx'],
'height' => $dimensions['sdy'],
'class' => 'pholio-mock-carousel-thumbnail',
'src' => $thumbfile->getPreview140URI(),
'style' => 'top: '.floor((140 - $dimensions['sdy'] ) / 2).'px',
));
$thumbnails[] = javelin_tag(
'a',
array(
'class' => 'pholio-mock-carousel-thumb-item',
'href' => '/M'.$this->mock->getID().'/'.$image->getID().'/',
),
$tag);
}
$mock_body = phutil_tag(
'div',
array(),
$thumbnails);
$icons_data = array(
'image' => count($this->mock->getImages()),
'like' => $this->mock->getTokenCount());
$icon_list = array();
foreach ($icons_data as $icon_name => $icon_value) {
$icon = phutil_tag(
'span',
array(
'class' =>
'pholio-mock-embed-icon sprite-icon action-'.$icon_name.'-grey',
),
' ');
$count = phutil_tag('span', array(), $icon_value);
$icon_list[] = phutil_tag(
'span',
array(
'class' => 'pholio-mock-embed-icons'
),
array($icon, $count));
}
$mock_footer = phutil_tag(
'div',
array(
'class' => 'pholio-mock-embed-footer',
),
$icon_list);
- $mock_view = phutil_tag(
+ return phutil_tag(
'div',
array(
'class' => 'pholio-mock-embed'
),
array($mock_header, $mock_body, $mock_footer));
-
- return $this->renderSingleView($mock_view);
}
}
diff --git a/src/applications/pholio/view/PholioMockImagesView.php b/src/applications/pholio/view/PholioMockImagesView.php
index a8f3a6c209..ef018537b6 100644
--- a/src/applications/pholio/view/PholioMockImagesView.php
+++ b/src/applications/pholio/view/PholioMockImagesView.php
@@ -1,163 +1,163 @@
<?php
final class PholioMockImagesView extends AphrontView {
private $mock;
private $imageID;
private $requestURI;
public function setRequestURI(PhutilURI $request_uri) {
$this->requestURI = $request_uri;
return $this;
}
public function getRequestURI() {
return $this->requestURI;
}
public function setImageID($image_id) {
$this->imageID = $image_id;
return $this;
}
public function getImageID() {
return $this->imageID;
}
public function setMock(PholioMock $mock) {
$this->mock = $mock;
return $this;
}
public function render() {
if (!$this->mock) {
throw new Exception("Call setMock() before render()!");
}
$mock = $this->mock;
require_celerity_resource('javelin-behavior-pholio-mock-view');
$images = array();
$panel_id = celerity_generate_unique_node_id();
$viewport_id = celerity_generate_unique_node_id();
$ids = mpull($mock->getImages(), 'getID');
if ($this->imageID && isset($ids[$this->imageID])) {
$selected_id = $this->imageID;
} else {
$selected_id = head_key($ids);
}
foreach ($mock->getImages() as $image) {
$file = $image->getFile();
$metadata = $file->getMetadata();
$x = idx($metadata, PhabricatorFile::METADATA_IMAGE_WIDTH);
$y = idx($metadata, PhabricatorFile::METADATA_IMAGE_HEIGHT);
$images[] = array(
'id' => $image->getID(),
'fullURI' => $image->getFile()->getBestURI(),
'pageURI' => '/M'.$mock->getID().'/'.$image->getID().'/',
'width' => $x,
'height' => $y,
'title' => $file->getName(),
'desc' => 'Lorem ipsum dolor sit amet: there is no way to set any '.
'descriptive text yet; were there, it would appear here.',
);
}
$login_uri = id(new PhutilURI('/login/'))
->setQueryParam('next', (string) $this->getRequestURI());
$config = array(
'mockID' => $mock->getID(),
'panelID' => $panel_id,
'viewportID' => $viewport_id,
'images' => $images,
'selectedID' => $selected_id,
'loggedIn' => $this->getUser()->isLoggedIn(),
'logInLink' => (string) $login_uri
);
Javelin::initBehavior('pholio-mock-view', $config);
$mockview = '';
$mock_wrapper = javelin_tag(
'div',
array(
'id' => $viewport_id,
'sigil' => 'mock-viewport',
'class' => 'pholio-mock-image-viewport'
),
'');
$mock_wrapper = javelin_tag(
'div',
array(
'id' => $panel_id,
'sigil' => 'mock-panel',
'class' => 'pholio-mock-image-panel',
),
$mock_wrapper);
$inline_comments_holder = javelin_tag(
'div',
array(
'id' => 'mock-inline-comments',
'sigil' => 'mock-inline-comments',
'class' => 'pholio-mock-inline-comments'
),
'');
$carousel_holder = '';
if (count($mock->getImages()) > 0) {
$thumbnails = array();
foreach ($mock->getImages() as $image) {
$thumbfile = $image->getFile();
$dimensions = PhabricatorImageTransformer::getPreviewDimensions(
$thumbfile,
140);
$tag = phutil_tag(
'img',
array(
'width' => $dimensions['sdx'],
'height' => $dimensions['sdy'],
'src' => $thumbfile->getPreview140URI(),
'class' => 'pholio-mock-carousel-thumbnail',
'style' => 'top: '.floor((140 - $dimensions['sdy'] ) / 2).'px',
));
$thumbnails[] = javelin_tag(
'a',
array(
'sigil' => 'mock-thumbnail',
'class' => 'pholio-mock-carousel-thumb-item',
'href' => '/M'.$mock->getID().'/'.$image->getID().'/',
'meta' => array(
'imageID' => $image->getID(),
),
),
$tag);
}
$carousel_holder = phutil_tag(
'div',
array(
'id' => 'pholio-mock-carousel',
'class' => 'pholio-mock-carousel',
),
$thumbnails);
}
$mockview[] = phutil_tag(
'div',
array(
'class' => 'pholio-mock-image-container',
'id' => 'pholio-mock-image-container'
),
array($mock_wrapper, $carousel_holder, $inline_comments_holder));
- return $this->renderSingleView($mockview);
+ return $mockview;
}
}
diff --git a/src/applications/transactions/view/PhabricatorApplicationTransactionCommentView.php b/src/applications/transactions/view/PhabricatorApplicationTransactionCommentView.php
index ec26997456..76eff67545 100644
--- a/src/applications/transactions/view/PhabricatorApplicationTransactionCommentView.php
+++ b/src/applications/transactions/view/PhabricatorApplicationTransactionCommentView.php
@@ -1,203 +1,197 @@
<?php
/**
* @concrete-extensible
*/
class PhabricatorApplicationTransactionCommentView extends AphrontView {
private $submitButtonName;
private $action;
private $previewPanelID;
private $previewTimelineID;
private $previewToggleID;
private $formID;
private $statusID;
private $commentID;
private $draft;
private $requestURI;
public function setRequestURI(PhutilURI $request_uri) {
$this->requestURI = $request_uri;
return $this;
}
public function getRequestURI() {
return $this->requestURI;
}
public function setDraft(PhabricatorDraft $draft) {
$this->draft = $draft;
return $this;
}
public function getDraft() {
return $this->draft;
}
public function setSubmitButtonName($submit_button_name) {
$this->submitButtonName = $submit_button_name;
return $this;
}
public function getSubmitButtonName() {
return $this->submitButtonName;
}
public function setAction($action) {
$this->action = $action;
return $this;
}
public function getAction() {
return $this->action;
}
public function render() {
$user = $this->getUser();
if (!$user->isLoggedIn()) {
$uri = id(new PhutilURI('/login/'))
->setQueryParam('next', (string) $this->getRequestURI());
- return self::renderSingleView(
- phutil_tag(
- 'div',
+ return phutil_tag(
+ 'div',
+ array(
+ 'class' => 'login-to-comment'
+ ),
+ javelin_tag(
+ 'a',
array(
- 'class' => 'login-to-comment'
+ 'class' => 'button',
+ 'sigil' => 'workflow',
+ 'href' => $uri
),
- javelin_tag(
- 'a',
- array(
- 'class' => 'button',
- 'sigil' => 'workflow',
- 'href' => $uri
- ),
- pht('Login to Comment'))));
+ pht('Login to Comment')));
}
$data = array();
$comment = $this->renderCommentPanel();
$preview = $this->renderPreviewPanel();
Javelin::initBehavior(
'phabricator-transaction-comment-form',
array(
'formID' => $this->getFormID(),
'timelineID' => $this->getPreviewTimelineID(),
'panelID' => $this->getPreviewPanelID(),
'statusID' => $this->getStatusID(),
'commentID' => $this->getCommentID(),
'loadingString' => pht('Loading Preview...'),
'savingString' => pht('Saving Draft...'),
'draftString' => pht('Saved Draft'),
'actionURI' => $this->getAction(),
'draftKey' => $this->getDraft()->getDraftKey(),
));
- return self::renderSingleView(
- array(
- $comment,
- $preview,
- ));
+ return array($comment, $preview);
}
private function renderCommentPanel() {
$status = phutil_tag(
'div',
array(
'id' => $this->getStatusID(),
),
'');
$draft_comment = '';
if ($this->getDraft()) {
$draft_comment = $this->getDraft()->getDraft();
}
return id(new AphrontFormView())
->setUser($this->getUser())
->setFlexible(true)
->addSigil('transaction-append')
->setWorkflow(true)
->setAction($this->getAction())
->setID($this->getFormID())
->appendChild(
id(new PhabricatorRemarkupControl())
->setID($this->getCommentID())
->setName('comment')
->setLabel(pht('Comment'))
->setUser($this->getUser())
->setValue($draft_comment))
->appendChild(
id(new AphrontFormSubmitControl())
->setValue($this->getSubmitButtonName()))
->appendChild(
id(new AphrontFormMarkupControl())
->setValue($status));
}
private function renderPreviewPanel() {
$preview = id(new PhabricatorTimelineView())
->setID($this->getPreviewTimelineID());
$header = phutil_tag(
'div',
array(
'class' => 'phabricator-timeline-preview-header',
),
pht('Preview'));
return phutil_tag(
'div',
array(
'id' => $this->getPreviewPanelID(),
'style' => 'display: none',
),
- self::renderSingleView(
- array(
- $header,
- $preview,
- )));
+ array(
+ $header,
+ $preview,
+ ));
}
private function getPreviewPanelID() {
if (!$this->previewPanelID) {
$this->previewPanelID = celerity_generate_unique_node_id();
}
return $this->previewPanelID;
}
private function getPreviewTimelineID() {
if (!$this->previewTimelineID) {
$this->previewTimelineID = celerity_generate_unique_node_id();
}
return $this->previewTimelineID;
}
private function getFormID() {
if (!$this->formID) {
$this->formID = celerity_generate_unique_node_id();
}
return $this->formID;
}
private function getStatusID() {
if (!$this->statusID) {
$this->statusID = celerity_generate_unique_node_id();
}
return $this->statusID;
}
private function getCommentID() {
if (!$this->commentID) {
$this->commentID = celerity_generate_unique_node_id();
}
return $this->commentID;
}
}
diff --git a/src/view/AphrontView.php b/src/view/AphrontView.php
index 0bd218c741..c9cf7ae6b6 100644
--- a/src/view/AphrontView.php
+++ b/src/view/AphrontView.php
@@ -1,73 +1,66 @@
<?php
abstract class AphrontView extends Phobject
implements PhutilSafeHTMLProducerInterface {
protected $user;
protected $children = array();
public function setUser(PhabricatorUser $user) {
$this->user = $user;
return $this;
}
protected function getUser() {
return $this->user;
}
protected function canAppendChild() {
return true;
}
final public function appendChild($child) {
if (!$this->canAppendChild()) {
$class = get_class($this);
throw new Exception(
pht("View '%s' does not support children.", $class));
}
$this->children[] = $child;
return $this;
}
final protected function renderChildren() {
- $out = array();
- foreach ($this->children as $child) {
- $out[] = $this->renderSingleView($child);
- }
- return $out;
+ return $this->children;
}
+ /**
+ * @deprecated
+ */
final protected function renderSingleView($child) {
- if ($child instanceof AphrontView) {
- return $child->render();
- } else if (is_array($child)) {
- $out = array();
- foreach ($child as $element) {
- $out[] = $this->renderSingleView($element);
- }
- return phutil_implode_html('', $out);
- } else {
- return $child;
- }
+ phutil_deprecated(
+ 'AphrontView->renderSingleView()',
+ "This method no longer does anything; it can be removed and replaced ".
+ "with its arguments.");
+ return $child;
}
final protected function isEmptyContent($content) {
if (is_array($content)) {
foreach ($content as $element) {
if (!$this->isEmptyContent($element)) {
return false;
}
}
return true;
} else {
return !strlen((string)$content);
}
}
abstract public function render();
public function producePhutilSafeHTML() {
return $this->render();
}
}
diff --git a/src/view/form/control/PhabricatorRemarkupControl.php b/src/view/form/control/PhabricatorRemarkupControl.php
index 3ca49c2120..a7b162b1c0 100644
--- a/src/view/form/control/PhabricatorRemarkupControl.php
+++ b/src/view/form/control/PhabricatorRemarkupControl.php
@@ -1,164 +1,163 @@
<?php
final class PhabricatorRemarkupControl extends AphrontFormTextAreaControl {
private $disableMacro = false;
public function setDisableMacros($disable) {
$this->disableMacro = $disable;
return $this;
}
protected function renderInput() {
$id = $this->getID();
if (!$id) {
$id = celerity_generate_unique_node_id();
$this->setID($id);
}
// We need to have this if previews render images, since Ajax can not
// currently ship JS or CSS.
require_celerity_resource('lightbox-attachment-css');
Javelin::initBehavior(
'aphront-drag-and-drop-textarea',
array(
'target' => $id,
'activatedClass' => 'aphront-textarea-drag-and-drop',
'uri' => '/file/dropupload/',
));
Javelin::initBehavior('phabricator-remarkup-assist', array());
Javelin::initBehavior('phabricator-tooltips', array());
$actions = array(
'b' => array(
'tip' => pht('Bold'),
),
'i' => array(
'tip' => pht('Italics'),
),
'tt' => array(
'tip' => pht('Monospaced'),
),
array(
'spacer' => true,
),
'ul' => array(
'tip' => pht('Bulleted List'),
),
'ol' => array(
'tip' => pht('Numbered List'),
),
'code' => array(
'tip' => pht('Code Block'),
),
'table' => array(
'tip' => pht('Table'),
)
);
if (!$this->disableMacro and function_exists('imagettftext')) {
$actions[] = array(
'spacer' => true,
);
$actions['meme'] = array(
'tip' => pht('Meme'),
);
}
$actions['help'] = array(
'tip' => pht('Help'),
'align' => 'right',
'href' => PhabricatorEnv::getDoclink(
'article/Remarkup_Reference.html'),
);
$buttons = array();
foreach ($actions as $action => $spec) {
if (idx($spec, 'spacer')) {
$buttons[] = phutil_tag(
'span',
array(
'class' => 'remarkup-assist-separator',
),
'');
continue;
}
$classes = array();
$classes[] = 'remarkup-assist-button';
if (idx($spec, 'align') == 'right') {
$classes[] = 'remarkup-assist-right';
}
$href = idx($spec, 'href', '#');
if ($href == '#') {
$meta = array('action' => $action);
$mustcapture = true;
$target = null;
} else {
$meta = array();
$mustcapture = null;
$target = '_blank';
}
$tip = idx($spec, 'tip');
if ($tip) {
$meta['tip'] = $tip;
}
require_celerity_resource('sprite-icon-css');
$buttons[] = javelin_tag(
'a',
array(
'class' => implode(' ', $classes),
'href' => $href,
'sigil' => 'remarkup-assist has-tooltip',
'meta' => $meta,
'mustcapture' => $mustcapture,
'target' => $target,
'tabindex' => -1,
),
phutil_tag(
'div',
array(
'class' => 'remarkup-assist sprite-icon remarkup-assist-'.$action,
),
''));
}
$buttons = phutil_tag(
'div',
array(
'class' => 'remarkup-assist-bar',
),
$buttons);
$monospaced_textareas = null;
$monospaced_textareas_class = null;
$user = $this->getUser();
if ($user) {
$monospaced_textareas = $user
->loadPreferences()
->getPreference(
PhabricatorUserPreferences::PREFERENCE_MONOSPACED_TEXTAREAS);
if ($monospaced_textareas == 'enabled') {
$monospaced_textareas_class = 'PhabricatorMonospaced';
}
}
$this->setCustomClass(
'remarkup-assist-textarea '.$monospaced_textareas_class);
return javelin_tag(
'div',
array(
'sigil' => 'remarkup-assist-control',
),
- $this->renderSingleView(
- array(
- $buttons,
- parent::renderInput(),
- )));
+ array(
+ $buttons,
+ parent::renderInput(),
+ ));
}
}
diff --git a/src/view/layout/AphrontCrumbsView.php b/src/view/layout/AphrontCrumbsView.php
index f73901f687..e9cee36a22 100644
--- a/src/view/layout/AphrontCrumbsView.php
+++ b/src/view/layout/AphrontCrumbsView.php
@@ -1,31 +1,31 @@
<?php
final class AphrontCrumbsView extends AphrontView {
private $crumbs = array();
public function setCrumbs(array $crumbs) {
$this->crumbs = $crumbs;
return $this;
}
public function render() {
require_celerity_resource('aphront-crumbs-view-css');
$out = array();
foreach ($this->crumbs as $crumb) {
- $out[] = $this->renderSingleView($crumb);
+ $out[] = $crumb;
}
$out = phutil_implode_html(
hsprintf('<span class="aphront-crumbs-spacer">'."\xC2\xBB".'</span>'),
$out);
return hsprintf(
'<div class="aphront-crumbs-view">'.
'<div class="aphront-crumbs-content">%s</div>'.
'</div>',
$out);
}
}
diff --git a/src/view/layout/AphrontSideNavFilterView.php b/src/view/layout/AphrontSideNavFilterView.php
index 2a38942edf..48e2c5e360 100644
--- a/src/view/layout/AphrontSideNavFilterView.php
+++ b/src/view/layout/AphrontSideNavFilterView.php
@@ -1,302 +1,301 @@
<?php
/**
* Provides a navigation sidebar. For example:
*
* $nav = new AphrontSideNavFilterView();
* $nav
* ->setBaseURI($some_uri)
* ->addLabel('Cats')
* ->addFilter('meow', 'Meow')
* ->addFilter('purr', 'Purr')
* ->addLabel('Dogs')
* ->addFilter('woof', 'Woof')
* ->addFilter('bark', 'Bark');
* $valid_filter = $nav->selectFilter($user_selection, $default = 'meow');
*
*/
final class AphrontSideNavFilterView extends AphrontView {
private $items = array();
private $baseURI;
private $selectedFilter = false;
private $flexible;
private $collapsed = false;
private $active;
private $menu;
private $crumbs;
private $classes = array();
private $menuID;
public function setMenuID($menu_id) {
$this->menuID = $menu_id;
return $this;
}
public function getMenuID() {
return $this->menuID;
}
public function __construct() {
$this->menu = new PhabricatorMenuView();
}
public function addClass($class) {
$this->classes[] = $class;
return $this;
}
public static function newFromMenu(PhabricatorMenuView $menu) {
$object = new AphrontSideNavFilterView();
$object->setBaseURI(new PhutilURI('/'));
$object->menu = $menu;
return $object;
}
public function setCrumbs(PhabricatorCrumbsView $crumbs) {
$this->crumbs = $crumbs;
return $this;
}
public function getCrumbs() {
return $this->crumbs;
}
public function setActive($active) {
$this->active = $active;
return $this;
}
public function setFlexible($flexible) {
$this->flexible = $flexible;
return $this;
}
public function setCollapsed($collapsed) {
$this->collapsed = $collapsed;
return $this;
}
public function getMenuView() {
return $this->menu;
}
public function addMenuItem(PhabricatorMenuItemView $item) {
$this->menu->addMenuItem($item);
return $this;
}
public function getMenu() {
return $this->menu;
}
public function addFilter($key, $name, $uri = null) {
return $this->addThing(
$key, $name, $uri, PhabricatorMenuItemView::TYPE_LINK);
}
public function addButton($key, $name, $uri = null) {
return $this->addThing(
$key, $name, $uri, PhabricatorMenuItemView::TYPE_BUTTON);
}
private function addThing(
$key,
$name,
$uri = null,
$type) {
$item = id(new PhabricatorMenuItemView())
->setName($name)
->setType($type);
if (strlen($key)) {
$item->setKey($key);
}
if ($uri) {
$item->setHref($uri);
} else {
$href = clone $this->baseURI;
$href->setPath(rtrim($href->getPath().$key, '/').'/');
$href = (string)$href;
$item->setHref($href);
}
return $this->addMenuItem($item);
}
public function addCustomBlock($block) {
$this->menu->addMenuItem(
id(new PhabricatorMenuItemView())
->setType(PhabricatorMenuItemView::TYPE_CUSTOM)
->appendChild($block));
return $this;
}
public function addLabel($name) {
return $this->addMenuItem(
id(new PhabricatorMenuItemView())
->setType(PhabricatorMenuItemView::TYPE_LABEL)
->setName($name));
}
public function setBaseURI(PhutilURI $uri) {
$this->baseURI = $uri;
return $this;
}
public function getBaseURI() {
return $this->baseURI;
}
public function selectFilter($key, $default = null) {
$this->selectedFilter = $default;
if ($this->menu->getItem($key) && strlen($key)) {
$this->selectedFilter = $key;
}
return $this->selectedFilter;
}
public function getSelectedFilter() {
return $this->selectedFilter;
}
public function render() {
if ($this->menu->getItems()) {
if (!$this->baseURI) {
throw new Exception(pht("Call setBaseURI() before render()!"));
}
if ($this->selectedFilter === false) {
throw new Exception(pht("Call selectFilter() before render()!"));
}
}
if ($this->selectedFilter !== null) {
$selected_item = $this->menu->getItem($this->selectedFilter);
if ($selected_item) {
$selected_item->addClass('phabricator-menu-item-selected');
}
}
require_celerity_resource('phabricator-side-menu-view-css');
return $this->renderFlexNav();
}
private function renderFlexNav() {
$user = $this->user;
require_celerity_resource('phabricator-nav-view-css');
$nav_classes = array();
$nav_classes[] = 'phabricator-nav';
$nav_id = null;
$drag_id = null;
$content_id = celerity_generate_unique_node_id();
$local_id = null;
$background_id = null;
$local_menu = null;
$main_id = celerity_generate_unique_node_id();
if ($this->flexible) {
$drag_id = celerity_generate_unique_node_id();
$flex_bar = phutil_tag(
'div',
array(
'class' => 'phabricator-nav-drag',
'id' => $drag_id,
),
'');
} else {
$flex_bar = null;
}
$nav_menu = null;
if ($this->menu->getItems()) {
$local_id = celerity_generate_unique_node_id();
$background_id = celerity_generate_unique_node_id();
if (!$this->collapsed) {
$nav_classes[] = 'has-local-nav';
}
$menu_background = phutil_tag(
'div',
array(
'class' => 'phabricator-nav-column-background',
'id' => $background_id,
),
'');
- $local_menu = $this->renderSingleView(
- array(
- $menu_background,
- phutil_tag(
- 'div',
- array(
- 'class' => 'phabricator-nav-local phabricator-side-menu',
- 'id' => $local_id,
- ),
- self::renderSingleView($this->menu->setID($this->getMenuID()))),
- ));
+ $local_menu = array(
+ $menu_background,
+ phutil_tag(
+ 'div',
+ array(
+ 'class' => 'phabricator-nav-local phabricator-side-menu',
+ 'id' => $local_id,
+ ),
+ $this->menu->setID($this->getMenuID())),
+ );
}
$crumbs = null;
if ($this->crumbs) {
$crumbs = $this->crumbs->render();
$nav_classes[] = 'has-crumbs';
}
if ($this->flexible) {
if (!$this->collapsed) {
$nav_classes[] = 'has-drag-nav';
}
Javelin::initBehavior(
'phabricator-nav',
array(
'mainID' => $main_id,
'localID' => $local_id,
'dragID' => $drag_id,
'contentID' => $content_id,
'backgroundID' => $background_id,
'collapsed' => $this->collapsed,
));
if ($this->active) {
Javelin::initBehavior(
'phabricator-active-nav',
array(
'localID' => $local_id,
));
}
}
$nav_classes = array_merge($nav_classes, $this->classes);
return phutil_tag(
'div',
array(
'class' => implode(' ', $nav_classes),
'id' => $main_id,
),
array(
$local_menu,
$flex_bar,
phutil_tag(
'div',
array(
'class' => 'phabricator-nav-content',
'id' => $content_id,
),
array(
$crumbs,
- phutil_implode_html('', $this->renderChildren()),
+ $this->renderChildren(),
))
));
}
}
diff --git a/src/view/layout/PhabricatorActionListView.php b/src/view/layout/PhabricatorActionListView.php
index 37c3252df9..2497090e14 100644
--- a/src/view/layout/PhabricatorActionListView.php
+++ b/src/view/layout/PhabricatorActionListView.php
@@ -1,49 +1,49 @@
<?php
final class PhabricatorActionListView extends AphrontView {
private $actions = array();
private $object;
public function setObject(PhabricatorLiskDAO $object) {
$this->object = $object;
return $this;
}
public function addAction(PhabricatorActionView $view) {
$this->actions[] = $view;
return $this;
}
public function render() {
if (!$this->user) {
throw new Exception(pht("Call setUser() before render()!"));
}
$event = new PhabricatorEvent(
PhabricatorEventType::TYPE_UI_DIDRENDERACTIONS,
array(
'object' => $this->object,
'actions' => $this->actions,
));
$event->setUser($this->user);
PhutilEventEngine::dispatchEvent($event);
$actions = $event->getValue('actions');
if (!$actions) {
return null;
}
require_celerity_resource('phabricator-action-list-view-css');
return phutil_tag(
'ul',
array(
'class' => 'phabricator-action-list-view',
),
- $this->renderSingleView($actions));
+ $actions);
}
}
diff --git a/src/view/layout/PhabricatorAnchorView.php b/src/view/layout/PhabricatorAnchorView.php
index 6ffd7e59fe..ec2a3b0dc8 100644
--- a/src/view/layout/PhabricatorAnchorView.php
+++ b/src/view/layout/PhabricatorAnchorView.php
@@ -1,45 +1,45 @@
<?php
final class PhabricatorAnchorView extends AphrontView {
private $anchorName;
private $navigationMarker;
public function setAnchorName($name) {
$this->anchorName = $name;
return $this;
}
public function setNavigationMarker($marker) {
$this->navigationMarker = $marker;
return $this;
}
public function render() {
$marker = null;
if ($this->navigationMarker) {
$marker = javelin_tag(
'legend',
array(
'class' => 'phabricator-anchor-navigation-marker',
'sigil' => 'marker',
'meta' => array(
'anchor' => $this->anchorName,
),
),
'');
}
$anchor = phutil_tag(
'a',
array(
'name' => $this->anchorName,
'id' => $this->anchorName,
'class' => 'phabricator-anchor-view',
),
'');
- return $this->renderSingleView(array($marker, $anchor));
+ return array($marker, $anchor);
}
}
diff --git a/src/view/layout/PhabricatorCrumbsView.php b/src/view/layout/PhabricatorCrumbsView.php
index 2ee9d48022..9cc8759050 100644
--- a/src/view/layout/PhabricatorCrumbsView.php
+++ b/src/view/layout/PhabricatorCrumbsView.php
@@ -1,78 +1,77 @@
<?php
final class PhabricatorCrumbsView extends AphrontView {
private $crumbs = array();
private $actions = array();
protected function canAppendChild() {
return false;
}
public function addCrumb(PhabricatorCrumbView $crumb) {
$this->crumbs[] = $crumb;
return $this;
}
public function addAction(PhabricatorMenuItemView $action) {
$this->actions[] = $action;
return $this;
}
public function render() {
require_celerity_resource('phabricator-crumbs-view-css');
$action_view = null;
if ($this->actions) {
$actions = array();
foreach ($this->actions as $action) {
$icon = null;
if ($action->getIcon()) {
$icon = phutil_tag(
'span',
array(
'class' => 'sprite-icon action-'.$action->getIcon(),
),
'');
}
$actions[] = javelin_tag(
'a',
array(
'href' => $action->getHref(),
'class' => 'phabricator-crumbs-action',
'sigil' => $action->getWorkflow() ? 'workflow' : null,
),
array(
$icon,
$action->getName(),
));
}
$action_view = phutil_tag(
'div',
array(
'class' => 'phabricator-crumbs-actions',
),
- $this->renderSingleView($actions));
+ $actions);
}
if ($this->crumbs) {
last($this->crumbs)->setIsLastCrumb(true);
}
return phutil_tag(
'div',
array(
'class' => 'phabricator-crumbs-view '.
'sprite-gradient gradient-breadcrumbs',
),
- $this->renderSingleView(
- array(
- $action_view,
- $this->crumbs,
- )));
+ array(
+ $action_view,
+ $this->crumbs,
+ ));
}
}
diff --git a/src/view/layout/PhabricatorHeaderView.php b/src/view/layout/PhabricatorHeaderView.php
index 63e0d9e930..a424c5800b 100644
--- a/src/view/layout/PhabricatorHeaderView.php
+++ b/src/view/layout/PhabricatorHeaderView.php
@@ -1,64 +1,64 @@
<?php
final class PhabricatorHeaderView extends AphrontView {
private $objectName;
private $header;
private $tags = array();
public function setHeader($header) {
$this->header = $header;
return $this;
}
public function setObjectName($object_name) {
$this->objectName = $object_name;
return $this;
}
public function addTag(PhabricatorTagView $tag) {
$this->tags[] = $tag;
return $this;
}
public function render() {
require_celerity_resource('phabricator-header-view-css');
$header = array($this->header);
if ($this->objectName) {
array_unshift(
$header,
phutil_tag(
'a',
array(
'href' => '/'.$this->objectName,
),
$this->objectName),
' ');
}
if ($this->tags) {
$header[] = phutil_tag(
'span',
array(
'class' => 'phabricator-header-tags',
),
- $this->renderSingleView($this->tags));
+ $this->tags);
}
return phutil_tag(
'div',
array(
'class' => 'phabricator-header-shell',
),
phutil_tag(
'h1',
array(
'class' => 'phabricator-header-view',
),
$header));
}
}
diff --git a/src/view/layout/PhabricatorMenuItemView.php b/src/view/layout/PhabricatorMenuItemView.php
index 6e021c8c97..e326052271 100644
--- a/src/view/layout/PhabricatorMenuItemView.php
+++ b/src/view/layout/PhabricatorMenuItemView.php
@@ -1,127 +1,129 @@
<?php
final class PhabricatorMenuItemView extends AphrontTagView {
const TYPE_LINK = 'type-link';
const TYPE_SPACER = 'type-spacer';
const TYPE_LABEL = 'type-label';
const TYPE_BUTTON = 'type-button';
const TYPE_CUSTOM = 'type-custom';
private $name;
private $href;
private $type = self::TYPE_LINK;
private $isExternal;
private $key;
private $icon;
private $selected;
public function setProperty($property) {
$this->property = $property;
return $this;
}
public function getProperty() {
return $this->property;
}
public function setSelected($selected) {
$this->selected = $selected;
return $this;
}
public function getSelected() {
return $this->selected;
}
public function setIcon($icon) {
$this->icon = $icon;
return $this;
}
public function getIcon() {
return $this->icon;
}
public function setKey($key) {
$this->key = (string)$key;
return $this;
}
public function getKey() {
return $this->key;
}
public function setType($type) {
$this->type = $type;
return $this;
}
public function getType() {
return $this->type;
}
public function setHref($href) {
$this->href = $href;
return $this;
}
public function getHref() {
return $this->href;
}
public function setName($name) {
$this->name = $name;
return $this;
}
public function getName() {
return $this->name;
}
public function setIsExternal($is_external) {
$this->isExternal = $is_external;
return $this;
}
public function getIsExternal() {
return $this->isExternal;
}
protected function getTagName() {
return $this->href ? 'a' : 'div';
}
protected function getTagAttributes() {
return array(
'class' => array(
'phabricator-menu-item-view',
'phabricator-menu-item-'.$this->type,
),
'href' => $this->href,
);
}
protected function getTagContent() {
$name = null;
if ($this->name) {
$external = null;
if ($this->isExternal) {
$external = " \xE2\x86\x97";
}
$name = phutil_tag(
'span',
array(
'class' => 'phabricator-menu-item-name',
),
- $this->name.$external);
+ array(
+ $this->name,
+ $external,
+ ));
}
- return $this->renderSingleView(
- array(
- $this->renderChildren(),
- $name,
- ));
+ return array(
+ $this->renderChildren(),
+ $name,
+ );
}
}
diff --git a/src/view/layout/PhabricatorMenuView.php b/src/view/layout/PhabricatorMenuView.php
index bd4c471fe7..9b313bc003 100644
--- a/src/view/layout/PhabricatorMenuView.php
+++ b/src/view/layout/PhabricatorMenuView.php
@@ -1,173 +1,173 @@
<?php
final class PhabricatorMenuView extends AphrontTagView {
private $items = array();
protected function canAppendChild() {
return false;
}
public function newLabel($name, $key = null) {
$item = id(new PhabricatorMenuItemView())
->setType(PhabricatorMenuItemView::TYPE_LABEL)
->setName($name);
if ($key !== null) {
$item->setKey($key);
}
$this->addMenuItem($item);
return $item;
}
public function newLink($name, $href, $key = null) {
$item = id(new PhabricatorMenuItemView())
->setType(PhabricatorMenuItemView::TYPE_LINK)
->setName($name)
->setHref($href);
if ($key !== null) {
$item->setKey($key);
}
$this->addMenuItem($item);
return $item;
}
public function newButton($name, $href) {
$item = id(new PhabricatorMenuItemView())
->setType(PhabricatorMenuItemView::TYPE_BUTTON)
->setName($name)
->setHref($href);
$this->addMenuItem($item);
return $item;
}
public function addMenuItem(PhabricatorMenuItemView $item) {
return $this->addMenuItemAfter(null, $item);
}
public function addMenuItemAfter($key, PhabricatorMenuItemView $item) {
if ($key === null) {
$this->items[] = $item;
return $this;
}
if (!$this->getItem($key)) {
throw new Exception(pht("No such key '%s' to add menu item after!",
$key));
}
$result = array();
foreach ($this->items as $other) {
$result[] = $other;
if ($other->getKey() == $key) {
$result[] = $item;
}
}
$this->items = $result;
return $this;
}
public function addMenuItemBefore($key, PhabricatorMenuItemView $item) {
if ($key === null) {
array_unshift($this->items, $item);
return $this;
}
$this->requireKey($key);
$result = array();
foreach ($this->items as $other) {
if ($other->getKey() == $key) {
$result[] = $item;
}
$result[] = $other;
}
$this->items = $result;
return $this;
}
public function addMenuItemToLabel($key, PhabricatorMenuItemView $item) {
$this->requireKey($key);
$other = $this->getItem($key);
if ($other->getType() != PhabricatorMenuItemView::TYPE_LABEL) {
throw new Exception(pht("Menu item '%s' is not a label!", $key));
}
$seen = false;
$after = null;
foreach ($this->items as $other) {
if (!$seen) {
if ($other->getKey() == $key) {
$seen = true;
}
} else {
if ($other->getType() == PhabricatorMenuItemView::TYPE_LABEL) {
break;
}
}
$after = $other->getKey();
}
return $this->addMenuItemAfter($after, $item);
}
private function requireKey($key) {
if (!$this->getItem($key)) {
throw new Exception(pht("No menu item with key '%s' exists!", $key));
}
}
public function getItem($key) {
$key = (string)$key;
// NOTE: We could optimize this, but need to update any map when items have
// their keys change. Since that's moderately complex, wait for a profile
// or use case.
foreach ($this->items as $item) {
if ($item->getKey() == $key) {
return $item;
}
}
return null;
}
public function getItems() {
return $this->items;
}
protected function willRender() {
$key_map = array();
foreach ($this->items as $item) {
$key = $item->getKey();
if ($key !== null) {
if (isset($key_map[$key])) {
throw new Exception(
pht("Menu contains duplicate items with key '%s'!", $key));
}
$key_map[$key] = $item;
}
}
}
protected function getTagAttributes() {
return array(
'class' => 'phabricator-menu-view',
);
}
protected function getTagContent() {
- return $this->renderSingleView($this->items);
+ return $this->items;
}
}
diff --git a/src/view/layout/PhabricatorObjectItemListView.php b/src/view/layout/PhabricatorObjectItemListView.php
index d98feaef38..feb224458d 100644
--- a/src/view/layout/PhabricatorObjectItemListView.php
+++ b/src/view/layout/PhabricatorObjectItemListView.php
@@ -1,82 +1,81 @@
<?php
final class PhabricatorObjectItemListView extends AphrontView {
private $header;
private $items;
private $pager;
private $stackable;
private $noDataString;
public function setHeader($header) {
$this->header = $header;
return $this;
}
public function setPager($pager) {
$this->pager = $pager;
return $this;
}
public function setNoDataString($no_data_string) {
$this->noDataString = $no_data_string;
return $this;
}
public function addItem(PhabricatorObjectItemView $item) {
$this->items[] = $item;
return $this;
}
public function setStackable() {
$this->stackable = true;
return $this;
}
public function render() {
require_celerity_resource('phabricator-object-item-list-view-css');
$classes = array();
$header = null;
if (strlen($this->header)) {
$header = phutil_tag(
'h1',
array(
'class' => 'phabricator-object-item-list-header',
),
$this->header);
}
if ($this->items) {
- $items = $this->renderSingleView($this->items);
+ $items = $this->items;
} else {
$string = nonempty($this->noDataString, pht('No data.'));
$items = id(new AphrontErrorView())
->setSeverity(AphrontErrorView::SEVERITY_NODATA)
->appendChild($string);
}
$pager = null;
if ($this->pager) {
- $pager = $this->renderSingleView($this->pager);
+ $pager = $this->pager;
}
$classes[] = 'phabricator-object-item-list-view';
if ($this->stackable) {
$classes[] = 'phabricator-object-list-stackable';
}
return phutil_tag(
'ul',
array(
'class' => implode(' ', $classes),
),
- $this->renderSingleView(
- array(
- $header,
- $items,
- $pager,
- )));
+ array(
+ $header,
+ $items,
+ $pager,
+ ));
}
}
diff --git a/src/view/layout/PhabricatorObjectItemView.php b/src/view/layout/PhabricatorObjectItemView.php
index e58f14b68c..b99f0055aa 100644
--- a/src/view/layout/PhabricatorObjectItemView.php
+++ b/src/view/layout/PhabricatorObjectItemView.php
@@ -1,195 +1,194 @@
<?php
final class PhabricatorObjectItemView extends AphrontView {
private $header;
private $href;
private $attributes = array();
private $details = array();
private $dates = array();
private $icons = array();
private $barColor;
private $object;
private $effect;
public function setEffect($effect) {
$this->effect = $effect;
return $this;
}
public function getEffect() {
return $this->effect;
}
public function setObject($object) {
$this->object = $object;
return $this;
}
public function getObject() {
return $this->object;
}
public function setHref($href) {
$this->href = $href;
return $this;
}
public function getHref() {
return $this->href;
}
public function setHeader($header) {
$this->header = $header;
return $this;
}
public function getHeader() {
return $this->header;
}
public function addIcon($icon, $label = null, $href = null) {
$this->icons[] = array(
'icon' => $icon,
'label' => $label,
'href' => $href,
);
return $this;
}
public function setBarColor($bar_color) {
$this->barColor = $bar_color;
return $this;
}
public function getBarColor() {
return $this->barColor;
}
public function addAttribute($attribute) {
$this->attributes[] = $attribute;
return $this;
}
public function render() {
$header = phutil_tag(
'a',
array(
'href' => $this->href,
'class' => 'phabricator-object-item-name',
),
$this->header);
$icons = null;
if ($this->icons) {
$icon_list = array();
foreach ($this->icons as $spec) {
$icon = $spec['icon'];
$icon = phutil_tag(
'span',
array(
'class' => 'phabricator-object-item-icon-image '.
'sprite-icon action-'.$icon,
),
'');
$label = phutil_tag(
'span',
array(
'class' => 'phabricator-object-item-icon-label',
),
$spec['label']);
if ($spec['href']) {
$icon_href = phutil_tag(
'a',
array('href' => $spec['href']),
array($label, $icon));
} else {
$icon_href = array($label, $icon);
}
$icon_list[] = phutil_tag(
'li',
array(
'class' => 'phabricator-object-item-icon',
),
$icon_href);
}
$icons = phutil_tag(
'ul',
array(
'class' => 'phabricator-object-item-icons',
),
$icon_list);
}
$attrs = null;
if ($this->attributes) {
$attrs = array();
$spacer = phutil_tag(
'span',
array(
'class' => 'phabricator-object-item-attribute-spacer',
),
"\xC2\xB7");
$first = true;
foreach ($this->attributes as $attribute) {
$attrs[] = phutil_tag(
'li',
array(
'class' => 'phabricator-object-item-attribute',
),
array(
($first ? null : $spacer),
$attribute,
));
$first = false;
}
$attrs = phutil_tag(
'ul',
array(
'class' => 'phabricator-object-item-attributes',
),
$attrs);
}
$classes = array();
$classes[] = 'phabricator-object-item';
if ($this->barColor) {
$classes[] = 'phabricator-object-item-bar-color-'.$this->barColor;
}
switch ($this->effect) {
case 'highlighted':
$classes[] = 'phabricator-object-item-highlighted';
break;
case null:
break;
default:
throw new Exception(pht("Invalid effect!"));
}
$content = phutil_tag(
'div',
array(
'class' => 'phabricator-object-item-content',
),
- $this->renderSingleView(
- array(
- $header,
- $attrs,
- $this->renderChildren(),
- )));
+ array(
+ $header,
+ $attrs,
+ $this->renderChildren(),
+ ));
return phutil_tag(
'li',
array(
'class' => implode(' ', $classes),
),
array($icons, $content));
}
}
diff --git a/src/view/layout/PhabricatorPinboardItemView.php b/src/view/layout/PhabricatorPinboardItemView.php
index 7bef64bb93..708efcff66 100644
--- a/src/view/layout/PhabricatorPinboardItemView.php
+++ b/src/view/layout/PhabricatorPinboardItemView.php
@@ -1,115 +1,114 @@
<?php
final class PhabricatorPinboardItemView extends AphrontView {
private $imageURI;
private $uri;
private $header;
private $iconBlock = array();
private $imageWidth;
private $imageHeight;
public function setHeader($header) {
$this->header = $header;
return $this;
}
public function setURI($uri) {
$this->uri = $uri;
return $this;
}
public function setImageURI($image_uri) {
$this->imageURI = $image_uri;
return $this;
}
public function setImageSize($x, $y) {
$this->imageWidth = $x;
$this->imageHeight = $y;
return $this;
}
public function addIconCount($icon, $count) {
$this->iconBlock[] = array($icon, $count);
return $this;
}
public function render() {
$header = null;
if ($this->header) {
$header = phutil_tag(
'div',
array(
'class' => 'phabricator-pinboard-item-header',
),
phutil_tag('a', array('href' => $this->uri), $this->header));
}
$image = phutil_tag(
'a',
array(
'href' => $this->uri,
'class' => 'phabricator-pinboard-item-image-link',
),
phutil_tag(
'img',
array(
'src' => $this->imageURI,
'width' => $this->imageWidth,
'height' => $this->imageHeight,
)));
$icons = array();
if ($this->iconBlock) {
$icon_list = array();
foreach ($this->iconBlock as $block) {
$icon = phutil_tag(
'span',
array(
'class' =>
'phabricator-pinboard-icon sprite-icon action-'.$block[0].'-grey',
),
'');
$count = phutil_tag('span', array(), $block[1]);
$icon_list[] = phutil_tag(
'span',
array(
'class' => 'phabricator-pinboard-item-count',
),
array($icon, $count));
}
$icons = phutil_tag(
'div',
array(
'class' => 'phabricator-pinboard-icons',
),
$icon_list);
}
$content = $this->renderChildren();
if ($content) {
$content = phutil_tag(
'div',
array(
'class' => 'phabricator-pinboard-item-content',
),
$content);
}
return phutil_tag(
'div',
array(
'class' => 'phabricator-pinboard-item-view',
),
- $this->renderSingleView(
- array(
- $header,
- $image,
- $icons,
- $content,
- )));
+ array(
+ $header,
+ $image,
+ $icons,
+ $content,
+ ));
}
}
diff --git a/src/view/layout/PhabricatorPinboardView.php b/src/view/layout/PhabricatorPinboardView.php
index ace3b0b34f..992580d6f7 100644
--- a/src/view/layout/PhabricatorPinboardView.php
+++ b/src/view/layout/PhabricatorPinboardView.php
@@ -1,37 +1,37 @@
<?php
final class PhabricatorPinboardView extends AphrontView {
private $items = array();
private $noDataString;
public function setNoDataString($no_data_string) {
$this->noDataString = $no_data_string;
return $this;
}
public function addItem(PhabricatorPinboardItemView $item) {
$this->items[] = $item;
return $this;
}
public function render() {
require_celerity_resource('phabricator-pinboard-view-css');
if (!$this->items) {
$string = nonempty($this->noDataString, pht('No data.'));
return id(new AphrontErrorView())
->setSeverity(AphrontErrorView::SEVERITY_NODATA)
->appendChild($string)
->render();
}
return phutil_tag(
'div',
array(
'class' => 'phabricator-pinboard-view',
),
- $this->renderSingleView($this->items));
+ $this->items);
}
}
diff --git a/src/view/layout/PhabricatorProfileHeaderView.php b/src/view/layout/PhabricatorProfileHeaderView.php
index c99b802907..50ca80909e 100644
--- a/src/view/layout/PhabricatorProfileHeaderView.php
+++ b/src/view/layout/PhabricatorProfileHeaderView.php
@@ -1,76 +1,76 @@
<?php
final class PhabricatorProfileHeaderView extends AphrontView {
protected $profilePicture;
protected $profileName;
protected $profileDescription;
protected $profileActions = array();
protected $profileStatus;
public function setProfilePicture($picture) {
$this->profilePicture = $picture;
return $this;
}
public function setName($name) {
$this->profileName = $name;
return $this;
}
public function setDescription($description) {
$this->profileDescription = $description;
return $this;
}
public function addAction($action) {
$this->profileActions[] = $action;
return $this;
}
public function setStatus($status) {
$this->profileStatus = $status;
return $this;
}
public function render() {
require_celerity_resource('phabricator-profile-header-css');
$image = null;
if ($this->profilePicture) {
$image = phutil_tag(
'div',
array(
'class' => 'profile-header-picture-frame',
'style' => 'background-image: url('.$this->profilePicture.');',
),
'');
}
$description = $this->profileDescription;
if ($this->profileStatus != '') {
$description = hsprintf(
'<strong>%s</strong>%s',
$this->profileStatus,
($description != '' ? "\xE2\x80\x94".$description : ''));
}
return hsprintf(
'<table class="phabricator-profile-header">
<tr>
<td class="profile-header-name">%s</td>
<td class="profile-header-actions" rowspan="2">%s</td>
<td class="profile-header-picture" rowspan="2">%s</td>
</tr>
<tr>
<td class="profile-header-description">%s</td>
</tr>
</table>
%s',
$this->profileName,
- self::renderSingleView($this->profileActions),
+ $this->profileActions,
$image,
$description,
- phutil_implode_html('', $this->renderChildren()));
+ $this->renderChildren());
}
}
diff --git a/src/view/layout/PhabricatorPropertyListView.php b/src/view/layout/PhabricatorPropertyListView.php
index 645fdbf084..4950821403 100644
--- a/src/view/layout/PhabricatorPropertyListView.php
+++ b/src/view/layout/PhabricatorPropertyListView.php
@@ -1,191 +1,191 @@
<?php
final class PhabricatorPropertyListView extends AphrontView {
private $parts = array();
private $hasKeyboardShortcuts;
private $object;
private $invokedWillRenderEvent;
protected function canAppendChild() {
return false;
}
public function setObject($object) {
$this->object = $object;
return $this;
}
public function setHasKeyboardShortcuts($has_keyboard_shortcuts) {
$this->hasKeyboardShortcuts = $has_keyboard_shortcuts;
return $this;
}
public function addProperty($key, $value) {
$current = array_pop($this->parts);
if (!$current || $current['type'] != 'property') {
if ($current) {
$this->parts[] = $current;
}
$current = array(
'type' => 'property',
'list' => array(),
);
}
$current['list'][] = array(
'key' => $key,
'value' => $value,
);
$this->parts[] = $current;
return $this;
}
public function addSectionHeader($name) {
$this->parts[] = array(
'type' => 'section',
'name' => $name,
);
return $this;
}
public function addTextContent($content) {
$this->parts[] = array(
'type' => 'text',
'content' => $content,
);
return $this;
}
public function addImageContent($content) {
$this->parts[] = array(
'type' => 'image',
'content' => $content,
);
return $this;
}
public function invokeWillRenderEvent() {
if ($this->object && $this->getUser() && !$this->invokedWillRenderEvent) {
$event = new PhabricatorEvent(
PhabricatorEventType::TYPE_UI_WILLRENDERPROPERTIES,
array(
'object' => $this->object,
'view' => $this,
));
$event->setUser($this->getUser());
PhutilEventEngine::dispatchEvent($event);
}
$this->invokedWillRenderEvent = true;
}
public function render() {
$this->invokeWillRenderEvent();
require_celerity_resource('phabricator-property-list-view-css');
$items = array();
foreach ($this->parts as $part) {
$type = $part['type'];
switch ($type) {
case 'property':
$items[] = $this->renderPropertyPart($part);
break;
case 'section':
$items[] = $this->renderSectionPart($part);
break;
case 'text':
case 'image':
$items[] = $this->renderTextPart($part);
break;
default:
throw new Exception(pht("Unknown part type '%s'!", $type));
}
}
return phutil_tag(
'div',
array(
'class' => 'phabricator-property-list-view',
),
- $this->renderSingleView($items));
+ $items);
}
private function renderPropertyPart(array $part) {
$items = array();
foreach ($part['list'] as $spec) {
$key = $spec['key'];
$value = $spec['value'];
$items[] = phutil_tag(
'dt',
array(
'class' => 'phabricator-property-list-key',
),
$key);
$items[] = phutil_tag(
'dd',
array(
'class' => 'phabricator-property-list-value',
),
- $this->renderSingleView($value));
+ $value);
}
$list = phutil_tag(
'dl',
array(
'class' => 'phabricator-property-list-properties',
),
$this->renderSingleView($items));
$shortcuts = null;
if ($this->hasKeyboardShortcuts) {
$shortcuts = new AphrontKeyboardShortcutsAvailableView();
}
return array(
$shortcuts,
phutil_tag(
'div',
array(
'class' => 'phabricator-property-list-container',
),
array(
$list,
phutil_tag(
'div',
array('class' => 'phabriator-property-list-view-end'),
''),
)));
}
private function renderSectionPart(array $part) {
return phutil_tag(
'div',
array(
'class' => 'phabricator-property-list-section-header',
),
$part['name']);
}
private function renderTextPart(array $part) {
$classes = array();
$classes[] = 'phabricator-property-list-text-content';
if ($part['type'] == 'image') {
$classes[] = 'phabricator-property-list-image-content';
$classes[] = 'phabricator-remarkup-dark';
}
return phutil_tag(
'div',
array(
'class' => implode($classes, ' '),
),
$part['content']);
}
}
diff --git a/src/view/layout/PhabricatorTimelineEventView.php b/src/view/layout/PhabricatorTimelineEventView.php
index fdc477340f..e113de5f49 100644
--- a/src/view/layout/PhabricatorTimelineEventView.php
+++ b/src/view/layout/PhabricatorTimelineEventView.php
@@ -1,305 +1,304 @@
<?php
final class PhabricatorTimelineEventView extends AphrontView {
private $userHandle;
private $title;
private $icon;
private $color;
private $classes = array();
private $contentSource;
private $dateCreated;
private $anchor;
private $isEditable;
private $isEdited;
private $transactionPHID;
private $isPreview;
public function setTransactionPHID($transaction_phid) {
$this->transactionPHID = $transaction_phid;
return $this;
}
public function getTransactionPHID() {
return $this->transactionPHID;
}
public function setIsEdited($is_edited) {
$this->isEdited = $is_edited;
return $this;
}
public function getIsEdited() {
return $this->isEdited;
}
public function setIsPreview($is_preview) {
$this->isPreview = $is_preview;
return $this;
}
public function getIsPreview() {
return $this->isPreview;
}
public function setIsEditable($is_editable) {
$this->isEditable = $is_editable;
return $this;
}
public function getIsEditable() {
return $this->isEditable;
}
public function setDateCreated($date_created) {
$this->dateCreated = $date_created;
return $this;
}
public function getDateCreated() {
return $this->dateCreated;
}
public function setContentSource(PhabricatorContentSource $content_source) {
$this->contentSource = $content_source;
return $this;
}
public function getContentSource() {
return $this->contentSource;
}
public function setUserHandle(PhabricatorObjectHandle $handle) {
$this->userHandle = $handle;
return $this;
}
public function setAnchor($anchor) {
$this->anchor = $anchor;
return $this;
}
public function setTitle($title) {
$this->title = $title;
return $this;
}
public function addClass($class) {
$this->classes[] = $class;
return $this;
}
public function setIcon($icon) {
$this->icon = $icon;
return $this;
}
public function setColor($color) {
$this->color = $color;
return $this;
}
public function render() {
$content = $this->renderChildren();
$title = $this->title;
if (($title === null) && $this->isEmptyContent($content)) {
$title = '';
}
$extra = $this->renderExtra();
if ($title !== null || $extra !== null) {
$title_classes = array();
$title_classes[] = 'phabricator-timeline-title';
$icon = null;
if ($this->icon) {
$title_classes[] = 'phabricator-timeline-title-with-icon';
$icon = phutil_tag(
'span',
array(
'class' => 'phabricator-timeline-icon-fill',
),
phutil_tag(
'span',
array(
'class' => 'phabricator-timeline-icon sprite-icon '.
'action-'.$this->icon.'-white',
),
''));
}
$title = phutil_tag(
'div',
array(
'class' => implode(' ', $title_classes),
),
array($title, $extra));
- $title = $this->renderSingleView(array($icon, $title));
+ $title = array($icon, $title);
}
$wedge = phutil_tag(
'div',
array(
'class' => 'phabricator-timeline-wedge phabricator-timeline-border',
),
'');
$image_uri = $this->userHandle->getImageURI();
$image = phutil_tag(
'div',
array(
'style' => 'background-image: url('.$image_uri.')',
'class' => 'phabricator-timeline-image',
),
'');
$content_classes = array();
$content_classes[] = 'phabricator-timeline-content';
$classes = array();
$classes[] = 'phabricator-timeline-event-view';
$classes[] = 'phabricator-timeline-border';
if ($content) {
$classes[] = 'phabricator-timeline-major-event';
$content = phutil_tag(
'div',
array(
'class' => implode(' ', $content_classes),
),
phutil_tag(
'div',
array(
'class' => 'phabricator-timeline-inner-content',
),
array(
$title,
phutil_tag(
'div',
array(
'class' => 'phabricator-timeline-core-content',
),
$content),
)));
$content = array($image, $wedge, $content);
} else {
$classes[] = 'phabricator-timeline-minor-event';
$content = phutil_tag(
'div',
array(
'class' => implode(' ', $content_classes),
),
array($image, $wedge, $title));
}
$outer_classes = $this->classes;
$outer_classes[] = 'phabricator-timeline-shell';
if ($this->color) {
$outer_classes[] = 'phabricator-timeline-'.$this->color;
}
$sigil = null;
$meta = null;
if ($this->getTransactionPHID()) {
$sigil = 'transaction';
$meta = array(
'phid' => $this->getTransactionPHID(),
'anchor' => $this->anchor,
);
}
return javelin_tag(
'div',
array(
'class' => implode(' ', $outer_classes),
'id' => $this->anchor ? 'anchor-'.$this->anchor : null,
'sigil' => $sigil,
'meta' => $meta,
),
phutil_tag(
'div',
array(
'class' => implode(' ', $classes),
),
$content));
}
private function renderExtra() {
$extra = array();
if ($this->getIsPreview()) {
$extra[] = pht('PREVIEW');
} else {
$xaction_phid = $this->getTransactionPHID();
if ($this->getIsEdited()) {
$extra[] = javelin_tag(
'a',
array(
'href' => '/transactions/history/'.$xaction_phid.'/',
'sigil' => 'workflow',
),
pht('Edited'));
}
if ($this->getIsEditable()) {
$extra[] = javelin_tag(
'a',
array(
'href' => '/transactions/edit/'.$xaction_phid.'/',
'sigil' => 'workflow transaction-edit',
),
pht('Edit'));
}
$source = $this->getContentSource();
if ($source) {
$extra[] = id(new PhabricatorContentSourceView())
->setContentSource($source)
->setUser($this->getUser())
->render();
}
if ($this->getDateCreated()) {
$date = phabricator_datetime(
$this->getDateCreated(),
$this->getUser());
if ($this->anchor) {
Javelin::initBehavior('phabricator-watch-anchor');
$anchor = id(new PhabricatorAnchorView())
->setAnchorName($this->anchor)
->render();
- $date = $this->renderSingleView(
- array(
- $anchor,
- phutil_tag(
- 'a',
- array(
- 'href' => '#'.$this->anchor,
- ),
- $date),
- ));
+ $date = array(
+ $anchor,
+ phutil_tag(
+ 'a',
+ array(
+ 'href' => '#'.$this->anchor,
+ ),
+ $date),
+ );
}
$extra[] = $date;
}
}
if ($extra) {
$extra = phutil_tag(
'span',
array(
'class' => 'phabricator-timeline-extra',
),
phutil_implode_html(" \xC2\xB7 ", $extra));
}
return $extra;
}
}
diff --git a/src/view/layout/PhabricatorTimelineView.php b/src/view/layout/PhabricatorTimelineView.php
index 3977a320b2..cdd93134b2 100644
--- a/src/view/layout/PhabricatorTimelineView.php
+++ b/src/view/layout/PhabricatorTimelineView.php
@@ -1,48 +1,48 @@
<?php
final class PhabricatorTimelineView extends AphrontView {
private $events = array();
private $id;
public function setID($id) {
$this->id = $id;
return $this;
}
public function addEvent(PhabricatorTimelineEventView $event) {
$this->events[] = $event;
return $this;
}
public function render() {
require_celerity_resource('phabricator-timeline-view-css');
$spacer = self::renderSpacer();
$events = array();
foreach ($this->events as $event) {
$events[] = $spacer;
- $events[] = $this->renderSingleView($event);
+ $events[] = $event;
}
$events[] = $spacer;
return phutil_tag(
'div',
array(
'class' => 'phabricator-timeline-view',
'id' => $this->id,
),
$events);
}
public static function renderSpacer() {
return phutil_tag(
'div',
array(
'class' => 'phabricator-timeline-event-view '.
'phabricator-timeline-spacer',
),
'');
}
}
diff --git a/src/view/layout/PhabricatorTransactionView.php b/src/view/layout/PhabricatorTransactionView.php
index a4906d6d54..a5f4c480c3 100644
--- a/src/view/layout/PhabricatorTransactionView.php
+++ b/src/view/layout/PhabricatorTransactionView.php
@@ -1,149 +1,149 @@
<?php
final class PhabricatorTransactionView extends AphrontView {
private $imageURI;
private $actions = array();
private $epoch;
private $contentSource;
private $anchorName;
private $anchorText;
private $isPreview;
private $classes = array();
public function setImageURI($uri) {
$this->imageURI = $uri;
return $this;
}
public function setActions(array $actions) {
$this->actions = $actions;
return $this;
}
public function setEpoch($epoch) {
$this->epoch = $epoch;
return $this;
}
public function setContentSource(PhabricatorContentSource $source) {
$this->contentSource = $source;
return $this;
}
public function setAnchor($anchor_name, $anchor_text) {
$this->anchorName = $anchor_name;
$this->anchorText = $anchor_text;
return $this;
}
public function addClass($class) {
$this->classes[] = $class;
return $this;
}
public function setIsPreview($preview) {
$this->isPreview = $preview;
return $this;
}
public function render() {
if (!$this->user) {
throw new Exception(pht("Call setUser() before render()!"));
}
require_celerity_resource('phabricator-transaction-view-css');
$info = $this->renderTransactionInfo();
$actions = $this->renderTransactionActions();
$style = $this->renderTransactionStyle();
$content = $this->renderTransactionContent();
$classes = implode(' ', $this->classes);
$transaction_id = $this->anchorName ? 'anchor-'.$this->anchorName : null;
return phutil_tag(
'div',
array(
'class' => 'phabricator-transaction-view',
'id' => $transaction_id,
'style' => $style,
),
hsprintf(
'<div class="phabricator-transaction-detail %s">'.
'<div class="phabricator-transaction-header">%s%s</div>'.
'%s'.
'</div>',
$classes,
$info,
$actions,
$content));
}
private function renderTransactionInfo() {
$info = array();
if ($this->contentSource) {
$content_source = new PhabricatorContentSourceView();
$content_source->setContentSource($this->contentSource);
$content_source->setUser($this->user);
$source = $content_source->render();
if ($source) {
$info[] = $source;
}
}
if ($this->isPreview) {
$info[] = 'PREVIEW';
} else if ($this->epoch) {
$info[] = phabricator_datetime($this->epoch, $this->user);
}
if ($this->anchorName) {
Javelin::initBehavior('phabricator-watch-anchor');
$anchor = id(new PhabricatorAnchorView())
->setAnchorName($this->anchorName)
->render();
$info[] = hsprintf(
'%s%s',
$anchor,
phutil_tag(
'a',
array('href' => '#'.$this->anchorName),
$this->anchorText));
}
$info = phutil_implode_html(" \xC2\xB7 ", $info);
return hsprintf(
'<span class="phabricator-transaction-info">%s</span>',
$info);
}
private function renderTransactionActions() {
- return phutil_implode_html('', $this->actions);
+ return $this->actions;
}
private function renderTransactionStyle() {
if ($this->imageURI) {
return 'background-image: url('.$this->imageURI.');';
} else {
return null;
}
}
private function renderTransactionContent() {
$content = $this->renderChildren();
if ($this->isEmptyContent($content)) {
return null;
}
return phutil_tag(
'div',
array('class' => 'phabricator-transaction-content'),
- $this->renderSingleView($content));
+ $content);
}
}
diff --git a/src/view/page/menu/PhabricatorMainMenuView.php b/src/view/page/menu/PhabricatorMainMenuView.php
index 6ad736d817..7c3a3cb163 100644
--- a/src/view/page/menu/PhabricatorMainMenuView.php
+++ b/src/view/page/menu/PhabricatorMainMenuView.php
@@ -1,433 +1,431 @@
<?php
final class PhabricatorMainMenuView extends AphrontView {
private $defaultSearchScope;
private $controller;
private $applicationMenu;
public function setApplicationMenu(PhabricatorMenuView $application_menu) {
$this->applicationMenu = $application_menu;
return $this;
}
public function getApplicationMenu() {
return $this->applicationMenu;
}
public function setController(PhabricatorController $controller) {
$this->controller = $controller;
return $this;
}
public function getController() {
return $this->controller;
}
public function setDefaultSearchScope($default_search_scope) {
$this->defaultSearchScope = $default_search_scope;
return $this;
}
public function getDefaultSearchScope() {
return $this->defaultSearchScope;
}
public function render() {
$user = $this->user;
require_celerity_resource('phabricator-main-menu-view');
$header_id = celerity_generate_unique_node_id();
$menus = array();
$alerts = array();
if ($user->isLoggedIn()) {
list($menu, $dropdown) = $this->renderNotificationMenu();
$alerts[] = $menu;
$menus[] = $dropdown;
}
$phabricator_menu = $this->renderPhabricatorMenu();
if ($alerts) {
$alerts = phutil_tag(
'div',
array(
'class' => 'phabricator-main-menu-alerts',
),
- self::renderSingleView($alerts));
+ $alerts);
}
$application_menu = $this->getApplicationMenu();
if ($application_menu) {
$application_menu->addClass('phabricator-dark-menu');
$application_menu->addClass('phabricator-application-menu');
}
return phutil_tag(
'div',
array(
'class' => 'phabricator-main-menu',
'id' => $header_id,
),
array(
- self::renderSingleView(array(
- $this->renderPhabricatorMenuButton($header_id),
- $application_menu
- ? $this->renderApplicationMenuButton($header_id)
- : null,
- $this->renderPhabricatorLogo(),
- $alerts,
- $phabricator_menu,
- $application_menu,
- )),
- self::renderSingleView($menus),
+ $this->renderPhabricatorMenuButton($header_id),
+ $application_menu
+ ? $this->renderApplicationMenuButton($header_id)
+ : null,
+ $this->renderPhabricatorLogo(),
+ $alerts,
+ $phabricator_menu,
+ $application_menu,
+ $menus,
));
}
private function renderSearch() {
$user = $this->user;
$result = null;
$keyboard_config = array(
'helpURI' => '/help/keyboardshortcut/',
);
if ($user->isLoggedIn()) {
$search = new PhabricatorMainMenuSearchView();
$search->setUser($user);
$search->setScope($this->getDefaultSearchScope());
$result = $search;
$pref_shortcut = PhabricatorUserPreferences::PREFERENCE_SEARCH_SHORTCUT;
if ($user->loadPreferences()->getPreference($pref_shortcut, true)) {
$keyboard_config['searchID'] = $search->getID();
}
}
Javelin::initBehavior('phabricator-keyboard-shortcuts', $keyboard_config);
if ($result) {
$result = id(new PhabricatorMenuItemView())
->addClass('phabricator-main-menu-search')
->appendChild($result);
}
return $result;
}
private function renderPhabricatorMenuButton($header_id) {
$button_id = celerity_generate_unique_node_id();
return javelin_tag(
'a',
array(
'class' => 'phabricator-main-menu-expand-button '.
'phabricator-expand-core-menu',
'sigil' => 'jx-toggle-class',
'meta' => array(
'map' => array(
$header_id => 'phabricator-core-menu-expanded',
$button_id => 'menu-icon-eye-blue',
),
),
),
phutil_tag(
'span',
array(
'class' => 'phabricator-menu-button-icon sprite-menu menu-icon-eye',
'id' => $button_id,
),
''));
}
public function renderApplicationMenuButton($header_id) {
$button_id = celerity_generate_unique_node_id();
return javelin_tag(
'a',
array(
'class' => 'phabricator-main-menu-expand-button '.
'phabricator-expand-application-menu',
'sigil' => 'jx-toggle-class',
'meta' => array(
'map' => array(
$header_id => 'phabricator-application-menu-expanded',
$button_id => 'menu-icon-app-blue',
),
),
),
phutil_tag(
'span',
array(
'class' => 'phabricator-menu-button-icon sprite-menu menu-icon-app',
'id' => $button_id,
),
''));
}
private function renderPhabricatorMenu() {
$user = $this->getUser();
$controller = $this->getController();
$applications = PhabricatorApplication::getAllInstalledApplications();
$core = array();
$more = array();
$actions = array();
require_celerity_resource('sprite-apps-large-css');
$group_core = PhabricatorApplication::GROUP_CORE;
foreach ($applications as $application) {
if ($application->shouldAppearInLaunchView()) {
$icon = $application->getIconName().'-light-large';
$item = id(new PhabricatorMenuItemView())
->setName($application->getName())
->setHref($application->getBaseURI())
->appendChild($this->renderMenuIcon($icon));
if ($application->getApplicationGroup() == $group_core) {
$core[] = $item;
} else {
$more[$application->getName()] = $item;
}
}
$app_actions = $application->buildMainMenuItems($user, $controller);
foreach ($app_actions as $action) {
$actions[] = $action;
}
}
$view = new PhabricatorMenuView();
$view->addClass('phabricator-dark-menu');
$view->addClass('phabricator-core-menu');
$search = $this->renderSearch();
if ($search) {
$view->addMenuItem($search);
}
$view
->newLabel(pht('Home'))
->addClass('phabricator-core-item-device');
$view->addMenuItem(
id(new PhabricatorMenuItemView())
->addClass('phabricator-core-item-device')
->setName(pht('Phabricator Home'))
->setHref('/')
->appendChild($this->renderMenuIcon('logo-light-large')));
if ($controller && $controller->getCurrentApplication()) {
$application = $controller->getCurrentApplication();
$icon = $application->getIconName().'-light-large';
$view->addMenuItem(
id(new PhabricatorMenuItemView())
->addClass('phabricator-core-item-device')
->setName(pht('%s Home', $application->getName()))
->appendChild($this->renderMenuIcon($icon))
->setHref($controller->getApplicationURI()));
}
if ($core) {
$view->addMenuItem(
id(new PhabricatorMenuItemView())
->addClass('phabricator-core-item-device')
->setType(PhabricatorMenuItemView::TYPE_LABEL)
->setName(pht('Core Applications')));
foreach ($core as $item) {
$item->addClass('phabricator-core-item-device');
$view->addMenuItem($item);
}
}
if ($actions) {
$view->addMenuItem(
id(new PhabricatorMenuItemView())
->addClass('phabricator-core-item-device')
->setType(PhabricatorMenuItemView::TYPE_LABEL)
->setName(pht('Actions')));
foreach ($actions as $action) {
$icon = $action->getIcon();
if ($icon) {
if ($action->getSelected()) {
$action->appendChild($this->renderMenuIcon($icon.'-blue-large'));
} else {
$action->appendChild($this->renderMenuIcon($icon.'-light-large'));
}
}
$view->addMenuItem($action);
}
}
if ($more) {
$view->addMenuItem(
id(new PhabricatorMenuItemView())
->addClass('phabricator-core-item-device')
->setType(PhabricatorMenuItemView::TYPE_LABEL)
->setName(pht('More Applications')));
ksort($more);
foreach ($more as $item) {
$item->addClass('phabricator-core-item-device');
$view->addMenuItem($item);
}
}
return $view;
}
private function renderPhabricatorLogo() {
return phutil_tag(
'a',
array(
'class' => 'phabricator-main-menu-logo',
'href' => '/',
),
phutil_tag(
'span',
array(
'class' => 'sprite-menu phabricator-main-menu-logo-image',
),
''));
}
private function renderNotificationMenu() {
$user = $this->user;
require_celerity_resource('phabricator-notification-css');
require_celerity_resource('phabricator-notification-menu-css');
require_celerity_resource('sprite-menu-css');
$container_classes = array(
'sprite-menu',
'alert-notifications',
);
$conpherence = id(new PhabricatorApplicationConpherence())->isBeta();
$allow_beta =
PhabricatorEnv::getEnvConfig('phabricator.show-beta-applications');
$message_tag = '';
if (!$conpherence || $allow_beta) {
$message_id = celerity_generate_unique_node_id();
$message_count_id = celerity_generate_unique_node_id();
$unread_status = ConpherenceParticipationStatus::BEHIND;
$unread = id(new ConpherenceParticipantQuery())
->withParticipantPHIDs(array($user->getPHID()))
->withParticipationStatus($unread_status)
->execute();
$message_count_number = count($unread);
if ($message_count_number > 999) {
$message_count_number = "\xE2\x88\x9E";
}
$message_count_tag = phutil_tag(
'span',
array(
'id' => $message_count_id,
'class' => 'phabricator-main-menu-message-count'
),
$message_count_number);
$message_icon_tag = phutil_tag(
'span',
array(
'class' => 'sprite-menu phabricator-main-menu-message-icon',
),
'');
if ($message_count_number) {
$container_classes[] = 'message-unread';
}
$message_tag = phutil_tag(
'a',
array(
'href' => '/conpherence/',
'class' => implode(' ', $container_classes),
'id' => $message_id,
),
array(
$message_icon_tag,
$message_count_tag,
));
}
$count_id = celerity_generate_unique_node_id();
$dropdown_id = celerity_generate_unique_node_id();
$bubble_id = celerity_generate_unique_node_id();
$count_number = id(new PhabricatorFeedStoryNotification())
->countUnread($user);
if ($count_number > 999) {
$count_number = "\xE2\x88\x9E";
}
$count_tag = phutil_tag(
'span',
array(
'id' => $count_id,
'class' => 'phabricator-main-menu-alert-count'
),
$count_number);
$icon_tag = phutil_tag(
'span',
array(
'class' => 'sprite-menu phabricator-main-menu-alert-icon',
),
'');
if ($count_number) {
$container_classes[] = 'alert-unread';
}
$bubble_tag = phutil_tag(
'a',
array(
'href' => '/notification/',
'class' => implode(' ', $container_classes),
'id' => $bubble_id,
),
array($icon_tag, $count_tag));
Javelin::initBehavior(
'aphlict-dropdown',
array(
'bubbleID' => $bubble_id,
'countID' => $count_id,
'dropdownID' => $dropdown_id,
'loadingText' => pht('Loading...'),
));
$notification_dropdown = javelin_tag(
'div',
array(
'id' => $dropdown_id,
'class' => 'phabricator-notification-menu',
'sigil' => 'phabricator-notification-menu',
'style' => 'display: none;',
),
'');
return array(
hsprintf('%s%s', $bubble_tag, $message_tag),
$notification_dropdown,
);
}
private function renderMenuIcon($name) {
return phutil_tag(
'span',
array(
'class' => 'phabricator-core-menu-icon '.
'sprite-apps-large app-'.$name,
),
'');
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Jan 19 2025, 22:54 (6 w, 3 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1129613
Default Alt Text
(153 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment