|
Lines 119-124
sub retrieve_data {
Link Here
|
| 119 |
get_template returns a Template object. Eventually this will probably be calling |
119 |
get_template returns a Template object. Eventually this will probably be calling |
| 120 |
C4:Template, but at the moment, it does not. |
120 |
C4:Template, but at the moment, it does not. |
| 121 |
|
121 |
|
|
|
122 |
The returned template contains 3 variables that can be used in the plugin |
| 123 |
templates: |
| 124 |
|
| 125 |
=over 8 |
| 126 |
|
| 127 |
=item B<CLASS> |
| 128 |
|
| 129 |
The name of the plugin class. |
| 130 |
|
| 131 |
=item B<METHOD> |
| 132 |
|
| 133 |
Then name of the plugin method used. For example 'tool' or 'report'. |
| 134 |
|
| 135 |
=item B<PLUGIN_PATH> |
| 136 |
|
| 137 |
The URL path to the plugin. It can be used in templates in order to localize |
| 138 |
ressources like images in html tags, or other templates. |
| 139 |
|
| 140 |
=item B<PLUGN_DIR> |
| 141 |
|
| 142 |
The absolute pathname to the plugin directory. Necessary to include other |
| 143 |
templates from a template with the [% INCLUDE %] directive. |
| 144 |
|
| 145 |
=over |
| 146 |
|
| 147 |
|
| 122 |
=cut |
148 |
=cut |
| 123 |
|
149 |
|
| 124 |
sub get_template { |
150 |
sub get_template { |
|
Lines 142-147
sub get_template {
Link Here
|
| 142 |
CLASS => $self->{'class'}, |
168 |
CLASS => $self->{'class'}, |
| 143 |
METHOD => scalar $self->{'cgi'}->param('method'), |
169 |
METHOD => scalar $self->{'cgi'}->param('method'), |
| 144 |
PLUGIN_PATH => $self->get_plugin_http_path(), |
170 |
PLUGIN_PATH => $self->get_plugin_http_path(), |
|
|
171 |
PLUGIN_DIR => $self->get_plugin_dir(), |
| 145 |
); |
172 |
); |
| 146 |
|
173 |
|
| 147 |
return $template; |
174 |
return $template; |
|
Lines 150-156
sub get_template {
Link Here
|
| 150 |
sub get_metadata { |
177 |
sub get_metadata { |
| 151 |
my ( $self, $args ) = @_; |
178 |
my ( $self, $args ) = @_; |
| 152 |
|
179 |
|
| 153 |
return $self->{'metadata'}; |
180 |
#FIXME: Why another encoding issue? For metadata containg non latin characters. |
|
|
181 |
my $metadata = $self->{metadata}; |
| 182 |
utf8::decode($metadata->{$_}) for keys %$metadata; |
| 183 |
return $metadata; |
| 154 |
} |
184 |
} |
| 155 |
|
185 |
|
| 156 |
=head2 get_qualified_table_name |
186 |
=head2 get_qualified_table_name |
|
Lines 185-190
sub get_plugin_http_path {
Link Here
|
| 185 |
return "/plugin/" . join( '/', split( '::', $self->{'class'} ) ); |
215 |
return "/plugin/" . join( '/', split( '::', $self->{'class'} ) ); |
| 186 |
} |
216 |
} |
| 187 |
|
217 |
|
|
|
218 |
=head2 get_plugin_dir |
| 219 |
|
| 220 |
To [% INCLUDE %] another TT template from a template, an absolute path to the |
| 221 |
template is required. This method returns that absolute file system path. |
| 222 |
|
| 223 |
usage: my $path = $self->get_plugin_dir(); |
| 224 |
|
| 225 |
=cut |
| 226 |
|
| 227 |
sub get_plugin_dir { |
| 228 |
my ($self) = @_; |
| 229 |
|
| 230 |
my $base = C4::Context->config('pluginsdir'); |
| 231 |
return "$base/" . join( '/', split( '::', $self->{'class'} ) ); |
| 232 |
} |
| 233 |
|
| 188 |
=head2 go_home |
234 |
=head2 go_home |
| 189 |
|
235 |
|
| 190 |
go_home is a quick redirect to the Koha plugins home page |
236 |
go_home is a quick redirect to the Koha plugins home page |
| 191 |
- |
|
|