Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/conpherence/controller/ConpherenceRoomPictureController.php b/src/applications/conpherence/controller/ConpherenceRoomPictureController.php
index fbf3def9cd..5be8331610 100644
--- a/src/applications/conpherence/controller/ConpherenceRoomPictureController.php
+++ b/src/applications/conpherence/controller/ConpherenceRoomPictureController.php
@@ -1,235 +1,238 @@
<?php
final class ConpherenceRoomPictureController
extends ConpherenceController {
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$conpherence = id(new ConpherenceThreadQuery())
->setViewer($viewer)
->withIDs(array($id))
->needProfileImage(true)
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
))
->executeOne();
if (!$conpherence) {
return new Aphront404Response();
}
$monogram = $conpherence->getMonogram();
$supported_formats = PhabricatorFile::getTransformableImageFormats();
+ if ($supported_formats) {
+ $supported_formats_message = pht('Supported image formats: %s.',
+ implode(', ', $supported_formats));
+ } else {
+ $supported_formats_message = pht('Server supports no image formats.');
+ }
$e_file = true;
$errors = array();
if ($request->isFormPost()) {
$phid = $request->getStr('phid');
$is_default = false;
if ($phid == PhabricatorPHIDConstants::PHID_VOID) {
$phid = null;
$is_default = true;
} else if ($phid) {
$file = id(new PhabricatorFileQuery())
->setViewer($viewer)
->withPHIDs(array($phid))
->executeOne();
} else {
if ($request->getFileExists('picture')) {
$file = PhabricatorFile::newFromPHPUpload(
$_FILES['picture'],
array(
'authorPHID' => $viewer->getPHID(),
'canCDN' => true,
));
} else {
$e_file = pht('Required');
$errors[] = pht(
'You must choose a file when uploading a new room picture.');
}
}
if (!$errors && !$is_default) {
if (!$file->isTransformableImage()) {
$e_file = pht('Not Supported');
- $errors[] = pht(
- 'This server only supports these image formats: %s.',
- implode(', ', $supported_formats));
+ $errors[] = $supported_formats_message;
} else {
$xform = PhabricatorFileTransform::getTransformByKey(
PhabricatorFileThumbnailTransform::TRANSFORM_PROFILE);
$xformed = $xform->executeTransform($file);
}
}
if (!$errors) {
if ($is_default) {
$new_value = null;
} else {
$xformed->attachToObject($conpherence->getPHID());
$new_value = $xformed->getPHID();
}
$xactions = array();
$xactions[] = id(new ConpherenceTransaction())
->setTransactionType(
ConpherenceThreadPictureTransaction::TRANSACTIONTYPE)
->setNewValue($new_value);
$editor = id(new ConpherenceEditor())
->setActor($viewer)
->setContentSourceFromRequest($request)
->setContinueOnMissingFields(true)
->setContinueOnNoEffect(true);
$editor->applyTransactions($conpherence, $xactions);
return id(new AphrontRedirectResponse())->setURI('/'.$monogram);
}
}
$title = pht('Edit Room Picture');
$form = id(new PHUIFormLayoutView())
->setUser($viewer);
$default_image = PhabricatorFile::loadBuiltin($viewer, 'conpherence.png');
$images = array();
$current = $conpherence->getProfileImagePHID();
$has_current = false;
if ($current) {
$file = id(new PhabricatorFileQuery())
->setViewer($viewer)
->withPHIDs(array($current))
->executeOne();
if ($file) {
if ($file->isTransformableImage()) {
$has_current = true;
$images[$current] = array(
'uri' => $file->getBestURI(),
'tip' => pht('Current Picture'),
);
}
}
}
$images[PhabricatorPHIDConstants::PHID_VOID] = array(
'uri' => $default_image->getBestURI(),
'tip' => pht('Default Picture'),
);
require_celerity_resource('people-profile-css');
Javelin::initBehavior('phabricator-tooltips', array());
$buttons = array();
foreach ($images as $phid => $spec) {
$button = javelin_tag(
'button',
array(
'class' => 'button-grey profile-image-button',
'sigil' => 'has-tooltip',
'meta' => array(
'tip' => $spec['tip'],
'size' => 300,
),
),
phutil_tag(
'img',
array(
'height' => 50,
'width' => 50,
'src' => $spec['uri'],
)));
$button = array(
phutil_tag(
'input',
array(
'type' => 'hidden',
'name' => 'phid',
'value' => $phid,
)),
$button,
);
$button = phabricator_form(
$viewer,
array(
'class' => 'profile-image-form',
'method' => 'POST',
),
$button);
$buttons[] = $button;
}
if ($has_current) {
$form->appendChild(
id(new AphrontFormMarkupControl())
->setLabel(pht('Current Picture'))
->setValue(array_shift($buttons)));
}
$form->appendChild(
id(new AphrontFormMarkupControl())
->setLabel(pht('Use Picture'))
->setValue($buttons));
$form_box = id(new PHUIObjectBoxView())
->setHeaderText($title)
->setFormErrors($errors)
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->setForm($form);
$upload_form = id(new AphrontFormView())
->setUser($viewer)
->setEncType('multipart/form-data')
->appendChild(
id(new AphrontFormFileControl())
->setName('picture')
->setLabel(pht('Upload Picture'))
->setError($e_file)
- ->setCaption(
- pht('Supported formats: %s', implode(', ', $supported_formats))))
+ ->setCaption($supported_formats_message))
->appendChild(
id(new AphrontFormSubmitControl())
->addCancelButton('/'.$monogram)
->setValue(pht('Upload Picture')));
$upload_box = id(new PHUIObjectBoxView())
->setHeaderText(pht('Upload New Picture'))
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->setForm($upload_form);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb($conpherence->getTitle(), '/'.$monogram);
$crumbs->addTextCrumb(pht('Room Picture'));
$crumbs->setBorder(true);
$header = id(new PHUIHeaderView())
->setHeader(pht('Edit Room Picture'))
->setHeaderIcon('fa-camera');
$view = id(new PHUITwoColumnView())
->setHeader($header)
->setFooter(array(
$form_box,
$upload_box,
));
return $this->newPage()
->setTitle($title)
->setCrumbs($crumbs)
->appendChild(
array(
$view,
));
}
}
diff --git a/src/applications/diffusion/controller/DiffusionRepositoryProfilePictureController.php b/src/applications/diffusion/controller/DiffusionRepositoryProfilePictureController.php
index cd4e3148c7..59a49def6f 100644
--- a/src/applications/diffusion/controller/DiffusionRepositoryProfilePictureController.php
+++ b/src/applications/diffusion/controller/DiffusionRepositoryProfilePictureController.php
@@ -1,249 +1,252 @@
<?php
final class DiffusionRepositoryProfilePictureController
extends DiffusionController {
public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();
$id = $request->getURIData('id');
$repository = id(new PhabricatorRepositoryQuery())
->setViewer($viewer)
->withIDs(array($id))
->needProfileImage(true)
->needURIs(true)
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
))
->executeOne();
if (!$repository) {
return new Aphront404Response();
}
$supported_formats = PhabricatorFile::getTransformableImageFormats();
+ if ($supported_formats) {
+ $supported_formats_message = pht('Supported image formats: %s.',
+ implode(', ', $supported_formats));
+ } else {
+ $supported_formats_message = pht('Server supports no image formats.');
+ }
$e_file = true;
$errors = array();
$done_uri = $repository->getURI();
if ($request->isFormPost()) {
$phid = $request->getStr('phid');
$is_default = false;
if ($phid == PhabricatorPHIDConstants::PHID_VOID) {
$phid = null;
$is_default = true;
} else if ($phid) {
$file = id(new PhabricatorFileQuery())
->setViewer($viewer)
->withPHIDs(array($phid))
->executeOne();
} else {
if ($request->getFileExists('picture')) {
$file = PhabricatorFile::newFromPHPUpload(
$_FILES['picture'],
array(
'authorPHID' => $viewer->getPHID(),
'canCDN' => true,
));
} else {
$e_file = pht('Required');
$errors[] = pht(
'You must choose a file when uploading a new profile picture.');
}
}
if (!$errors && !$is_default) {
if (!$file->isTransformableImage()) {
$e_file = pht('Not Supported');
- $errors[] = pht(
- 'This server only supports these image formats: %s.',
- implode(', ', $supported_formats));
+ $errors[] = $supported_formats_message;
} else {
$xform = PhabricatorFileTransform::getTransformByKey(
PhabricatorFileThumbnailTransform::TRANSFORM_PROFILE);
$xformed = $xform->executeTransform($file);
}
}
if (!$errors) {
if ($is_default) {
$repository->setProfileImagePHID(null);
} else {
$repository->setProfileImagePHID($xformed->getPHID());
$xformed->attachToObject($repository->getPHID());
}
$repository->save();
return id(new AphrontRedirectResponse())->setURI($done_uri);
}
}
$title = pht('Edit Picture');
$form = id(new PHUIFormLayoutView())
->setUser($viewer);
$default_image = PhabricatorFile::loadBuiltin(
$viewer, 'repo/code.png');
$images = array();
$current = $repository->getProfileImagePHID();
$has_current = false;
if ($current) {
$files = id(new PhabricatorFileQuery())
->setViewer($viewer)
->withPHIDs(array($current))
->execute();
if ($files) {
$file = head($files);
if ($file->isTransformableImage()) {
$has_current = true;
$images[$current] = array(
'uri' => $file->getBestURI(),
'tip' => pht('Current Picture'),
);
}
}
}
$builtins = array(
'repo/repo-git.png',
'repo/repo-svn.png',
'repo/repo-hg.png',
'repo/building.png',
'repo/cloud.png',
'repo/commit.png',
'repo/database.png',
'repo/desktop.png',
'repo/gears.png',
'repo/globe.png',
'repo/locked.png',
'repo/microchip.png',
'repo/mobile.png',
'repo/repo.png',
'repo/servers.png',
);
foreach ($builtins as $builtin) {
$file = PhabricatorFile::loadBuiltin($viewer, $builtin);
$images[$file->getPHID()] = array(
'uri' => $file->getBestURI(),
'tip' => pht('Builtin Image'),
);
}
$images[PhabricatorPHIDConstants::PHID_VOID] = array(
'uri' => $default_image->getBestURI(),
'tip' => pht('Default Picture'),
);
require_celerity_resource('people-profile-css');
Javelin::initBehavior('phabricator-tooltips', array());
$buttons = array();
foreach ($images as $phid => $spec) {
$style = null;
if (isset($spec['style'])) {
$style = $spec['style'];
}
$button = javelin_tag(
'button',
array(
'class' => 'button-grey profile-image-button',
'sigil' => 'has-tooltip',
'meta' => array(
'tip' => $spec['tip'],
'size' => 300,
),
),
phutil_tag(
'img',
array(
'height' => 50,
'width' => 50,
'src' => $spec['uri'],
)));
$button = array(
phutil_tag(
'input',
array(
'type' => 'hidden',
'name' => 'phid',
'value' => $phid,
)),
$button,
);
$button = phabricator_form(
$viewer,
array(
'class' => 'profile-image-form',
'method' => 'POST',
),
$button);
$buttons[] = $button;
}
if ($has_current) {
$form->appendChild(
id(new AphrontFormMarkupControl())
->setLabel(pht('Current Picture'))
->setValue(array_shift($buttons)));
}
$form->appendChild(
id(new AphrontFormMarkupControl())
->setLabel(pht('Use Picture'))
->setValue($buttons));
$form_box = id(new PHUIObjectBoxView())
->setHeaderText($title)
->setFormErrors($errors)
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->setForm($form);
$upload_form = id(new AphrontFormView())
->setUser($viewer)
->setEncType('multipart/form-data')
->appendChild(
id(new AphrontFormFileControl())
->setName('picture')
->setLabel(pht('Upload Picture'))
->setError($e_file)
- ->setCaption(
- pht('Supported formats: %s', implode(', ', $supported_formats))))
+ ->setCaption($supported_formats_message))
->appendChild(
id(new AphrontFormSubmitControl())
->addCancelButton($done_uri)
->setValue(pht('Upload Picture')));
$header = id(new PHUIHeaderView())
->setHeader(pht('Edit Repository Picture'))
->setHeaderIcon('fa-camera-retro');
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb($repository->getName(), $repository->getURI());
$crumbs->addTextCrumb(pht('Edit Picture'));
$crumbs->setBorder(true);
$upload_box = id(new PHUIObjectBoxView())
->setHeaderText(pht('Upload New Picture'))
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->setForm($upload_form);
$view = id(new PHUITwoColumnView())
->setHeader($header)
->setFooter(array(
$form_box,
$upload_box,
));
return $this->newPage()
->setTitle($title)
->setCrumbs($crumbs)
->appendChild($view);
}
}
diff --git a/src/applications/people/controller/PhabricatorPeopleProfilePictureController.php b/src/applications/people/controller/PhabricatorPeopleProfilePictureController.php
index d50eccff13..72f90f024b 100644
--- a/src/applications/people/controller/PhabricatorPeopleProfilePictureController.php
+++ b/src/applications/people/controller/PhabricatorPeopleProfilePictureController.php
@@ -1,290 +1,293 @@
<?php
final class PhabricatorPeopleProfilePictureController
extends PhabricatorPeopleProfileController {
public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();
$id = $request->getURIData('id');
$user = id(new PhabricatorPeopleQuery())
->setViewer($viewer)
->withIDs(array($id))
->needProfileImage(true)
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
))
->executeOne();
if (!$user) {
return new Aphront404Response();
}
$this->setUser($user);
$name = $user->getUserName();
$done_uri = '/p/'.$name.'/';
$supported_formats = PhabricatorFile::getTransformableImageFormats();
+ if ($supported_formats) {
+ $supported_formats_message = pht('Supported image formats: %s.',
+ implode(', ', $supported_formats));
+ } else {
+ $supported_formats_message = pht('Server supports no image formats.');
+ }
$e_file = true;
$errors = array();
if ($request->isFormPost()) {
$phid = $request->getStr('phid');
$is_default = false;
if ($phid == PhabricatorPHIDConstants::PHID_VOID) {
$phid = null;
$is_default = true;
} else if ($phid) {
$file = id(new PhabricatorFileQuery())
->setViewer($viewer)
->withPHIDs(array($phid))
->executeOne();
} else {
if ($request->getFileExists('picture')) {
$file = PhabricatorFile::newFromPHPUpload(
$_FILES['picture'],
array(
'authorPHID' => $viewer->getPHID(),
'canCDN' => true,
));
} else {
$e_file = pht('Required');
$errors[] = pht(
'You must choose a file when uploading a new profile picture.');
}
}
if (!$errors && !$is_default) {
if (!$file->isTransformableImage()) {
$e_file = pht('Not Supported');
- $errors[] = pht(
- 'This server only supports these image formats: %s.',
- implode(', ', $supported_formats));
+ $errors[] = $supported_formats_message;
} else {
$xform = PhabricatorFileTransform::getTransformByKey(
PhabricatorFileThumbnailTransform::TRANSFORM_PROFILE);
$xformed = $xform->executeTransform($file);
}
}
if (!$errors) {
if ($is_default) {
$user->setProfileImagePHID(null);
} else {
$user->setProfileImagePHID($xformed->getPHID());
$xformed->attachToObject($user->getPHID());
}
$user->save();
return id(new AphrontRedirectResponse())->setURI($done_uri);
}
}
$title = pht('Edit Profile Picture');
$form = id(new PHUIFormLayoutView())
->setUser($viewer);
$default_image = $user->getDefaultProfileImagePHID();
if ($default_image) {
$default_image = id(new PhabricatorFileQuery())
->setViewer($viewer)
->withPHIDs(array($default_image))
->executeOne();
}
if (!$default_image) {
$default_image = PhabricatorFile::loadBuiltin($viewer, 'profile.png');
}
$images = array();
$current = $user->getProfileImagePHID();
$has_current = false;
if ($current) {
$files = id(new PhabricatorFileQuery())
->setViewer($viewer)
->withPHIDs(array($current))
->execute();
if ($files) {
$file = head($files);
if ($file->isTransformableImage()) {
$has_current = true;
$images[$current] = array(
'uri' => $file->getBestURI(),
'tip' => pht('Current Picture'),
);
}
}
}
$builtins = array(
'user1.png',
'user2.png',
'user3.png',
'user4.png',
'user5.png',
'user6.png',
'user7.png',
'user8.png',
'user9.png',
);
foreach ($builtins as $builtin) {
$file = PhabricatorFile::loadBuiltin($viewer, $builtin);
$images[$file->getPHID()] = array(
'uri' => $file->getBestURI(),
'tip' => pht('Builtin Image'),
);
}
// Try to add external account images for any associated external accounts.
$accounts = id(new PhabricatorExternalAccountQuery())
->setViewer($viewer)
->withUserPHIDs(array($user->getPHID()))
->needImages(true)
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
))
->execute();
foreach ($accounts as $account) {
$file = $account->getProfileImageFile();
if ($account->getProfileImagePHID() != $file->getPHID()) {
// This is a default image, just skip it.
continue;
}
$config = $account->getProviderConfig();
$provider = $config->getProvider();
$tip = pht('Picture From %s', $provider->getProviderName());
if ($file->isTransformableImage()) {
$images[$file->getPHID()] = array(
'uri' => $file->getBestURI(),
'tip' => $tip,
);
}
}
$images[PhabricatorPHIDConstants::PHID_VOID] = array(
'uri' => $default_image->getBestURI(),
'tip' => pht('Default Picture'),
);
require_celerity_resource('people-profile-css');
Javelin::initBehavior('phabricator-tooltips', array());
$buttons = array();
foreach ($images as $phid => $spec) {
$style = null;
if (isset($spec['style'])) {
$style = $spec['style'];
}
$button = javelin_tag(
'button',
array(
'class' => 'button-grey profile-image-button',
'sigil' => 'has-tooltip',
'meta' => array(
'tip' => $spec['tip'],
'size' => 300,
),
),
phutil_tag(
'img',
array(
'height' => 50,
'width' => 50,
'src' => $spec['uri'],
)));
$button = array(
phutil_tag(
'input',
array(
'type' => 'hidden',
'name' => 'phid',
'value' => $phid,
)),
$button,
);
$button = phabricator_form(
$viewer,
array(
'class' => 'profile-image-form',
'method' => 'POST',
),
$button);
$buttons[] = $button;
}
if ($has_current) {
$form->appendChild(
id(new AphrontFormMarkupControl())
->setLabel(pht('Current Picture'))
->setValue(array_shift($buttons)));
}
$form->appendChild(
id(new AphrontFormMarkupControl())
->setLabel(pht('Use Picture'))
->setValue($buttons));
$form_box = id(new PHUIObjectBoxView())
->setHeaderText($title)
->setFormErrors($errors)
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->setForm($form);
$upload_form = id(new AphrontFormView())
->setUser($viewer)
->setEncType('multipart/form-data')
->appendChild(
id(new AphrontFormFileControl())
->setName('picture')
->setLabel(pht('Upload Picture'))
->setError($e_file)
- ->setCaption(
- pht('Supported formats: %s', implode(', ', $supported_formats))))
+ ->setCaption($supported_formats_message))
->appendChild(
id(new AphrontFormSubmitControl())
->addCancelButton($done_uri)
->setValue(pht('Upload Picture')));
$upload_box = id(new PHUIObjectBoxView())
->setHeaderText(pht('Upload New Picture'))
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->setForm($upload_form);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Edit Profile Picture'));
$crumbs->setBorder(true);
$nav = $this->newNavigation(
$user,
PhabricatorPeopleProfileMenuEngine::ITEM_MANAGE);
$header = $this->buildProfileHeader();
$view = id(new PHUITwoColumnView())
->setHeader($header)
->addClass('project-view-home')
->addClass('project-view-people-home')
->setFooter(array(
$form_box,
$upload_box,
));
return $this->newPage()
->setTitle($title)
->setCrumbs($crumbs)
->setNavigation($nav)
->appendChild($view);
}
}
diff --git a/src/applications/phame/controller/blog/PhameBlogHeaderPictureController.php b/src/applications/phame/controller/blog/PhameBlogHeaderPictureController.php
index 0106b9571d..4bec8efecc 100644
--- a/src/applications/phame/controller/blog/PhameBlogHeaderPictureController.php
+++ b/src/applications/phame/controller/blog/PhameBlogHeaderPictureController.php
@@ -1,139 +1,142 @@
<?php
final class PhameBlogHeaderPictureController
extends PhameBlogController {
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$blog = id(new PhameBlogQuery())
->setViewer($viewer)
->withIDs(array($id))
->needHeaderImage(true)
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
))
->executeOne();
if (!$blog) {
return new Aphront404Response();
}
$blog_uri = '/phame/blog/manage/'.$id;
$supported_formats = PhabricatorFile::getTransformableImageFormats();
+ if ($supported_formats) {
+ $supported_formats_message = pht('Supported image formats: %s.',
+ implode(', ', $supported_formats));
+ } else {
+ $supported_formats_message = pht('Server supports no image formats.');
+ }
$e_file = true;
$errors = array();
$delete_header = ($request->getInt('delete') == 1);
if ($request->isFormPost()) {
if ($request->getFileExists('header')) {
$file = PhabricatorFile::newFromPHPUpload(
$_FILES['header'],
array(
'authorPHID' => $viewer->getPHID(),
'canCDN' => true,
));
} else if (!$delete_header) {
$e_file = pht('Required');
$errors[] = pht(
'You must choose a file when uploading a new blog header.');
}
if (!$errors && !$delete_header) {
if (!$file->isTransformableImage()) {
$e_file = pht('Not Supported');
- $errors[] = pht(
- 'This server only supports these image formats: %s.',
- implode(', ', $supported_formats));
+ $errors[] = $supported_formats_message;
}
}
if (!$errors) {
if ($delete_header) {
$new_value = null;
} else {
$file->attachToObject($blog->getPHID());
$new_value = $file->getPHID();
}
$xactions = array();
$xactions[] = id(new PhameBlogTransaction())
->setTransactionType(PhameBlogHeaderImageTransaction::TRANSACTIONTYPE)
->setNewValue($new_value);
$editor = id(new PhameBlogEditor())
->setActor($viewer)
->setContentSourceFromRequest($request)
->setContinueOnMissingFields(true)
->setContinueOnNoEffect(true);
$editor->applyTransactions($blog, $xactions);
return id(new AphrontRedirectResponse())->setURI($blog_uri);
}
}
$title = pht('Edit Blog Header');
$upload_form = id(new AphrontFormView())
->setUser($viewer)
->setEncType('multipart/form-data')
->appendChild(
id(new AphrontFormFileControl())
->setName('header')
->setLabel(pht('Upload Header'))
->setError($e_file)
- ->setCaption(
- pht('Supported formats: %s', implode(', ', $supported_formats))))
+ ->setCaption($supported_formats_message))
->appendChild(
id(new AphrontFormCheckboxControl())
->setName('delete')
->setLabel(pht('Delete Header'))
->addCheckbox(
'delete',
1,
null,
null))
->appendChild(
id(new AphrontFormSubmitControl())
->addCancelButton($blog_uri)
->setValue(pht('Upload Header')));
$upload_box = id(new PHUIObjectBoxView())
->setHeaderText(pht('Upload New Header'))
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->setForm($upload_form);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(
pht('Blogs'),
$this->getApplicationURI('blog/'));
$crumbs->addTextCrumb(
$blog->getName(),
$this->getApplicationURI('blog/view/'.$id));
$crumbs->addTextCrumb(pht('Blog Header'));
$crumbs->setBorder(true);
$header = id(new PHUIHeaderView())
->setHeader(pht('Edit Blog Header'))
->setHeaderIcon('fa-camera');
$view = id(new PHUITwoColumnView())
->setHeader($header)
->setFooter(array(
$upload_box,
));
return $this->newPage()
->setTitle($title)
->setCrumbs($crumbs)
->appendChild(
array(
$view,
));
}
}
diff --git a/src/applications/phame/controller/blog/PhameBlogProfilePictureController.php b/src/applications/phame/controller/blog/PhameBlogProfilePictureController.php
index 4e69034253..91daa784cd 100644
--- a/src/applications/phame/controller/blog/PhameBlogProfilePictureController.php
+++ b/src/applications/phame/controller/blog/PhameBlogProfilePictureController.php
@@ -1,241 +1,244 @@
<?php
final class PhameBlogProfilePictureController
extends PhameBlogController {
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$blog = id(new PhameBlogQuery())
->setViewer($viewer)
->withIDs(array($id))
->needProfileImage(true)
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
))
->executeOne();
if (!$blog) {
return new Aphront404Response();
}
$blog_uri = '/phame/blog/manage/'.$id;
$supported_formats = PhabricatorFile::getTransformableImageFormats();
+ if ($supported_formats) {
+ $supported_formats_message = pht('Supported image formats: %s.',
+ implode(', ', $supported_formats));
+ } else {
+ $supported_formats_message = pht('Server supports no image formats.');
+ }
$e_file = true;
$errors = array();
if ($request->isFormPost()) {
$phid = $request->getStr('phid');
$is_default = false;
if ($phid == PhabricatorPHIDConstants::PHID_VOID) {
$phid = null;
$is_default = true;
} else if ($phid) {
$file = id(new PhabricatorFileQuery())
->setViewer($viewer)
->withPHIDs(array($phid))
->executeOne();
} else {
if ($request->getFileExists('picture')) {
$file = PhabricatorFile::newFromPHPUpload(
$_FILES['picture'],
array(
'authorPHID' => $viewer->getPHID(),
'canCDN' => true,
));
} else {
$e_file = pht('Required');
$errors[] = pht(
'You must choose a file when uploading a new blog picture.');
}
}
if (!$errors && !$is_default) {
if (!$file->isTransformableImage()) {
$e_file = pht('Not Supported');
- $errors[] = pht(
- 'This server only supports these image formats: %s.',
- implode(', ', $supported_formats));
+ $errors[] = $supported_formats_message;
} else {
$xform = PhabricatorFileTransform::getTransformByKey(
PhabricatorFileThumbnailTransform::TRANSFORM_PROFILE);
$xformed = $xform->executeTransform($file);
}
}
if (!$errors) {
if ($is_default) {
$new_value = null;
} else {
$xformed->attachToObject($blog->getPHID());
$new_value = $xformed->getPHID();
}
$xactions = array();
$xactions[] = id(new PhameBlogTransaction())
->setTransactionType(
PhameBlogProfileImageTransaction::TRANSACTIONTYPE)
->setNewValue($new_value);
$editor = id(new PhameBlogEditor())
->setActor($viewer)
->setContentSourceFromRequest($request)
->setContinueOnMissingFields(true)
->setContinueOnNoEffect(true);
$editor->applyTransactions($blog, $xactions);
return id(new AphrontRedirectResponse())->setURI($blog_uri);
}
}
$title = pht('Edit Blog Picture');
$form = id(new PHUIFormLayoutView())
->setUser($viewer);
$default_image = PhabricatorFile::loadBuiltin($viewer, 'blog.png');
$images = array();
$current = $blog->getProfileImagePHID();
$has_current = false;
if ($current) {
$files = id(new PhabricatorFileQuery())
->setViewer($viewer)
->withPHIDs(array($current))
->execute();
if ($files) {
$file = head($files);
if ($file->isTransformableImage()) {
$has_current = true;
$images[$current] = array(
'uri' => $file->getBestURI(),
'tip' => pht('Current Picture'),
);
}
}
}
$images[PhabricatorPHIDConstants::PHID_VOID] = array(
'uri' => $default_image->getBestURI(),
'tip' => pht('Default Picture'),
);
require_celerity_resource('people-profile-css');
Javelin::initBehavior('phabricator-tooltips', array());
$buttons = array();
foreach ($images as $phid => $spec) {
$button = javelin_tag(
'button',
array(
'class' => 'button-grey profile-image-button',
'sigil' => 'has-tooltip',
'meta' => array(
'tip' => $spec['tip'],
'size' => 300,
),
),
phutil_tag(
'img',
array(
'height' => 50,
'width' => 50,
'src' => $spec['uri'],
)));
$button = array(
phutil_tag(
'input',
array(
'type' => 'hidden',
'name' => 'phid',
'value' => $phid,
)),
$button,
);
$button = phabricator_form(
$viewer,
array(
'class' => 'profile-image-form',
'method' => 'POST',
),
$button);
$buttons[] = $button;
}
if ($has_current) {
$form->appendChild(
id(new AphrontFormMarkupControl())
->setLabel(pht('Current Picture'))
->setValue(array_shift($buttons)));
}
$form->appendChild(
id(new AphrontFormMarkupControl())
->setLabel(pht('Use Picture'))
->setValue($buttons));
$form_box = id(new PHUIObjectBoxView())
->setHeaderText($title)
->setFormErrors($errors)
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->setForm($form);
$upload_form = id(new AphrontFormView())
->setUser($viewer)
->setEncType('multipart/form-data')
->appendChild(
id(new AphrontFormFileControl())
->setName('picture')
->setLabel(pht('Upload Picture'))
->setError($e_file)
- ->setCaption(
- pht('Supported formats: %s', implode(', ', $supported_formats))))
+ ->setCaption($supported_formats_message))
->appendChild(
id(new AphrontFormSubmitControl())
->addCancelButton($blog_uri)
->setValue(pht('Upload Picture')));
$upload_box = id(new PHUIObjectBoxView())
->setHeaderText(pht('Upload New Picture'))
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->setForm($upload_form);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(
pht('Blogs'),
$this->getApplicationURI('blog/'));
$crumbs->addTextCrumb(
$blog->getName(),
$this->getApplicationURI('blog/view/'.$id));
$crumbs->addTextCrumb(pht('Blog Picture'));
$crumbs->setBorder(true);
$header = id(new PHUIHeaderView())
->setHeader(pht('Edit Blog Picture'))
->setHeaderIcon('fa-camera');
$view = id(new PHUITwoColumnView())
->setHeader($header)
->setFooter(array(
$form_box,
$upload_box,
));
return $this->newPage()
->setTitle($title)
->setCrumbs($crumbs)
->appendChild(
array(
$view,
));
}
}
diff --git a/src/applications/phame/controller/post/PhamePostHeaderPictureController.php b/src/applications/phame/controller/post/PhamePostHeaderPictureController.php
index 60075cc077..db8f662c39 100644
--- a/src/applications/phame/controller/post/PhamePostHeaderPictureController.php
+++ b/src/applications/phame/controller/post/PhamePostHeaderPictureController.php
@@ -1,136 +1,139 @@
<?php
final class PhamePostHeaderPictureController
extends PhamePostController {
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$post = id(new PhamePostQuery())
->setViewer($viewer)
->withIDs(array($id))
->needHeaderImage(true)
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
))
->executeOne();
if (!$post) {
return new Aphront404Response();
}
$post_uri = '/phame/post/view/'.$id;
$supported_formats = PhabricatorFile::getTransformableImageFormats();
+ if ($supported_formats) {
+ $supported_formats_message = pht('Supported image formats: %s.',
+ implode(', ', $supported_formats));
+ } else {
+ $supported_formats_message = pht('Server supports no image formats.');
+ }
$e_file = true;
$errors = array();
$delete_header = ($request->getInt('delete') == 1);
if ($request->isFormPost()) {
if ($request->getFileExists('header')) {
$file = PhabricatorFile::newFromPHPUpload(
$_FILES['header'],
array(
'authorPHID' => $viewer->getPHID(),
'canCDN' => true,
));
} else if (!$delete_header) {
$e_file = pht('Required');
$errors[] = pht(
'You must choose a file when uploading a new post header.');
}
if (!$errors && !$delete_header) {
if (!$file->isTransformableImage()) {
$e_file = pht('Not Supported');
- $errors[] = pht(
- 'This server only supports these image formats: %s.',
- implode(', ', $supported_formats));
+ $errors[] = $supported_formats_message;
}
}
if (!$errors) {
if ($delete_header) {
$new_value = null;
} else {
$file->attachToObject($post->getPHID());
$new_value = $file->getPHID();
}
$xactions = array();
$xactions[] = id(new PhamePostTransaction())
->setTransactionType(PhamePostHeaderImageTransaction::TRANSACTIONTYPE)
->setNewValue($new_value);
$editor = id(new PhamePostEditor())
->setActor($viewer)
->setContentSourceFromRequest($request)
->setContinueOnMissingFields(true)
->setContinueOnNoEffect(true);
$editor->applyTransactions($post, $xactions);
return id(new AphrontRedirectResponse())->setURI($post_uri);
}
}
$title = pht('Edit Post Header');
$upload_form = id(new AphrontFormView())
->setUser($viewer)
->setEncType('multipart/form-data')
->appendChild(
id(new AphrontFormFileControl())
->setName('header')
->setLabel(pht('Upload Header'))
->setError($e_file)
- ->setCaption(
- pht('Supported formats: %s', implode(', ', $supported_formats))))
+ ->setCaption($supported_formats_message))
->appendChild(
id(new AphrontFormCheckboxControl())
->setName('delete')
->setLabel(pht('Delete Header'))
->addCheckbox(
'delete',
1,
null,
null))
->appendChild(
id(new AphrontFormSubmitControl())
->addCancelButton($post_uri)
->setValue(pht('Upload Header')));
$upload_box = id(new PHUIObjectBoxView())
->setHeaderText(pht('Upload New Header'))
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->setForm($upload_form);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(
$post->getTitle(),
$this->getApplicationURI('post/view/'.$id));
$crumbs->addTextCrumb(pht('Post Header'));
$crumbs->setBorder(true);
$header = id(new PHUIHeaderView())
->setHeader(pht('Edit Post Header'))
->setHeaderIcon('fa-camera');
$view = id(new PHUITwoColumnView())
->setHeader($header)
->setFooter(array(
$upload_box,
));
return $this->newPage()
->setTitle($title)
->setCrumbs($crumbs)
->appendChild(
array(
$view,
));
}
}
diff --git a/src/applications/phortune/controller/merchant/PhortuneMerchantPictureController.php b/src/applications/phortune/controller/merchant/PhortuneMerchantPictureController.php
index 96f4f8e367..a3b9ada7af 100644
--- a/src/applications/phortune/controller/merchant/PhortuneMerchantPictureController.php
+++ b/src/applications/phortune/controller/merchant/PhortuneMerchantPictureController.php
@@ -1,223 +1,226 @@
<?php
final class PhortuneMerchantPictureController
extends PhortuneMerchantController {
protected function shouldRequireMerchantEditCapability() {
return true;
}
protected function handleMerchantRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$merchant = $this->getMerchant();
$uri = $merchant->getDetailsURI();
$supported_formats = PhabricatorFile::getTransformableImageFormats();
+ if ($supported_formats) {
+ $supported_formats_message = pht('Supported image formats: %s.',
+ implode(', ', $supported_formats));
+ } else {
+ $supported_formats_message = pht('Server supports no image formats.');
+ }
$e_file = true;
$errors = array();
if ($request->isFormPost()) {
$phid = $request->getStr('phid');
$is_default = false;
if ($phid == PhabricatorPHIDConstants::PHID_VOID) {
$phid = null;
$is_default = true;
} else if ($phid) {
$file = id(new PhabricatorFileQuery())
->setViewer($viewer)
->withPHIDs(array($phid))
->executeOne();
} else {
if ($request->getFileExists('picture')) {
$file = PhabricatorFile::newFromPHPUpload(
$_FILES['picture'],
array(
'authorPHID' => $viewer->getPHID(),
'canCDN' => true,
));
} else {
$e_file = pht('Required');
$errors[] = pht(
'You must choose a file when uploading a merchant logo.');
}
}
if (!$errors && !$is_default) {
if (!$file->isTransformableImage()) {
$e_file = pht('Not Supported');
- $errors[] = pht(
- 'This server only supports these image formats: %s.',
- implode(', ', $supported_formats));
+ $errors[] = $supported_formats_message;
} else {
$xform = PhabricatorFileTransform::getTransformByKey(
PhabricatorFileThumbnailTransform::TRANSFORM_PROFILE);
$xformed = $xform->executeTransform($file);
}
}
if (!$errors) {
if ($is_default) {
$new_value = null;
} else {
$xformed->attachToObject($merchant->getPHID());
$new_value = $xformed->getPHID();
}
$xactions = array();
$xactions[] = id(new PhortuneMerchantTransaction())
->setTransactionType(
PhortuneMerchantPictureTransaction::TRANSACTIONTYPE)
->setNewValue($new_value);
$editor = id(new PhortuneMerchantEditor())
->setActor($viewer)
->setContentSourceFromRequest($request)
->setContinueOnMissingFields(true)
->setContinueOnNoEffect(true);
$editor->applyTransactions($merchant, $xactions);
return id(new AphrontRedirectResponse())->setURI($uri);
}
}
$title = pht('Edit Logo');
$form = id(new PHUIFormLayoutView())
->setUser($viewer);
$default_image = PhabricatorFile::loadBuiltin($viewer, 'merchant.png');
$images = array();
$current = $merchant->getProfileImagePHID();
$has_current = false;
if ($current) {
$file = id(new PhabricatorFileQuery())
->setViewer($viewer)
->withPHIDs(array($current))
->executeOne();
if ($file) {
if ($file->isTransformableImage()) {
$has_current = true;
$images[$current] = array(
'uri' => $file->getBestURI(),
'tip' => pht('Current Picture'),
);
}
}
}
$images[PhabricatorPHIDConstants::PHID_VOID] = array(
'uri' => $default_image->getBestURI(),
'tip' => pht('Default Picture'),
);
require_celerity_resource('people-profile-css');
Javelin::initBehavior('phabricator-tooltips', array());
$buttons = array();
foreach ($images as $phid => $spec) {
$button = javelin_tag(
'button',
array(
'class' => 'button-grey profile-image-button',
'sigil' => 'has-tooltip',
'meta' => array(
'tip' => $spec['tip'],
'size' => 300,
),
),
phutil_tag(
'img',
array(
'height' => 50,
'width' => 50,
'src' => $spec['uri'],
)));
$button = array(
phutil_tag(
'input',
array(
'type' => 'hidden',
'name' => 'phid',
'value' => $phid,
)),
$button,
);
$button = phabricator_form(
$viewer,
array(
'class' => 'profile-image-form',
'method' => 'POST',
),
$button);
$buttons[] = $button;
}
if ($has_current) {
$form->appendChild(
id(new AphrontFormMarkupControl())
->setLabel(pht('Current Logo'))
->setValue(array_shift($buttons)));
}
$form->appendChild(
id(new AphrontFormMarkupControl())
->setLabel(pht('Use Logo'))
->setValue($buttons));
$form_box = id(new PHUIObjectBoxView())
->setHeaderText($title)
->setFormErrors($errors)
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->setForm($form);
$upload_form = id(new AphrontFormView())
->setUser($viewer)
->setEncType('multipart/form-data')
->appendChild(
id(new AphrontFormFileControl())
->setName('picture')
->setLabel(pht('Upload Logo'))
->setError($e_file)
- ->setCaption(
- pht('Supported formats: %s', implode(', ', $supported_formats))))
+ ->setCaption($supported_formats_message))
->appendChild(
id(new AphrontFormSubmitControl())
->addCancelButton($uri)
->setValue(pht('Upload Logo')));
$upload_box = id(new PHUIObjectBoxView())
->setHeaderText(pht('Upload New Logo'))
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->setForm($upload_form);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Edit Logo'));
$header = id(new PHUIHeaderView())
->setHeader(pht('Edit Logo'))
->setHeaderIcon('fa-camera');
$view = id(new PHUITwoColumnView())
->setHeader($header)
->setFooter(array(
$form_box,
$upload_box,
));
return $this->newPage()
->setTitle($title)
->setCrumbs($crumbs)
->appendChild(
array(
$view,
));
}
}
diff --git a/src/applications/project/controller/PhabricatorProjectEditPictureController.php b/src/applications/project/controller/PhabricatorProjectEditPictureController.php
index d141dc07e2..b8be55899b 100644
--- a/src/applications/project/controller/PhabricatorProjectEditPictureController.php
+++ b/src/applications/project/controller/PhabricatorProjectEditPictureController.php
@@ -1,354 +1,357 @@
<?php
final class PhabricatorProjectEditPictureController
extends PhabricatorProjectController {
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$project = id(new PhabricatorProjectQuery())
->setViewer($viewer)
->withIDs(array($id))
->needImages(true)
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
))
->executeOne();
if (!$project) {
return new Aphront404Response();
}
$this->setProject($project);
$manage_uri = $this->getApplicationURI('manage/'.$project->getID().'/');
$supported_formats = PhabricatorFile::getTransformableImageFormats();
+ if ($supported_formats) {
+ $supported_formats_message = pht('Supported image formats: %s.',
+ implode(', ', $supported_formats));
+ } else {
+ $supported_formats_message = pht('Server supports no image formats.');
+ }
$e_file = true;
$errors = array();
if ($request->isFormPost()) {
$phid = $request->getStr('phid');
$is_default = false;
if ($phid == PhabricatorPHIDConstants::PHID_VOID) {
$phid = null;
$is_default = true;
} else if ($phid) {
$file = id(new PhabricatorFileQuery())
->setViewer($viewer)
->withPHIDs(array($phid))
->executeOne();
} else {
if ($request->getFileExists('picture')) {
$file = PhabricatorFile::newFromPHPUpload(
$_FILES['picture'],
array(
'authorPHID' => $viewer->getPHID(),
'canCDN' => true,
));
} else {
$e_file = pht('Required');
$errors[] = pht(
'You must choose a file when uploading a new project picture.');
}
}
if (!$errors && !$is_default) {
if (!$file->isTransformableImage()) {
$e_file = pht('Not Supported');
- $errors[] = pht(
- 'This server only supports these image formats: %s.',
- implode(', ', $supported_formats));
+ $errors[] = $supported_formats_message;
} else {
$xform = PhabricatorFileTransform::getTransformByKey(
PhabricatorFileThumbnailTransform::TRANSFORM_PROFILE);
$xformed = $xform->executeTransform($file);
}
}
if (!$errors) {
if ($is_default) {
$new_value = null;
} else {
$new_value = $xformed->getPHID();
}
$xactions = array();
$xactions[] = id(new PhabricatorProjectTransaction())
->setTransactionType(
PhabricatorProjectImageTransaction::TRANSACTIONTYPE)
->setNewValue($new_value);
$editor = id(new PhabricatorProjectTransactionEditor())
->setActor($viewer)
->setContentSourceFromRequest($request)
->setContinueOnMissingFields(true)
->setContinueOnNoEffect(true);
$editor->applyTransactions($project, $xactions);
return id(new AphrontRedirectResponse())->setURI($manage_uri);
}
}
$title = pht('Edit Project Picture');
$form = id(new PHUIFormLayoutView())
->setUser($viewer);
$builtin = PhabricatorProjectIconSet::getIconImage(
$project->getIcon());
$default_image = PhabricatorFile::loadBuiltin($this->getViewer(),
'projects/'.$builtin);
$images = array();
$current = $project->getProfileImagePHID();
$has_current = false;
if ($current) {
$files = id(new PhabricatorFileQuery())
->setViewer($viewer)
->withPHIDs(array($current))
->execute();
if ($files) {
$file = head($files);
if ($file->isTransformableImage()) {
$has_current = true;
$images[$current] = array(
'uri' => $file->getBestURI(),
'tip' => pht('Current Picture'),
);
}
}
}
$root = dirname(phutil_get_library_root('phabricator'));
$root = $root.'/resources/builtin/projects/v3/';
$builtins = id(new FileFinder($root))
->withType('f')
->withFollowSymlinks(true)
->find();
foreach ($builtins as $builtin) {
$file = PhabricatorFile::loadBuiltin($viewer, 'projects/v3/'.$builtin);
$images[$file->getPHID()] = array(
'uri' => $file->getBestURI(),
'tip' => pht('Builtin Image'),
);
}
$images[PhabricatorPHIDConstants::PHID_VOID] = array(
'uri' => $default_image->getBestURI(),
'tip' => pht('Default Picture'),
);
require_celerity_resource('people-profile-css');
Javelin::initBehavior('phabricator-tooltips', array());
$buttons = array();
foreach ($images as $phid => $spec) {
$button = javelin_tag(
'button',
array(
'class' => 'button-grey profile-image-button',
'sigil' => 'has-tooltip',
'meta' => array(
'tip' => $spec['tip'],
'size' => 300,
),
),
phutil_tag(
'img',
array(
'height' => 50,
'width' => 50,
'src' => $spec['uri'],
)));
$button = array(
phutil_tag(
'input',
array(
'type' => 'hidden',
'name' => 'phid',
'value' => $phid,
)),
$button,
);
$button = phabricator_form(
$viewer,
array(
'class' => 'profile-image-form',
'method' => 'POST',
),
$button);
$buttons[] = $button;
}
if ($has_current) {
$form->appendChild(
id(new AphrontFormMarkupControl())
->setLabel(pht('Current Picture'))
->setValue(array_shift($buttons)));
}
$form->appendChild(
id(new AphrontFormMarkupControl())
->setLabel(pht('Use Picture'))
->setValue(
array(
$this->renderDefaultForm($project),
$buttons,
)));
$launch_id = celerity_generate_unique_node_id();
$input_id = celerity_generate_unique_node_id();
Javelin::initBehavior(
'launch-icon-composer',
array(
'launchID' => $launch_id,
'inputID' => $input_id,
));
$compose_button = javelin_tag(
'button',
array(
'class' => 'button-grey',
'id' => $launch_id,
'sigil' => 'icon-composer',
),
pht('Choose Icon and Color...'));
$compose_input = javelin_tag(
'input',
array(
'type' => 'hidden',
'id' => $input_id,
'name' => 'phid',
));
$compose_form = phabricator_form(
$viewer,
array(
'class' => 'profile-image-form',
'method' => 'POST',
),
array(
$compose_input,
$compose_button,
));
$form->appendChild(
id(new AphrontFormMarkupControl())
->setLabel(pht('Custom'))
->setValue($compose_form));
$upload_form = id(new AphrontFormView())
->setUser($viewer)
->setEncType('multipart/form-data')
->appendChild(
id(new AphrontFormFileControl())
->setName('picture')
->setLabel(pht('Upload Picture'))
->setError($e_file)
- ->setCaption(
- pht('Supported formats: %s', implode(', ', $supported_formats))))
+ ->setCaption($supported_formats_message))
->appendChild(
id(new AphrontFormSubmitControl())
->addCancelButton($manage_uri)
->setValue(pht('Upload Picture')));
$form_box = id(new PHUIObjectBoxView())
->setHeaderText($title)
->setFormErrors($errors)
->setForm($form);
$upload_box = id(new PHUIObjectBoxView())
->setHeaderText(pht('Upload New Picture'))
->setForm($upload_form);
$nav = $this->newNavigation(
$project,
PhabricatorProject::ITEM_MANAGE);
return $this->newPage()
->setTitle($title)
->setNavigation($nav)
->appendChild(
array(
$form_box,
$upload_box,
));
}
private function renderDefaultForm(PhabricatorProject $project) {
$viewer = $this->getViewer();
$compose_color = $project->getDisplayIconComposeColor();
$compose_icon = $project->getDisplayIconComposeIcon();
$default_builtin = id(new PhabricatorFilesComposeIconBuiltinFile())
->setColor($compose_color)
->setIcon($compose_icon);
$file_builtins = PhabricatorFile::loadBuiltins(
$viewer,
array($default_builtin));
$file_builtin = head($file_builtins);
$default_button = javelin_tag(
'button',
array(
'class' => 'button-grey profile-image-button',
'sigil' => 'has-tooltip',
'meta' => array(
'tip' => pht('Use Icon and Color'),
'size' => 300,
),
),
phutil_tag(
'img',
array(
'height' => 50,
'width' => 50,
'src' => $file_builtin->getBestURI(),
)));
$inputs = array(
'projectPHID' => $project->getPHID(),
'icon' => $compose_icon,
'color' => $compose_color,
);
foreach ($inputs as $key => $value) {
$inputs[$key] = javelin_tag(
'input',
array(
'type' => 'hidden',
'name' => $key,
'value' => $value,
));
}
$default_form = phabricator_form(
$viewer,
array(
'class' => 'profile-image-form',
'method' => 'POST',
'action' => '/file/compose/',
),
array(
$inputs,
$default_button,
));
return $default_form;
}
}

File Metadata

Mime Type
text/x-diff
Expires
Sat, Sep 20, 2:16 AM (53 m, 45 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
241287
Default Alt Text
(58 KB)

Event Timeline