Differential D16217 Diff 39014 src/applications/phame/controller/blog/PhameBlogHeaderPictureController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phame/controller/blog/PhameBlogHeaderPictureController.php
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | if ($request->isFormPost()) { | ||||
$errors[] = pht( | $errors[] = pht( | ||||
'This server only supports these image formats: %s.', | 'This server only supports these image formats: %s.', | ||||
implode(', ', $supported_formats)); | implode(', ', $supported_formats)); | ||||
} | } | ||||
} | } | ||||
if (!$errors) { | if (!$errors) { | ||||
if ($delete_header) { | if ($delete_header) { | ||||
$blog->setHeaderImagePHID(null); | $new_value = null; | ||||
} else { | } else { | ||||
$blog->setHeaderImagePHID($file->getPHID()); | |||||
$file->attachToObject($blog->getPHID()); | $file->attachToObject($blog->getPHID()); | ||||
$new_value = $file->getPHID(); | |||||
} | } | ||||
$blog->save(); | |||||
$xactions = array(); | |||||
$xactions[] = id(new PhameBlogTransaction()) | |||||
->setTransactionType(PhameBlogTransaction::TYPE_HEADERIMAGE) | |||||
->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); | return id(new AphrontRedirectResponse())->setURI($blog_uri); | ||||
} | } | ||||
} | } | ||||
$title = pht('Edit Blog Header'); | $title = pht('Edit Blog Header'); | ||||
$upload_form = id(new AphrontFormView()) | $upload_form = id(new AphrontFormView()) | ||||
->setUser($viewer) | ->setUser($viewer) | ||||
▲ Show 20 Lines • Show All 57 Lines • Show Last 20 Lines |