Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Implemented file package type

Fixed library package type to properly copy the data - This introduces a new bug!
Implemented SQL exporter from platform
Implemented -n command line option
Added all backend components to the build file
  • Loading branch information...
commit 6556c4a064d4b5cd1948ddc522dd73ed463642df 1 parent ff335ff
Hannes Papenberg Hackwar authored
18 README.markdown
Source Rendered
@@ -2,4 +2,20 @@ Joomla! Extension Tools
2 2 =======================
3 3 The Joomla! Extension Tools are a set of tools to help developers in creating, packaging and distributing Joomla! extensions.
4 4
5   -The builder that you can find in the /builder directory, requires the Joomla! Platform in the root directory of this repository. This code is tested on version 11.4 of the platform. You can get the required code <a href="https://github.com/joomla/joomla-platform/zipball/11.4">here</a>.
  5 +The builder that you can find in the /builder directory, requires the Joomla! Platform in the root directory of this repository. This code is tested on version 11.4 of the platform. You can get the required code <a href="https://github.com/joomla/joomla-platform/zipball/11.4">here</a>.
  6 +
  7 +There are a few command line options for the builder. The usage is as follows:
  8 +
  9 +php build.php <config file> -j <joomla folder> [-b <build folder> -n -v]
  10 +
  11 +The commands in brackets are optional.
  12 +
  13 +<config file> This is a file like the build.jet found in this repository
  14 +
  15 +-j <joomla folder> The absolute path to the Joomla folder that we are building this stuff from.
  16 +
  17 +-b <build folder> The folder to copy all the temporary files to and save the completed packages in.
  18 +
  19 +-n Create the database schemas by using the MySQL Exporter found in the platform. ATTENTION: There is a bug in 11.4 of the platform, where this exporter does not work properly. Go to /libraries/joomla/database/database/mysqlexporter.php line 168 and add "false" in the method parameters. This has been fixed in 12.1.
  20 +
  21 +-v Verbose output. This is mostly not used right now.
96 builder/build.jet
@@ -14,8 +14,90 @@
14 14 </common>
15 15 <components>
16 16 <component>
  17 + <name>com_admin</name>
  18 + </component>
  19 + <component>
  20 + <name>com_banners</name>
  21 + <sql>
  22 + <table>#__banners</table>
  23 + <table>#__banner_clients</table>
  24 + <table>#__banner_tracks</table>
  25 + </sql>
  26 + </component>
  27 + <component>
  28 + <name>com_cache</name>
  29 + </component>
  30 + <component>
  31 + <name>com_categories</name>
  32 + </component>
  33 + <component>
  34 + <name>com_checkin</name>
  35 + </component>
  36 + <component>
  37 + <name>com_config</name>
  38 + </component>
  39 + <component>
  40 + <name>com_contact</name>
  41 + <sql>
  42 + <table>#__contact_details</table>
  43 + </sql>
  44 + </component>
  45 + <component>
17 46 <name>com_content</name>
18   - <version>2.8</version> <!-- Only necessary when you want to override the version from "common" -->
  47 + <version>2.8</version>
  48 + <sql>
  49 + <table>#__content</table>
  50 + <table>#__content_frontpage</table>
  51 + <table>#__content_rating</table>
  52 + </sql>
  53 + </component>
  54 + <component>
  55 + <name>com_cpanel</name>
  56 + </component>
  57 + <component>
  58 + <name>com_finder</name>
  59 + </component>
  60 + <component>
  61 + <name>com_installer</name>
  62 + </component>
  63 + <component>
  64 + <name>com_languages</name>
  65 + </component>
  66 + <component>
  67 + <name>com_login</name>
  68 + </component>
  69 + <component>
  70 + <name>com_media</name>
  71 + </component>
  72 + <component>
  73 + <name>com_menus</name>
  74 + </component>
  75 + <component>
  76 + <name>com_messages</name>
  77 + </component>
  78 + <component>
  79 + <name>com_modules</name>
  80 + </component>
  81 + <component>
  82 + <name>com_newsfeeds</name>
  83 + </component>
  84 + <component>
  85 + <name>com_plugins</name>
  86 + </component>
  87 + <component>
  88 + <name>com_redirect</name>
  89 + </component>
  90 + <component>
  91 + <name>com_search</name>
  92 + </component>
  93 + <component>
  94 + <name>com_templates</name>
  95 + </component>
  96 + <component>
  97 + <name>com_users</name>
  98 + </component>
  99 + <component>
  100 + <name>com_weblinks</name>
19 101 </component>
20 102 </components>
21 103 <files>
@@ -46,36 +128,36 @@
46 128 <module>
47 129 <name>mod_menu</name>
48 130 <client>administrator</client>
49   - <config><!-- Here are the JForm Field defs --></config>
  131 + <config></config>
50 132 </module>
51 133 <module>
52 134 <name>mod_languages</name>
53 135 <client>site</client>
54   - <config><!-- Here are the JForm Field defs --></config>
  136 + <config></config>
55 137 </module>
56 138 </modules>
57 139 <plugins>
58 140 <plugin>
59 141 <name>plg_system_debug</name>
60 142 <folder>system</folder>
61   - <config><!-- Here are the JForm Field defs --></config>
  143 + <config></config>
62 144 </plugin>
63 145 <plugin>
64 146 <name>plg_system_highlight</name>
65 147 <folder>system</folder>
66   - <config><!-- Here are the JForm Field defs --></config>
  148 + <config></config>
67 149 </plugin>
68 150 </plugins>
69 151 <templates>
70 152 <template>
71 153 <name>beez5</name>
72 154 <client>site</client>
73   - <config><!-- Here are the JForm Field defs --></config>
  155 + <config></config>
74 156 </template>
75 157 <template>
76 158 <name>beez_20</name>
77 159 <client>site</client>
78   - <config><!-- Here are the JForm Field defs --></config>
  160 + <config></config>
79 161 </template>
80 162 </templates>
81 163 <packages>
10 builder/build.php
@@ -31,7 +31,7 @@ protected function doExecute()
31 31 $this->out('JOOMLA! EXTENSION TOOLS',true,true);
32 32 $this->out('Extension Builder',true,true);
33 33 $this->out(str_repeat('=', 79));
34   -
  34 +
35 35 $this->loadPropertiesFromCLI();
36 36
37 37 if(count($this->input->args)) {
@@ -39,6 +39,8 @@ protected function doExecute()
39 39 } else {
40 40 $this->loadPropertiesFromInput();
41 41 }
  42 +
  43 + $config = JFactory::getConfig($this->joomlafolder.'configuration.php');
42 44
43 45 if(!$this->joomlafolder) {
44 46 $this->out('*FATAL ERROR* No Joomla installation as build source given!');
@@ -138,8 +140,8 @@ protected function loadPropertiesFromFile($file)
138 140
139 141 $options = call_user_func(array('JBuilder'.$type, 'getOptions'));
140 142
141   - $opts = $this->options;
142 143 foreach($extensions as $extension) {
  144 + $opts = $this->options;
143 145 foreach($extension->children() as $exopt) {
144 146 if(!in_array($exopt->getName(), $options)) {
145 147 continue;
@@ -195,6 +197,10 @@ protected function loadPropertiesFromCLI()
195 197 } elseif($this->input->get('build')) {
196 198 $this->buildfolder = $this->input->get('build', null, 'STRING');
197 199 }
  200 +
  201 + if($this->input->get('n')) {
  202 + $this->options['newSQL'] = true;
  203 + }
198 204
199 205 if($this->buildfolder) {
200 206 if(is_dir($this->buildfolder)){
25 builder/extensions/extension.php
@@ -9,6 +9,8 @@ class JBuilderExtension
9 9
10 10 protected $joomlafolder = null;
11 11
  12 + protected $sql = null;
  13 +
12 14 public static function getInstance($type, $options)
13 15 {
14 16 $types = array(
@@ -95,6 +97,13 @@ protected function setManifestData(JBuilderHelperManifest $manifest)
95 97 $manifest->setBuildFolder($this->buildfolder);
96 98 $manifest->setVersion($this->options['version']);
97 99 $manifest->setJVersion($this->options['joomlaversion']);
  100 + if($this->sql) {
  101 + $manifest->setSQL($this->sql);
  102 + }
  103 + if(isset($this->options['newSQL'])) {
  104 + $manifest->setOption('newSQL', true);
  105 + }
  106 +
98 107 return $manifest;
99 108 }
100 109
@@ -145,7 +154,23 @@ protected function prepareLanguageFiles($clients)
145 154
146 155 protected function prepareSQL()
147 156 {
  157 + if(!isset($this->options['sql'])) {
  158 + return;
  159 + }
148 160 $this->out('['.$this->name.'] Preparing database tables and sample content');
  161 +
  162 + $db = JFactory::getDBO();
  163 + $db->setQuery('SELECT * from #__banners');
  164 + $exporter = new JDatabaseExporterMySQL();
  165 + $exporter->setDbo($db);
  166 + $tables = array();
  167 + foreach($this->options['sql'] as $table) {
  168 + $tables[] = (string)$table;
  169 + }
  170 +
  171 + $exporter->from($tables);
  172 +
  173 + $this->sql = (string)$exporter;
149 174 }
150 175
151 176 protected function addIndexFiles()
14 builder/extensions/file.php
@@ -23,6 +23,20 @@ public function build()
23 23 $this->out('TRYING TO BUILD '.$this->options['name'].' FILE EXTENSION...');
24 24 $this->out(str_repeat('-', 79));
25 25
  26 + if($this->options['files']) {
  27 + foreach($this->options['files'] as $element) {
  28 + if($element->getName() == 'folder') {
  29 + if(is_dir($this->joomlafolder.(string)$element)) {
  30 + JFolder::copy($this->joomlafolder.(string)$element, $this->buildfolder.$element, '', true);
  31 + }
  32 + } elseif($element->getName() == 'file') {
  33 + if(is_file($this->joomlafolder.(string)$element)) {
  34 + JFile::copy($this->joomlafolder.(string)$element, $this->buildfolder.(string)$element);
  35 + }
  36 + }
  37 + }
  38 + }
  39 +
26 40 $this->prepareLanguageFiles(array('site', 'administrator'));
27 41
28 42 $this->addIndexFiles();
2  builder/extensions/library.php
@@ -35,7 +35,7 @@ public function build()
35 35 if(is_dir($this->joomlafolder.'libraries/'.$this->name.'/')) {
36 36 $this->out('['.$this->name.'] Found library files');
37 37 JFolder::create($this->buildfolder.$this->name);
38   - JFolder::copy($this->joomlafolder.'libraries/'.$this->name.'/', $this->buildfolder.$this->name, '', true);
  38 + JFolder::copy($this->joomlafolder.'libraries/'.$this->name.'/', $this->buildfolder, '', true);
39 39 }
40 40
41 41 $this->prepareMediaFiles();
142 builder/helpers/manifest.php
@@ -2,6 +2,7 @@
2 2
3 3 class JBuilderHelperManifest extends JBuilderHelperBase {
4 4
  5 + protected $options = array();
5 6 private $type = null;
6 7 private $extname = null;
7 8 private $exttitle = null;
@@ -18,6 +19,12 @@ class JBuilderHelperManifest extends JBuilderHelperBase {
18 19 private $client = null;
19 20 private $tag = null;
20 21 private $dom = null;
  22 + private $sql = null;
  23 +
  24 + public function setOption($key, $value)
  25 + {
  26 + $this->options[$key] = $value;
  27 + }
21 28
22 29 public function setType($type)
23 30 {
@@ -99,6 +106,11 @@ public function setTag($tag)
99 106 {
100 107 $this->tag = $tag;
101 108 }
  109 +
  110 + public function setSQL($sql)
  111 + {
  112 + $this->sql = $sql;
  113 + }
102 114
103 115 public function main()
104 116 {
@@ -252,66 +264,80 @@ private function createSQL($root)
252 264 if(!in_array($this->type, array('component', 'file', 'module', 'plugin')))
253 265 return $root;
254 266
255   - $path = $this->buildfolder;
256   - if($this->type == 'component')
257   - $path .= '/admin';
258   -
259   - if(is_dir($path.'/sql')) {
260   - if(file_exists($path.'/sql/install.mysql.utf8.sql')) {
261   - $install = $this->dom->createElement('install');
  267 + if(isset($this->options['newSQL'])) {
  268 + if($this->sql) {
  269 + $xml = simplexml_load_string($this->sql);
  270 + $tables = $xml->xpath('database');
  271 + $tables = $tables[0]->children();
262 272 $sql = $this->dom->createElement('sql');
263   - $folder = $path.'/sql/';
264   - $dir = opendir($folder);
265   - while(false !== ($entry = readdir($dir))) {
266   - if(is_file($folder.$entry) && substr($entry, 0, 7) == 'install') {
267   - $data = explode('.', $entry);
268   - $e = $this->dom->createElement('file', 'sql/'.$entry);
269   - $e->setAttribute('charset', 'utf8');
270   - $e->setAttribute('folder', 'sql');
271   - $e->setAttribute('driver', $data[1]);
272   - $sql->appendChild($e);
273   - }
  273 + foreach($tables as $table) {
  274 + $temp = $this->dom->importNode(dom_import_simplexml($table), true);
  275 +
  276 + $sql->appendChild($temp);
274 277 }
275   - $install->appenChild($sql);
276   - $root->appendChild($install);
  278 + $root->appendChild($sql);
277 279 }
  280 + } else {
  281 + $path = $this->buildfolder;
  282 + if($this->type == 'component')
  283 + $path .= '/admin';
278 284
279   - if(file_exists($path.'/sql/uninstall.mysql.utf8.sql')) {
280   - $uninstall = $this->dom->createElement('uninstall');
281   - $sql = $this->dom->createElement('sql');
282   - $folder = $path.'/sql/';
283   - $dir = opendir($folder);
284   - while(false !== ($entry = readdir($dir))) {
285   - if(is_file($folder.$entry) && substr($entry, 0, 9) == 'uninstall') {
286   - $data = explode('.', $entry);
287   - $e = $this->dom->createElement('file', 'sql/'.$entry);
288   - $e->setAttribute('charset', 'utf8');
289   - $e->setAttribute('folder', 'sql');
290   - $e->setAttribute('driver', $data[1]);
291   - $sql->appendChild($e);
  285 + if(is_dir($path.'/sql')) {
  286 + if(file_exists($path.'/sql/install.mysql.utf8.sql')) {
  287 + $install = $this->dom->createElement('install');
  288 + $sql = $this->dom->createElement('sql');
  289 + $folder = $path.'/sql/';
  290 + $dir = opendir($folder);
  291 + while(false !== ($entry = readdir($dir))) {
  292 + if(is_file($folder.$entry) && substr($entry, 0, 7) == 'install') {
  293 + $data = explode('.', $entry);
  294 + $e = $this->dom->createElement('file', 'sql/'.$entry);
  295 + $e->setAttribute('charset', 'utf8');
  296 + $e->setAttribute('folder', 'sql');
  297 + $e->setAttribute('driver', $data[1]);
  298 + $sql->appendChild($e);
  299 + }
292 300 }
  301 + $install->appendChild($sql);
  302 + $root->appendChild($install);
  303 + }
  304 +
  305 + if(file_exists($path.'/sql/uninstall.mysql.utf8.sql')) {
  306 + $uninstall = $this->dom->createElement('uninstall');
  307 + $sql = $this->dom->createElement('sql');
  308 + $folder = $path.'/sql/';
  309 + $dir = opendir($folder);
  310 + while(false !== ($entry = readdir($dir))) {
  311 + if(is_file($folder.$entry) && substr($entry, 0, 9) == 'uninstall') {
  312 + $data = explode('.', $entry);
  313 + $e = $this->dom->createElement('file', 'sql/'.$entry);
  314 + $e->setAttribute('charset', 'utf8');
  315 + $e->setAttribute('folder', 'sql');
  316 + $e->setAttribute('driver', $data[1]);
  317 + $sql->appendChild($e);
  318 + }
  319 + }
  320 + $uninstall->appendChild($sql);
  321 + $root->appendChild($uninstall);
293 322 }
294   - $uninstall->appendChild($sql);
295   - $root->appendChild($uninstall);
296   - }
297 323
298   - if(is_dir($path.'/sql/updates')) {
299   - $update = $this->dom->createElement('update');
300   - $schemas = $this->dom->createElement('schemas');
301   - $folder = $path.'/sql/updates/';
302   - $dir = opendir($folder);
303   - while(false !== ($entry = readdir($dir))) {
304   - if(is_dir($folder.$entry)) {
305   - $e = $this->dom->createElement('schemapath', 'sql/updates/'.$entry);
306   - $e->setAttribute('type', $entry);
307   - $schemas->appendChild($e);
  324 + if(is_dir($path.'/sql/updates')) {
  325 + $update = $this->dom->createElement('update');
  326 + $schemas = $this->dom->createElement('schemas');
  327 + $folder = $path.'/sql/updates/';
  328 + $dir = opendir($folder);
  329 + while(false !== ($entry = readdir($dir))) {
  330 + if(is_dir($folder.$entry)) {
  331 + $e = $this->dom->createElement('schemapath', 'sql/updates/'.$entry);
  332 + $e->setAttribute('type', $entry);
  333 + $schemas->appendChild($e);
  334 + }
308 335 }
  336 + $update->appendChild($schemas);
  337 + $root->appendChild($update);
309 338 }
310   - $update->appendChild($schemas);
311   - $root->appendChild($update);
312 339 }
313 340 }
314   -
315 341 return $root;
316 342 }
317 343
@@ -412,17 +438,13 @@ private function buildComponent($root)
412 438
413 439 private function buildFile($root)
414 440 {
415   - /**$languages = array('component', 'language', 'library', 'module', 'plugin', 'template');
416   - if(in_array($this->type, $languages))
417   - {
418   - //Handle media file section
419   - if(is_dir($this->buildfolder.'/language/')) {
420   - $mediafiles = $this->dom->createElement('media');
421   - $mediafiles->setAttribute('destination', $this->extname);
422   - $mediafiles = $this->filelist($this->buildfolder.'/media/', $mediafiles);
423   - $root->appendChild($mediafiles);
424   - }
425   - }**/
  441 + $exclude = array('language', 'media');
  442 + //Handle file section
  443 + if(is_dir($this->buildfolder)) {
  444 + $files = $this->dom->createElement('files');
  445 + $files = $this->filelist($this->buildfolder, $files, $exclude);
  446 + $root->appendChild($files);
  447 + }
426 448
427 449 return $root;
428 450 }

0 comments on commit 6556c4a

Please sign in to comment.
Something went wrong with that request. Please try again.