When PHPExcel is not installed, detect it and provide install instructions
Summary: Depends on D18957. Ref T13049. To do Excel exports, PHPExcel needs to be installed on the system somewhere. This library is enormous (1K files, ~100K SLOC), which is why we don't just include it in `externals/`. This install process is a little weird and we could improve it, but users don't seem to have too much difficulty with it. This shouldn't be worse than the existing workflow in Maniphest, and I tried to make it at least slightly more clear. Test Plan: Uninstalled PHPExcel, got it marked "Unavailable" and got reasonably-helpful-ish guidance on how to get it to work. Reinstalled, exported, got a sheet. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13049 Differential Revision: https://secure.phabricator.com/D18958
This commit is contained in:
@@ -418,8 +418,24 @@ final class PhabricatorApplicationSearchController
|
||||
$filename = phutil_utf8_strtolower($filename);
|
||||
$filename = PhabricatorFile::normalizeFileName($filename);
|
||||
|
||||
$formats = PhabricatorExportFormat::getAllEnabledExportFormats();
|
||||
$format_options = mpull($formats, 'getExportFormatName');
|
||||
$all_formats = PhabricatorExportFormat::getAllExportFormats();
|
||||
|
||||
$available_options = array();
|
||||
$unavailable_options = array();
|
||||
$formats = array();
|
||||
$unavailable_formats = array();
|
||||
foreach ($all_formats as $key => $format) {
|
||||
if ($format->isExportFormatEnabled()) {
|
||||
$available_options[$key] = $format->getExportFormatName();
|
||||
$formats[$key] = $format;
|
||||
} else {
|
||||
$unavailable_options[$key] = pht(
|
||||
'%s (Not Available)',
|
||||
$format->getExportFormatName());
|
||||
$unavailable_formats[$key] = $format;
|
||||
}
|
||||
}
|
||||
$format_options = $available_options + $unavailable_options;
|
||||
|
||||
// Try to default to the format the user used last time. If you just
|
||||
// exported to Excel, you probably want to export to Excel again.
|
||||
@@ -433,6 +449,22 @@ final class PhabricatorApplicationSearchController
|
||||
$e_format = null;
|
||||
if ($request->isFormPost()) {
|
||||
$format_key = $request->getStr('format');
|
||||
|
||||
if (isset($unavailable_formats[$format_key])) {
|
||||
$unavailable = $unavailable_formats[$format_key];
|
||||
$instructions = $unavailable->getInstallInstructions();
|
||||
|
||||
$markup = id(new PHUIRemarkupView($viewer, $instructions))
|
||||
->setRemarkupOption(
|
||||
PHUIRemarkupView::OPTION_PRESERVE_LINEBREAKS,
|
||||
false);
|
||||
|
||||
return $this->newDialog()
|
||||
->setTitle(pht('Export Format Not Available'))
|
||||
->appendChild($markup)
|
||||
->addCancelButton($cancel_uri, pht('Done'));
|
||||
}
|
||||
|
||||
$format = idx($formats, $format_key);
|
||||
|
||||
if (!$format) {
|
||||
|
||||
Reference in New Issue
Block a user