1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-27 01:02:42 +01:00

Conpherence - fix a few bugs

Summary: fixes the "click edit and it clears title" bug. fixes a "upload the same image again and I get nothing" bug by making the create file codepath also copy dimensions if the file already exists, rather than making a copy sans dimensions. fixes the "title is so long it breaks the widget" bug by truncating the text AND adding some CSS to prevent it from happening.

Test Plan: messed around with a conpherence. changed the title, changed the picture, changed the crop and all worked. uploaded some long file names and verified they were truncated nicely.

Reviewers: epriestley, chad

Reviewed By: chad

CC: aran, Korvin

Maniphest Tasks: T2399

Differential Revision: https://secure.phabricator.com/D5378
This commit is contained in:
Bob Trahan 2013-03-18 16:31:38 -07:00
parent 1a92976c14
commit b8c04419f0
4 changed files with 28 additions and 4 deletions

View file

@ -77,7 +77,7 @@ final class ConpherenceUpdateController extends
$xactions[] = id(new ConpherenceTransaction())
->setTransactionType(ConpherenceTransactionType::TYPE_PICTURE)
->setNewValue($orig_file->getPHID());
// do 2 transformations "crudely"
// do a transformation "crudely"
$xformer = new PhabricatorImageTransformer();
$header_file = $xformer->executeConpherenceTransform(
$orig_file,
@ -105,7 +105,14 @@ final class ConpherenceUpdateController extends
$title = $conpherence->getTitle();
$updated = true;
$fancy_ajax_style = false;
} else if ($top !== null || $left !== null) {
}
// all other metadata updates are continue requests
if (!$request->isContinueRequest()) {
break;
}
if ($top !== null || $left !== null) {
$file = $conpherence->getImage(ConpherenceImageData::SIZE_ORIG);
$xformer = new PhabricatorImageTransformer();
$xformed = $xformer->executeConpherenceTransform(
@ -128,7 +135,7 @@ final class ConpherenceUpdateController extends
->setNewValue($title);
$updated = true;
}
if (!$updated && $request->isContinueRequest()) {
if (!$updated) {
$errors[] = pht(
'That was a non-update. Try cancel.');
}

View file

@ -39,7 +39,7 @@ final class ConpherenceFileWidgetView extends AphrontView {
'');
$file_view = id(new PhabricatorFileLinkView())
->setFilePHID($file->getPHID())
->setFileName($file->getName())
->setFileName(phutil_utf8_shorten($file->getName(), 38))
->setFileViewable($file->isViewableImage())
->setFileViewURI($file->getBestURI())
->setCustomClass('file-title');

View file

@ -165,6 +165,7 @@ final class PhabricatorFile extends PhabricatorFileDAO
$new_file->setStorageHandle($copy_of_storage_handle);
$new_file->setStorageFormat($copy_of_storage_format);
$new_file->setMimeType($copy_of_mimeType);
$new_file->copyDimensions($file);
$new_file->save();
@ -636,6 +637,20 @@ final class PhabricatorFile extends PhabricatorFileDAO
return $this;
}
public function copyDimensions(PhabricatorFile $file) {
$metadata = $file->getMetadata();
$width = idx($metadata, self::METADATA_IMAGE_WIDTH);
if ($width) {
$this->metadata[self::METADATA_IMAGE_WIDTH] = $width;
}
$height = idx($metadata, self::METADATA_IMAGE_HEIGHT);
if ($height) {
$this->metadata[self::METADATA_IMAGE_HEIGHT] = $height;
}
return $this;
}
public static function getMetadataName($metadata) {
switch ($metadata) {
case self::METADATA_IMAGE_WIDTH:

View file

@ -87,6 +87,8 @@
position: relative;
top: -4px;
left: 20px;
overflow-x: hidden;
width: 270px;
font-weight: bold;
}
.conpherence-widget-pane #widgets-files .file-uploaded-by {