jBootstrap 0.0.1
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/.gitignore +3 -0
- data/.rvmrc +34 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +15 -0
- data/README.md +37 -0
- data/Rakefile +2 -0
- data/bin/jbootstrap +4 -0
- data/jbootstrap.gemspec +18 -0
- data/lib/jbootstrap.rb +14 -0
- data/lib/jbootstrap/generators/component.rb +58 -0
- data/lib/jbootstrap/runner.rb +13 -0
- data/lib/jbootstrap/templates/component/Gemfile +6 -0
- data/lib/jbootstrap/templates/component/Guardfile +9 -0
- data/lib/jbootstrap/templates/component/README.md.tt +7 -0
- data/lib/jbootstrap/templates/component/admin/abstracts/controller.php.tt +85 -0
- data/lib/jbootstrap/templates/component/admin/abstracts/model.php.tt +268 -0
- data/lib/jbootstrap/templates/component/admin/abstracts/table.php.tt +40 -0
- data/lib/jbootstrap/templates/component/admin/abstracts/view.php.tt +98 -0
- data/lib/jbootstrap/templates/component/admin/admin.COM_NAME.php.tt +27 -0
- data/lib/jbootstrap/templates/component/admin/install.php +10 -0
- data/lib/jbootstrap/templates/component/admin/language/en-GB/en-GB.com_COM_NAME.ini.tt +41 -0
- data/lib/jbootstrap/templates/component/admin/language/en-GB/en-GB.com_COM_NAME.menu.ini.tt +6 -0
- data/lib/jbootstrap/templates/component/admin/language/fr-FR/fr-FR.com_COM_NAME.ini.tt +42 -0
- data/lib/jbootstrap/templates/component/admin/language/fr-FR/fr-FR.com_COM_NAME.menu.ini.tt +6 -0
- data/lib/jbootstrap/templates/component/admin/uninstall.php +9 -0
- data/lib/jbootstrap/templates/component/com_COM_NAME.xml.tt +65 -0
- data/lib/jbootstrap/templates/component/gitignore +3 -0
- data/lib/jbootstrap/templates/component/site/COM_NAME.php.tt +35 -0
- data/lib/jbootstrap/templates/component/site/abstracts/controller.php.tt +24 -0
- data/lib/jbootstrap/templates/component/site/abstracts/model.php.tt +78 -0
- data/lib/jbootstrap/templates/component/site/abstracts/view.php.tt +36 -0
- data/lib/jbootstrap/templates/component/site/controller.php.tt +19 -0
- data/lib/jbootstrap/templates/component/site/language/en-GB/en-GB.com_COM_NAME.ini.tt +0 -0
- data/lib/jbootstrap/templates/component/site/language/fr-FR/fr-FR.com_COM_NAME.ini.tt +0 -0
- data/lib/jbootstrap/templates/front/site/models/COM_NAME_SINGULAR.php +16 -0
- metadata +96 -0
data/.gitignore
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# This is an RVM Project .rvmrc file, used to automatically load the ruby
|
4
|
+
# development environment upon cd'ing into the directory
|
5
|
+
|
6
|
+
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
|
7
|
+
# Only full ruby name is supported here, for short names use:
|
8
|
+
# echo "rvm use 1.9.3" > .rvmrc
|
9
|
+
environment_id="ruby-1.9.3-p194"
|
10
|
+
|
11
|
+
# Uncomment the following lines if you want to verify rvm version per project
|
12
|
+
# rvmrc_rvm_version="1.14.12 (stable)" # 1.10.1 seams as a safe start
|
13
|
+
# eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
|
14
|
+
# echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
|
15
|
+
# return 1
|
16
|
+
# }
|
17
|
+
|
18
|
+
# First we attempt to load the desired environment directly from the environment
|
19
|
+
# file. This is very fast and efficient compared to running through the entire
|
20
|
+
# CLI and selector. If you want feedback on which environment was used then
|
21
|
+
# insert the word 'use' after --create as this triggers verbose mode.
|
22
|
+
if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
|
23
|
+
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
|
24
|
+
then
|
25
|
+
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
|
26
|
+
[[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
|
27
|
+
\. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
|
28
|
+
else
|
29
|
+
# If the environment file has not yet been created, use the RVM CLI to select.
|
30
|
+
rvm --create "$environment_id" || {
|
31
|
+
echo "Failed to create RVM environment '${environment_id}'."
|
32
|
+
return 1
|
33
|
+
}
|
34
|
+
fi
|
data/Gemfile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
gemspec
|
data/Gemfile.lock
ADDED
data/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# jBootstrap
|
2
|
+
|
3
|
+
jBootstrap is a collection of Joomla-related Thor tasks and abstract templates. It makes developing a new Joomla component rather trivial.
|
4
|
+
|
5
|
+
Note that jBootstrap is programmed for Joomla 1.5, which is unfortunately the requirement I had when developing the software. I'll accept pull requests into other branches if someone wants to update it for newer versions.
|
6
|
+
|
7
|
+
## Pre-requisites
|
8
|
+
|
9
|
+
- Ruby >= 1.9.2
|
10
|
+
- Bundler
|
11
|
+
|
12
|
+
## Use
|
13
|
+
|
14
|
+
1. Clone the repository.
|
15
|
+
2. `cd jbootstrap && bundle install`
|
16
|
+
3. `cd .. && thor install jbootstrap`
|
17
|
+
4. `cd NEW_EXTENSION_DIRECTORY`
|
18
|
+
5. `thor jbootstrap:generate:component NAME`
|
19
|
+
|
20
|
+
This will install the jbootstrap namespaces into the `thor` command so you can use it anywhere.
|
21
|
+
|
22
|
+
## Advanced Use
|
23
|
+
|
24
|
+
### Generators
|
25
|
+
|
26
|
+
#### Component generator
|
27
|
+
|
28
|
+
Run by calling `thor jbootstrap:generate:component NAME`, where `NAME` is the name of your component (i.e. 'Movies').
|
29
|
+
|
30
|
+
#### Backend scaffold generator
|
31
|
+
|
32
|
+
|
33
|
+
First clone the repository
|
34
|
+
|
35
|
+
There are no examples at present (all of them are proprietary, sorry), but the basic workflow is inheriting from the abstract instead of the default Joomla controllers and models, etc...
|
36
|
+
|
37
|
+
Good luck!
|
data/Rakefile
ADDED
data/bin/jbootstrap
ADDED
data/jbootstrap.gemspec
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'jBootstrap'
|
3
|
+
s.version = '0.0.1'
|
4
|
+
s.date = '2012-11-12'
|
5
|
+
s.summary = 'Generator and abstract classes for Joomla 1.5 components.'
|
6
|
+
s.description = 'Generator and abstract classes for Joomla 1.5 components.'
|
7
|
+
s.author = 'Rob Yurkowski'
|
8
|
+
s.email = 'rob@yurkowski.net'
|
9
|
+
|
10
|
+
s.require_paths = %w[lib]
|
11
|
+
|
12
|
+
s.executables = %w[jbootstrap]
|
13
|
+
#s.default_executable = 'jbootstrap'
|
14
|
+
|
15
|
+
s.add_dependency 'thor', '~> 0.16.0'
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
end
|
data/lib/jbootstrap.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), *%w[.. lib])))
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'rubygems'
|
5
|
+
rescue LoadError
|
6
|
+
end
|
7
|
+
|
8
|
+
require 'thor'
|
9
|
+
require 'thor/group'
|
10
|
+
require 'thor/runner'
|
11
|
+
require 'date'
|
12
|
+
|
13
|
+
require 'jbootstrap/generators/component'
|
14
|
+
require 'jbootstrap/runner'
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module JBootstrap
|
2
|
+
module Generators
|
3
|
+
class Component < Thor::Group
|
4
|
+
|
5
|
+
include Thor::Actions
|
6
|
+
attr_accessor :name, :description, :date, :singular_name
|
7
|
+
|
8
|
+
desc "Generates a new component from template."
|
9
|
+
argument :name, :type => :string, :desc => "The human name of the component"
|
10
|
+
|
11
|
+
def self.source_root
|
12
|
+
File.expand_path(File.join(File.dirname(__FILE__), %w[.. templates component]))
|
13
|
+
end
|
14
|
+
|
15
|
+
def set_variables
|
16
|
+
@name = name
|
17
|
+
@singular_name = name.chop
|
18
|
+
@description = description
|
19
|
+
@date = Date.today.strftime '%B %Y'
|
20
|
+
end
|
21
|
+
|
22
|
+
def create_readme
|
23
|
+
template 'README.md.tt'
|
24
|
+
end
|
25
|
+
|
26
|
+
def create_manifest
|
27
|
+
template "com_COM_NAME.xml.tt", "com_#{@name.downcase}.xml"
|
28
|
+
end
|
29
|
+
|
30
|
+
def create_helpers
|
31
|
+
copy_file "gitignore", ".gitignore"
|
32
|
+
copy_file "Guardfile"
|
33
|
+
copy_file "Gemfile"
|
34
|
+
run "bundle check"
|
35
|
+
run "bundle install"
|
36
|
+
end
|
37
|
+
|
38
|
+
def create_backend
|
39
|
+
directory "admin/abstracts"
|
40
|
+
copy_file "admin/install.php", "admin/install.php"
|
41
|
+
copy_file "admin/uninstall.php", "admin/uninstall.php"
|
42
|
+
template "admin/admin.COM_NAME.php.tt", "admin/admin.#{@name.downcase}.php"
|
43
|
+
template "admin/language/en-GB/en-GB.com_COM_NAME.ini.tt", "admin/language/en-GB/en-GB.com_#{@name.downcase}.ini"
|
44
|
+
template "admin/language/en-GB/en-GB.com_COM_NAME.menu.ini.tt", "admin/language/fr-FR/fr-FR.com_#{@name.downcase}.ini"
|
45
|
+
template "admin/language/en-GB/en-GB.com_COM_NAME.menu.ini.tt", "admin/language/en-GB/en-GB.com_#{@name.downcase}.menu.ini"
|
46
|
+
template "admin/language/en-GB/en-GB.com_COM_NAME.menu.ini.tt", "admin/language/fr-FR/fr-FR.com_#{@name.downcase}.menu.ini"
|
47
|
+
end
|
48
|
+
|
49
|
+
def create_frontend
|
50
|
+
directory "site/abstracts"
|
51
|
+
template "site/language/en-GB/en-GB.com_COM_NAME.ini.tt", "site/language/en-GB/en-GB.com_#{@name.downcase}.ini"
|
52
|
+
template "site/language/fr-FR/fr-FR.com_COM_NAME.ini.tt", "site/language/fr-FR/fr-FR.com_#{@name.downcase}.ini"
|
53
|
+
template "site/COM_NAME.php.tt", "site/#{@name.downcase}.php"
|
54
|
+
template "site/controller.php.tt"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
notification :off
|
5
|
+
|
6
|
+
guard 'sass', :input => 'site/assets/css'
|
7
|
+
guard 'sass', :input => 'admin/assets/css'
|
8
|
+
guard 'coffeescript', :input => 'site/assets/js'
|
9
|
+
guard 'coffeescript', :input => 'admin/assets/js'
|
@@ -0,0 +1,85 @@
|
|
1
|
+
<?php
|
2
|
+
defined('_JEXEC') or die('Restricted Access');
|
3
|
+
jimport('joomla.application.component.controller');
|
4
|
+
|
5
|
+
class AbstractController extends JController
|
6
|
+
{
|
7
|
+
|
8
|
+
var $_object_name;
|
9
|
+
var $_collection_name;
|
10
|
+
var $_view;
|
11
|
+
var $_model;
|
12
|
+
var $_cids;
|
13
|
+
|
14
|
+
function __construct($object_name, $collection_name = '')
|
15
|
+
{
|
16
|
+
parent::__construct();
|
17
|
+
|
18
|
+
$this->_object_name = $object_name;
|
19
|
+
$this->_collection_name = (($collection_name === '') ? $object_name . 's' : $collection_name);
|
20
|
+
$this->_view = $this->getView($this->_object_name, 'html');
|
21
|
+
$this->_model = $this->getModel($this->_object_name);
|
22
|
+
|
23
|
+
$this->_view->setModel($this->_model, true);
|
24
|
+
}
|
25
|
+
|
26
|
+
// List view
|
27
|
+
public function display()
|
28
|
+
{
|
29
|
+
$this->_view->setLayout('list');
|
30
|
+
$this->_view->display();
|
31
|
+
}
|
32
|
+
|
33
|
+
public function edit()
|
34
|
+
{
|
35
|
+
$this->_view->edit($this->getCids(0));
|
36
|
+
}
|
37
|
+
|
38
|
+
public function add()
|
39
|
+
{
|
40
|
+
$this->_view->add();
|
41
|
+
}
|
42
|
+
|
43
|
+
public function save()
|
44
|
+
{
|
45
|
+
if ($this->_model->store()) $msg = JText::sprintf('COM_<%= @name.upcase %>_SAVED_OBJECT', $this->_object_name);
|
46
|
+
else $msg = JText::sprintf('COM_<%= @name.upcase %>_ERROR_SAVING_OBJECT', $this->_object_name, $this->_model->getError());
|
47
|
+
|
48
|
+
$this->setRedirect($this->getRedirectURL(), $msg);
|
49
|
+
}
|
50
|
+
|
51
|
+
public function cancel()
|
52
|
+
{
|
53
|
+
$this->setRedirect($this->getRedirectURL(), JText::_('COM_<%= @name.upcase %>_CANCELLED'));
|
54
|
+
}
|
55
|
+
|
56
|
+
public function remove()
|
57
|
+
{
|
58
|
+
if ($this->_model->delete($this->getCids())) $msg = JText::sprintf('COM_<%= @name.upcase %>_OBJECT_DELETED', ucfirst($this->_object_name));
|
59
|
+
else $msg = JText::sprintf('COM_<%= @name.upcase %>_ERROR_DELETING_OBJECT', $this->_object_name, $this->_model->getError());
|
60
|
+
$this->setRedirect($this->getRedirectURL(), $msg);
|
61
|
+
}
|
62
|
+
|
63
|
+
protected function getRedirectURL()
|
64
|
+
{
|
65
|
+
$url = sprintf('index.php?option=%s&c=%s&task=display',
|
66
|
+
JRequest::getVar('option'),
|
67
|
+
$this->_collection_name);
|
68
|
+
|
69
|
+
return JRoute::_($url, false);
|
70
|
+
}
|
71
|
+
|
72
|
+
protected function getCids($index = null)
|
73
|
+
{
|
74
|
+
if (!isset($this->_cids))
|
75
|
+
{
|
76
|
+
$this->_cids = JRequest::getVar('cid', null, 'default', 'array');
|
77
|
+
if ($this->_cids === null) JError::raiseError(500, JText::_('COM_<%= @name.upcase %>_MISSING_CID_PARAMETER'));
|
78
|
+
}
|
79
|
+
|
80
|
+
if (isset($index)) return (int)$this->_cids[$index];
|
81
|
+
else return $this->_cids;
|
82
|
+
}
|
83
|
+
}
|
84
|
+
|
85
|
+
?>
|
@@ -0,0 +1,268 @@
|
|
1
|
+
<?php
|
2
|
+
defined('_JEXEC') or die('Restricted Access');
|
3
|
+
jimport('joomla.application.component.model');
|
4
|
+
|
5
|
+
class AbstractModel extends JModel
|
6
|
+
{
|
7
|
+
var $_db;
|
8
|
+
var $_tablename;
|
9
|
+
var $_table;
|
10
|
+
var $_object_name;
|
11
|
+
var $_collection_name;
|
12
|
+
|
13
|
+
var $_collection = null;
|
14
|
+
var $_total = null;
|
15
|
+
var $_pagination = null;
|
16
|
+
|
17
|
+
function __construct($object_name, $collection_name = '')
|
18
|
+
{
|
19
|
+
parent::__construct();
|
20
|
+
|
21
|
+
$this->_object_name = $object_name;
|
22
|
+
$this->_collection_name = (($collection_name === '') ? $object_name . 's' : $collection_name);
|
23
|
+
$this->_db = $this->getDBO();
|
24
|
+
$this->_table =& $this->getTable($this->_object_name);
|
25
|
+
|
26
|
+
$this->setSortingInfo();
|
27
|
+
}
|
28
|
+
|
29
|
+
// Gets the collection for the index
|
30
|
+
public function getCollection()
|
31
|
+
{
|
32
|
+
if (empty($this->_collection))
|
33
|
+
{
|
34
|
+
$query = $this->getIndexQuery() . $this->getIndexOrder();
|
35
|
+
$limitstart = $this->getState('limitstart');
|
36
|
+
$limit = $this->getState('limit');
|
37
|
+
|
38
|
+
$this->_collection = $this->_getList($query, $limitstart, $limit);
|
39
|
+
}
|
40
|
+
|
41
|
+
return $this->_collection;
|
42
|
+
}
|
43
|
+
|
44
|
+
// Retrieves the pagination object for the index.
|
45
|
+
public function getPagination()
|
46
|
+
{
|
47
|
+
if (empty($this->_pagination))
|
48
|
+
{
|
49
|
+
jimport('joomla.html.pagination');
|
50
|
+
|
51
|
+
$total = $this->getTotal();
|
52
|
+
$limitstart = $this->getState('limitstart');
|
53
|
+
$limit = $this->getState('limit');
|
54
|
+
|
55
|
+
$this->_pagination = new JPagination($total, $limitstart, $limit);
|
56
|
+
}
|
57
|
+
|
58
|
+
return $this->_pagination;
|
59
|
+
}
|
60
|
+
|
61
|
+
// Returns the total number of records on the index page.
|
62
|
+
public function getTotal()
|
63
|
+
{
|
64
|
+
if (empty($this->_total))
|
65
|
+
{
|
66
|
+
$query = $this->getIndexQuery();
|
67
|
+
$this->_total = $this->_getListCount($query);
|
68
|
+
}
|
69
|
+
|
70
|
+
return $this->_total;
|
71
|
+
}
|
72
|
+
|
73
|
+
// Retrieves a single item.
|
74
|
+
public function getItem($id)
|
75
|
+
{
|
76
|
+
$query = sprintf("SELECT * FROM %s WHERE %s = %d",
|
77
|
+
$this->getTableName(),
|
78
|
+
$this->nq('id'),
|
79
|
+
(int)$id);
|
80
|
+
|
81
|
+
$this->_db->setQuery($query);
|
82
|
+
|
83
|
+
$item = $this->_db->loadObject();
|
84
|
+
if (is_object($item)) return $item;
|
85
|
+
else JError::raiseError(500, JText::sprintf('COM_<%= @name.upcase %>_OBJECT_NOT_FOUND', $this->_object_name, $id));
|
86
|
+
}
|
87
|
+
|
88
|
+
public function getItemByOrdering($position)
|
89
|
+
{
|
90
|
+
$query = sprintf("SELECT %s FROM %s WHERE %s = %d LIMIT 1",
|
91
|
+
$this->nq('id'),
|
92
|
+
$this->getTableName(),
|
93
|
+
$this->nq('ordering'),
|
94
|
+
(int) $position);
|
95
|
+
|
96
|
+
$this->_db->setQuery($query);
|
97
|
+
return $this->_db->loadObject();
|
98
|
+
}
|
99
|
+
|
100
|
+
public function getCollectionByOrdering()
|
101
|
+
{
|
102
|
+
$query = sprintf("SELECT %s FROM %s ORDER BY %s",
|
103
|
+
$this->nq('id'),
|
104
|
+
$this->getTableName(),
|
105
|
+
$this->nq('ordering'));
|
106
|
+
|
107
|
+
$this->_db->setQuery($query);
|
108
|
+
return $this->_db->loadObjectList();
|
109
|
+
}
|
110
|
+
|
111
|
+
// Gets an empty item which can be used to save.
|
112
|
+
public function getNewItem()
|
113
|
+
{
|
114
|
+
$this->_table->id = 0;
|
115
|
+
return $this->_table;
|
116
|
+
}
|
117
|
+
|
118
|
+
// Persist the item to the database, performing validations.
|
119
|
+
public function store()
|
120
|
+
{
|
121
|
+
$item = JRequest::get('post');
|
122
|
+
$this->beforeStoreCallback($item);
|
123
|
+
|
124
|
+
if (!$this->_table->bind($item)) return $this->failWithDBError();
|
125
|
+
if (isset($this->_table->ordering) && !$this->_table->id)
|
126
|
+
{
|
127
|
+
$where = 'region_id = ' . (int) $row->region_id;
|
128
|
+
$this->_table->ordering = $this->_table->getNextOrder($where);
|
129
|
+
}
|
130
|
+
|
131
|
+
if (!$this->_table->check()) return $this->failWithTableError();
|
132
|
+
if (!$this->_table->store()) return $this->failWithDBError();
|
133
|
+
$inserted_id = $this->_table->id;
|
134
|
+
|
135
|
+
if ($this->afterStoreCallback($item, $inserted_id))
|
136
|
+
{
|
137
|
+
return true;
|
138
|
+
}
|
139
|
+
else
|
140
|
+
{
|
141
|
+
$this->delete(array($inserted_id));
|
142
|
+
$this->setError($this->afterStoreCallbackFailureMessage());
|
143
|
+
return false;
|
144
|
+
}
|
145
|
+
}
|
146
|
+
|
147
|
+
protected function beforeStoreCallback(&$item)
|
148
|
+
{
|
149
|
+
$this->_table->reset();
|
150
|
+
}
|
151
|
+
|
152
|
+
protected function afterStoreCallback(&$item, $new_id)
|
153
|
+
{
|
154
|
+
return true;
|
155
|
+
}
|
156
|
+
|
157
|
+
protected function afterStoreCallbackFailureMessage()
|
158
|
+
{
|
159
|
+
return JText::_('COM_<%= @name.upcase %>_AFTER_SAVE_CALLBACK_FAILED');
|
160
|
+
}
|
161
|
+
|
162
|
+
// Delete the item from the database.
|
163
|
+
public function delete($cids)
|
164
|
+
{
|
165
|
+
$field = $this->_db->nameQuote('id');
|
166
|
+
$query = sprintf("DELETE FROM %s WHERE %s in (%s)",
|
167
|
+
$this->getTableName(),
|
168
|
+
$field,
|
169
|
+
implode(",", $cids));
|
170
|
+
|
171
|
+
$this->_db->setQuery($query);
|
172
|
+
if (!$this->_db->query())
|
173
|
+
{
|
174
|
+
$this->setError($this->_db->getErrorMsg());
|
175
|
+
return false;
|
176
|
+
}
|
177
|
+
|
178
|
+
return true;
|
179
|
+
}
|
180
|
+
|
181
|
+
// For running Quote a bit shorter.
|
182
|
+
public function q($text)
|
183
|
+
{
|
184
|
+
return $this->_db->Quote($text);
|
185
|
+
}
|
186
|
+
|
187
|
+
// For running nameQuote a little bit shorter
|
188
|
+
public function nq($text)
|
189
|
+
{
|
190
|
+
return $this->_db->nameQuote($text);
|
191
|
+
}
|
192
|
+
|
193
|
+
// Override this to change the query performed by the index action.
|
194
|
+
protected function getIndexQuery()
|
195
|
+
{
|
196
|
+
return "SELECT * FROM {$this->getTableName()}";
|
197
|
+
}
|
198
|
+
|
199
|
+
// Used to specify ordering from headers inside an index.
|
200
|
+
protected function getIndexOrder()
|
201
|
+
{
|
202
|
+
global $mainframe, $option;
|
203
|
+
$filter_order = $this->getState('filter_order');
|
204
|
+
$filter_order_Dir = $this->getState('filter_order_Dir');
|
205
|
+
|
206
|
+
return ' ORDER BY ' . $filter_order . ' ' . $filter_order_Dir;
|
207
|
+
}
|
208
|
+
|
209
|
+
// Override this to change the default sort column.
|
210
|
+
protected function getDefaultSortColumn()
|
211
|
+
{
|
212
|
+
return 'id';
|
213
|
+
}
|
214
|
+
|
215
|
+
// This must be overridden to allow sorting by other atributes.
|
216
|
+
protected function getSortableAttributes()
|
217
|
+
{
|
218
|
+
return array('id');
|
219
|
+
}
|
220
|
+
|
221
|
+
// Used to get a namequoted version of the model's table.
|
222
|
+
protected function getTableName()
|
223
|
+
{
|
224
|
+
if (!empty($this->_tablename)) return $this->_tablename;
|
225
|
+
|
226
|
+
$this->_tablename = $this->_db->nameQuote('#__<%= @name.downcase %>_' . $this->_collection_name);
|
227
|
+
return $this->_tablename;
|
228
|
+
}
|
229
|
+
|
230
|
+
// Die, retrieving the error message from the database
|
231
|
+
protected function failWithDBError()
|
232
|
+
{
|
233
|
+
$this->setError($this->_db->getErrorMsg());
|
234
|
+
return false;
|
235
|
+
}
|
236
|
+
|
237
|
+
// Die, retrieving the error from the table object
|
238
|
+
private function failWithTableError()
|
239
|
+
{
|
240
|
+
$this->setError($this->_table->getError());
|
241
|
+
return false;
|
242
|
+
}
|
243
|
+
|
244
|
+
// Sets sorting state in model construction
|
245
|
+
protected function setSortingInfo()
|
246
|
+
{
|
247
|
+
global $mainframe, $option;
|
248
|
+
$limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'));
|
249
|
+
$limitstart = $mainframe->getUserStateFromRequest($option . $this->_collection_name . 'limitstart', 'limitstart', 0);
|
250
|
+
$this->setState('limit', $limit);
|
251
|
+
$this->setState('limitstart', $limitstart);
|
252
|
+
|
253
|
+
$filter_order = $mainframe->getUserStateFromRequest($option . $this->_object_name . 'filter_order', 'filter_order', $this->getDefaultSortColumn(), 'cmd');
|
254
|
+
$filter_order_Dir = strtoupper($mainframe->getUserStateFromRequest($option . $this->_object_name . 'filter_order_Dir', 'filter_order_Dir', 'ASC', 'word'));
|
255
|
+
|
256
|
+
// Do some whitelisting
|
257
|
+
if ($filter_order_Dir != 'ASC' && $filter_order_Dir != 'DESC') $filter_order_Dir = 'ASC';
|
258
|
+
if (!in_array($filter_order, $this->getSortableAttributes())) $filter_order = $this->getDefaultSortColumn();
|
259
|
+
|
260
|
+
if ($filter_order == 'ordering') $filter_order = 'region_id, ordering';
|
261
|
+
|
262
|
+
$this->setState('filter_order', $filter_order);
|
263
|
+
$this->setState('filter_order_Dir', $filter_order_Dir);
|
264
|
+
}
|
265
|
+
|
266
|
+
}
|
267
|
+
|
268
|
+
?>
|
@@ -0,0 +1,40 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
defined('_JEXEC') or die('Restricted Access');
|
4
|
+
|
5
|
+
class AbstractTable extends JTable
|
6
|
+
{
|
7
|
+
var $_object_name;
|
8
|
+
var $_validation_errors = array();
|
9
|
+
|
10
|
+
function __construct(&$db, $object_name, $collection_name = '')
|
11
|
+
{
|
12
|
+
$this->_object_name = $object_name;
|
13
|
+
$this->_collection_name = (($collection_name === '') ? $object_name . 's' : $collection_name);
|
14
|
+
parent::__construct('#__component_' . $this->_collection_name, 'id', $db);
|
15
|
+
}
|
16
|
+
|
17
|
+
public function check()
|
18
|
+
{
|
19
|
+
$this->validate();
|
20
|
+
if (!empty($this->_validation_errors))
|
21
|
+
{
|
22
|
+
$this->setError(implode('; ', $this->_validation_errors) . '.');
|
23
|
+
return false;
|
24
|
+
}
|
25
|
+
|
26
|
+
return true;
|
27
|
+
}
|
28
|
+
|
29
|
+
public function validate()
|
30
|
+
{
|
31
|
+
return true;
|
32
|
+
}
|
33
|
+
|
34
|
+
public function addError($msg)
|
35
|
+
{
|
36
|
+
array_push($this->_validation_errors, $msg);
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
?>
|
@@ -0,0 +1,98 @@
|
|
1
|
+
<?php
|
2
|
+
defined('_JEXEC') or die('Restricted Access');
|
3
|
+
jimport('joomla.application.component.view');
|
4
|
+
|
5
|
+
class AbstractView extends JView
|
6
|
+
{
|
7
|
+
var $_section_title;
|
8
|
+
var $_object_name;
|
9
|
+
var $_collection_name;
|
10
|
+
var $_model;
|
11
|
+
|
12
|
+
function __construct($section_title, $object_name, $collection_name = '')
|
13
|
+
{
|
14
|
+
parent::__construct();
|
15
|
+
|
16
|
+
$this->_section_title = JText::_($section_title);
|
17
|
+
$this->_object_name = $object_name;
|
18
|
+
$this->_collection_name = (($collection_name === '') ? $object_name . 's' : $collection_name);
|
19
|
+
}
|
20
|
+
|
21
|
+
public function display($tpl = null)
|
22
|
+
{
|
23
|
+
global $mainframe;
|
24
|
+
|
25
|
+
$this->_model = $this->getModel();
|
26
|
+
$this->setTitle();
|
27
|
+
$this->indexOptions();
|
28
|
+
|
29
|
+
$lists = array();
|
30
|
+
$state =& $this->get('state');
|
31
|
+
$lists['order'] = $state->get('filter_order');
|
32
|
+
$lists['order_Dir'] = $state->get('filter_order_Dir');
|
33
|
+
|
34
|
+
$page =& $this->_model->getPagination();
|
35
|
+
$this->assignRef('lists', $lists);
|
36
|
+
$this->assignRef('page', $page);
|
37
|
+
|
38
|
+
$this->indexAssigns();
|
39
|
+
parent::display($tpl);
|
40
|
+
}
|
41
|
+
|
42
|
+
protected function indexAssigns()
|
43
|
+
{
|
44
|
+
$this->assignRef($this->_collection_name, $this->_model->getCollection());
|
45
|
+
}
|
46
|
+
|
47
|
+
public function edit($id)
|
48
|
+
{
|
49
|
+
$this->_model = $this->getModel();
|
50
|
+
$this->setTitle(': [<small>' . JText::_('COM_<%= @name.upcase %>_EDIT_TITLE') . '</small>]');
|
51
|
+
$this->editOptions();
|
52
|
+
|
53
|
+
$this->editAssigns($id);
|
54
|
+
|
55
|
+
parent::display();
|
56
|
+
}
|
57
|
+
|
58
|
+
protected function editAssigns($id)
|
59
|
+
{
|
60
|
+
$this->assignRef($this->_object_name, $this->_model->getItem($id));
|
61
|
+
}
|
62
|
+
|
63
|
+
public function add()
|
64
|
+
{
|
65
|
+
$this->_model = $this->getModel();
|
66
|
+
$this->setTitle(': [<small>' . JText::_('COM_<%= @name.upcase %>_ADD_TITLE') . '</small>]');
|
67
|
+
$this->editOptions();
|
68
|
+
|
69
|
+
$this->addAssigns();
|
70
|
+
|
71
|
+
parent::display();
|
72
|
+
}
|
73
|
+
|
74
|
+
protected function addAssigns()
|
75
|
+
{
|
76
|
+
$this->assignRef($this->_object_name, $this->_model->getNewItem());
|
77
|
+
}
|
78
|
+
|
79
|
+
protected function setTitle($text = '')
|
80
|
+
{
|
81
|
+
JToolBarHelper::title($this->_section_title . $text, 'generic.png');
|
82
|
+
}
|
83
|
+
|
84
|
+
protected function indexOptions()
|
85
|
+
{
|
86
|
+
JToolBarHelper::deleteList();
|
87
|
+
JToolBarHelper::editListX();
|
88
|
+
JToolBarHelper::addNewX();
|
89
|
+
}
|
90
|
+
|
91
|
+
protected function editOptions()
|
92
|
+
{
|
93
|
+
JToolBarHelper::save();
|
94
|
+
JToolBarHelper::cancel();
|
95
|
+
}
|
96
|
+
}
|
97
|
+
|
98
|
+
?>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<?php
|
2
|
+
defined('_JEXEC') or die('Restricted access');
|
3
|
+
// $document = &JFactory::getDocument();
|
4
|
+
// $document->addScript('components' . DS . 'COM_<%= @name.upcase %>' . DS . 'assets' . DS . 'js' . DS . 'jquery.js');
|
5
|
+
// $document->addScript('components' . DS . 'COM_<%= @name.upcase %>' . DS . 'assets' . DS . 'js' . DS . '<%= @name.downcase %>.js');
|
6
|
+
$component_acceptable_controllers = array('<%= @name %>');
|
7
|
+
|
8
|
+
function stop($msg)
|
9
|
+
{
|
10
|
+
echo '<pre>'; var_dump($msg); echo '</pre>';
|
11
|
+
$mainframe =& JFactory::getApplication();
|
12
|
+
$mainframe->close();
|
13
|
+
}
|
14
|
+
|
15
|
+
$c = JRequest::getVar('c', '<%= @name %>');
|
16
|
+
if (!in_array($c, $component_acceptable_controllers)) $c = '<%= @name %>';
|
17
|
+
|
18
|
+
require_once(JPATH_COMPONENT . DS . 'controllers' . DS . $c . '.php');
|
19
|
+
|
20
|
+
$c = '<%= @name.capitalize %>Controller' . ucfirst($c);
|
21
|
+
$controller = new $c();
|
22
|
+
$controller->execute(JRequest::getVar('task', 'display'));
|
23
|
+
|
24
|
+
// Redirect if set
|
25
|
+
$controller->redirect();
|
26
|
+
|
27
|
+
?>
|
@@ -0,0 +1,41 @@
|
|
1
|
+
################################################################################
|
2
|
+
# admin/abstracts/controller.php
|
3
|
+
################################################################################
|
4
|
+
|
5
|
+
# 1: object name
|
6
|
+
COM_<%= @name.upcase %>_SAVED_OBJECT=Saved %1$s
|
7
|
+
# 1: object name
|
8
|
+
# 2: error
|
9
|
+
COM_<%= @name.upcase %>_ERROR_SAVING_OBJECT=There was an error when saving %1$s: %2$s
|
10
|
+
|
11
|
+
COM_<%= @name.upcase %>_CANCELLED=Cancelled
|
12
|
+
|
13
|
+
# 1: object name
|
14
|
+
COM_<%= @name.upcase %>_OBJECT_DELETED=%1$s deleted
|
15
|
+
|
16
|
+
# 1: object name
|
17
|
+
# 2: error
|
18
|
+
COM_<%= @name.upcase %>_ERROR_DELETING_OBJECT=Error deleting %1$s: %2$s
|
19
|
+
|
20
|
+
COM_<%= @name.upcase %>_MISSING_CID_PARAMETER=Missing 'CID' parameter from request
|
21
|
+
|
22
|
+
################################################################################
|
23
|
+
# admin/abstracts/model.php
|
24
|
+
################################################################################
|
25
|
+
|
26
|
+
# 1: object name
|
27
|
+
# 2: id
|
28
|
+
COM_<%= @name.upcase %>_OBJECT_NOT_FOUND=%1$s [%2%s] not found.
|
29
|
+
COM_<%= @name.upcase %>_AFTER_SAVE_CALLBACK_FAILED=The after save callback failed.
|
30
|
+
|
31
|
+
################################################################################
|
32
|
+
# admin/abstracts/view.php
|
33
|
+
################################################################################
|
34
|
+
|
35
|
+
COM_<%= @name.upcase %>_COMPONENT_PACKAGES_TITLE=Component Packages
|
36
|
+
COM_<%= @name.upcase %>_COMPONENT_CHANNELS_TITLE=Component Channels
|
37
|
+
COM_<%= @name.upcase %>_COMPONENT_POSTALCODES_TITLE=Component Postal Codes
|
38
|
+
COM_<%= @name.upcase %>_COMPONENT_REGIONS_TITLE=Component Regions
|
39
|
+
|
40
|
+
COM_<%= @name.upcase %>_EDIT_TITLE=Edit
|
41
|
+
COM_<%= @name.upcase %>_ADD_TITLE=Add
|
@@ -0,0 +1,42 @@
|
|
1
|
+
################################################################################
|
2
|
+
# admin/abstracts/controller.php
|
3
|
+
################################################################################
|
4
|
+
|
5
|
+
# 1: object name
|
6
|
+
COM_<%= @name.upcase %>_SAVED_OBJECT=%1$s a été sauvegardé.
|
7
|
+
# 1: object name
|
8
|
+
# 2: error
|
9
|
+
COM_<%= @name.upcase %>_ERROR_SAVING_OBJECT=Une erreur est survenue lors de la sauvegarde de %1$s: %2$s
|
10
|
+
|
11
|
+
COM_<%= @name.upcase %>_CANCELLED=Annulé
|
12
|
+
|
13
|
+
# 1: object name
|
14
|
+
COM_<%= @name.upcase %>_OBJECT_DELETED=%1$s a été effacé
|
15
|
+
|
16
|
+
# 1: object name
|
17
|
+
# 2: error
|
18
|
+
COM_<%= @name.upcase %>_ERROR_DELETING_OBJECT=Une erreur est survenue lors de l'effacement de %1$s: %2$s
|
19
|
+
|
20
|
+
COM_<%= @name.upcase %>_MISSING_CID_PARAMETER=La requête ne contient pas de paramètre 'CID'.
|
21
|
+
|
22
|
+
################################################################################
|
23
|
+
# admin/abstracts/model.php
|
24
|
+
################################################################################
|
25
|
+
|
26
|
+
# 1: object name
|
27
|
+
# 2: id
|
28
|
+
COM_<%= @name.upcase %>_OBJECT_NOT_FOUND=%1$s [%2%s] est introuvable.
|
29
|
+
COM_<%= @name.upcase %>_AFTER_SAVE_CALLBACK_FAILED=Le rappel de la sauvegarde a échoué.
|
30
|
+
|
31
|
+
|
32
|
+
################################################################################
|
33
|
+
# admin/abstracts/view.php
|
34
|
+
################################################################################
|
35
|
+
|
36
|
+
COM_<%= @name.upcase %>_COMPONENT_PACKAGES_TITLE=Forfaits pour la télévision
|
37
|
+
COM_<%= @name.upcase %>_COMPONENT_CHANNELS_TITLE=Chaînes télévisées
|
38
|
+
COM_<%= @name.upcase %>_COMPONENT_POSTALCODES_TITLE=Codes postaux
|
39
|
+
COM_<%= @name.upcase %>_COMPONENT_REGIONS_TITLE=Régions
|
40
|
+
|
41
|
+
COM_<%= @name.upcase %>_EDIT_TITLE=Modifier
|
42
|
+
COM_<%= @name.upcase %>_ADD_TITLE=Ajouter
|
@@ -0,0 +1,65 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<install type="component" version="1.5.0" method="upgrade">
|
3
|
+
<name><%= @name.capitalize %></name>
|
4
|
+
<creationDate><%= @date %></creationDate>
|
5
|
+
<author>Rob Yurkowski</author>
|
6
|
+
<authorEmail>rob@peerless-studios.com</authorEmail>
|
7
|
+
<authorUrl>http://www.peerless-studios.com</authorUrl>
|
8
|
+
<copyright>Copyright 2012</copyright>
|
9
|
+
<license>License</license>
|
10
|
+
<version>1.0.0</version>
|
11
|
+
<description><%= @description %></description>
|
12
|
+
|
13
|
+
<languages folder="site">
|
14
|
+
<language tag="en-GB">language/en-GB/en-GB.com_<%= @name %>.ini</language>
|
15
|
+
<language tag="fr-FR">language/fr-FR/fr-FR.com_<%= @name %>.ini</language>
|
16
|
+
</languages>
|
17
|
+
|
18
|
+
<installfile>install.php</installfile>
|
19
|
+
<uninstallfile>uninstall.php</uninstallfile>
|
20
|
+
|
21
|
+
<install>
|
22
|
+
<sql>
|
23
|
+
<file driver="mysql" charset="utf8">install.sql</file>
|
24
|
+
</sql>
|
25
|
+
</install>
|
26
|
+
|
27
|
+
<uninstall>
|
28
|
+
<sql>
|
29
|
+
<file driver="mysql">uninstall.sql</file>
|
30
|
+
</sql>
|
31
|
+
</uninstall>
|
32
|
+
|
33
|
+
<files folder="site">
|
34
|
+
<filename>abstracts/model.php</filename>
|
35
|
+
|
36
|
+
<filename>controller.php</filename>
|
37
|
+
<filename><%= @name %>.php</filename>
|
38
|
+
</files>
|
39
|
+
|
40
|
+
<administration>
|
41
|
+
<menu>COM_<%= @name.upcase %></menu>
|
42
|
+
<submenu>
|
43
|
+
<menu link="c=<%= @name %>&option=com_<%= @name %>"><%= @name.upcase %></menu>
|
44
|
+
</submenu>
|
45
|
+
<files folder="admin">
|
46
|
+
<filename>install.php</filename>
|
47
|
+
<filename>uninstall.php</filename>
|
48
|
+
<filename>install.sql</filename>
|
49
|
+
<filename>uninstall.sql</filename>
|
50
|
+
|
51
|
+
<filename>abstracts/model.php</filename>
|
52
|
+
<filename>abstracts/view.php</filename>
|
53
|
+
<filename>abstracts/controller.php</filename>
|
54
|
+
<filename>abstracts/table.php</filename>
|
55
|
+
|
56
|
+
<filename>admin.<%= @name %>.php</filename>
|
57
|
+
</files>
|
58
|
+
<languages folder="admin">
|
59
|
+
<language tag="en-GB">language/en-GB/en-GB.com_<%= @name %>.ini</language>
|
60
|
+
<language tag="fr-FR">language/fr-FR/fr-FR.com_<%= @name %>.ini</language>
|
61
|
+
<language tag="en-GB">language/en-GB/en-GB.com_<%= @name %>.menu.ini</language>
|
62
|
+
<language tag="fr-FR">language/fr-FR/fr-FR.com_<%= @name %>.menu.ini</language>
|
63
|
+
</languages>
|
64
|
+
</administration>
|
65
|
+
</install>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
defined('_JEXEC') or die('Restricted access');
|
4
|
+
|
5
|
+
$document = &JFactory::getDocument();
|
6
|
+
$document->addStyleSheet('components' . DS . 'COM_<%= @name.upcase %>' . DS . 'assets' . DS . 'css' . DS . '<%= @name.downcase %>.css');
|
7
|
+
$document->addScript('components' . DS . 'COM_<%= @name.upcase %>' . DS . 'assets' . DS . 'js' . DS . 'jquery.js');
|
8
|
+
$document->addScript('components' . DS . 'COM_<%= @name.upcase %>' . DS . 'assets' . DS . 'js' . DS . '<%= @name.downcase %>.js');
|
9
|
+
|
10
|
+
function stop($msg)
|
11
|
+
{
|
12
|
+
echo '<pre>'; var_dump($msg); echo '</pre>';
|
13
|
+
$mainframe =& JFactory::getApplication();
|
14
|
+
$mainframe->close();
|
15
|
+
}
|
16
|
+
|
17
|
+
function transliterate($msg)
|
18
|
+
{
|
19
|
+
$transliterables = explode('.', "à.á.â.ã.ä.ç.è.é.ê.ë.î.ï.À.Á.Â.Ã.Ä.Ç.È.É.Ê.Ë.Î.Ï");
|
20
|
+
$replacements = explode('.', "a.a.a.a.a.c.e.e.e.e.i.i.A.A.A.A.A.C.E.E.E.E.I.I");
|
21
|
+
return str_replace($transliterables, $replacements, $msg);
|
22
|
+
}
|
23
|
+
|
24
|
+
|
25
|
+
// Require base controller
|
26
|
+
require_once(JPATH_COMPONENT . DS . 'controller.php');
|
27
|
+
|
28
|
+
$controller = new <%= @name.capitalize %>Controller();
|
29
|
+
|
30
|
+
$controller->execute(JRequest::getVar('task', 'display'));
|
31
|
+
|
32
|
+
// Redirect if set
|
33
|
+
$controller->redirect();
|
34
|
+
|
35
|
+
?>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<?php
|
2
|
+
defined('_JEXEC') or die('Restricted Access');
|
3
|
+
jimport('joomla.application.component.controller');
|
4
|
+
|
5
|
+
class AbstractFrontendController extends JController
|
6
|
+
{
|
7
|
+
var $_object_name;
|
8
|
+
var $_collection_name;
|
9
|
+
var $_view;
|
10
|
+
var $_model;
|
11
|
+
|
12
|
+
function __construct($object_name, $collection_name = '')
|
13
|
+
{
|
14
|
+
parent::__construct();
|
15
|
+
|
16
|
+
$this->_object_name = $object_name;
|
17
|
+
$this->_collection_name = (($collection_name === '') ? $object_name . 's' : $collection_name);
|
18
|
+
$this->_view = $this->getView($this->_object_name, 'html');
|
19
|
+
$this->_model = $this->getModel($this->_object_name);
|
20
|
+
|
21
|
+
$this->_view->setModel($this->_model, true);
|
22
|
+
}
|
23
|
+
}
|
24
|
+
?>
|
@@ -0,0 +1,78 @@
|
|
1
|
+
<?php
|
2
|
+
defined('_JEXEC') or die('Restricted Access');
|
3
|
+
jimport('joomla.application.component.model');
|
4
|
+
|
5
|
+
class AbstractFrontendModel extends JModel
|
6
|
+
{
|
7
|
+
var $_db;
|
8
|
+
var $_object_name;
|
9
|
+
var $_collection_name;
|
10
|
+
var $_tablename;
|
11
|
+
|
12
|
+
function __construct($object_name, $collection_name = '')
|
13
|
+
{
|
14
|
+
parent::__construct();
|
15
|
+
|
16
|
+
$this->_object_name = $object_name;
|
17
|
+
$this->_collection_name = (($collection_name === '') ? $object_name . 's' : $collection_name);
|
18
|
+
$this->_db = $this->getDBO();
|
19
|
+
}
|
20
|
+
|
21
|
+
// Gets the collection for the index
|
22
|
+
public function getCollection()
|
23
|
+
{
|
24
|
+
$this->_db->setQuery($this->getIndexQuery());
|
25
|
+
return $this->_db->loadObjectList();
|
26
|
+
}
|
27
|
+
|
28
|
+
// Retrieves a single item.
|
29
|
+
public function getItem($id)
|
30
|
+
{
|
31
|
+
$query = sprintf("SELECT * FROM %s WHERE %s = %d",
|
32
|
+
$this->getTableName(),
|
33
|
+
$this->nq('id'),
|
34
|
+
(int)$id);
|
35
|
+
|
36
|
+
$this->_db->setQuery($query);
|
37
|
+
|
38
|
+
$item = $this->_db->loadObject();
|
39
|
+
if (is_object($item)) return $item;
|
40
|
+
else JError::raiseError(500, "{$this->_object_name} [$id] not found.");
|
41
|
+
}
|
42
|
+
|
43
|
+
// For running Quote a bit shorter.
|
44
|
+
public function q($text)
|
45
|
+
{
|
46
|
+
return $this->_db->Quote($text);
|
47
|
+
}
|
48
|
+
|
49
|
+
// For running nameQuote a little bit shorter
|
50
|
+
public function nq($text)
|
51
|
+
{
|
52
|
+
return $this->_db->nameQuote($text);
|
53
|
+
}
|
54
|
+
|
55
|
+
// Override this to change the query performed by the index action.
|
56
|
+
protected function getIndexQuery()
|
57
|
+
{
|
58
|
+
return "SELECT * FROM {$this->getTableName()}";
|
59
|
+
}
|
60
|
+
|
61
|
+
// Die, retrieving the error message from the database
|
62
|
+
protected function failWithDBError()
|
63
|
+
{
|
64
|
+
$this->setError($this->_db->getErrorMsg());
|
65
|
+
return false;
|
66
|
+
}
|
67
|
+
|
68
|
+
protected function getTableName()
|
69
|
+
{
|
70
|
+
if (!empty($this->_tablename)) return $this->_tablename;
|
71
|
+
|
72
|
+
$this->_tablename = $this->_db_namequote('#__<%= @name.downcase %>_' . $this->_collection_name);
|
73
|
+
return $this->_tablename;
|
74
|
+
}
|
75
|
+
|
76
|
+
}
|
77
|
+
|
78
|
+
?>
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
defined('_JEXEC') or die('Restricted Access');
|
4
|
+
jimport('joomla.application.component.view');
|
5
|
+
|
6
|
+
class AbstractFrontendView extends JView
|
7
|
+
{
|
8
|
+
var $_object_name;
|
9
|
+
var $_collection_name;
|
10
|
+
var $_model;
|
11
|
+
|
12
|
+
function __construct($object_name, $collection_name = '')
|
13
|
+
{
|
14
|
+
parent::__construct();
|
15
|
+
|
16
|
+
$this->_object_name = $object_name;
|
17
|
+
$this->_collection_name = (($collection_name === '') ? $object_name . 's' : $collection_name);
|
18
|
+
}
|
19
|
+
|
20
|
+
public function display($tpl = null)
|
21
|
+
{
|
22
|
+
$this->_model =& $this->getModel();
|
23
|
+
|
24
|
+
$this->displayAssigns();
|
25
|
+
parent::display($tpl);
|
26
|
+
}
|
27
|
+
|
28
|
+
protected function displayAssigns()
|
29
|
+
{
|
30
|
+
$collection_get_method_name = 'get' . ucfirst($this->_collection_name);
|
31
|
+
$this->assignRef($this->_collection_name, $this->_model->{$collection_get_method_name}());
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
|
36
|
+
?>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
defined('_JEXEC') or die('Restricted access');
|
4
|
+
require_once(JPATH_COMPONENT . DS . 'abstracts' . DS . 'controller.php');
|
5
|
+
|
6
|
+
class <%= @name.capitalize %>Controller extends AbstractFrontendController
|
7
|
+
{
|
8
|
+
function __construct()
|
9
|
+
{
|
10
|
+
parent::__construct('<%= singular_name.downcase %>');
|
11
|
+
}
|
12
|
+
|
13
|
+
public function display()
|
14
|
+
{
|
15
|
+
$this->_view->display();
|
16
|
+
}
|
17
|
+
}
|
18
|
+
|
19
|
+
?>
|
File without changes
|
File without changes
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
defined('_JEXEC') or die('Restricted Access');
|
4
|
+
require_once(JPATH_COMPONENT . DS . 'abstracts' . DS . 'model.php');
|
5
|
+
|
6
|
+
class COM_NAME_UCFIRSTModelCOM_ENTITY_SINGULAR extends AbstractFrontendModel
|
7
|
+
{
|
8
|
+
|
9
|
+
function __construct()
|
10
|
+
{
|
11
|
+
parent::__construct('COM_ENTITY_SINGULAR');
|
12
|
+
}
|
13
|
+
|
14
|
+
}
|
15
|
+
|
16
|
+
?>
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jBootstrap
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Rob Yurkowski
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-11-12 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: thor
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.16.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.16.0
|
30
|
+
description: Generator and abstract classes for Joomla 1.5 components.
|
31
|
+
email: rob@yurkowski.net
|
32
|
+
executables:
|
33
|
+
- jbootstrap
|
34
|
+
extensions: []
|
35
|
+
extra_rdoc_files: []
|
36
|
+
files:
|
37
|
+
- .gitignore
|
38
|
+
- .rvmrc
|
39
|
+
- Gemfile
|
40
|
+
- Gemfile.lock
|
41
|
+
- README.md
|
42
|
+
- Rakefile
|
43
|
+
- bin/jbootstrap
|
44
|
+
- jbootstrap.gemspec
|
45
|
+
- lib/jbootstrap.rb
|
46
|
+
- lib/jbootstrap/generators/component.rb
|
47
|
+
- lib/jbootstrap/runner.rb
|
48
|
+
- lib/jbootstrap/templates/component/Gemfile
|
49
|
+
- lib/jbootstrap/templates/component/Guardfile
|
50
|
+
- lib/jbootstrap/templates/component/README.md.tt
|
51
|
+
- lib/jbootstrap/templates/component/admin/abstracts/controller.php.tt
|
52
|
+
- lib/jbootstrap/templates/component/admin/abstracts/model.php.tt
|
53
|
+
- lib/jbootstrap/templates/component/admin/abstracts/table.php.tt
|
54
|
+
- lib/jbootstrap/templates/component/admin/abstracts/view.php.tt
|
55
|
+
- lib/jbootstrap/templates/component/admin/admin.COM_NAME.php.tt
|
56
|
+
- lib/jbootstrap/templates/component/admin/install.php
|
57
|
+
- lib/jbootstrap/templates/component/admin/language/en-GB/en-GB.com_COM_NAME.ini.tt
|
58
|
+
- lib/jbootstrap/templates/component/admin/language/en-GB/en-GB.com_COM_NAME.menu.ini.tt
|
59
|
+
- lib/jbootstrap/templates/component/admin/language/fr-FR/fr-FR.com_COM_NAME.ini.tt
|
60
|
+
- lib/jbootstrap/templates/component/admin/language/fr-FR/fr-FR.com_COM_NAME.menu.ini.tt
|
61
|
+
- lib/jbootstrap/templates/component/admin/uninstall.php
|
62
|
+
- lib/jbootstrap/templates/component/com_COM_NAME.xml.tt
|
63
|
+
- lib/jbootstrap/templates/component/gitignore
|
64
|
+
- lib/jbootstrap/templates/component/site/COM_NAME.php.tt
|
65
|
+
- lib/jbootstrap/templates/component/site/abstracts/controller.php.tt
|
66
|
+
- lib/jbootstrap/templates/component/site/abstracts/model.php.tt
|
67
|
+
- lib/jbootstrap/templates/component/site/abstracts/view.php.tt
|
68
|
+
- lib/jbootstrap/templates/component/site/controller.php.tt
|
69
|
+
- lib/jbootstrap/templates/component/site/language/en-GB/en-GB.com_COM_NAME.ini.tt
|
70
|
+
- lib/jbootstrap/templates/component/site/language/fr-FR/fr-FR.com_COM_NAME.ini.tt
|
71
|
+
- lib/jbootstrap/templates/front/site/models/COM_NAME_SINGULAR.php
|
72
|
+
homepage:
|
73
|
+
licenses: []
|
74
|
+
post_install_message:
|
75
|
+
rdoc_options: []
|
76
|
+
require_paths:
|
77
|
+
- lib
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
80
|
+
requirements:
|
81
|
+
- - ! '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - ! '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 1.8.24
|
93
|
+
signing_key:
|
94
|
+
specification_version: 3
|
95
|
+
summary: Generator and abstract classes for Joomla 1.5 components.
|
96
|
+
test_files: []
|