jbootstrap 0.0.3.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/jbootstrap.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'jbootstrap'
3
- s.version = '0.0.3.2'
3
+ s.version = '0.0.4'
4
4
  s.date = '2012-11-12'
5
5
  s.summary = 'Generator and abstract classes for Joomla 1.5 components.'
6
6
  s.description = 'Generator and abstract classes for Joomla 1.5 components.'
@@ -6,14 +6,42 @@ module JBootstrap
6
6
  desc "Generates a new backend scaffold."
7
7
  argument :scaffold_name, :type => :string, :desc => "The name of the resource to be created."
8
8
 
9
- def self.source_route
9
+ def self.source_root
10
10
  File.expand_path(File.join(File.dirname(__FILE__), %w[.. templates backend]))
11
11
  end
12
12
 
13
13
  def set_variables
14
14
  @scaffold_name = scaffold_name.downcase
15
+ @scaffold_singular_name = options[:singular_name] || @scaffold_name.chop
16
+ @component_name = options[:component_name] || File.basename(Dir.pwd).sub('com_', '').downcase
17
+ @component_singular_name = options[:component_singular_name] || @component_name.chop
15
18
  end
16
19
 
20
+ def copy_files
21
+ template "admin/controllers/SC_NAME.php.tt", "admin/controllers/#{@scaffold_name}.php"
22
+ template "admin/models/SC_SINGULAR_NAME.php.tt", "admin/models/#{@scaffold_singular_name}.php"
23
+ template "admin/tables/SC_SINGULAR_NAME.php.tt", "admin/tables/#{@scaffold_singular_name}.php"
24
+ template "admin/views/SC_SINGULAR_NAME/view.html.php.tt", "admin/views/#{@scaffold_singular_name}/view.html.php"
25
+ template "admin/views/SC_SINGULAR_NAME/tmpl/default.php.tt", "admin/views/#{@scaffold_singular_name}/tmpl/default.php"
26
+ template "admin/views/SC_SINGULAR_NAME/tmpl/list.php", "admin/views/#{@scaffold_singular_name}/tmpl/list.php"
27
+ end
28
+
29
+ def inject_manifest
30
+ inject_into_file "com_#{@component_name}.xml", :after => %Q{<files folder="admin">\n} do
31
+ "\t\t\t<filename>admin/controllers/#{@scaffold_name}.php<filename>\n" +
32
+ "\t\t\t<filename>admin/models/#{@scaffold_singular_name}.php</filename>\n" +
33
+ "\t\t\t<filename>admin/tables/#{@scaffold_singular_name}.php</filename>\n" +
34
+ "\t\t\t<filename>admin/views/#{@scaffold_singular_name}/view.html.php</filename>\n" +
35
+ "\t\t\t<filename>admin/views/#{@scaffold_singular_name}/tmpl/default.php</filename>\n" +
36
+ "\t\t\t<filename>admin/views/#{@scaffold_singular_name}/tmpl/list.php</filename>\n"
37
+ end
38
+ end
39
+
40
+ def update_acceptable_controllers
41
+ gsub_file "admin/admin.#{@component_name}.php",
42
+ /\$component_acceptable_controllers = array\((.+?)\);/,
43
+ "$component_acceptable_controllers = array(\1, #{@scaffold_name})"
44
+ end
17
45
  end
18
46
  end
19
47
  end
@@ -25,9 +25,9 @@ module JBootstrap
25
25
 
26
26
  def inject_manifest
27
27
  inject_into_file "com_#{@component_name.downcase}.xml", :after => %Q{<files folder="site">\n} do
28
- "\t\t<filename>site/models/#{@scaffold_singular_name}.php\n" +
29
- "\t\t<filename>site/views/#{@scaffold_singular_name}/view.html.php\n" +
30
- "\t\t<filename>site/views/#{@scaffold_singular_name}/tmpl/default.php\n"
28
+ "\t\t<filename>site/models/#{@scaffold_singular_name}.php</filename>\n" +
29
+ "\t\t<filename>site/views/#{@scaffold_singular_name}/view.html.php</filename>\n" +
30
+ "\t\t<filename>site/views/#{@scaffold_singular_name}/tmpl/default.php</filename>\n"
31
31
  end
32
32
  end
33
33
  end
@@ -0,0 +1,13 @@
1
+ <?php
2
+ defined('_JEXEC') or die('Restricted Access');
3
+ require_once(JPATH_COMPONENT . DS . 'abstracts' . DS . 'controller.php');
4
+
5
+ class <%= @component_name.capitalize %>Controller<%= @scaffold_name.capitalize %> extends AbstractController
6
+ {
7
+
8
+ function __construct()
9
+ {
10
+ parent::__construct('<%= @scaffold_singular_name %>');
11
+ }
12
+ }
13
+
@@ -0,0 +1,18 @@
1
+ <?php
2
+ defined('_JEXEC') or die('Restricted Access');
3
+ require_once(JPATH_COMPONENT . DS . 'abstracts' . DS . 'model.php');
4
+
5
+ class <%= @component_name.capitalize %>Model<%= @scaffold_singular_name.capitalize %> extends AbstractModel
6
+ {
7
+ function __construct()
8
+ {
9
+ parent::__construct('<%= @scaffold_singular_name.capitalize %>');
10
+ }
11
+
12
+ protected function getSortableAttributes()
13
+ {
14
+ return array('id');
15
+ }
16
+ }
17
+
18
+ ?>
@@ -0,0 +1,26 @@
1
+ <?php
2
+ defined('_JEXEC') or die('Restricted Access');
3
+ require_once(JPATH_COMPONENT . DS . 'abstracts' . DS . 'table.php');
4
+
5
+ class Table<%= @scaffold_singular_name.capitalize %> extends AbstractTable
6
+ {
7
+ var $id = 0;
8
+ var $name = '';
9
+
10
+ function __construct(&$db)
11
+ {
12
+ parent::__construct($db, '<%= @scaffold_singular_name.capitalize %>');
13
+ }
14
+
15
+ public function validate()
16
+ {
17
+ $this->requireName();
18
+ }
19
+
20
+ protected function requireName()
21
+ {
22
+ if (!$this->name) $this->addError(JText::_('COM_<%= @component_name.upcase %>_NAME_REQUIRED'));
23
+ }
24
+ }
25
+
26
+ ?>
@@ -0,0 +1,45 @@
1
+ <?php
2
+ defined('_JEXEC') or die('Restricted access');
3
+ ?>
4
+
5
+ <form action="index.php" method="post" name="adminForm">
6
+ <table class="adminlist">
7
+ <thead>
8
+ <tr>
9
+ <th width="20"><input type="checkbox" name="toggle" value="" onclick="checkAll(<?= count($this-><%= @scaffold_name %>); ?>);" /></th>
10
+ <th><?= JHTML::_('grid.sort', 'COM_<%= @component_name.upcase %>_NAME', 'name', $this->lists['order_Dir'], $this->lists['order']); ?></th>
11
+ </tr>
12
+ </thead>
13
+ <tbody>
14
+ <?
15
+ $i = $k = 0;
16
+ foreach($this-><%= @scaffold_name %> as $row)
17
+ {
18
+ $checked = JHTML::_('grid.id', $i, $row->id);
19
+ $link = JRoute::_('index.php?c=' . JRequest::getVar('c') . '&option=' . JRequest::getVar('option')
20
+ . '&task=edit&cid[]=' . $row->id . '&hidemainmenu=1');
21
+ ?>
22
+ <tr class="<?= "row$k"; ?>">
23
+ <td><?= $checked ?></td>
24
+ <td><a href="<?= $link ?>"><?= $row->name ?></a></td>
25
+ </tr>
26
+ <?
27
+ $k = 1 - $k;
28
+ $i++;
29
+ } ?>
30
+
31
+ </tbody>
32
+ <tfoot>
33
+ <tr>
34
+ <td colspan="10"><?= $this->page->getListFooter(); ?></td>
35
+ </tr>
36
+ </tfoot>
37
+ </table>
38
+ <input type="hidden" name="option" value="<?= JRequest::getVar('option'); ?>" />
39
+ <input type="hidden" name="c" value="<?= JRequest::getVar('c'); ?>" />
40
+ <input type="hidden" name="task" value="" />
41
+ <input type="hidden" name="boxchecked" value="0" />
42
+ <input type="hidden" name="hidemainmenu" value="0" />
43
+ <input type="hidden" name="filter_order" value="<?= $this->lists['order']; ?>" />
44
+ <input type="hidden" name="filter_order_Dir" value="" />
45
+ </form>
@@ -0,0 +1,13 @@
1
+ <?php
2
+ defined('_JEXEC') or die('Restricted Access');
3
+ require_once(JPATH_COMPONENT . DS . 'abstracts' . DS . 'view.php');
4
+
5
+ class <%= @component_name.capitalize %>View<%= @scaffold_singular_name.capitalize %> extends AbstractView
6
+ {
7
+ function __construct()
8
+ {
9
+ parent::__construct('COM_<%= @component_name.upcase %>_<%= @scaffold_name.upcase %>_TITLE', '<%= @scaffold_singular_name %>');
10
+ }
11
+ }
12
+
13
+ ?>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jbootstrap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3.2
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -47,6 +47,12 @@ files:
47
47
  - lib/jbootstrap/generators/component.rb
48
48
  - lib/jbootstrap/generators/frontend.rb
49
49
  - lib/jbootstrap/runner.rb
50
+ - lib/jbootstrap/templates/backend/admin/controllers/SC_NAME.php.tt
51
+ - lib/jbootstrap/templates/backend/admin/models/SC_SINGULAR_NAME.php.tt
52
+ - lib/jbootstrap/templates/backend/admin/tables/SC_SINGULAR_NAME.php.tt
53
+ - lib/jbootstrap/templates/backend/admin/views/SC_SINGULAR_NAME/tmpl/default.php.tt
54
+ - lib/jbootstrap/templates/backend/admin/views/SC_SINGULAR_NAME/tmpl/list.php.tt
55
+ - lib/jbootstrap/templates/backend/admin/views/SC_SINGULAR_NAME/view.html.php.tt
50
56
  - lib/jbootstrap/templates/component/Gemfile
51
57
  - lib/jbootstrap/templates/component/Guardfile
52
58
  - lib/jbootstrap/templates/component/README.md.tt