Page MenuHomePhabricator

D18958.id45482.diff
No OneTemporary

D18958.id45482.diff

diff --git a/src/applications/search/controller/PhabricatorApplicationSearchController.php b/src/applications/search/controller/PhabricatorApplicationSearchController.php
--- a/src/applications/search/controller/PhabricatorApplicationSearchController.php
+++ b/src/applications/search/controller/PhabricatorApplicationSearchController.php
@@ -418,8 +418,24 @@
$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 @@
$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) {
diff --git a/src/infrastructure/export/format/PhabricatorExcelExportFormat.php b/src/infrastructure/export/format/PhabricatorExcelExportFormat.php
--- a/src/infrastructure/export/format/PhabricatorExcelExportFormat.php
+++ b/src/infrastructure/export/format/PhabricatorExcelExportFormat.php
@@ -14,7 +14,30 @@
}
public function isExportFormatEnabled() {
- return true;
+ // TODO: PHPExcel has a dependency on the PHP zip extension. We should test
+ // for that here, since it fatals if we don't have the ZipArchive class.
+ return @include_once 'PHPExcel.php';
+ }
+
+ public function getInstallInstructions() {
+ return pht(<<<EOHELP
+Data can not be exported to Excel because the PHPExcel library is not
+installed. This software component is required for Phabricator to create
+Excel files.
+
+You can install PHPExcel from GitHub:
+
+> https://github.com/PHPOffice/PHPExcel
+
+Briefly:
+
+ - Clone that repository somewhere on the sever
+ (like `/path/to/example/PHPExcel`).
+ - Update your PHP `%s` setting (in `php.ini`) to include the PHPExcel
+ `Classes` directory (like `/path/to/example/PHPExcel/Classes`).
+EOHELP
+ ,
+ 'include_path');
}
public function getFileExtension() {
diff --git a/src/infrastructure/export/format/PhabricatorExportFormat.php b/src/infrastructure/export/format/PhabricatorExportFormat.php
--- a/src/infrastructure/export/format/PhabricatorExportFormat.php
+++ b/src/infrastructure/export/format/PhabricatorExportFormat.php
@@ -50,16 +50,4 @@
->execute();
}
- final public static function getAllEnabledExportFormats() {
- $formats = self::getAllExportFormats();
-
- foreach ($formats as $key => $format) {
- if (!$format->isExportFormatEnabled()) {
- unset($formats[$key]);
- }
- }
-
- return $formats;
- }
-
}

File Metadata

Mime Type
text/plain
Expires
Mon, Dec 23, 7:46 PM (4 h, 50 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6921898
Default Alt Text
D18958.id45482.diff (3 KB)

Event Timeline