From ea58b6aceae30e27a624184b72adacf0a98148bb Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 29 Jan 2018 08:56:49 -0800 Subject: [PATCH] Remove the old, non-modular Excel export workflow from Maniphest Summary: Depends on D18960. Ref T13049. Now that Maniphest fully supports "Export Data", remove the old hard-coded version. This is a backward compatibility break with the handful of installs that might have defined a custom export by subclassing `ManiphestExcelFormat`. I suspect this is almost zero installs, and that the additional data in the new format may serve most of the needs of this tiny number of installs. They can upgrade to `ExportEngineExtensions` fairly easily if this isn't true. Test Plan: - Viewed Maniphest, no longer saw the old export workflow. - Grepped for `export` and similar strings to try to hunt everything down. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13049 Differential Revision: https://secure.phabricator.com/D18961 --- src/__phutil_library_map__.php | 8 - .../PhabricatorManiphestApplication.php | 1 - .../controller/ManiphestExportController.php | 135 ----------------- .../export/ManiphestExcelDefaultFormat.php | 140 ------------------ .../maniphest/export/ManiphestExcelFormat.php | 35 ----- .../ManiphestExcelFormatTestCase.php | 10 -- .../view/ManiphestTaskResultListView.php | 13 +- ...PhabricatorApplicationSearchController.php | 2 +- 8 files changed, 2 insertions(+), 342 deletions(-) delete mode 100644 src/applications/maniphest/controller/ManiphestExportController.php delete mode 100644 src/applications/maniphest/export/ManiphestExcelDefaultFormat.php delete mode 100644 src/applications/maniphest/export/ManiphestExcelFormat.php delete mode 100644 src/applications/maniphest/export/__tests__/ManiphestExcelFormatTestCase.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 132c112879..1f71d97460 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1525,10 +1525,6 @@ phutil_register_library_map(array( 'ManiphestEditProjectsCapability' => 'applications/maniphest/capability/ManiphestEditProjectsCapability.php', 'ManiphestEditStatusCapability' => 'applications/maniphest/capability/ManiphestEditStatusCapability.php', 'ManiphestEmailCommand' => 'applications/maniphest/command/ManiphestEmailCommand.php', - 'ManiphestExcelDefaultFormat' => 'applications/maniphest/export/ManiphestExcelDefaultFormat.php', - 'ManiphestExcelFormat' => 'applications/maniphest/export/ManiphestExcelFormat.php', - 'ManiphestExcelFormatTestCase' => 'applications/maniphest/export/__tests__/ManiphestExcelFormatTestCase.php', - 'ManiphestExportController' => 'applications/maniphest/controller/ManiphestExportController.php', 'ManiphestGetTaskTransactionsConduitAPIMethod' => 'applications/maniphest/conduit/ManiphestGetTaskTransactionsConduitAPIMethod.php', 'ManiphestHovercardEngineExtension' => 'applications/maniphest/engineextension/ManiphestHovercardEngineExtension.php', 'ManiphestInfoConduitAPIMethod' => 'applications/maniphest/conduit/ManiphestInfoConduitAPIMethod.php', @@ -6780,10 +6776,6 @@ phutil_register_library_map(array( 'ManiphestEditProjectsCapability' => 'PhabricatorPolicyCapability', 'ManiphestEditStatusCapability' => 'PhabricatorPolicyCapability', 'ManiphestEmailCommand' => 'MetaMTAEmailTransactionCommand', - 'ManiphestExcelDefaultFormat' => 'ManiphestExcelFormat', - 'ManiphestExcelFormat' => 'Phobject', - 'ManiphestExcelFormatTestCase' => 'PhabricatorTestCase', - 'ManiphestExportController' => 'ManiphestController', 'ManiphestGetTaskTransactionsConduitAPIMethod' => 'ManiphestConduitAPIMethod', 'ManiphestHovercardEngineExtension' => 'PhabricatorHovercardEngineExtension', 'ManiphestInfoConduitAPIMethod' => 'ManiphestConduitAPIMethod', diff --git a/src/applications/maniphest/application/PhabricatorManiphestApplication.php b/src/applications/maniphest/application/PhabricatorManiphestApplication.php index 4376eb3f32..0075770863 100644 --- a/src/applications/maniphest/application/PhabricatorManiphestApplication.php +++ b/src/applications/maniphest/application/PhabricatorManiphestApplication.php @@ -57,7 +57,6 @@ final class PhabricatorManiphestApplication extends PhabricatorApplication { $this->getEditRoutePattern('edit/') => 'ManiphestTaskEditController', ), - 'export/(?P[^/]+)/' => 'ManiphestExportController', 'subpriority/' => 'ManiphestSubpriorityController', ), ); diff --git a/src/applications/maniphest/controller/ManiphestExportController.php b/src/applications/maniphest/controller/ManiphestExportController.php deleted file mode 100644 index 1201c50478..0000000000 --- a/src/applications/maniphest/controller/ManiphestExportController.php +++ /dev/null @@ -1,135 +0,0 @@ -getViewer(); - $key = $request->getURIData('key'); - - $ok = @include_once 'PHPExcel.php'; - if (!$ok) { - $dialog = $this->newDialog(); - - $inst1 = pht( - 'This system does not have PHPExcel installed. This software '. - 'component is required to export tasks to Excel. Have your system '. - 'administrator install it from:'); - - $inst2 = pht( - 'Your PHP "%s" needs to be updated to include the '. - 'PHPExcel Classes directory.', - 'include_path'); - - $dialog->setTitle(pht('Excel Export Not Configured')); - $dialog->appendChild(hsprintf( - '

%s

'. - '
'. - '

'. - ''. - 'https://github.com/PHPOffice/PHPExcel'. - ''. - '

'. - '
'. - '

%s

', - $inst1, - $inst2)); - - $dialog->addCancelButton('/maniphest/'); - return id(new AphrontDialogResponse())->setDialog($dialog); - } - - // 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. - - $saved = id(new PhabricatorSavedQueryQuery()) - ->setViewer($viewer) - ->withQueryKeys(array($key)) - ->executeOne(); - if (!$saved) { - $engine = id(new ManiphestTaskSearchEngine()) - ->setViewer($viewer); - if ($engine->isBuiltinQuery($key)) { - $saved = $engine->buildSavedQueryFromBuiltin($key); - } - if (!$saved) { - return new Aphront404Response(); - } - } - - $formats = ManiphestExcelFormat::loadAllFormats(); - $export_formats = array(); - foreach ($formats as $format_class => $format_object) { - $export_formats[$format_class] = $format_object->getName(); - } - - if (!$request->isDialogFormPost()) { - $dialog = new AphrontDialogView(); - $dialog->setUser($viewer); - - $dialog->setTitle(pht('Export Tasks to Excel')); - $dialog->appendChild( - phutil_tag( - 'p', - array(), - pht('Do you want to export the query results to Excel?'))); - - $form = id(new PHUIFormLayoutView()) - ->appendChild( - id(new AphrontFormSelectControl()) - ->setLabel(pht('Format:')) - ->setName('excel-format') - ->setOptions($export_formats)); - - $dialog->appendChild($form); - - $dialog->addCancelButton('/maniphest/'); - $dialog->addSubmitButton(pht('Export to Excel')); - return id(new AphrontDialogResponse())->setDialog($dialog); - } - - $format = idx($formats, $request->getStr('excel-format')); - if ($format === null) { - throw new Exception(pht('Excel format object not found.')); - } - - $saved->makeEphemeral(); - $saved->setParameter('limit', PHP_INT_MAX); - - $engine = id(new ManiphestTaskSearchEngine()) - ->setViewer($viewer); - - $query = $engine->buildQueryFromSavedQuery($saved); - $query->setViewer($viewer); - $tasks = $query->execute(); - - $all_projects = array_mergev(mpull($tasks, 'getProjectPHIDs')); - $all_assigned = mpull($tasks, 'getOwnerPHID'); - - $handles = id(new PhabricatorHandleQuery()) - ->setViewer($viewer) - ->withPHIDs(array_merge($all_projects, $all_assigned)) - ->execute(); - - $workbook = new PHPExcel(); - $format->buildWorkbook($workbook, $tasks, $handles, $viewer); - $writer = PHPExcel_IOFactory::createWriter($workbook, 'Excel2007'); - - ob_start(); - $writer->save('php://output'); - $data = ob_get_clean(); - - $mime = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; - - return id(new AphrontFileResponse()) - ->setMimeType($mime) - ->setDownload($format->getFileName().'.xlsx') - ->setContent($data); - } - -} diff --git a/src/applications/maniphest/export/ManiphestExcelDefaultFormat.php b/src/applications/maniphest/export/ManiphestExcelDefaultFormat.php deleted file mode 100644 index 1451ae504e..0000000000 --- a/src/applications/maniphest/export/ManiphestExcelDefaultFormat.php +++ /dev/null @@ -1,140 +0,0 @@ -setActiveSheetIndex(0); - $sheet->setTitle(pht('Tasks')); - - $widths = array( - null, - 15, - null, - 10, - 15, - 15, - 60, - 30, - 20, - 100, - ); - - foreach ($widths as $col => $width) { - if ($width !== null) { - $sheet->getColumnDimension($this->col($col))->setWidth($width); - } - } - - $status_map = ManiphestTaskStatus::getTaskStatusMap(); - $pri_map = ManiphestTaskPriority::getTaskPriorityMap(); - - $date_format = null; - - $rows = array(); - $rows[] = array( - pht('ID'), - pht('Owner'), - pht('Status'), - pht('Priority'), - pht('Date Created'), - pht('Date Updated'), - pht('Title'), - pht('Tags'), - pht('URI'), - pht('Description'), - ); - - $is_date = array( - false, - false, - false, - false, - true, - true, - false, - false, - false, - false, - ); - - $header_format = array( - 'font' => array( - 'bold' => true, - ), - ); - - foreach ($tasks as $task) { - $task_owner = null; - if ($task->getOwnerPHID()) { - $task_owner = $handles[$task->getOwnerPHID()]->getName(); - } - - $projects = array(); - foreach ($task->getProjectPHIDs() as $phid) { - $projects[] = $handles[$phid]->getName(); - } - $projects = implode(', ', $projects); - - $rows[] = array( - 'T'.$task->getID(), - $task_owner, - idx($status_map, $task->getStatus(), '?'), - idx($pri_map, $task->getPriority(), '?'), - $this->computeExcelDate($task->getDateCreated()), - $this->computeExcelDate($task->getDateModified()), - $task->getTitle(), - $projects, - PhabricatorEnv::getProductionURI('/T'.$task->getID()), - id(new PhutilUTF8StringTruncator()) - ->setMaximumBytes(512) - ->truncateString($task->getDescription()), - ); - } - - foreach ($rows as $row => $cols) { - foreach ($cols as $col => $spec) { - $cell_name = $this->col($col).($row + 1); - $cell = $sheet - ->setCellValue($cell_name, $spec, $return_cell = true); - - if ($row == 0) { - $sheet->getStyle($cell_name)->applyFromArray($header_format); - } - - if ($is_date[$col]) { - $code = PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD2; - $sheet - ->getStyle($cell_name) - ->getNumberFormat() - ->setFormatCode($code); - } else { - $cell->setDataType(PHPExcel_Cell_DataType::TYPE_STRING); - } - } - } - } - - private function col($n) { - return chr(ord('A') + $n); - } - -} diff --git a/src/applications/maniphest/export/ManiphestExcelFormat.php b/src/applications/maniphest/export/ManiphestExcelFormat.php deleted file mode 100644 index e455a63656..0000000000 --- a/src/applications/maniphest/export/ManiphestExcelFormat.php +++ /dev/null @@ -1,35 +0,0 @@ -setAncestorClass(__CLASS__) - ->setSortMethod('getOrder') - ->execute(); - } - - abstract public function getName(); - abstract public function getFileName(); - - public function getOrder() { - return 0; - } - - protected function computeExcelDate($epoch) { - $seconds_per_day = (60 * 60 * 24); - $offset = ($seconds_per_day * 25569); - - return ($epoch + $offset) / $seconds_per_day; - } - - /** - * @phutil-external-symbol class PHPExcel - */ - abstract public function buildWorkbook( - PHPExcel $workbook, - array $tasks, - array $handles, - PhabricatorUser $user); - -} diff --git a/src/applications/maniphest/export/__tests__/ManiphestExcelFormatTestCase.php b/src/applications/maniphest/export/__tests__/ManiphestExcelFormatTestCase.php deleted file mode 100644 index a3c312fcd2..0000000000 --- a/src/applications/maniphest/export/__tests__/ManiphestExcelFormatTestCase.php +++ /dev/null @@ -1,10 +0,0 @@ -assertTrue(true); - } - -} diff --git a/src/applications/maniphest/view/ManiphestTaskResultListView.php b/src/applications/maniphest/view/ManiphestTaskResultListView.php index b4cf9a544c..6aafcbdccb 100644 --- a/src/applications/maniphest/view/ManiphestTaskResultListView.php +++ b/src/applications/maniphest/view/ManiphestTaskResultListView.php @@ -175,8 +175,7 @@ final class ManiphestTaskResultListView extends ManiphestView { } if (!$user->isLoggedIn()) { - // Don't show the batch editor or excel export for logged-out users. - // Technically we //could// let them export, but ehh. + // Don't show the batch editor for logged-out users. return null; } @@ -220,14 +219,6 @@ final class ManiphestTaskResultListView extends ManiphestView { ), pht("Bulk Edit Selected \xC2\xBB")); - $export = javelin_tag( - 'a', - array( - 'href' => '/maniphest/export/'.$saved_query->getQueryKey().'/', - 'class' => 'button button-grey', - ), - pht('Export to Excel')); - $hidden = phutil_tag( 'div', array( @@ -239,14 +230,12 @@ final class ManiphestTaskResultListView extends ManiphestView { ''. ''. ''. - ''. ''. ''. ''. '
%s%s%s%s%s%s
', $select_all, $select_none, - $export, '', $submit, $hidden); diff --git a/src/applications/search/controller/PhabricatorApplicationSearchController.php b/src/applications/search/controller/PhabricatorApplicationSearchController.php index f0bf9bb365..ea46886a15 100644 --- a/src/applications/search/controller/PhabricatorApplicationSearchController.php +++ b/src/applications/search/controller/PhabricatorApplicationSearchController.php @@ -154,7 +154,7 @@ final class PhabricatorApplicationSearchController $saved_query = $engine->buildSavedQueryFromRequest($request); // Save the query to generate a query key, so "Save Custom Query..." and - // other features like Maniphest's "Export..." work correctly. + // other features like "Bulk Edit" and "Export Data" work correctly. $engine->saveQuery($saved_query); }