Overview
  • Namespace
  • Class

Namespaces

  • rpf
    • api
      • module
    • extension
      • module
    • system
      • module

Classes

  • rpf\api\api
  • rpf\api\apiModule
  • rpf\api\bbRpc
  • rpf\api\module\bbCustomer_getFreeOrdNr
  • rpf\api\module\bbCustomer_readAddress
  • rpf\api\module\bbCustomer_readDiscount
  • rpf\api\module\bbCustomer_readEntry
  • rpf\api\module\bbCustomer_readPayment
  • rpf\api\module\bbCustomer_readTitle
  • rpf\api\module\bbCustomer_saveAdress
  • rpf\api\module\bbCustomer_validateAddress
  • rpf\api\module\bbCustomer_validateEntry
  • rpf\api\module\bbCustomer_validatePayinfo
  • rpf\api\module\bbDomain_readEntry
  • rpf\api\module\bbDomain_readFrontpage
  • rpf\api\module\bbDomain_readHandles
  • rpf\api\module\bbDomain_readPhpini
  • rpf\api\module\bbDomain_readSettings
  • rpf\api\module\bbDomain_readSubdomain
  • rpf\api\module\bbDomain_readWebalizerSettings
  • rpf\api\module\bbDomain_searchEntry
  • rpf\api\module\bbEmail_readAccount
  • rpf\api\module\bbMysql_inuseEntry
  • rpf\api\module\bbMysql_makeBackup
  • rpf\api\module\bbMysql_readEntry
  • rpf\api\module\bbOrder_readAccountAddress
  • rpf\api\module\bbOrder_readAccountEntry
  • rpf\api\module\bbOrder_readDisposition
  • rpf\api\module\bbOrder_readEntry
  • rpf\api\module\bbQuota_readEntry
  • rpf\api\module\customer
  • rpf\api\module\email
  • rpf\api\module\order
  • rpf\api\module\placeholder
  • rpf\api\module\user
  • rpf\extension\extension
  • rpf\extension\extensionModule
  • rpf\extension\invoiceTextExport
  • rpf\extension\mailExport
  • rpf\extension\module\domainExport
  • rpf\extension\module\index
  • rpf\extension\module\mgntRatioExport
  • rpf\system\module
  • rpf\system\module\log
  • rpf\system\module\moduleManager
  • rpf\system\rpf

Exceptions

  • rpf\system\module\exception
 1 <?php
 2 
 3 namespace rpf\extension\module;
 4 use rpf\api\module\bbDomain_readEntry;
 5 use rpf\extension\extensionModule;
 6 use rpf\system\module\log;
 7 
 8 /**
 9  * Class domainExport
10  *
11  * This class provides methods to export all domains into a CSV-Export
12  *
13  * @author Andreas Doebeling <ad@1601.com>
14  * @copyright 1601.production siegler&thuemmler ohg
15  * @link https://github.com/ADoebeling
16  * @link http://xing.doebeling.de
17  * @link https://www.1601.com
18  * @version 0.1.160401_1ad
19  *
20  * @package system\extension
21  */
22 class domainExport extends extensionModule
23 {
24     protected $domainList = array();
25 
26     /**
27      * Building a list of all domains, matching set filter
28      *
29      * - OrderNr
30      * - (Sub-)Domain
31      * - PHP-Version
32      * - Target
33      */
34     public function buildDomainList()
35     {
36         /** @var bbDomain_readEntry $domains */
37         $domains = $this->getApi()->getDomainReadEntry();
38         
39         $result = $domains
40             ->addSettings()
41             ->addSubdomain()
42             ->get();
43 
44         if (!is_array($result))
45         {
46             log::warning('There are no domains you could export?!', __METHOD__);
47         }
48         else
49         {
50             foreach ($result as $domain)
51             {
52                 $phpVersion = &$domain['settings']['php_version'];
53                 if (isset($domain['subdomain']) && is_array($domain['subdomain']))
54                 foreach ($domain['subdomain'] as $subdomain)
55                 {
56                     $this->domainList[$subdomain['name']] =
57                         [
58                             'name' => $subdomain['name'],
59                             'orderNr' => $subdomain['ordnr'],
60                             'phpVersion' => $phpVersion,
61                             'target' => $subdomain['target']
62                         ];
63                 }
64             }
65         }
66         return $this;
67     }
68 
69     protected function getCsv()
70     {
71         if (empty($this->domainList)) $this->buildDomainList();
72         $csv = "(Sub-)Domain;RP2-Order;PHP-Version;Target\n";
73         foreach($this->domainList as $domain => $fields)
74         {
75             foreach ($fields as $row) $csv .= "$row;";
76             $csv .= "\n";
77         }
78         return $csv;
79     }
80 
81     /**
82      * Send application/csv-header and starts downloading the csv
83      *
84      * @param string $filename
85      * @return $this
86      * @throws \Exception
87      */
88     public function sendDownloadCsv($filename = NULL)
89     {
90         $filename = $filename !== NULL ? $filename : 'DomainExport_'.date('ymd').'_1SRV.csv';
91         log::info("Download started: $filename", __METHOD__);
92         header('Content-Type: text/html; charset=iso-8859-15');
93         header('Content-Type: application/csv');
94         header("Content-Disposition: attachment; filename=\"$filename\";");
95         echo utf8_decode($this->getCsv());
96         return $this;
97     }
98 
99 }
API documentation generated by ApiGen