FOSSology  4.7.1
Open Source License Compliance by Open Source Software
AdminCustomTextToCSV.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2025 Harshit Gandhi <gandhiharshit716@gmail.com>
4  SPDX-FileCopyrightText: © Fossology contributors
5 
6  SPDX-License-Identifier: GPL-2.0-only
7 */
8 
9 namespace Fossology\UI\Page;
10 
14 use Symfony\Component\HttpFoundation\Request;
15 use Symfony\Component\HttpFoundation\Response;
16 
18 {
19  const NAME = "admin_custom_text_to_csv";
20 
21  function __construct()
22  {
23  parent::__construct(self::NAME, array(
24  self::TITLE => "Admin Custom Text CSV Export",
25  self::MENU_LIST => "Admin::Text Management::Export::CSV Export All",
26  self::REQUIRES_LOGIN => true,
27  self::PERMISSION => Auth::PERM_ADMIN
28  ));
29  }
30 
35  protected function handle(Request $request)
36  {
37  $confirmed = $request->get('confirmed', false);
38  $referer = $request->headers->get('referer');
39  $fileName = "fossology-custom-text-export-" . date("YMj-Gis") . '.csv';
40 
41  if (!$confirmed) {
42  $downloadUrl = "?mod=" . self::NAME . "&cp_pk=" . $request->get('cp_pk') . "&confirmed=true";
43  return DownloadUtil::getDownloadConfirmationResponse($downloadUrl, $fileName, $referer);
44  }
45 
46  $customTextExport = $GLOBALS['container']->get('app.custom_text_export');
47  $content = $customTextExport->export(intval($request->get('cp_pk')));
48  return DownloadUtil::getDownloadResponse($content, $fileName);
49  }
50 }
51 
52 register_plugin(new AdminCustomTextToCSV());
Contains the constants and helpers for authentication of user.
Definition: Auth.php:24
static getDownloadConfirmationResponse($downloadUrl, $fileName, $referer)
static getDownloadResponse($content, $fileName, $contentType='text/csv')