-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass.tx_synthesis_compilefiles.php
176 lines (155 loc) · 5.67 KB
/
class.tx_synthesis_compilefiles.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<?php
/***************************************************************
* Copyright notice
*
* (c) 2012 Jon Langeland <jl@typoconsult.dk>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* TYPO3 Extension Kickstarter
*
* @author Kasper Skårhøj <kasperYYYY@typo3.com>
* @author Ingo Renner <ingo@typo3.org>
* @author Jon Klixbüll Langeland <kemo@discworld.dk>
*/
require_once (t3lib_extMgm::extPath ( 'synthesis' ) . 'class.tx_synthesis_sectionbase.php');
class tx_synthesis_compilefiles extends tx_synthesis_sectionbase {
// Internal:
var $fileArray = array ();
var $ext_tables = array ();
var $ext_tca = array ();
var $ext_tables_sql = array ();
var $ext_localconf = array ();
var $ext_locallang = array ();
var $ext_locallang_db = array ();
var $extKey = '';
var $charMaxLng = 2; // Varchars are created instead of chars when over this length.
/**
* Creates all files that are necessary for an extension
* - ext_localconf.php
* - ext_tables.php
* - Configuration/TCA/tca.php
* - ext_tables.sql
* - Resources/Private/Language/locallang.xml
* - Resources/Private/Language/locallang_db.xml
* - Configuration/Synthesis/wizard_form.html
* - Configuration/Synthesis/wizard_form.dat
* - Documentation/ChangeLog
* - Documentation/README.txt
* - ext_icon.gif
*
* @param string $extKey: the extension key
* @return void
*/
function makeFilesArray($extKey) {
$this->ext_localconf = array ();
$this->ext_tables = array ();
$this->fileArray = array ();
foreach ( $this->wizArray as $catID => $catData ) {
if ($this->sections [$catID]) {
$path = t3lib_div::getFileAbsFileName ( $this->sections [$catID] ['filepath'] );
if (is_file ( $path )) {
require_once ($path);
$section = t3lib_div::makeInstance ( $this->sections [$catID] ['classname'] );
$section->wizard = &$this;
foreach ( $catData as $k => $config ) {
$section->render_extPart ( $k, $config, $extKey );
}
}
}
}
if (is_array ( $this->wizArray ['sv'] )) {
reset ( $this->wizArray ['sv'] );
while ( list ( $k, $config ) = each ( $this->wizArray ['sv'] ) ) {
$this->EM_CONF_presets ['clearCacheOnLoad'] = 1;
}
}
// Write the ext_localconf.php file:
if (count ( $this->ext_localconf )) {
$this->addFileToFileArray ( 'ext_localconf.php', trim ( $this->wrapBody ( '
<?php
if (!defined(\'TYPO3_MODE\')) {
die (\'Access denied.\');
}
', implode ( chr ( 10 ), $this->ext_localconf ), '?>
', 0 ) ) );
}
// Write the ext_tables.php file:
if (count ( $this->ext_tables )) {
$this->addFileToFileArray ( 'ext_tables.php', trim ( $this->wrapBody ( '
<?php
if (!defined(\'TYPO3_MODE\')) {
die (\'Access denied.\');
}
', implode ( chr ( 10 ), $this->ext_tables ), '
?>
', 0 ) ) );
}
// Write the tca.php file:
if (count ( $this->ext_tca )) {
$this->addFileToFileArray ( 'Configuration/TCA/tca.php', trim ( $this->wrapBody ( '
<?php
if (!defined(\'TYPO3_MODE\')) {
die (\'Access denied.\');
}
', implode ( chr ( 10 ), $this->ext_tca ), '
?>
', 0 ) ) );
}
// Write the ext_tables.sql file:
if (count ( $this->ext_tables_sql )) {
$this->addFileToFileArray ( 'ext_tables.sql', trim ( $this->sPS ( implode ( chr ( 10 ), $this->ext_tables_sql ) ) ) );
}
// Local lang file:
if (count ( $this->ext_locallang )) {
$this->addLocalLangFile ( $this->ext_locallang, 'locallang.xml', 'Language labels for extension \'' . $extKey . '\'' );
}
// Local lang DB file:
if (count ( $this->ext_locallang_db )) {
$this->addLocalLangFile ( $this->ext_locallang_db, 'locallang_db.xml', 'Language labels for database tables/fields belonging to extension \'' . $extKey . '\'', 'database' );
}
// The form used to generate the extension:
$this->dontPrintImages = 1;
$this->addFileToFileArray ( 'Configuration/Synthesis/wizard_form.html', trim ( $this->sPS ( '
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<body>
' . $this->totalForm () . '
</body>
</html>
' ) ) );
$this->addFileToFileArray ( 'Configuration/Synthesis/wizard_form.dat', serialize ( $this->wizArray ) );
$this->addFileToFileArray ( 'Documentation/ChangeLog', date ( 'Y-m-d' ) . ' ' . $this->userField ( 'name' ) . ' <' . $this->userField ( 'email' ) . '>
* Initial code generated with synthesis
' );
$this->addFileToFileArray ( 'Documentation/README.txt', '
Feel free to add some documentation or simply add a link to the online manual.
' );
// icon:
$this->addFileToFileArray ( 'ext_icon.gif', t3lib_div::getUrl ( t3lib_extMgm::extPath ( 'synthesis' ) . 'res/notfound.gif' ) );
}
}
// Include extension?
if (defined ( 'TYPO3_MODE' ) && $TYPO3_CONF_VARS [TYPO3_MODE] ['XCLASS'] ['ext/synthesis/class.tx_synthesis_compilefiles.php']) {
include_once ($TYPO3_CONF_VARS [TYPO3_MODE] ['XCLASS'] ['ext/synthesis/class.tx_synthesis_compilefiles.php']);
}
?>