Differential D18958 Diff 45482 src/applications/search/controller/PhabricatorApplicationSearchController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/search/controller/PhabricatorApplicationSearchController.php
Show First 20 Lines • Show All 412 Lines • ▼ Show 20 Lines | if ($named_query) { | ||||
$sheet_title = $named_query->getQueryName(); | $sheet_title = $named_query->getQueryName(); | ||||
} else { | } else { | ||||
$filename = $engine->getResultTypeDescription(); | $filename = $engine->getResultTypeDescription(); | ||||
$sheet_title = $engine->getResultTypeDescription(); | $sheet_title = $engine->getResultTypeDescription(); | ||||
} | } | ||||
$filename = phutil_utf8_strtolower($filename); | $filename = phutil_utf8_strtolower($filename); | ||||
$filename = PhabricatorFile::normalizeFileName($filename); | $filename = PhabricatorFile::normalizeFileName($filename); | ||||
$formats = PhabricatorExportFormat::getAllEnabledExportFormats(); | $all_formats = PhabricatorExportFormat::getAllExportFormats(); | ||||
$format_options = mpull($formats, 'getExportFormatName'); | |||||
$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 | // 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. | // exported to Excel, you probably want to export to Excel again. | ||||
$format_key = $this->readExportFormatPreference(); | $format_key = $this->readExportFormatPreference(); | ||||
if (!isset($formats[$format_key])) { | if (!isset($formats[$format_key])) { | ||||
$format_key = head_key($format_options); | $format_key = head_key($format_options); | ||||
} | } | ||||
$errors = array(); | $errors = array(); | ||||
$e_format = null; | $e_format = null; | ||||
if ($request->isFormPost()) { | if ($request->isFormPost()) { | ||||
$format_key = $request->getStr('format'); | $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); | $format = idx($formats, $format_key); | ||||
if (!$format) { | if (!$format) { | ||||
$e_format = pht('Invalid'); | $e_format = pht('Invalid'); | ||||
$errors[] = pht('Choose a valid export format.'); | $errors[] = pht('Choose a valid export format.'); | ||||
} | } | ||||
if (!$errors) { | if (!$errors) { | ||||
▲ Show 20 Lines • Show All 510 Lines • Show Last 20 Lines |