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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
|
# Replace Template with your importer name.
# The package name must exactly match the file name (.pm)
package GCImport::GCImportTemplate;
###################################################
#
# Copyright 2005-2007 Tian
#
# This file is part of GCstar.
#
# GCstar 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.
#
# GCstar 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.
#
# You should have received a copy of the GNU General Public License
# along with GCstar; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
#
###################################################
use strict;
use GCImport::GCImportBase;
{
# Replace Template with your importer name
# It must be the same name as the one used for file and main package name
package GCImport::GCImporterTemplate;
use base qw(GCImport::GCImportBaseClass);
# Add your needed use clauses here
# new
# Constructor
# Returns reference to current object.
sub new
{
my $proto = shift;
my $class = ref($proto) || $proto;
my $self = $class->SUPER::new();
# Do your initialization stuff here
bless ($self, $class);
return $self;
}
# wantsFieldsSelection
# This function lets a plugin decide if it wants the user to specify fields to be used
# Returns a true value when fields selection is needed.
sub wantsFieldsSelection
{
return 0;
}
# wantsFileSelection
# Some plugins doens't need a file (they can get their information
# from a database as an example. This function specify if a file
# is needed or not.
# Returns true if a file is needed.
sub wantsFileSelection
{
return 1;
}
# getName
# Used to create Import menu.
# If you need a string that depends on language, do NOT define
# this method and provide a member called Name in languages files
# Returns a string containing the name.
sub getName
{
my $self = shift;
# Should return the importer name as it will be displayed in Import menu.
return "Template";
}
# getFilePatterns
# Used to add filters in file selection dialog box.
# A *.* filter is always added also.
# Returns the file as a list of array references.
sub getFilePatterns
{
return (['Description 1', '*.ext1'], ['Description 2', '*.ext2']);
}
# getOptions
# Used to create import dialog window.
# Returns an array with needed options.
sub getOptions
{
my $self = shift;
# Should return an array of associative arrays.
# Here is an example.
return [
{
name => 'withJs',
type => 'checkBox',
label => 'ImportHTMLWithJS',
default => '1'
},
{
name => 'title',
type => 'shortText',
label => 'ImportHTMLTitle',
default => 'Movies list'
},
]
# For each entry, you have to specify:
#
# - name: A unique name that will be used to retrieve the option value
# - type: One out of checkBox, shortText, longText, number, list, fileSelection, colorSelection
# - label: a member of lang files (lib/gcstar/GCLang/*.pm) that will be used to display an informative label
# - default: Default value (for the first time exporter is used in a session).
#
# There are other values that are only valid for some types.
#
# - min: Minimum value allowed (for number only).
# - max: Maximum value (for number only).
# - height: Height of the widget displayed in pixels (for longText only).
# - valuesList: A comma separated list of values to be used (for list only).
# In all processing functions below, values entered by user are accessible through:
#
# $self->{options}->{name}
#
# Where name should be replaced with specified name above.
}
# In there processing functions, you can use options fields specified through getOptions
# But there is also some predifined values:
#
# - $self->{options}->{file} File name used to export data.
# - $self->{options}->{movies} A reference to the array containing the information.
# - $self->{options}->{lang} A reference to the hash containing current language translations.
# getMoviesArray
# Called to generate the movies array.
# Each item of this array have to be an associative array with these fields:
#
# - $movie->{title}
# - $movie->{date}
# - $movie->{time}
# - $movie->{director}
# - $movie->{country}
# - $movie->{age}
# - $movie->{type}
# - $movie->{image}
# - $movie->{original}
# - $movie->{actors}
# - $movie->{comment}
# - $movie->{synopsis}
# - $movie->{seen}
# - $movie->{number}
# - $movie->{rating}
# - $movie->{format}
# - $movie->{url}
# - $movie->{place}
# - $movie->{video}
# - $movie->{audio}
# - $movie->{subt}
# - $movie->{borrower}
# - $movie->{lendDate}
# - $movie->{history}
#
# Returns the movies array.
sub getMoviesArray
{
my ($self, $file) = @_;
my @result;
# Your code here
# Add movies to results;
return \@result;
}
# getEndInfo
# Used to display some information to user when export is ended.
# To localize your message, use $self->{options}->{lang}.
# Returns a string that will be displayed in a message box.
sub getEndInfo
{
my $self = shift;
my $message;
# Your code here
# Don't do put anything in message if you don't want information to be displayed.
return $message;
}
}
1;
|